QcMinecartCollisions Namespace
How minecarts meet each other and living bodies in a tick (decision E-382), worked out from the carts as they were before any of them moved, so the order of the table does not matter: carts that run into each other bounce along the line between them and pass most of their speed on, living bodies push carts away (a cart never moves a body), and after the carts moved, none of them ends deeper in a cart it overlapped, so carts pushed against a blocked cart stop instead of sinking into it. More...
| Header: | #include <server/minecarts/QcMinecartCollisions.h> |
Classes
| struct | Pair |
Variables
| const double | bodyPushSpeed |
| const double | restitution |
Functions
| QList<QcMinecart> | keptApart(QList<QcMinecart> carts, const QList<QcMinecartCollisions::Pair> &pairs, const QList<QcVec3> &before) |
| QList<QcVec3> | pushes(const QList<QcMinecart> &carts, const QList<QcMinecartCollisions::Pair> &pairs, const QList<QcAabb> &bodies) |
| QList<QcMinecartCollisions::Pair> | touching(const QList<QcMinecart> &carts, const QcRails::Table &rails, const QcBlockAccess &world) |
Detailed Description
Carts that only touch leave each other be, so a crowd comes to rest.
Classes
class Pair
Two awake carts whose bodies overlap, by table index (first < second), and the horizontal line from the first to the second. More...
Variable Documentation
const double QcMinecartCollisions::bodyPushSpeed
Speed a body that walks into a cart gives it, metres per second.
const double QcMinecartCollisions::restitution
Share of their speed against each other two carts keep when they bump (1 would bounce without loss).
Function Documentation
QList<QcMinecart> QcMinecartCollisions::keptApart(QList<QcMinecart> carts, const QList<QcMinecartCollisions::Pair> &pairs, const QList<QcVec3> &before)
Returns carts after keeping them apart: after the carts moved from before (their positions at the start of the tick, by table index): takes back as much of each cart's step as it needs so no pair of pairs ends closer along its line than it started, sharing the take-back between the carts that moved towards each other. A cart keeps the same share of its speed as of its step. Takes the carts and gives them back (moved in and out, no copy).
QList<QcVec3> QcMinecartCollisions::pushes(const QList<QcMinecart> &carts, const QList<QcMinecartCollisions::Pair> &pairs, const QList<QcAabb> &bodies)
Returns the changes of velocity the carts of pairs give each other and bodies (boxes of living bodies that ride no cart) give the carts, by table index.
QList<QcMinecartCollisions::Pair> QcMinecartCollisions::touching(const QList<QcMinecart> &carts, const QcRails::Table &rails, const QcBlockAccess &world)
Returns the pairs of awake carts whose bodies overlap, with their lines along the tracks of rails in world.