QtCraft API C++ classes QML types Handbook

QcBodyGrid Class

Bodies sorted into columns of one block (decision E-882), so that the push on one body (QcBodyPush::between) looks only at the bodies in the columns within reach of it instead of at all of them: building costs a sort of the bodies, a look-up a binary search per column around the body. More...

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

Public Functions

void add(const QcBodyPush::Body &body)
void clear()
void finish()
qsizetype size() const
QcVec3 sum(const QcBodyPush::Body &self) const

Detailed Description

Keeps its storage when cleared and sorts in place, so a grid built anew every tick allocates nothing once it held as many bodies.

Member Function Documentation

void QcBodyGrid::add(const QcBodyPush::Body &body)

Adds body.

void QcBodyGrid::clear()

Forgets all bodies.

void QcBodyGrid::finish()

Sorts the bodies into their columns: after the last add(), before sum().

qsizetype QcBodyGrid::size() const

Returns the number of bodies added.

QcVec3 QcBodyGrid::sum(const QcBodyPush::Body &self) const

Returns the sum of the pushes of the bodies on self (QcBodyPush::between); self itself must not be in the grid.