esp::physics::RigidObject class

A RigidBase representing an individual rigid object instance attached to a SceneNode, updating its state through simulation. This may be a esp::physics::MotionType::STATIC scene collision geometry or an object of any MotionType which can interact with other members of a physical world. Must have a collision mesh. By default, a RigidObject is MotionType::KINEMATIC without an underlying simulator implementation. Derived classes can be used to introduce specific implementations of dynamics.

Base classes

class RigidBase
This class specifies the functionality expected of rigid objects and stages, particularly with regard to dynamic simulation, if such a library, such as bullet, is available.

Derived classes

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

Constructors, destructors, conversion operators

RigidObject(scene::SceneNode* rigidBodyNode, int objectId, const assets::ResourceManager& resMgr)
Constructor for a esp::physics::RigidObject.
~RigidObject() defaulted override
Virtual destructor for a esp::physics::RigidObject.

Public functions

auto initialize(metadata::attributes::AbstractObjectAttributes::ptr initAttributes) -> bool override
Initializes the esp::physics::RigidObject that inherits from this class.
auto finalizeObject() -> bool override
Finalize the creation of the RigidObject.
auto getInitializationAttributes() const -> std::shared_ptr<metadata::attributes::ObjectAttributes>
Get a copy of the template used to initialize this object.
void setIsCOMCorrected(bool _isCOMCorrected)
Set whether this object is COM corrected, which determines how the intial transformation is applied when placing the object.
auto getUncorrectedTranslation() const -> Magnum::Vector3 override
Reverses the COM correction transformation for objects that require it.
auto getCOMCorrection() const -> Magnum::Vector3
Retrieves the COM correction translation for objects that require it.
void setMotionType(MotionType mt) override
Set the MotionType of the object. If the construct is a physics::RigidStage, it can only be physics::MotionType::STATIC. If the object is physics::RigidObject it can also be set to physics::MotionType::KINEMATIC. Only if a dervied physics::PhysicsManager implementing dynamics is in use can the object be set to physics::MotionType::DYNAMIC.
auto getVelocityControl() -> VelocityControl::ptr
Retrieves a reference to the VelocityControl struct for this object.
void resetStateFromSceneInstanceAttr() override
Set the object's state from a esp::metadata::attributes::SceneObjectInstanceAttributes.

Protected variables

bool isCOMCorrected_
Whether or not this object's placement should be COM corrected.
VelocityControl::ptr velControl_
Convenience variable: specifies a constant control velocity (linear | angular) applied to the rigid body before each step.

Private functions

auto initialization_LibSpecific() -> bool override
Finalize the initialization of this esp::physics::RigidObject's geometry. This is overridden by inheriting class specific to certain physics libraries. Necessary to support kinematic objects without any dynamics support.
auto finalizeObject_LibSpecific() -> bool override
any physics-lib-specific finalization code that needs to be run after RigidObject is created. Overridden by inheriting class specific to certain physics libraries. Necessary to support kinematic objects without any dynamics support.

Function documentation

esp::physics::RigidObject::RigidObject(scene::SceneNode* rigidBodyNode, int objectId, const assets::ResourceManager& resMgr)

Constructor for a esp::physics::RigidObject.

Parameters
rigidBodyNode The scene::SceneNode this feature will be attached to.
objectId
resMgr

bool esp::physics::RigidObject::initialize(metadata::attributes::AbstractObjectAttributes::ptr initAttributes) override

Initializes the esp::physics::RigidObject that inherits from this class.

Parameters
initAttributes The template structure defining relevant physical parameters for this object
Returns true if initialized successfully, false otherwise.

bool esp::physics::RigidObject::finalizeObject() override

Finalize the creation of the RigidObject.

Returns whether successful finalization.

std::shared_ptr<metadata::attributes::ObjectAttributes> esp::physics::RigidObject::getInitializationAttributes() const

Get a copy of the template used to initialize this object.

Returns A copy of the esp::metadata::attributes::ObjectAttributes template used to create this object.

void esp::physics::RigidObject::setMotionType(MotionType mt) override

Set the MotionType of the object. If the construct is a physics::RigidStage, it can only be physics::MotionType::STATIC. If the object is physics::RigidObject it can also be set to physics::MotionType::KINEMATIC. Only if a dervied physics::PhysicsManager implementing dynamics is in use can the object be set to physics::MotionType::DYNAMIC.

Parameters
mt The desired MotionType.

bool esp::physics::RigidObject::initialization_LibSpecific() override private

Finalize the initialization of this esp::physics::RigidObject's geometry. This is overridden by inheriting class specific to certain physics libraries. Necessary to support kinematic objects without any dynamics support.

Returns true if initialized successfully, false otherwise.

bool esp::physics::RigidObject::finalizeObject_LibSpecific() override private

any physics-lib-specific finalization code that needs to be run after RigidObject is created. Overridden by inheriting class specific to certain physics libraries. Necessary to support kinematic objects without any dynamics support.

Returns whether successful finalization.