QcSwimSpace Namespace
Room for a swimming body in the water (decisions E-502, E-972): where a creature that lives in water fits with its whole box, and which moves keep it there. Shared by QcSwimRoutes and the swimmers' steering (QcFishSwimming). More...
| Header: | #include <server/pathing/QcSwimSpace.h> |
Variables
| const double | edgeMargin |
| const double | lineStep |
Functions
| bool | clearLine(const QcBlockAccess &world, const QcVec3 &from, const QcVec3 &to, QcPhysics::BodySize body) |
| bool | fits(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize body) |
| QcVec3 | keepInside(const QcVec3 &move, const QcVec3 &feet, QcPhysics::BodySize body, const QcBlockAccess &world, double reach) |
| QcVec3 | pointIn(QcBlockPos cell, QcPhysics::BodySize body) |
Detailed Description
Variable Documentation
const double QcSwimSpace::edgeMargin
How far beyond a move a body tests for room, in metres, so that it stops a hair before the edge of the water instead of on it.
const double QcSwimSpace::lineStep
Distance between the points a straight line is tested at, in metres.
Function Documentation
bool QcSwimSpace::clearLine(const QcBlockAccess &world, const QcVec3 &from, const QcVec3 &to, QcPhysics::BodySize body)
Returns whether a body of body fits in the water of world all along the straight line from from to to, tested every lineStep (from itself is not tested).
bool QcSwimSpace::fits(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize body)
Returns whether a body of body with its feet at feet lies wholly in the water of world: every cell its box overlaps holds water, and the top of the box stays below the surface of the cells it reaches into (QcBoatMotion::waterSurfaceAt).
QcVec3 QcSwimSpace::keepInside(const QcVec3 &move, const QcVec3 &feet, QcPhysics::BodySize body, const QcBlockAccess &world, double reach)
Returns move without the components along which a body of body with its feet at feet would leave the water of world: each axis is tested on its own, the body shifted by the component times reach plus edgeMargin, so a body sliding along a wall keeps the component along the wall. Where the components each fit but the whole move does not (a corner of air or rock across the way), only the largest component is kept. The body must fit where it is (fits).
QcVec3 QcSwimSpace::pointIn(QcBlockPos cell, QcPhysics::BodySize body)
Returns the feet of a body of body resting in the cell cell: in the middle of the cell horizontally, its centre at the cell's middle height but its feet not below the cell's floor.