QcPhysics Namespace
Deterministic movement and collision shared by server (authoritative) and client (prediction). More...
| Header: | #include <common/physics/QcPhysics.h> |
Classes
| struct | BodySize |
| struct | MoveResult |
| struct | Steering |
| struct | SurfaceFactors |
Variables
| const double | gravity |
| const double | jumpVelocity |
| const double | liquidExitSpeed |
| const double | lyingPivot |
| const double | playerEyeHeight |
| const double | playerHeight |
| const double | playerWidth |
| const double | sneakEyeHeight |
| const double | stepHeight |
| const double | swimSpeed |
| const double | terminalVelocity |
| const double | tickDuration |
| const double | tickRate |
| const double | usingItemFactor |
| const double | waterAcceleration |
| const double | waterGravity |
| const double | waterSinkSpeed |
Functions
| QcBlockPos | blockContaining(const QcVec3 &point) |
| QcAabb | boxAt(const QcVec3 &feet, double width, double height) |
| bool | clingsToWall(const QcBlockAccess &world, const QcAabb &box) |
| QList<QcAabb> | collisionBoxesAt(const QcBlockAccess &world, QcBlockPos pos) |
| double | eyeHeight(bool crouches) |
| bool | feetInLiquid(const QcBlockAccess &world, const QcVec3 &feet) |
| bool | isLiquidAt(const QcBlockAccess &world, QcBlockPos pos) |
| bool | isSolidAt(const QcBlockAccess &world, QcBlockPos pos) |
| bool | isWaterAt(const QcBlockAccess &world, QcBlockPos pos) |
| double | liquidFactorAt(const QcBlockAccess &world, QcBlockPos pos) |
| QcAabb | lyingBoxAt(const QcVec3 &feet, float yaw, double width, double height) |
| QcPhysics::MoveResult | moveBox(const QcAabb &box, const QcVec3 &delta, const QcBlockAccess &world) |
| bool | overlapsBlocks(const QcBlockAccess &world, const QcAabb &box) |
| double | slideKeep(double slipperiness, double drag, double dt) |
| double | slowdownInside(const QcBlockAccess &world, const QcAabb &box) |
| QcPhysics::SurfaceFactors | surfaceUnder(const QcBlockAccess &world, const QcVec3 &feet) |
| bool | touchesClimbable(const QcBlockAccess &world, const QcAabb &box) |
Detailed Description
Units: metres, seconds, metres per second.
Classes
class BodySize
Width and height of an entity's collision box. More...
class MoveResult
The outcome of moveBox(): the movement that was possible and the axes on which blocks stopped it. More...
class Steering
What an entity wants for one tick: wish is the horizontal movement direction (length <= 1), speed its target speed, jump jumps on ground, swims up in water or climbs, hold keeps a climber in place, keepsToEdges stops it at edges it would drop off (a sneaking player, sneakEdgeDepth), slideDrag is how it slides on slippery ground (footDrag, itemDrag, coastDrag). More...
class SurfaceFactors
Walking speed and jump factors of the block under a body's feet (mud), and its slipperiness (ice). More...
Variable Documentation
const double QcPhysics::gravity
Downward acceleration out of liquids (m/s²).
const double QcPhysics::jumpVelocity
Upward velocity of a jump from the ground (scaled by SurfaceFactors::jump).
const double QcPhysics::liquidExitSpeed
Leaving a liquid at its shore (decision E-918): a player whose feet are still in the liquid but whose body is above it (QcEntityMotion::inWater false) and who walks into a wall is lifted with this speed, enough to step out onto a bank one block above the liquid's cell, not onto a higher one. The same rule in water and lava, on server and client.
const double QcPhysics::lyingPivot
A body lying on its back (a sleeping villager, decision E-411) turns around this height above its feet: its feet end up this far ahead of feet in the direction it faces, its head behind.
const double QcPhysics::playerEyeHeight
Height of the player's eyes above the feet.
const double QcPhysics::playerHeight
Height of the player's collision box.
const double QcPhysics::playerWidth
Width of the player's collision box.
const double QcPhysics::sneakEyeHeight
Height of the eyes of a player who crouches (sneaks on foot, not flying or riding) above the feet, as in the role model (decision E-961). The collision box keeps playerHeight.
const double QcPhysics::stepHeight
Bodies on the ground walk up steps this high without jumping (slabs, stairs).
const double QcPhysics::swimSpeed
Target speed of a player in a liquid.
const double QcPhysics::terminalVelocity
Fastest fall out of liquids.
const double QcPhysics::tickDuration
Seconds per tick.
const double QcPhysics::tickRate
Ticks per second of the simulation.
const double QcPhysics::usingItemFactor
The share of a player's horizontal speed left while he holds an item in use (draws a bow, decision E-986), as in the role model: it scales walking, sneaking, swimming and flying alike.
const double QcPhysics::waterAcceleration
How fast the horizontal velocity approaches the wished one in a liquid, per second.
const double QcPhysics::waterGravity
Downward acceleration in a liquid (m/s²).
const double QcPhysics::waterSinkSpeed
Fastest sinking in a liquid (scaled by the liquid's factor).
Function Documentation
QcBlockPos QcPhysics::blockContaining(const QcVec3 &point)
Returns the block cell that holds point (each coordinate rounded down).
QcAabb QcPhysics::boxAt(const QcVec3 &feet, double width, double height)
Returns the box of a standing body of width and height with its feet at the middle of its bottom face, feet.
bool QcPhysics::clingsToWall(const QcBlockAccess &world, const QcAabb &box)
Returns whether a wall climber with the box box touches a block of world beside it or above it: from a hair above its feet up to clingAbove over its top or its first metre, whichever is higher, grown sideways by clingReach.
QList<QcAabb> QcPhysics::collisionBoxesAt(const QcBlockAccess &world, QcBlockPos pos)
Returns the world-space collision boxes of the block at pos in world (a unit box where data is missing, none below the world).
[constexpr] double QcPhysics::eyeHeight(bool crouches)
Returns the height of the player's eyes above the feet while he crouches or stands.
bool QcPhysics::feetInLiquid(const QcBlockAccess &world, const QcVec3 &feet)
Returns whether the feet at feet stand in a liquid of world (the cell a hand's width above them), also while the body is above the surface (QcEntityMotion::inWater false): such a body climbs out at a bank and lands softly (decision E-918).
bool QcPhysics::isLiquidAt(const QcBlockAccess &world, QcBlockPos pos)
Returns whether the block at pos in world is a liquid.
bool QcPhysics::isSolidAt(const QcBlockAccess &world, QcBlockPos pos)
Returns true when the block at pos in world blocks movement. Unloaded chunks inside the world's height are solid so nothing falls through missing data; the void below the world is open (decision E-288).
bool QcPhysics::isWaterAt(const QcBlockAccess &world, QcBlockPos pos)
Returns whether pos in world holds water: a liquid that sets nothing alight (not lava).
double QcPhysics::liquidFactorAt(const QcBlockAccess &world, QcBlockPos pos)
Returns the movement factor of the liquid at pos in world (lava is slow), 1 outside liquids.
QcAabb QcPhysics::lyingBoxAt(const QcVec3 &feet, float yaw, double width, double height)
Returns the box of a body of width and height lying on its back around feet and facing yaw (along an axis, as beds lie): along its length from lyingPivot ahead of feet to height - lyingPivot behind them, width across, half its width high.
QcPhysics::MoveResult QcPhysics::moveBox(const QcAabb &box, const QcVec3 &delta, const QcBlockAccess &world)
Returns the move of box by delta, clipped against the solid blocks of world (Y first, then X, then Z).
bool QcPhysics::overlapsBlocks(const QcBlockAccess &world, const QcAabb &box)
Returns whether box overlaps the collision boxes of any block in world (a unit box where data is missing): a body there is stuck inside blocks.
double QcPhysics::slideKeep(double slipperiness, double drag, double dt)
Returns the share of its horizontal velocity a body on ground of slipperiness keeps per tick of dt seconds: (slipperiness x drag) per 1/20 s on slippery ground or for a body that coasts, else 0.
double QcPhysics::slowdownInside(const QcBlockAccess &world, const QcAabb &box)
Returns the smallest movement factor of the blocks of world that box overlaps (cobwebs), 1 without any.
QcPhysics::SurfaceFactors QcPhysics::surfaceUnder(const QcBlockAccess &world, const QcVec3 &feet)
Returns the factors of the block just below feet in world; the defaults where there is no valid block.
bool QcPhysics::touchesClimbable(const QcBlockAccess &world, const QcAabb &box)
Returns whether box overlaps a climbable block in world.