ReactPhysics3D: reactphysics3d::Collider Class Reference

| ReactPhysics3D v0.10.2 C++ Physics engine library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
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.
virtual | ~Collider ()
| Destructor.
| Collider (const Collider &collider)=delete
| Deleted copy-constructor.
Collider & | operator= (const Collider &collider)=delete
| Deleted assignment operator.
Entity | getEntity () const
| Return the corresponding entity of the collider.
CollisionShape * | getCollisionShape ()
| Return a pointer to the collision shape.
const CollisionShape * | getCollisionShape () const
| Return a const pointer to the collision shape.
Body * | getBody () const
| Return the parent body.
void * | getUserData () const
| Return a pointer to the user data attached to this body.
void | setUserData (void *userData)
| Attach user data to this body.
const Transform & | getLocalToBodyTransform () const
| Return the local to parent body transform.
void | setLocalToBodyTransform (const Transform &transform)
| Set the local to parent body transform.
const Transform | getLocalToWorldTransform () const
| Return the local to world transform.
const AABB | getWorldAABB () const
| Return the AABB of the collider in world-space.
bool | testAABBOverlap (const AABB &worldAABB) const
| Test if the collider overlaps with a given AABB.
bool | testPointInside (const Vector3 &worldPoint)
| Return true if a point is inside the collision shape.
bool | raycast (const Ray &ray, RaycastInfo &raycastInfo)
| Raycast method with feedback information.
unsigned short | getCollideWithMaskBits () const
| Return the collision bits mask.
void | setCollideWithMaskBits (unsigned short collideWithMaskBits)
| Set the collision bits mask.
unsigned short | getCollisionCategoryBits () const
| Return the collision category bits.
void | setCollisionCategoryBits (unsigned short collisionCategoryBits)
| Set the collision category bits.
int | getBroadPhaseId () const
| Return the broad-phase id.
Material & | getMaterial ()
| Return a reference to the material properties of the collider.
void | setMaterial (const Material &material)
| Set a new material for this collider.
bool | getIsTrigger () const
| Return true if the collider is a trigger.
void | setIsTrigger (bool isTrigger) const
| Set whether the collider is a trigger.
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.
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.

## 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

  entity | Entity of the collider
  body | Pointer to the body
  memoryManager | Reference 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

  | ray | Ray to use for the raycasting in world-space
  [out] | raycastInfo | Result 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

  collideWithMaskBits | The 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

  collisionCategoryBits | The 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

  isSimulationCollider | True 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

  isTrigger | True 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

  isWorldQueryCollider | True 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

  transform | The 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

  material | The 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

  userData | Pointer 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

  worldAABB | The 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

  worldPoint | Point 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:

- include/reactphysics3d/collision/Collider.h
- src/collision/Collider.cpp