diff --git a/src/esp/bindings/PhysicsObjectBindings.cpp b/src/esp/bindings/PhysicsObjectBindings.cpp index f3d3d7d29f..7f6a0b8f21 100644 --- a/src/esp/bindings/PhysicsObjectBindings.cpp +++ b/src/esp/bindings/PhysicsObjectBindings.cpp @@ -298,6 +298,12 @@ void declareRigidBaseWrapper(py::module& m, ". To change the values, use the object's " "'intertia_diagonal' property.") .c_str()) + .def_property_readonly( + "com_correction", &RigidBaseWrapper::getCOMCorrection, + ("Get the COM correction vector for this " + objType + + ". This tracks the local change in translation from the original " + "frame to center the COM locally.") + .c_str()) .def_property("linear_damping", &RigidBaseWrapper::getLinearDamping, &RigidBaseWrapper::setLinearDamping, ("Get or set this " + objType + diff --git a/src/esp/physics/PhysicsObjectBase.h b/src/esp/physics/PhysicsObjectBase.h index 8ffc83facd..db77ff4370 100644 --- a/src/esp/physics/PhysicsObjectBase.h +++ b/src/esp/physics/PhysicsObjectBase.h @@ -487,7 +487,7 @@ class PhysicsObjectBase : public Magnum::SceneGraph::AbstractFeature3D { /** * @brief Reverses the COM correction transformation for objects that require - * it. Currently a simple passthrough for stages and Articulated Objects. + * it. Currently a simple passthrough for stages and articulated objects. */ virtual Magnum::Vector3 getUncorrectedTranslation() const { return getTranslation(); @@ -495,7 +495,8 @@ class PhysicsObjectBase : public Magnum::SceneGraph::AbstractFeature3D { /** @brief Accessed internally. Get an appropriately cast copy of the @ref * metadata::attributes::SceneObjectInstanceAttributes used to place the - * object within the scene, updated to have the c. + * object within the scene, updated to have the current transformation and + * status of the object. * @return A copy of the initialization template used to create this object * instance or nullptr if no template exists. */ diff --git a/src/esp/physics/RigidObject.h b/src/esp/physics/RigidObject.h index 613afb77ab..6c0164791a 100644 --- a/src/esp/physics/RigidObject.h +++ b/src/esp/physics/RigidObject.h @@ -7,8 +7,7 @@ /** @file * @brief Class @ref esp::physics::RigidObject, enum @ref - * esp::physics::MotionType, enum @ref esp::physics::RigidObjectType, struct - * @ref VelocityControl + * esp::physics::MotionType, struct @ref esp::physics::VelocityControl */ #include @@ -162,27 +161,37 @@ class RigidObject : public RigidBase { /** * @brief Reverses the COM correction transformation for objects that require - * it. Currently a simple passthrough for stages and Articulated Objects. + * it. */ Magnum::Vector3 getUncorrectedTranslation() const override { auto translation = getTranslation(); - auto rotation = getRotation(); if (isCOMCorrected_) { + auto rotation = getRotation(); translation += rotation.transformVector(visualNode_->translation()); } return translation; } /** - * @brief Set the @ref MotionType of the object. If the object is @ref - * ObjectType::SCENE it can only be @ref esp::physics::MotionType::STATIC. If - * the object is - * @ref ObjectType::OBJECT is can also be set to @ref - * esp::physics::MotionType::KINEMATIC. Only if a dervied @ref PhysicsManager - * implementing dynamics is in use can the object be set to @ref - * esp::physics::MotionType::DYNAMIC. - * @param mt The desirved @ref MotionType. - * @return true if successfully set, false otherwise. + * @brief Retrieves the COM correction translation for objects that require + * it. + */ + Magnum::Vector3 getCOMCorrection() const { + if (isCOMCorrected_) { + return visualNode_->translation(); + } + return Magnum::Vector3(); + } // getCOMCorrection + + /** + * @brief Set the @ref MotionType of the object. If the construct is a @ref + * physics::RigidStage, it can only be @ref + * physics::MotionType::STATIC. If the object is + * @ref physics::RigidObject it can also be set to @ref + * physics::MotionType::KINEMATIC. Only if a dervied @ref + * physics::PhysicsManager implementing dynamics is in use can the object + * be set to @ref physics::MotionType::DYNAMIC. + * @param mt The desired @ref MotionType. */ void setMotionType(MotionType mt) override; diff --git a/src/esp/physics/bullet/BulletRigidObject.h b/src/esp/physics/bullet/BulletRigidObject.h index a2687b0120..62195df9cc 100644 --- a/src/esp/physics/bullet/BulletRigidObject.h +++ b/src/esp/physics/bullet/BulletRigidObject.h @@ -29,8 +29,7 @@ namespace physics { /** * @brief An individual rigid object instance implementing an interface with - * Bullet physics to enable dynamic objects. See @ref btRigidBody for @ref - * esp::physics::RigidObjectType::OBJECT. + * Bullet physics to enable dynamic objects. See @ref btRigidBody. * * Utilizes Magnum::BulletIntegration::MotionState to synchronize SceneNode * state with internal btRigidBody states @@ -482,7 +481,7 @@ class BulletRigidObject : public BulletBase, */ Magnum::Range3D getCollisionShapeAabb() const override; - /** @brief Object data: All components of a @ref esp::physics::RigidObjectType::OBJECT are + /** @brief Object data: All @ref BulletRigidObject components are * wrapped into one @ref btRigidBody. */ std::unique_ptr bObjectRigidBody_; diff --git a/src/esp/physics/objectWrappers/ManagedRigidBase.h b/src/esp/physics/objectWrappers/ManagedRigidBase.h index 7756162b41..45a8e1afcd 100644 --- a/src/esp/physics/objectWrappers/ManagedRigidBase.h +++ b/src/esp/physics/objectWrappers/ManagedRigidBase.h @@ -105,6 +105,13 @@ class AbstractManagedRigidBase } } // setCOM + Magnum::Vector3 getCOMCorrection() const { + if (auto sp = this->getObjectReference()) { + return sp->getCOMCorrection(); + } + return Magnum::Vector3(); + } // getCOMCorrection + double getFrictionCoefficient() const { if (auto sp = this->getObjectReference()) { return sp->getFrictionCoefficient();