esp::physics::BulletBase class

This class is intended to implement bullet-specific.

Derived classes

class BulletArticulatedLink
class BulletRigidObject
An individual rigid object instance implementing an interface with Bullet physics to enable dynamic objects. See btRigidBody.
class BulletRigidStage
An individual rigid stage instance implementing an interface with Bullet physics to enable dynamics. See btCollisionObject.

Public static functions

static void constructJoinedConvexShapeFromMeshes(const Magnum::Matrix4& transformFromParentToWorld, const std::vector<assets::CollisionMeshData>& meshGroup, const assets::MeshTransformNode& node, btConvexHullShape* bConvexShape)
Recursively construct a btConvexHullShape for collision by joining loaded mesh assets.
static void constructConvexShapesFromMeshes(const Magnum::Matrix4& transformFromParentToWorld, const std::vector<assets::CollisionMeshData>& meshGroup, const assets::MeshTransformNode& node, btCompoundShape* bObjectShape, std::vector<std::unique_ptr<btConvexHullShape>>& bObjectConvexShapes)
Recursively construct a btCompoundShape for collision from loaded mesh assets. A btConvexHullShape is constructed for each sub-component, transformed to object-local space and added to the compound in a flat manner for efficiency.

Constructors, destructors, conversion operators

BulletBase(std::shared_ptr<btMultiBodyDynamicsWorld> bWorld, std::shared_ptr<std::map<const btCollisionObject*, int>> collisionObjToObjIds)
~BulletBase() virtual
Destructor cleans up simulation structures for the object.

Public functions

auto getMargin() const -> double virtual
Get the scalar collision margin of an object. Retun 0.0 for a esp::physics::RigidStage. See btCompoundShape::getMargin.
void setMargin(const double margin) virtual
Set the scalar collision margin of an object. Does not affect esp::physics::RigidStage. See btCompoundShape::setMargin.
auto getCollisionShapeAabb() const -> Magnum::Range3D pure virtual
Query the Aabb from bullet physics for the root compound shape of the rigid body in its local space. See btCompoundShape::getAabb.

Protected variables

std::shared_ptr<btMultiBodyDynamicsWorld> bWorld_
A pointer to the Bullet world to which this object belongs. See btMultiBodyDynamicsWorld.
std::vector<std::unique_ptr<btRigidBody>> bStaticCollisionObjects_
Static data: All components of a esp::physics::RigidStage are stored here. Also, all objects set to STATIC are stored here.
std::vector<std::unique_ptr<btConvexHullShape>> bObjectConvexShapes_
Object data: Composite convex collision shape.
std::vector<std::unique_ptr<btCollisionShape>> bGenericShapes_
std::shared_ptr<std::map<const btCollisionObject*, int>> collisionObjToObjIds_

Function documentation

static void esp::physics::BulletBase::constructJoinedConvexShapeFromMeshes(const Magnum::Matrix4& transformFromParentToWorld, const std::vector<assets::CollisionMeshData>& meshGroup, const assets::MeshTransformNode& node, btConvexHullShape* bConvexShape)

Recursively construct a btConvexHullShape for collision by joining loaded mesh assets.

Parameters
transformFromParentToWorld The cumulative parent-to-world transformation matrix constructed by composition down the MeshTransformNode tree to the current node.
meshGroup Access structure for collision mesh data.
node The current MeshTransformNode in the recursion.
bConvexShape The convex we are building. Should be a new, empty shape when passed into entry point.

static void esp::physics::BulletBase::constructConvexShapesFromMeshes(const Magnum::Matrix4& transformFromParentToWorld, const std::vector<assets::CollisionMeshData>& meshGroup, const assets::MeshTransformNode& node, btCompoundShape* bObjectShape, std::vector<std::unique_ptr<btConvexHullShape>>& bObjectConvexShapes)

Recursively construct a btCompoundShape for collision from loaded mesh assets. A btConvexHullShape is constructed for each sub-component, transformed to object-local space and added to the compound in a flat manner for efficiency.

Parameters
transformFromParentToWorld The cumulative parent-to-world transformation matrix constructed by composition down the MeshTransformNode tree to the current node.
meshGroup Access structure for collision mesh data.
node The current MeshTransformNode in the recursion.
bObjectShape The compound shape parent for all generated convexes
bObjectConvexShapes Datastructure to cache generated convex shapes

double esp::physics::BulletBase::getMargin() const virtual

Get the scalar collision margin of an object. Retun 0.0 for a esp::physics::RigidStage. See btCompoundShape::getMargin.

Returns The scalar collision margin of the object.

void esp::physics::BulletBase::setMargin(const double margin) virtual

Set the scalar collision margin of an object. Does not affect esp::physics::RigidStage. See btCompoundShape::setMargin.

Parameters
margin The new scalar collision margin of the object.

Magnum::Range3D esp::physics::BulletBase::getCollisionShapeAabb() const pure virtual

Query the Aabb from bullet physics for the root compound shape of the rigid body in its local space. See btCompoundShape::getAabb.

Returns The Aabb.

Variable documentation

std::vector<std::unique_ptr<btCollisionShape>> esp::physics::BulletBase::bGenericShapes_ protected

list of btCollisionShape for storing arbitrary collision shapes referenced within the bObjectShape_.

std::shared_ptr<std::map<const btCollisionObject*, int>> esp::physics::BulletBase::collisionObjToObjIds_ protected

keep a map of collision objects to object ids for quick lookups from Bullet collision checking.