Improve API documentation

This commit is contained in:
Daniel Chappuis 2021-11-23 17:36:23 +01:00
parent 74f5a7f493
commit 80c7d1289c
6 changed files with 78 additions and 2 deletions

View File

@ -151,10 +151,10 @@ class RigidBodyComponents : public Components {
/// For each body, the array of the indices of contact pairs in which the body is involved
Array<uint>* mContactPairs;
/// For each body, the array of lock translation vectors
/// For each body, the vector of lock translation vectors
Vector3* mLinearLockAxisFactors;
/// For each body, the array of lock rotation vectors
/// For each body, the vector of lock rotation vectors
Vector3* mAngularLockAxisFactors;
// -------------------- Methods -------------------- //

View File

@ -864,21 +864,43 @@ bool RigidBody::isGravityEnabled() const {
}
// Return the linear lock axis factor
/// The linear lock axis factor specify whether linear motion along world-space axes X,Y,Z is
/// restricted or not.
/**
* @return A Vector3 with the linear lock axis factor for each X,Y,Z world-space axis
*/
const Vector3& RigidBody::getLinearLockAxisFactor() const {
return mWorld.mRigidBodyComponents.getLinearLockAxisFactor(mEntity);
}
// Set the linear lock axis factor
/// This method allows to restrict the linear motion of a rigid body along the world-space
/// axes X,Y and Z. For instance, it's possible to disable the linear motion of a body
/// along a given axis by setting a lock axis factor of zero.
/**
* @param linearLockAxisFactor A Vector3 with the lock factor for each world-space axis X,Y,Z
*/
void RigidBody::setLinearLockAxisFactor(const Vector3& linearLockAxisFactor) const {
mWorld.mRigidBodyComponents.setLinearLockAxisFactor(mEntity, linearLockAxisFactor);
}
// Return the angular lock axis factor
/// The angular lock axis factor specify whether angular motion around world-space axes X,Y,Z is
/// restricted or not.
/**
* @return A Vector3 with the angular lock axis factor for each X,Y,Z world-space axis
*/
const Vector3& RigidBody::getAngularLockAxisFactor() const {
return mWorld.mRigidBodyComponents.getAngularLockAxisFactor(mEntity);
}
// Set the angular lock axis factor
/// This method allows to restrict the angular motion of a rigid body around the world-space
/// axes X,Y and Z. For instance, it's possible to disable the angular motion of a body
/// around a given axis by setting a lock axis factor of zero.
/**
* @param angularLockAxisFactor A Vector3 with the lock factor for each world-space axis X,Y,Z
*/
void RigidBody::setAngularLockAxisFactor(const Vector3& angularLockAxisFactor) const {
mWorld.mRigidBodyComponents.setAngularLockAxisFactor(mEntity, angularLockAxisFactor);
}
@ -943,11 +965,17 @@ void RigidBody::resetTorque() {
}
// Return the total manually applied force on the body (in world-space)
/**
* @return The total manually applied force on the body (in world-space)
*/
const Vector3& RigidBody::getForce() const {
return mWorld.mRigidBodyComponents.getExternalForce(mEntity);
}
// Return the total manually applied torque on the body (in world-space)
/**
* @return The total manually applied torque on the body (in world-space)
*/
const Vector3& RigidBody::getTorque() const {
return mWorld.mRigidBodyComponents.getExternalTorque(mEntity);
}

View File

@ -62,6 +62,12 @@ BallAndSocketJoint::BallAndSocketJoint(Entity entity, PhysicsWorld& world, const
}
// Enable/disable the cone limit of the joint
/// It is possible to enable a cone-limit for the BallAndSocketJoint in order to
/// restrict the angular motion between the two bodies. Use this method to enable/disable
/// the cone-limit.
/**
* @param isLimitEnabled True if the limit must be enabled and false otherwise
*/
void BallAndSocketJoint::enableConeLimit(bool isLimitEnabled) {
mWorld.mBallAndSocketJointsComponents.setIsConeLimitEnabled(mEntity, isLimitEnabled);
@ -69,6 +75,9 @@ void BallAndSocketJoint::enableConeLimit(bool isLimitEnabled) {
}
// Return true if the cone limit or the joint is enabled
/**
* @return True if the cone-limit is enabled for this joint
*/
bool BallAndSocketJoint::isConeLimitEnabled() const {
return mWorld.mBallAndSocketJointsComponents.getIsConeLimitEnabled(mEntity);
}
@ -88,6 +97,9 @@ void BallAndSocketJoint::setConeLimitHalfAngle(decimal coneHalfAngle) {
}
// Set the normalized cone limit axis of body 1 in local-space of body 1
/**
* @param localAxisBody1 The normalized axis for the cone-limit in local-space of body 1
*/
void BallAndSocketJoint::setConeLimitLocalAxisBody1(const Vector3& localAxisBody1) {
mWorld.mBallAndSocketJointsComponents.setConeLimitLocalAxisBody1(mEntity, localAxisBody1);
@ -95,6 +107,9 @@ void BallAndSocketJoint::setConeLimitLocalAxisBody1(const Vector3& localAxisBody
}
// Set the normalized cone limit axis of body 2 in local-space of body 2
/**
* @param localAxisBody1 The normalized axis for the cone-limit in local-space of body 2
*/
void BallAndSocketJoint::setConeLimitLocalAxisBody2(const Vector3& localAxisBody2) {
mWorld.mBallAndSocketJointsComponents.setConeLimitLocalAxisBody2(mEntity, localAxisBody2);
@ -102,11 +117,17 @@ void BallAndSocketJoint::setConeLimitLocalAxisBody2(const Vector3& localAxisBody
}
// Return the cone angle limit (in radians) from [0; PI]
/**
* @return The half-angle (in radians) of the cone-limit
*/
decimal BallAndSocketJoint::getConeLimitHalfAngle() const {
return mWorld.mBallAndSocketJointsComponents.getConeLimitHalfAngle(mEntity);
}
// Return the current cone angle in radians (in [0, pi])
/**
* @return The current half-angle (in radians) of the joint with respect to the cone-limit axis
*/
decimal BallAndSocketJoint::getConeHalfAngle() const {
// Get the bodies entities
@ -124,12 +145,18 @@ decimal BallAndSocketJoint::getConeHalfAngle() const {
}
// Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current force (in Newtons) applied on body 2
*/
Vector3 BallAndSocketJoint::getReactionForce(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
return mWorld.mBallAndSocketJointsComponents.getImpulse(mEntity) / timeStep;
}
// Return the torque (in Newtons * meters) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current torque (in Newtons * meters) on body 2
*/
Vector3 BallAndSocketJoint::getReactionTorque(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
return Vector3(0, 0, 0);

View File

@ -72,12 +72,18 @@ FixedJoint::FixedJoint(Entity entity, PhysicsWorld& world, const FixedJointInfo&
}
// Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current force (in Newtons) applied on body 2
*/
Vector3 FixedJoint::getReactionForce(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
return mWorld.mFixedJointsComponents.getImpulseTranslation(mEntity) / timeStep;
}
// Return the torque (in Newtons * meters) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current torque (in Newtons * meters) applied on body 2
*/
Vector3 FixedJoint::getReactionTorque(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
return mWorld.mFixedJointsComponents.getImpulseRotation(mEntity) / timeStep;

View File

@ -162,6 +162,9 @@ void HingeJoint::resetLimits() {
}
// Set the motor speed
/**
* @param motorSpeed The speed of the motor
*/
void HingeJoint::setMotorSpeed(decimal motorSpeed) {
if (motorSpeed != mWorld.mHingeJointsComponents.getMotorSpeed(mEntity)) {
@ -267,12 +270,18 @@ decimal HingeJoint::getAngle() const {
}
// Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current force (in Newtons) applied on body 2
*/
Vector3 HingeJoint::getReactionForce(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
return mWorld.mHingeJointsComponents.getImpulseTranslation(mEntity) / timeStep;
}
// Return the torque (in Newtons * meters) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current torque (in Newtons * meters) applied on body 2
*/
Vector3 HingeJoint::getReactionTorque(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);

View File

@ -295,6 +295,9 @@ decimal SliderJoint::getMaxTranslationLimit() const {
}
// Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current force (in Newtons) applied on body 2
*/
Vector3 SliderJoint::getReactionForce(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);
@ -314,6 +317,9 @@ Vector3 SliderJoint::getReactionForce(decimal timeStep) const {
}
// Return the torque (in Newtons * meters) on body 2 required to satisfy the joint constraint in world-space
/**
* @return The current torque (in Newtons * meters) applied on body 2
*/
Vector3 SliderJoint::getReactionTorque(decimal timeStep) const {
assert(timeStep > MACHINE_EPSILON);