ReactPhysics3D
v0.10.2
C++ Physics engine library
|
This class represents a body. More...
#include <include/reactphysics3d/body/Body.h>
Public Member Functions | |
Body (PhysicsWorld &world, Entity entity) | |
Constructor. | |
virtual | ~Body () |
Destructor. | |
Body (const Body &body)=delete | |
Deleted copy-constructor. | |
Body & | operator= (const Body &body)=delete |
Deleted assignment operator. | |
Entity | getEntity () const |
Return the corresponding entity of the body. | |
bool | isActive () const |
Return true if the body is active. | |
void * | getUserData () const |
Return a pointer to the user data attached to this body. | |
void | setUserData (void *userData) |
Attach user data to this body. | |
virtual void | setIsActive (bool isActive) |
Set whether or not the body is active. | |
const Transform & | getTransform () const |
Return the current position and orientation. | |
virtual void | setTransform (const Transform &transform) |
Set the current position and orientation. | |
virtual Collider * | addCollider (CollisionShape *collisionShape, const Transform &transform) |
Create a new collider and add it to the body. | |
virtual void | removeCollider (Collider *collider) |
Remove a collider from the body. | |
bool | testPointInside (const Vector3 &worldPoint) const |
Return true if a point is inside the collision body. | |
bool | raycast (const Ray &ray, RaycastInfo &raycastInfo) |
Raycast method with feedback information. | |
bool | testAABBOverlap (const AABB &worldAABB) const |
Test if the collision body overlaps with a given AABB. | |
AABB | getAABB () const |
Compute and return the AABB of the body by merging all colliders AABBs. | |
const Collider * | getCollider (uint32 colliderIndex) const |
Return a const pointer to a given collider of the body. | |
Collider * | getCollider (uint32 colliderIndex) |
Return a pointer to a given collider of the body. | |
uint32 | getNbColliders () const |
Return the number of colliders associated with this body. | |
Vector3 | getWorldPoint (const Vector3 &localPoint) const |
Return the world-space coordinates of a point given the local-space coordinates of the body. | |
Vector3 | getWorldVector (const Vector3 &localVector) const |
Return the world-space vector of a vector given in local-space coordinates of the body. | |
Vector3 | getLocalPoint (const Vector3 &worldPoint) const |
Return the body local-space coordinates of a point given in the world-space coordinates. | |
Vector3 | getLocalVector (const Vector3 &worldVector) const |
Return the body local-space coordinates of a vector given in the world-space coordinates. | |
void | setIsDebugEnabled (bool enabled) |
Set whether or not debug lines are computed for this body. | |
bool | isDebugEnabled () const |
Return true if debug lines should be computed for this body. | |
This class represents a body.
Body::Body | ( | PhysicsWorld & | world, |
Entity | entity | ||
) |
Constructor.
world | The reference to the physics world where the body is created |
entity | Entity of the body |
|
virtual |
Create a new collider and add it to the body.
This method will return a pointer to a new collider.
A collider is an object with a collision shape that is attached to a body. It is possible to attach multiple colliders to a given body. You can use the returned collider to get and set information about the corresponding collision shape for that body.
collisionShape | A pointer to the collision shape of the new collider |
transform | The transformation of the collider that transforms the local-space of the collider into the local-space of the body |
Reimplemented in reactphysics3d::RigidBody.
AABB Body::getAABB | ( | ) | const |
Collider * Body::getCollider | ( | uint32 | colliderIndex | ) |
Return a pointer to a given collider of the body.
colliderIndex | Index of a Collider of the body |
const Collider * Body::getCollider | ( | uint32 | colliderIndex | ) | const |
Return a const pointer to a given collider of the body.
colliderIndex | Index of a Collider of the body |
RP3D_FORCE_INLINE Entity reactphysics3d::Body::getEntity | ( | ) | const |
Return the corresponding entity of the body.
Return the body local-space coordinates of a point given in the world-space coordinates.
worldPoint | A point in world-space coordinates |
Return the body local-space coordinates of a vector given in the world-space coordinates.
worldVector | A vector in world-space coordinates |
uint32 Body::getNbColliders | ( | ) | const |
Return the number of colliders associated with this body.
const Transform & Body::getTransform | ( | ) | const |
Return the current position and orientation.
void * Body::getUserData | ( | ) | const |
Return a pointer to the user data attached to this body.
Return the world-space coordinates of a point given the local-space coordinates of the body.
localPoint | A point in the local-space coordinates of the body |
Return the world-space vector of a vector given in local-space coordinates of the body.
localVector | A vector in the local-space coordinates of the body |
bool Body::isActive | ( | ) | const |
Return true if the body is active.
bool Body::isDebugEnabled | ( | ) | const |
Return true if debug lines should be computed for this body.
bool Body::raycast | ( | const Ray & | ray, |
RaycastInfo & | raycastInfo | ||
) |
Raycast method with feedback information.
The method returns the closest hit among all the collision shapes of the body.
ray | The ray used to raycast agains the body | |
[out] | raycastInfo | Structure that contains the result of the raycasting (valid only if the method returned true) |
|
virtual |
Remove a collider from the body.
To remove a collider, you need to specify its pointer.
collider | The pointer of the collider you want to remove |
Reimplemented in reactphysics3d::RigidBody.
|
virtual |
Set whether or not the body is active.
isActive | True if you want to activate the body |
Reimplemented in reactphysics3d::RigidBody.
void Body::setIsDebugEnabled | ( | bool | enabled | ) |
|
virtual |
Set the current position and orientation.
transform | The transformation of the body that transforms the local-space of the body into world-space |
Reimplemented in reactphysics3d::RigidBody.
void Body::setUserData | ( | void * | userData | ) |
Attach user data to this body.
userData | A pointer to the user data you want to attach to the body |
RP3D_FORCE_INLINE bool reactphysics3d::Body::testAABBOverlap | ( | const AABB & | worldAABB | ) | const |
bool Body::testPointInside | ( | const Vector3 & | worldPoint | ) | const |
Return true if a point is inside the collision body.
This method returns true if a point is inside any collision shape of the body.
worldPoint | The point to test (in world-space coordinates) |