Improve Doxygen API Reference documentation

This commit is contained in:
Daniel Chappuis 2020-05-25 00:27:13 +02:00
parent ab86620412
commit cfdab52573
7 changed files with 134 additions and 22 deletions

View File

@ -40,7 +40,6 @@ class ContactManifold;
class CollisionBody; class CollisionBody;
class Collider; class Collider;
class MemoryManager; class MemoryManager;
class CollisionCallbackInfo;
// Class CollisionCallback // Class CollisionCallback
/** /**
@ -55,7 +54,7 @@ class CollisionCallback {
// Class ContactPoint // Class ContactPoint
/** /**
* This class represents a contact point between two bodies of the physics world. * This class represents a contact point between two colliders of the physics world.
*/ */
class ContactPoint { class ContactPoint {
@ -78,21 +77,33 @@ class CollisionCallback {
ContactPoint(const ContactPoint& contactPoint) = default; ContactPoint(const ContactPoint& contactPoint) = default;
/// Assignment operator /// Assignment operator
ContactPoint& operator=(const ContactPoint& contactPoint) = default; ContactPoint& operator=(const ContactPoint& contactPoint) = delete;
/// Destructor /// Destructor
~ContactPoint() = default; ~ContactPoint() = default;
/// Return the penetration depth /// Return the penetration depth
/**
* @return The penetration depth between the two colliders at this contact point
*/
decimal getPenetrationDepth() const; decimal getPenetrationDepth() const;
/// Return the world-space contact normal /// Return the world-space contact normal
/**
* @return The world-space contact normal
*/
const Vector3& getWorldNormal() const; const Vector3& getWorldNormal() const;
/// Return the contact point on the first collider in the local-space of the first collider /// Return the contact point on the first collider in the local-space of the first collider
/**
* @return The local-space contact point on the first collider
*/
const Vector3& getLocalPointOnCollider1() const; const Vector3& getLocalPointOnCollider1() const;
/// Return the contact point on the second collider in the local-space of the second collider /// Return the contact point on the second collider in the local-space of the second collider
/**
* @return The local-space contact point on the second collider
*/
const Vector3& getLocalPointOnCollider2() const; const Vector3& getLocalPointOnCollider2() const;
// -------------------- Friendship -------------------- // // -------------------- Friendship -------------------- //
@ -102,7 +113,7 @@ class CollisionCallback {
// Class ContactPair // Class ContactPair
/** /**
* This class represents the contact between two bodies of the physics world. * This class represents the contact between two colliders of the physics world.
* A contact pair contains a list of contact points. * A contact pair contains a list of contact points.
*/ */
class ContactPair { class ContactPair {
@ -152,30 +163,52 @@ class CollisionCallback {
ContactPair(const ContactPair& contactPair) = default; ContactPair(const ContactPair& contactPair) = default;
/// Assignment operator /// Assignment operator
ContactPair& operator=(const ContactPair& contactPair) = default; ContactPair& operator=(const ContactPair& contactPair) = delete;
/// Destructor /// Destructor
~ContactPair() = default; ~ContactPair() = default;
/// Return the number of contact points in the contact pair /// Return the number of contact points in the contact pair
/**
* @return The number of contact points in the contact pair
*/
uint getNbContactPoints() const; uint getNbContactPoints() const;
/// Return a given contact point /// Return a given contact point
/**
* @param index Index of the contact point to retrieve
* @return A contact point object
*/
ContactPoint getContactPoint(uint index) const; ContactPoint getContactPoint(uint index) const;
/// Return a pointer to the first body in contact /// Return a pointer to the first body in contact
/**
* @return A pointer to the first colliding body of the pair
*/
CollisionBody* getBody1() const; CollisionBody* getBody1() const;
/// Return a pointer to the second body in contact /// Return a pointer to the second body in contact
/**
* @return A pointer to the second colliding body of the pair
*/
CollisionBody* getBody2() const; CollisionBody* getBody2() const;
/// Return a pointer to the first collider in contact (in body 1) /// Return a pointer to the first collider in contact (in body 1)
/**
* @return A pointer to the first collider of the contact pair
*/
Collider* getCollider1() const; Collider* getCollider1() const;
/// Return a pointer to the second collider in contact (in body 2) /// Return a pointer to the second collider in contact (in body 2)
/**
* @return A pointer to the second collider of the contact pair
*/
Collider* getCollider2() const; Collider* getCollider2() const;
/// Return the corresponding type of event for this contact pair /// Return the corresponding type of event for this contact pair
/**
* @return The type of contact event for this contact pair
*/
EventType getEventType() const; EventType getEventType() const;
// -------------------- Friendship -------------------- // // -------------------- Friendship -------------------- //
@ -235,9 +268,16 @@ class CollisionCallback {
// -------------------- Methods -------------------- // // -------------------- Methods -------------------- //
/// Return the number of contact pairs /// Return the number of contact pairs
/**
* @return The number of contact pairs
*/
uint getNbContactPairs() const; uint getNbContactPairs() const;
/// Return a given contact pair /// Return a given contact pair
/**
* @param index Index of the contact pair to retrieve
* @return A contact pair object
*/
ContactPair getContactPair(uint index) const; ContactPair getContactPair(uint index) const;
// -------------------- Friendship -------------------- // // -------------------- Friendship -------------------- //

View File

@ -34,11 +34,10 @@ namespace reactphysics3d {
// Class EventListener // Class EventListener
/** /**
* This class can be used to receive event callbacks from the physics engine. * This class can be used to receive notifications about events that occur during the simulation.
* In order to receive callbacks, you need to create a new class that inherits from * In order to receive callbacks, you need to create a new class that inherits from
* this one and you must override the methods you need. Then, you need to register your * this one and you must override the methods that you need. Then, you will need to register your
* new event listener class to the physics world using the PhysicsWorld::setEventListener() * new event listener class to the physics world using the PhysicsWorld::setEventListener() method.
* method.
*/ */
class EventListener : public CollisionCallback { class EventListener : public CollisionCallback {

View File

@ -78,7 +78,7 @@ class PhysicsWorld {
/// Name of the world /// Name of the world
std::string worldName; std::string worldName;
/// Gravity vector of the world /// Gravity force vector of the world (in Newtons)
Vector3 gravity; Vector3 gravity;
/// Distance threshold for two contact points for a valid persistent contact (in meters) /// Distance threshold for two contact points for a valid persistent contact (in meters)
@ -567,6 +567,9 @@ inline void PhysicsWorld::testOverlap(CollisionBody* body, OverlapCallback& over
/// Use this method if you are not interested in contacts but if you simply want to know /// Use this method if you are not interested in contacts but if you simply want to know
/// which bodies overlap. If you want to get the contacts, you need to use the /// which bodies overlap. If you want to get the contacts, you need to use the
/// testCollision() method instead. /// testCollision() method instead.
/**
* @param overlapCallback Pointer to the callback class to report overlap
*/
inline void PhysicsWorld::testOverlap(OverlapCallback& overlapCallback) { inline void PhysicsWorld::testOverlap(OverlapCallback& overlapCallback) {
mCollisionDetection.testOverlap(overlapCallback); mCollisionDetection.testOverlap(overlapCallback);
} }
@ -700,6 +703,9 @@ inline void PhysicsWorld::setEventListener(EventListener* eventListener) {
// Return the number of CollisionBody in the physics world // Return the number of CollisionBody in the physics world
/// Note that even if a RigidBody is also a collision body, this method does not return the rigid bodies /// Note that even if a RigidBody is also a collision body, this method does not return the rigid bodies
/**
* @return The number of collision bodies in the physics world
*/
inline uint PhysicsWorld::getNbCollisionBodies() const { inline uint PhysicsWorld::getNbCollisionBodies() const {
return mCollisionBodies.size(); return mCollisionBodies.size();
} }
@ -733,6 +739,9 @@ inline CollisionBody* PhysicsWorld::getCollisionBody(uint index) {
} }
// Return the number of RigidBody in the physics world // Return the number of RigidBody in the physics world
/**
* @return The number of rigid bodies in the physics world
*/
inline uint PhysicsWorld::getNbRigidBodies() const { inline uint PhysicsWorld::getNbRigidBodies() const {
return mRigidBodies.size(); return mRigidBodies.size();
} }
@ -766,16 +775,25 @@ inline RigidBody* PhysicsWorld::getRigidBody(uint index) {
} }
// Return true if the debug rendering is enabled // Return true if the debug rendering is enabled
/**
* @return True if the debug rendering is enabled and false otherwise
*/
inline bool PhysicsWorld::getIsDebugRenderingEnabled() const { inline bool PhysicsWorld::getIsDebugRenderingEnabled() const {
return mIsDebugRenderingEnabled; return mIsDebugRenderingEnabled;
} }
// Set to true if debug rendering is enabled // Set to true if debug rendering is enabled
/**
* @param isEnabled True if you want to enable the debug rendering and false otherwise
*/
inline void PhysicsWorld::setIsDebugRenderingEnabled(bool isEnabled) { inline void PhysicsWorld::setIsDebugRenderingEnabled(bool isEnabled) {
mIsDebugRenderingEnabled = isEnabled; mIsDebugRenderingEnabled = isEnabled;
} }
// Return a reference to the Debug Renderer of the world // Return a reference to the Debug Renderer of the world
/**
* @return A reference to the DebugRenderer object of the world
*/
inline DebugRenderer& PhysicsWorld::getDebugRenderer() { inline DebugRenderer& PhysicsWorld::getDebugRenderer() {
return mDebugRenderer; return mDebugRenderer;
} }

View File

@ -260,41 +260,67 @@ class DebugRenderer : public EventListener {
}; };
// Return the number of lines // Return the number of lines
/**
* @return The number of lines in the array of lines to draw
*/
inline uint32 DebugRenderer::getNbLines() const { inline uint32 DebugRenderer::getNbLines() const {
return mLines.size(); return mLines.size();
} }
// Return a reference to the list of lines // Return a reference to the list of lines
/**
* @return The list of lines to draw
*/
inline const List<DebugRenderer::DebugLine>& DebugRenderer::getLines() const { inline const List<DebugRenderer::DebugLine>& DebugRenderer::getLines() const {
return mLines; return mLines;
} }
// Return a pointer to the array of lines // Return a pointer to the array of lines
/**
* @return A pointer to the first element of the lines array to draw
*/
inline const DebugRenderer::DebugLine* DebugRenderer::getLinesArray() const { inline const DebugRenderer::DebugLine* DebugRenderer::getLinesArray() const {
return &(mLines[0]); return &(mLines[0]);
} }
// Return the number of triangles // Return the number of triangles
/**
* @return The number of triangles in the array of triangles to draw
*/
inline uint32 DebugRenderer::getNbTriangles() const { inline uint32 DebugRenderer::getNbTriangles() const {
return mTriangles.size(); return mTriangles.size();
} }
// Return a reference to the list of triangles // Return a reference to the list of triangles
/**
* @return The list of triangles to draw
*/
inline const List<DebugRenderer::DebugTriangle>& DebugRenderer::getTriangles() const { inline const List<DebugRenderer::DebugTriangle>& DebugRenderer::getTriangles() const {
return mTriangles; return mTriangles;
} }
// Return a pointer to the array of triangles // Return a pointer to the array of triangles
/**
* @return A pointer to the first element of the triangles array to draw
*/
inline const DebugRenderer::DebugTriangle* DebugRenderer::getTrianglesArray() const { inline const DebugRenderer::DebugTriangle* DebugRenderer::getTrianglesArray() const {
return &(mTriangles[0]); return &(mTriangles[0]);
} }
// Return whether a debug item is displayed or not // Return whether a debug item is displayed or not
/**
* @param item A debug item
* @return True if the given debug item is being displayed and false otherwise
*/
inline bool DebugRenderer::getIsDebugItemDisplayed(DebugItem item) const { inline bool DebugRenderer::getIsDebugItemDisplayed(DebugItem item) const {
return mDisplayedDebugItems & static_cast<uint32>(item); return mDisplayedDebugItems & static_cast<uint32>(item);
} }
// Set whether a debug info is displayed or not // Set whether a debug info is displayed or not
/**
* @param item A debug item to draw
* @param isDisplayed True if the given debug item has to be displayed and false otherwise
*/
inline void DebugRenderer::setIsDebugItemDisplayed(DebugItem item, bool isDisplayed) { inline void DebugRenderer::setIsDebugItemDisplayed(DebugItem item, bool isDisplayed) {
const uint32 itemFlag = static_cast<uint32>(item); const uint32 itemFlag = static_cast<uint32>(item);
uint32 resetBit = ~(itemFlag); uint32 resetBit = ~(itemFlag);
@ -305,11 +331,17 @@ inline void DebugRenderer::setIsDebugItemDisplayed(DebugItem item, bool isDispla
} }
// Get the contact point sphere radius // Get the contact point sphere radius
/**
* @return The radius of the sphere used to display a contact point
*/
inline decimal DebugRenderer::getContactPointSphereRadius() const { inline decimal DebugRenderer::getContactPointSphereRadius() const {
return mContactPointSphereRadius; return mContactPointSphereRadius;
} }
// Set the contact point sphere radius // Set the contact point sphere radius
/**
* @param radius The radius of the sphere used to display a contact point
*/
inline void DebugRenderer::setContactPointSphereRadius(decimal radius) { inline void DebugRenderer::setContactPointSphereRadius(decimal radius) {
assert(radius > decimal(0.0)); assert(radius > decimal(0.0));
mContactPointSphereRadius = radius; mContactPointSphereRadius = radius;
@ -317,11 +349,17 @@ inline void DebugRenderer::setContactPointSphereRadius(decimal radius) {
// Return the length of contact normal // Return the length of contact normal
/**
* @return The length of the contact normal to display
*/
inline decimal DebugRenderer::getContactNormalLength() const { inline decimal DebugRenderer::getContactNormalLength() const {
return mContactNormalLength; return mContactNormalLength;
} }
// Return the length of contact normal // Return the length of contact normal
/**
* @param contactNormalLength The length of the contact normal to display
*/
inline void DebugRenderer::setContactNormalLength(decimal contactNormalLength) { inline void DebugRenderer::setContactNormalLength(decimal contactNormalLength) {
mContactNormalLength = contactNormalLength; mContactNormalLength = contactNormalLength;
} }

View File

@ -44,6 +44,9 @@ RigidBody::RigidBody(PhysicsWorld& world, Entity entity) : CollisionBody(world,
} }
// Return the type of the body // Return the type of the body
/**
* @return The type of rigid body (static, kinematic or dynamic)
*/
BodyType RigidBody::getType() const { BodyType RigidBody::getType() const {
return mWorld.mRigidBodyComponents.getBodyType(mEntity); return mWorld.mRigidBodyComponents.getBodyType(mEntity);
} }
@ -136,7 +139,7 @@ decimal RigidBody::getMass() const {
/// reset to zero at the end of each call of the PhyscisWorld::update() method. /// reset to zero at the end of each call of the PhyscisWorld::update() method.
/// You can only apply a force to a dynamic body otherwise, this method will do nothing. /// You can only apply a force to a dynamic body otherwise, this method will do nothing.
/** /**
* @param force The force to apply on the body * @param force The force to apply on the body (in Newtons)
* @param point The point where the force is applied (in local-space coordinates) * @param point The point where the force is applied (in local-space coordinates)
*/ */
void RigidBody::applyForceAtLocalPosition(const Vector3& force, const Vector3& point) { void RigidBody::applyForceAtLocalPosition(const Vector3& force, const Vector3& point) {
@ -168,7 +171,7 @@ void RigidBody::applyForceAtLocalPosition(const Vector3& force, const Vector3& p
/// reset to zero at the end of each call of the PhyscisWorld::update() method. /// reset to zero at the end of each call of the PhyscisWorld::update() method.
/// You can only apply a force to a dynamic body otherwise, this method will do nothing. /// You can only apply a force to a dynamic body otherwise, this method will do nothing.
/** /**
* @param force The force to apply on the body * @param force The force to apply on the body (in Newtons)
* @param point The point where the force is applied (in world-space coordinates) * @param point The point where the force is applied (in world-space coordinates)
*/ */
void RigidBody::applyForceAtWorldPosition(const Vector3& force, const Vector3& point) { void RigidBody::applyForceAtWorldPosition(const Vector3& force, const Vector3& point) {
@ -192,6 +195,9 @@ void RigidBody::applyForceAtWorldPosition(const Vector3& force, const Vector3& p
} }
// Return the local inertia tensor of the body (in body coordinates) // Return the local inertia tensor of the body (in body coordinates)
/**
* @return A vector with the three values of the diagonal 3x3 matrix of the local-space inertia tensor
*/
const Vector3& RigidBody::getLocalInertiaTensor() const { const Vector3& RigidBody::getLocalInertiaTensor() const {
return mWorld.mRigidBodyComponents.getLocalInertiaTensor(mEntity); return mWorld.mRigidBodyComponents.getLocalInertiaTensor(mEntity);
@ -200,8 +206,7 @@ const Vector3& RigidBody::getLocalInertiaTensor() const {
// Set the local inertia tensor of the body (in local-space coordinates) // Set the local inertia tensor of the body (in local-space coordinates)
/// Note that an inertia tensor with a zero value on its diagonal is interpreted as infinite inertia. /// Note that an inertia tensor with a zero value on its diagonal is interpreted as infinite inertia.
/** /**
* @param inertiaTensorLocal The 3x3 inertia tensor matrix of the body in local-space * @param inertiaTensorLocal A vector with the three values of the diagonal 3x3 matrix of the local-space inertia tensor
* coordinates
*/ */
void RigidBody::setLocalInertiaTensor(const Vector3& inertiaTensorLocal) { void RigidBody::setLocalInertiaTensor(const Vector3& inertiaTensorLocal) {
@ -223,7 +228,7 @@ void RigidBody::setLocalInertiaTensor(const Vector3& inertiaTensorLocal) {
/// reset to zero at the end of each call of the PhyscisWorld::update() method. /// reset to zero at the end of each call of the PhyscisWorld::update() method.
/// You can only apply a force to a dynamic body otherwise, this method will do nothing. /// You can only apply a force to a dynamic body otherwise, this method will do nothing.
/** /**
* @param force The external force to apply on the center of mass of the body * @param force The external force to apply on the center of mass of the body (in Newtons)
*/ */
void RigidBody::applyForceToCenterOfMass(const Vector3& force) { void RigidBody::applyForceToCenterOfMass(const Vector3& force) {
@ -281,6 +286,9 @@ void RigidBody::setLocalCenterOfMass(const Vector3& centerOfMass) {
} }
// Return the center of mass of the body (in local-space coordinates) // Return the center of mass of the body (in local-space coordinates)
/**
* @return The local-space position of the center of mass of the body
*/
const Vector3& RigidBody::getLocalCenterOfMass() const { const Vector3& RigidBody::getLocalCenterOfMass() const {
return mWorld.mRigidBodyComponents.getCenterOfMassLocal(mEntity); return mWorld.mRigidBodyComponents.getCenterOfMassLocal(mEntity);
} }
@ -550,7 +558,7 @@ void RigidBody::setMass(decimal mass) {
/// returned collider to get and set information about the corresponding /// returned collider to get and set information about the corresponding
/// collision shape for that body. /// collision shape for that body.
/** /**
* @param collisionShape The collision shape of the new collider * @param collisionShape A pointer to the collision shape of the new collider
* @param transform The transformation of the collider that transforms the * @param transform The transformation of the collider that transforms the
* local-space of the collider into the local-space of the body * local-space of the collider into the local-space of the body
* @return A pointer to the collider that has been created * @return A pointer to the collider that has been created

View File

@ -103,7 +103,10 @@ void Collider::setCollideWithMaskBits(unsigned short collideWithMaskBits) {
std::to_string(collideWithMaskBits), __FILE__, __LINE__); std::to_string(collideWithMaskBits), __FILE__, __LINE__);
} }
// Set the local to parent body transform // Set the local to body transform
/**
* @param transform The transform from local-space of the collider into the local-space of the body
*/
void Collider::setLocalToBodyTransform(const Transform& transform) { void Collider::setLocalToBodyTransform(const Transform& transform) {
mBody->mWorld.mCollidersComponents.setLocalToBodyTransform(mEntity, transform); mBody->mWorld.mCollidersComponents.setLocalToBodyTransform(mEntity, transform);
@ -137,7 +140,7 @@ const AABB Collider::getWorldAABB() const {
// Return a pointer to the collision shape // Return a pointer to the collision shape
/** /**
* @return Pointer to the internal collision shape * @return Pointer to the collision shape
*/ */
CollisionShape* Collider::getCollisionShape() { CollisionShape* Collider::getCollisionShape() {
return mBody->mWorld.mCollidersComponents.getCollisionShape(mEntity); return mBody->mWorld.mCollidersComponents.getCollisionShape(mEntity);
@ -145,7 +148,7 @@ CollisionShape* Collider::getCollisionShape() {
// Return a const pointer to the collision shape // Return a const pointer to the collision shape
/** /**
* @return Pointer to the internal collision shape * @return Pointer to the collision shape
*/ */
const CollisionShape* Collider::getCollisionShape() const { const CollisionShape* Collider::getCollisionShape() const {
return mBody->mWorld.mCollidersComponents.getCollisionShape(mEntity); return mBody->mWorld.mCollidersComponents.getCollisionShape(mEntity);
@ -158,8 +161,8 @@ int Collider::getBroadPhaseId() const {
// Return the local to parent body transform // Return the local to parent body transform
/** /**
* @return The transformation that transforms the local-space of the collision shape * @return The transformation that transforms the local-space of the collider
* to the local-space of the parent body * to the local-space of the body
*/ */
const Transform& Collider::getLocalToBodyTransform() const { const Transform& Collider::getLocalToBodyTransform() const {
return mBody->mWorld.mCollidersComponents.getLocalToBodyTransform(mEntity); return mBody->mWorld.mCollidersComponents.getLocalToBodyTransform(mEntity);
@ -238,11 +241,17 @@ const Transform Collider::getLocalToWorldTransform() const {
} }
// Return true if the collider is a trigger // Return true if the collider is a trigger
/**
* @return True if this collider is a trigger and false otherwise
*/
bool Collider::getIsTrigger() const { bool Collider::getIsTrigger() const {
return mBody->mWorld.mCollidersComponents.getIsTrigger(mEntity); return mBody->mWorld.mCollidersComponents.getIsTrigger(mEntity);
} }
// Set whether the collider is a trigger // Set whether the collider is a trigger
/**
* @param isTrigger True if you want to set this collider as a trigger and false otherwise
*/
void Collider::setIsTrigger(bool isTrigger) const { void Collider::setIsTrigger(bool isTrigger) const {
mBody->mWorld.mCollidersComponents.setIsTrigger(mEntity, isTrigger); mBody->mWorld.mCollidersComponents.setIsTrigger(mEntity, isTrigger);
} }

View File

@ -75,7 +75,7 @@ CollisionCallback::ContactPair::EventType CollisionCallback::ContactPair::getEve
return EventType::ContactStart; return EventType::ContactStart;
} }
// CollisionCallbackInfo Constructor // Constructor
CollisionCallback::CallbackData::CallbackData(List<reactphysics3d::ContactPair>* contactPairs, List<ContactManifold>* manifolds, CollisionCallback::CallbackData::CallbackData(List<reactphysics3d::ContactPair>* contactPairs, List<ContactManifold>* manifolds,
List<reactphysics3d::ContactPoint>* contactPoints, List<reactphysics3d::ContactPair>& lostContactPairs, PhysicsWorld& world) List<reactphysics3d::ContactPoint>* contactPoints, List<reactphysics3d::ContactPair>& lostContactPairs, PhysicsWorld& world)
:mContactPairs(contactPairs), mContactManifolds(manifolds), mContactPoints(contactPoints), mLostContactPairs(lostContactPairs), :mContactPairs(contactPairs), mContactManifolds(manifolds), mContactPoints(contactPoints), mLostContactPairs(lostContactPairs),