QtCraft API C++ classes QML types Handbook

QcBodyFit Namespace

Where a body fits into the world: clear of the collision boxes of the blocks around it. More...

Header: #include <common/physics/QcBodyFit.h>

Types

enum class Unloaded { Clear, Blocked }

Functions

std::optional<QcVec3> clearFeet(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize size)
bool overlapsBlocks(const QcBlockAccess &world, const QcAabb &box, QcBodyFit::Unloaded unloaded)
bool overlapsBlocks(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize size, QcBodyFit::Unloaded unloaded)

Detailed Description

Type Documentation

enum class QcBodyFit::Unloaded

How cells without data (chunks not loaded) count.

ConstantValueDescription
QcBodyFit::Unloaded::Clear0They count as free.
QcBodyFit::Unloaded::Blocked1They count as blocked.

Function Documentation

std::optional<QcVec3> QcBodyFit::clearFeet(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize size)

Returns the feet position nearest to feet where a body of size is clear of the blocks of world: feet itself when it is (cells not loaded count as clear there, so a body at the edge of the loaded world stays), else one metre up onto the top of the block it is in, a metre north, east, south or west, or a metre down, never below y 0 (cells not loaded block these). Nothing when all of them are blocked.

bool QcBodyFit::overlapsBlocks(const QcBlockAccess &world, const QcAabb &box, QcBodyFit::Unloaded unloaded)

Returns whether box overlaps a collision box of a block of world (cells without data as unloaded says), including boxes reaching up from the cell below (fences, walls and gates are 1.5 m high). The box is shrunk by a millionth of a metre on every side, so a body resting against a face or a post after a clipped move does not count.

bool QcBodyFit::overlapsBlocks(const QcBlockAccess &world, const QcVec3 &feet, QcPhysics::BodySize size, QcBodyFit::Unloaded unloaded)

Returns the same for the box of a body of size with its feet at feet.