ReactPhysics3D  v0.10.1
C++ Physics engine library
reactphysics3d::Collider Class Reference

A collider has a collision shape (box, sphere, capsule, ...) and is attached to a RigidBody. More...

#include <include/reactphysics3d/collision/Collider.h>

Public Member Functions

 Collider (Entity entity, Body *body, MemoryManager &memoryManager)
 Constructor. More...
 
virtual ~Collider ()
 Destructor.
 
 Collider (const Collider &collider)=delete
 Deleted copy-constructor.
 
Collideroperator= (const Collider &collider)=delete
 Deleted assignment operator.
 
Entity getEntity () const
 Return the corresponding entity of the collider. More...
 
CollisionShapegetCollisionShape ()
 Return a pointer to the collision shape. More...
 
const CollisionShapegetCollisionShape () const
 Return a const pointer to the collision shape. More...
 
BodygetBody () const
 Return the parent body. More...
 
void * getUserData () const
 Return a pointer to the user data attached to this body. More...
 
void setUserData (void *userData)
 Attach user data to this body. More...
 
const TransformgetLocalToBodyTransform () const
 Return the local to parent body transform. More...
 
void setLocalToBodyTransform (const Transform &transform)
 Set the local to parent body transform. More...
 
const Transform getLocalToWorldTransform () const
 Return the local to world transform. More...
 
const AABB getWorldAABB () const
 Return the AABB of the collider in world-space. More...
 
bool testAABBOverlap (const AABB &worldAABB) const
 Test if the collider overlaps with a given AABB. More...
 
bool testPointInside (const Vector3 &worldPoint)
 Return true if a point is inside the collision shape. More...
 
bool raycast (const Ray &ray, RaycastInfo &raycastInfo)
 Raycast method with feedback information. More...
 
unsigned short getCollideWithMaskBits () const
 Return the collision bits mask. More...
 
void setCollideWithMaskBits (unsigned short collideWithMaskBits)
 Set the collision bits mask. More...
 
unsigned short getCollisionCategoryBits () const
 Return the collision category bits. More...
 
void setCollisionCategoryBits (unsigned short collisionCategoryBits)
 Set the collision category bits. More...
 
int getBroadPhaseId () const
 Return the broad-phase id.
 
MaterialgetMaterial ()
 Return a reference to the material properties of the collider. More...
 
void setMaterial (const Material &material)
 Set a new material for this collider. More...
 
bool getIsTrigger () const
 Return true if the collider is a trigger. More...
 
void setIsTrigger (bool isTrigger) const
 Set whether the collider is a trigger. More...
 
bool getIsSimulationCollider () const
 Return true if the collider can generate contacts for the simulation of the associated body.
 
void setIsSimulationCollider (bool isSimulationCollider) const
 Set whether the collider can generate contacts for the simulation of the associated body. More...
 
bool getIsWorldQueryCollider () const
 Return true if the collider will be part of results of queries on the PhysicsWorld.
 
void setIsWorldQueryCollider (bool isWorldQueryCollider) const
 Set whether the collider will be part of results of queries on the PhysicsWorld. More...
 

Detailed Description

A collider has a collision shape (box, sphere, capsule, ...) and is attached to a RigidBody.

A body can have multiple colliders. The collider also have a mass value and a Material with many physics parameters like friction or bounciness. When you create a body, you need to attach at least one collider to it if you want that body to be able to collide in the physics world.

Constructor & Destructor Documentation

◆ Collider()

Collider::Collider ( Entity  entity,
Body body,
MemoryManager memoryManager 
)

Constructor.

Parameters
entityEntity of the collider
bodyPointer to the body
memoryManagerReference to the memory manager

Member Function Documentation

◆ getBody()

RP3D_FORCE_INLINE Body * reactphysics3d::Collider::getBody ( ) const

Return the parent body.

Returns
Pointer to the parent body

◆ getCollideWithMaskBits()

unsigned short Collider::getCollideWithMaskBits ( ) const

Return the collision bits mask.

Returns
The bits mask that specifies with which collision category this shape will collide

◆ getCollisionCategoryBits()

unsigned short Collider::getCollisionCategoryBits ( ) const

Return the collision category bits.

Returns
The collision category bits mask of the collider

◆ getCollisionShape() [1/2]

CollisionShape * Collider::getCollisionShape ( )

Return a pointer to the collision shape.

Returns
Pointer to the collision shape

◆ getCollisionShape() [2/2]

const CollisionShape * Collider::getCollisionShape ( ) const

Return a const pointer to the collision shape.

Returns
Pointer to the collision shape

◆ getEntity()

RP3D_FORCE_INLINE Entity reactphysics3d::Collider::getEntity ( ) const

Return the corresponding entity of the collider.

Returns
The entity of the collider

◆ getIsTrigger()

bool Collider::getIsTrigger ( ) const

Return true if the collider is a trigger.

Returns
True if this collider is a trigger and false otherwise

◆ getLocalToBodyTransform()

const Transform & Collider::getLocalToBodyTransform ( ) const

Return the local to parent body transform.

Returns
The transformation that transforms the local-space of the collider to the local-space of the body

◆ getLocalToWorldTransform()

const Transform Collider::getLocalToWorldTransform ( ) const

Return the local to world transform.

Returns
The transformation that transforms the local-space of the collision shape to the world-space

◆ getMaterial()

Material & Collider::getMaterial ( )

Return a reference to the material properties of the collider.

Returns
A reference to the material of the body

◆ getUserData()

RP3D_FORCE_INLINE void * reactphysics3d::Collider::getUserData ( ) const

Return a pointer to the user data attached to this body.

Returns
A pointer to the user data stored into the collider

◆ getWorldAABB()

const AABB Collider::getWorldAABB ( ) const

Return the AABB of the collider in world-space.

Returns
The AABB of the collider in world-space

◆ raycast()

bool Collider::raycast ( const Ray ray,
RaycastInfo raycastInfo 
)

Raycast method with feedback information.

Parameters
rayRay to use for the raycasting in world-space
[out]raycastInfoResult of the raycasting that is valid only if the methods returned true
Returns
True if the ray hits the collision shape

◆ setCollideWithMaskBits()

void Collider::setCollideWithMaskBits ( unsigned short  collideWithMaskBits)

Set the collision bits mask.

Parameters
collideWithMaskBitsThe bits mask that specifies with which collision category this shape will collide

◆ setCollisionCategoryBits()

void Collider::setCollisionCategoryBits ( unsigned short  collisionCategoryBits)

Set the collision category bits.

Parameters
collisionCategoryBitsThe collision category bits mask of the collider

◆ setIsSimulationCollider()

void Collider::setIsSimulationCollider ( bool  isSimulationCollider) const

Set whether the collider can generate contacts for the simulation of the associated body.

Note that a collider cannot be a simulation collider and a trigger at the same time.

If you set this to true, this collider will stop being a trigger.

Parameters
isSimulationColliderTrue if this collider can generate contacts for the simulation of the associated body.

◆ setIsTrigger()

void Collider::setIsTrigger ( bool  isTrigger) const

Set whether the collider is a trigger.

Note that a collider cannot be a simulation collider and a trigger at the same time.

If you set this to true, this collider will stop being a simulation collider.

Parameters
isTriggerTrue if you want to set this collider as a trigger and false otherwise

◆ setIsWorldQueryCollider()

void Collider::setIsWorldQueryCollider ( bool  isWorldQueryCollider) const

Set whether the collider will be part of results of queries on the PhysicsWorld.

Parameters
isWorldQueryColliderTrue if this collider will be part of results of queries on the PhysicsWorld

◆ setLocalToBodyTransform()

void Collider::setLocalToBodyTransform ( const Transform transform)

Set the local to parent body transform.

Parameters
transformThe transform from local-space of the collider into the local-space of the body

◆ setMaterial()

void Collider::setMaterial ( const Material material)

Set a new material for this collider.

Parameters
materialThe material you want to set to the body

◆ setUserData()

RP3D_FORCE_INLINE void reactphysics3d::Collider::setUserData ( void *  userData)

Attach user data to this body.

Parameters
userDataPointer to the user data you want to store within the collider

◆ testAABBOverlap()

RP3D_FORCE_INLINE bool reactphysics3d::Collider::testAABBOverlap ( const AABB worldAABB) const

Test if the collider overlaps with a given AABB.

Parameters
worldAABBThe AABB (in world-space coordinates) that will be used to test overlap
Returns
True if the given AABB overlaps with the AABB of the collision body

◆ testPointInside()

bool Collider::testPointInside ( const Vector3 worldPoint)

Return true if a point is inside the collision shape.

Parameters
worldPointPoint to test in world-space coordinates
Returns
True if the point is inside the collision shape

The documentation for this class was generated from the following files: