ReactPhysics3D: reactphysics3d::DebugRenderer Class Reference

| ReactPhysics3D v0.10.2 C++ Physics engine library

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
reactphysics3d::DebugRenderer Class Reference

This class is used to display physics debug information directly into the user application view. More...

`#include <include/reactphysics3d/utils/DebugRenderer.h>`

Inheritance diagram for reactphysics3d::DebugRenderer:

## Classes
struct | DebugLine
| Struture that represents a line of the DebugRenderer. More...
struct | DebugTriangle
| Struture that represents a triangle of the DebugRenderer. More...

## Public Types
enum class | DebugColor { RED = 0xff0000 , GREEN = 0x00ff00 , BLUE = 0x0000ff , BLACK = 0x000000 , WHITE = 0xffffff , YELLOW = 0xffff00 , MAGENTA = 0xff00ff , CYAN = 0x00ffff }
| Enumeration with basic colors.
enum class | DebugItem { COLLIDER_AABB = 1 << 0 , COLLIDER_BROADPHASE_AABB = 1 << 1 , COLLISION_SHAPE = 1 << 2 , CONTACT_POINT = 1 << 3 , CONTACT_NORMAL = 1 << 4 , COLLISION_SHAPE_NORMAL = 1 << 5 }
| Enumeration with debug item to renderer. More...

## Public Member Functions
| DebugRenderer (MemoryAllocator &allocator)
| Constructor.
| ~DebugRenderer ()
| Destructor.
uint32 | getNbLines () const
| Return the number of lines.
const Array< DebugLine > & | getLines () const
| Return a reference to the array of lines.
const DebugLine * | getLinesArray () const
| Return a pointer to the array of lines.
uint32 | getNbTriangles () const
| Return the number of triangles.
const Array< DebugTriangle > & | getTriangles () const
| Return a reference to the array of triangles.
const DebugTriangle * | getTrianglesArray () const
| Return a pointer to the array of triangles.
bool | getIsDebugItemDisplayed (DebugItem item) const
| Return whether a debug item is displayed or not.
void | setIsDebugItemDisplayed (DebugItem item, bool isDisplayed)
| Set whether a debug info is displayed or not.
decimal | getContactPointSphereRadius () const
| Get the contact point sphere radius.
void | setContactPointSphereRadius (decimal radius)
| Set the contact point sphere radius.
decimal | getContactNormalLength () const
| Return the length of contact normal.
void | setContactNormalLength (decimal contactNormalLength)
| Return the length of contact normal.
void | computeDebugRenderingPrimitives (const PhysicsWorld &world)
| Generate the rendering primitives (triangles, lines, ...) of a physics world.
void | reset ()
| Clear all the debugging primitives (points, lines, triangles, ...)
virtual void | onContact (const CollisionCallback::CallbackData &callbackData) override
| Called when some contacts occur.
Public Member Functions inherited from reactphysics3d::EventListener
| EventListener ()=default
| Constructor.
virtual | ~EventListener () override=default
| Destructor.
virtual void | onContact (const CollisionCallback::CallbackData &) override
| Called when some contacts occur.
virtual void | onTrigger (const OverlapCallback::CallbackData &)
| Called when some trigger events occur.
Public Member Functions inherited from reactphysics3d::CollisionCallback
virtual | ~CollisionCallback ()=default
| Destructor.
virtual void | onContact (const CallbackData &callbackData)=0
| This method is called when some contacts occur.

## Detailed Description

This class is used to display physics debug information directly into the user application view.

For instance, it is possible to display AABBs of colliders, colliders or contact points. This class can be used to get the debug information as arrays of basic primitives (points, linges, triangles, ...). You can use this to render physics debug information in your simulation on top of your object. Note that you should use this only for debugging purpose and you should disable it when you compile the final release version of your application because computing/rendering phyiscs debug information can be expensive.

## Member Enumeration Documentation

## ◆ DebugItem

enum class reactphysics3d::DebugRenderer::DebugItem
| strong

Enumeration with debug item to renderer.

Enumerator
COLLIDER_AABB | Display the AABB for each collider.
COLLIDER_BROADPHASE_AABB | Display the fat AABB of the broad phase collision detection for each collider.
COLLISION_SHAPE | Display the collision shape of each collider.
CONTACT_POINT | Display the contact points.
CONTACT_NORMAL | Display the contact normals.
COLLISION_SHAPE_NORMAL | Display the face normals of the collision shapes.

## Member Function Documentation

## ◆ getContactNormalLength()

RP3D_FORCE_INLINE decimal reactphysics3d::DebugRenderer::getContactNormalLength | ( |  | ) | const

Return the length of contact normal.

Returns
  The length of the contact normal to display

## ◆ getContactPointSphereRadius()

RP3D_FORCE_INLINE decimal reactphysics3d::DebugRenderer::getContactPointSphereRadius | ( |  | ) | const

Get the contact point sphere radius.

Returns
  The radius of the sphere used to display a contact point

## ◆ getIsDebugItemDisplayed()

RP3D_FORCE_INLINE bool reactphysics3d::DebugRenderer::getIsDebugItemDisplayed | ( | DebugItem | item | ) | const

Return whether a debug item is displayed or not.

Parameters

  item | A debug item

Returns
  True if the given debug item is being displayed and false otherwise

## ◆ getLines()

RP3D_FORCE_INLINE const Array< DebugRenderer::DebugLine > & reactphysics3d::DebugRenderer::getLines | ( |  | ) | const

Return a reference to the array of lines.

Returns
  The array of lines to draw

## ◆ getLinesArray()

RP3D_FORCE_INLINE const DebugRenderer::DebugLine * reactphysics3d::DebugRenderer::getLinesArray | ( |  | ) | const

Return a pointer to the array of lines.

Returns
  A pointer to the first element of the lines array to draw

## ◆ getNbLines()

RP3D_FORCE_INLINE uint32 reactphysics3d::DebugRenderer::getNbLines | ( |  | ) | const

Return the number of lines.

Returns
  The number of lines in the array of lines to draw

## ◆ getNbTriangles()

RP3D_FORCE_INLINE uint32 reactphysics3d::DebugRenderer::getNbTriangles | ( |  | ) | const

Return the number of triangles.

Returns
  The number of triangles in the array of triangles to draw

## ◆ getTriangles()

RP3D_FORCE_INLINE const Array< DebugRenderer::DebugTriangle > & reactphysics3d::DebugRenderer::getTriangles | ( |  | ) | const

Return a reference to the array of triangles.

Returns
  The array of triangles to draw

## ◆ getTrianglesArray()

RP3D_FORCE_INLINE const DebugRenderer::DebugTriangle * reactphysics3d::DebugRenderer::getTrianglesArray | ( |  | ) | const

Return a pointer to the array of triangles.

Returns
  A pointer to the first element of the triangles array to draw

## ◆ onContact()

void DebugRenderer::onContact | ( | const CollisionCallback::CallbackData & | callbackData | ) |
| overridevirtual

Called when some contacts occur.

Reimplemented from reactphysics3d::EventListener.

## ◆ setContactNormalLength()

RP3D_FORCE_INLINE void reactphysics3d::DebugRenderer::setContactNormalLength | ( | decimal | contactNormalLength | ) |

Return the length of contact normal.

Parameters

  contactNormalLength | The length of the contact normal to display

## ◆ setContactPointSphereRadius()

RP3D_FORCE_INLINE void reactphysics3d::DebugRenderer::setContactPointSphereRadius | ( | decimal | radius | ) |

Set the contact point sphere radius.

Parameters

  radius | The radius of the sphere used to display a contact point

## ◆ setIsDebugItemDisplayed()

RP3D_FORCE_INLINE void reactphysics3d::DebugRenderer::setIsDebugItemDisplayed | ( | DebugItem | item,
|  | bool | isDisplayed
| ) |  |

Set whether a debug info is displayed or not.

Parameters

  item | A debug item to draw
  isDisplayed | True if the given debug item has to be displayed and false otherwise

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

- include/reactphysics3d/utils/DebugRenderer.h
- src/utils/DebugRenderer.cpp