diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f12e5c..2c322eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## Release candidate + +Note that this release contains some public API changes. Please read carefully the following changes before upgrading to this new version and +do not hesitate to take a look at the user manual. + +### Added + + - Method RigidBody::resetForce() to reset the accumulated external force on a rigid body has beend added + - Method RigidBody::resetTorque() to reset the accumulated external torque on a rigid body has beend added + +### Changed + +### Removed + +### Fixed + ## Version 0.8.0 (May 31, 2020) Note that this release contains some public API changes. Please read carefully the following changes before upgrading to this new version and diff --git a/include/reactphysics3d/body/RigidBody.h b/include/reactphysics3d/body/RigidBody.h index 1e73386f..bc2353e0 100644 --- a/include/reactphysics3d/body/RigidBody.h +++ b/include/reactphysics3d/body/RigidBody.h @@ -165,6 +165,12 @@ class RigidBody : public CollisionBody { /// Apply an external torque to the body. void applyTorque(const Vector3& torque); + /// Reset the accumulated force to zero + void resetForce(); + + /// Reset the accumulated torque to zero + void resetTorque(); + /// Return whether or not the body is allowed to sleep bool isAllowedToSleep() const; diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 3ee7fca2..d5a07888 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -806,6 +806,26 @@ void RigidBody::applyTorque(const Vector3& torque) { mWorld.mRigidBodyComponents.setExternalTorque(mEntity, externalTorque + torque); } +// Reset the accumulated force to zero +void RigidBody::resetForce() { + + // If it is not a dynamic body, we do nothing + if (mWorld.mRigidBodyComponents.getBodyType(mEntity) != BodyType::DYNAMIC) return; + + // Set the external force to zero + mWorld.mRigidBodyComponents.setExternalForce(mEntity, Vector3(0, 0, 0)); +} + +// Reset the accumulated torque to zero +void RigidBody::resetTorque() { + + // If it is not a dynamic body, we do nothing + if (mWorld.mRigidBodyComponents.getBodyType(mEntity) != BodyType::DYNAMIC) return; + + // Set the external torque to zero + mWorld.mRigidBodyComponents.setExternalTorque(mEntity, Vector3(0, 0, 0)); +} + // Set the variable to know whether or not the body is sleeping void RigidBody::setIsSleeping(bool isSleeping) {