ReactPhysics3D
v0.10.2
C++ Physics engine library
|
This class represents a physics world. More...
#include <include/reactphysics3d/engine/PhysicsWorld.h>
Classes | |
struct | WorldSettings |
Structure WorldSettings. More... | |
Public Member Functions | |
CollisionDispatch & | getCollisionDispatch () |
Get the collision dispatch configuration. | |
void | raycast (const Ray &ray, RaycastCallback *raycastCallback, unsigned short raycastWithCategoryMaskBits=0xFFFF) const |
Ray cast method. | |
bool | testOverlap (Body *body1, Body *body2) |
Return true if two bodies overlap (collide) | |
void | testOverlap (Body *body, OverlapCallback &overlapCallback) |
Report all the bodies that overlap (collide) with the body in parameter. | |
void | testOverlap (OverlapCallback &overlapCallback) |
Report all the bodies that overlap (collide) in the world. | |
void | testCollision (Body *body1, Body *body2, CollisionCallback &callback) |
Test collision and report contacts between two bodies. | |
void | testCollision (Body *body, CollisionCallback &callback) |
Test collision and report all the contacts involving the body in parameter. | |
void | testCollision (CollisionCallback &callback) |
Test collision and report contacts between each colliding bodies in the world. | |
MemoryManager & | getMemoryManager () |
Return a reference to the memory manager of the world. | |
AABB | getWorldAABB (const Collider *collider) const |
Return the current world-space AABB of given collider. | |
const std::string & | getName () const |
Return the name of the world. | |
PhysicsWorld (const PhysicsWorld &world)=delete | |
Deleted copy-constructor. | |
PhysicsWorld & | operator= (const PhysicsWorld &world)=delete |
Deleted assignment operator. | |
void | update (decimal timeStep) |
Update the physics simulation. | |
uint16 | getNbIterationsVelocitySolver () const |
Get the number of iterations for the velocity constraint solver. | |
void | setNbIterationsVelocitySolver (uint16 nbIterations) |
Set the number of iterations for the velocity constraint solver. | |
uint16 | getNbIterationsPositionSolver () const |
Get the number of iterations for the position constraint solver. | |
void | setNbIterationsPositionSolver (uint32 nbIterations) |
Set the number of iterations for the position constraint solver. | |
void | setContactsPositionCorrectionTechnique (ContactsPositionCorrectionTechnique technique) |
Set the position correction technique used for contacts. | |
RigidBody * | createRigidBody (const Transform &transform) |
Create a rigid body into the physics world. | |
void | enableDisableJoints () |
Disable the joints for pair of sleeping bodies. | |
void | destroyRigidBody (RigidBody *rigidBody) |
Destroy a rigid body and all the joints which it belongs. | |
Joint * | createJoint (const JointInfo &jointInfo) |
Create a joint between two bodies in the world and return a pointer to the new joint. | |
void | destroyJoint (Joint *joint) |
Destroy a joint. | |
Vector3 | getGravity () const |
Return the gravity vector of the world. | |
void | setGravity (const Vector3 &gravity) |
Set the gravity vector of the world. | |
bool | isGravityEnabled () const |
Return if the gravity is on. | |
void | setIsGravityEnabled (bool isGravityEnabled) |
Enable/Disable the gravity. | |
bool | isSleepingEnabled () const |
Return true if the sleeping technique is enabled. | |
void | enableSleeping (bool isSleepingEnabled) |
Enable/Disable the sleeping technique. | |
decimal | getSleepLinearVelocity () const |
Return the current sleep linear velocity. | |
void | setSleepLinearVelocity (decimal sleepLinearVelocity) |
Set the sleep linear velocity. | |
decimal | getSleepAngularVelocity () const |
Return the current sleep angular velocity. | |
void | setSleepAngularVelocity (decimal sleepAngularVelocity) |
Set the sleep angular velocity. | |
decimal | getTimeBeforeSleep () const |
Return the time a body is required to stay still before sleeping. | |
void | setTimeBeforeSleep (decimal timeBeforeSleep) |
Set the time a body is required to stay still before sleeping. | |
void | setEventListener (EventListener *eventListener) |
Set an event listener object to receive events callbacks. | |
uint32 | getNbRigidBodies () const |
Return the number of RigidBody in the physics world. | |
const RigidBody * | getRigidBody (uint32 index) const |
Return a constant pointer to a given RigidBody of the world. | |
RigidBody * | getRigidBody (uint32 index) |
Return a pointer to a given RigidBody of the world. | |
bool | getIsDebugRenderingEnabled () const |
Return true if the debug rendering is enabled. | |
void | setIsDebugRenderingEnabled (bool isEnabled) |
Set to true if debug rendering is enabled. | |
DebugRenderer & | getDebugRenderer () |
Return a reference to the Debug Renderer of the world. | |
This class represents a physics world.
Create a joint between two bodies in the world and return a pointer to the new joint.
jointInfo | The information that is necessary to create the joint |
Create a rigid body into the physics world.
transform | Transformation from body local-space to world-space |
void PhysicsWorld::destroyJoint | ( | Joint * | joint | ) |
Destroy a joint.
joint | Pointer to the joint you want to destroy |
void PhysicsWorld::destroyRigidBody | ( | RigidBody * | rigidBody | ) |
Destroy a rigid body and all the joints which it belongs.
rigidBody | Pointer to the body you want to destroy |
void PhysicsWorld::enableSleeping | ( | bool | isSleepingEnabled | ) |
Enable/Disable the sleeping technique.
The sleeping technique is used to put bodies that are not moving into sleep to speed up the simulation.
isSleepingEnabled | True if you want to enable the sleeping technique and false otherwise |
RP3D_FORCE_INLINE CollisionDispatch & reactphysics3d::PhysicsWorld::getCollisionDispatch | ( | ) |
Get the collision dispatch configuration.
This can be used to replace default collision detection algorithms by your custom algorithm for instance.
CollisionDispatch | Pointer to a collision dispatch object describing which collision detection algorithm to use for two given collision shapes |
RP3D_FORCE_INLINE DebugRenderer & reactphysics3d::PhysicsWorld::getDebugRenderer | ( | ) |
Return a reference to the Debug Renderer of the world.
RP3D_FORCE_INLINE Vector3 reactphysics3d::PhysicsWorld::getGravity | ( | ) | const |
Return the gravity vector of the world.
RP3D_FORCE_INLINE bool reactphysics3d::PhysicsWorld::getIsDebugRenderingEnabled | ( | ) | const |
Return true if the debug rendering is enabled.
RP3D_FORCE_INLINE const std::string & reactphysics3d::PhysicsWorld::getName | ( | ) | const |
Return the name of the world.
RP3D_FORCE_INLINE uint16 reactphysics3d::PhysicsWorld::getNbIterationsPositionSolver | ( | ) | const |
Get the number of iterations for the position constraint solver.
RP3D_FORCE_INLINE uint16 reactphysics3d::PhysicsWorld::getNbIterationsVelocitySolver | ( | ) | const |
Get the number of iterations for the velocity constraint solver.
RP3D_FORCE_INLINE uint32 reactphysics3d::PhysicsWorld::getNbRigidBodies | ( | ) | const |
Return the number of RigidBody in the physics world.
RigidBody * PhysicsWorld::getRigidBody | ( | uint32 | index | ) |
const RigidBody * PhysicsWorld::getRigidBody | ( | uint32 | index | ) | const |
RP3D_FORCE_INLINE decimal reactphysics3d::PhysicsWorld::getSleepAngularVelocity | ( | ) | const |
Return the current sleep angular velocity.
RP3D_FORCE_INLINE decimal reactphysics3d::PhysicsWorld::getSleepLinearVelocity | ( | ) | const |
Return the current sleep linear velocity.
RP3D_FORCE_INLINE decimal reactphysics3d::PhysicsWorld::getTimeBeforeSleep | ( | ) | const |
Return the time a body is required to stay still before sleeping.
Return the current world-space AABB of given collider.
collider | Pointer to a collider |
RP3D_FORCE_INLINE bool reactphysics3d::PhysicsWorld::isGravityEnabled | ( | ) | const |
Return if the gravity is on.
RP3D_FORCE_INLINE bool reactphysics3d::PhysicsWorld::isSleepingEnabled | ( | ) | const |
Return true if the sleeping technique is enabled.
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::raycast | ( | const Ray & | ray, |
RaycastCallback * | raycastCallback, | ||
unsigned short | raycastWithCategoryMaskBits = 0xFFFF |
||
) | const |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::setContactsPositionCorrectionTechnique | ( | ContactsPositionCorrectionTechnique | technique | ) |
Set the position correction technique used for contacts.
technique | Technique used for the position correction (Baumgarte or Split Impulses) |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::setEventListener | ( | EventListener * | eventListener | ) |
Set an event listener object to receive events callbacks.
If you use "nullptr" as an argument, the events callbacks will be disabled.
eventListener | Pointer to the event listener object that will receive event callbacks during the simulation |
void PhysicsWorld::setGravity | ( | const Vector3 & | gravity | ) |
Set the gravity vector of the world.
gravity | The gravity vector (in meter per seconds squared) |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::setIsDebugRenderingEnabled | ( | bool | isEnabled | ) |
Set to true if debug rendering is enabled.
isEnabled | True if you want to enable the debug rendering and false otherwise |
void PhysicsWorld::setIsGravityEnabled | ( | bool | isGravityEnabled | ) |
Enable/Disable the gravity.
isGravityEnabled | True if you want to enable the gravity in the world and false otherwise |
void PhysicsWorld::setNbIterationsPositionSolver | ( | uint32 | nbIterations | ) |
Set the number of iterations for the position constraint solver.
nbIterations | Number of iterations for the position solver |
void PhysicsWorld::setNbIterationsVelocitySolver | ( | uint16 | nbIterations | ) |
Set the number of iterations for the velocity constraint solver.
nbIterations | Number of iterations for the velocity solver |
void PhysicsWorld::setSleepAngularVelocity | ( | decimal | sleepAngularVelocity | ) |
Set the sleep angular velocity.
When the velocity of a body becomes smaller than the sleep linear/angular velocity for a given amount of time, the body starts sleeping and does not need to be simulated anymore.
sleepAngularVelocity | The sleep angular velocity (in radian per second) |
void PhysicsWorld::setSleepLinearVelocity | ( | decimal | sleepLinearVelocity | ) |
Set the sleep linear velocity.
When the velocity of a body becomes smaller than the sleep linear/angular velocity for a given amount of time, the body starts sleeping and does not need to be simulated anymore.
sleepLinearVelocity | The sleep linear velocity (in meters per second) |
void PhysicsWorld::setTimeBeforeSleep | ( | decimal | timeBeforeSleep | ) |
Set the time a body is required to stay still before sleeping.
timeBeforeSleep | Time a body is required to stay still before sleeping (in seconds) |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::testCollision | ( | Body * | body, |
CollisionCallback & | callback | ||
) |
Test collision and report all the contacts involving the body in parameter.
Use this method if you only want to get all the contacts involving a given body.
All the contacts will be reported using the callback object in paramater. If you are not interested in the contacts but you only want to know if the bodies collide, you can use the testOverlap() method instead.
body | Pointer to the body against which we need to test collision |
callback | Pointer to the object with the callback method to report contacts |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::testCollision | ( | Body * | body1, |
Body * | body2, | ||
CollisionCallback & | callback | ||
) |
Test collision and report contacts between two bodies.
Use this method if you only want to get all the contacts between two bodies.
All the contacts will be reported using the callback object in paramater. If you are not interested in the contacts but you only want to know if the bodies collide, you can use the testOverlap() method instead.
body1 | Pointer to the first body to test |
body2 | Pointer to the second body to test |
callback | Pointer to the object with the callback method |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::testCollision | ( | CollisionCallback & | callback | ) |
Test collision and report contacts between each colliding bodies in the world.
Use this method if you want to get all the contacts between colliding bodies in the world.
All the contacts will be reported using the callback object in paramater. If you are not interested in the contacts but you only want to know if the bodies collide, you can use the testOverlap() method instead.
callback | Pointer to the object with the callback method to report contacts |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::testOverlap | ( | Body * | body, |
OverlapCallback & | overlapCallback | ||
) |
Report all the bodies that overlap (collide) with the body in parameter.
Use this method if you are not interested in contacts but if you simply want to know which bodies overlap with the body in parameter.
If you want to get the contacts, you need to use the testCollision() method instead.
body | Pointer to the collision body to test overlap with |
overlapCallback | Pointer to the callback class to report overlap |
Return true if two bodies overlap (collide)
Use this method if you are not interested in contacts but if you simply want to know if the two bodies overlap.
If you want to get the contacts, you need to use the testCollision() method instead.
body1 | Pointer to the first body |
body2 | Pointer to a second body |
RP3D_FORCE_INLINE void reactphysics3d::PhysicsWorld::testOverlap | ( | OverlapCallback & | overlapCallback | ) |
Report all the bodies that overlap (collide) in the world.
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 testCollision() method instead.
overlapCallback | Pointer to the callback class to report overlap |
void PhysicsWorld::update | ( | decimal | timeStep | ) |
Update the physics simulation.
timeStep | The amount of time to step the simulation by (in seconds) |