SuperDex Physics C++ API
Loading...
Searching...
No Matches
superdex::DebugDraw Class Referenceabstract

Manages debug visualization features for a scene. More...

#include <mochi_debug_draw.h>

Public Member Functions

virtual void Enable (bool enable)=0
 Enable or disable debug drawing for the entire scene.
virtual void EnableActor (ActorHandle actor, bool enable, Error &error)=0
 Enable or disable debug drawing for a specific actor.
virtual void EnableFeature (int index, bool enable)=0
 Enable or disable a specific feature.
virtual int FindFeature (std::string_view name) const =0
 Find a feature by name.
virtual DebugDrawData GatherData ()=0
 Generate debug draw primitives for all currently enabled features.
virtual std::string_view GetFeatureDescription (int index) const =0
 Get the description of a feature by index.
virtual std::string_view GetFeatureName (int index) const =0
 Get the name of a feature by index.
virtual int GetNumFeatures () const =0
 Get the number of debug draw features available.
virtual bool IsEnabled () const =0
 Check if debug drawing is enabled for the scene.
virtual bool IsFeatureEnabled (int index) const =0
 Check if a feature is currently enabled.

Protected Member Functions

virtual ~DebugDraw ()=default

Detailed Description

Manages debug visualization features for a scene.

Provides a feature-based system for visualizing various aspects of the physics simulation. The client application is responsible for rendering the generated primitives using its own graphics API. Features can be individually enabled or disabled, such as visualizing contact points, normals, velocities, or AABBs.

Note
Must be accessed on the same thread as the owning Scene.
Debug draw is disabled by default.
If consuming the data on a different thread, the client must deep-copy the underlying data into client-owned buffers before the scene thread calls GatherData again or modifies the Scene. Copying DebugDrawData itself is a shallow copy of Span views into internal buffers and does not transfer ownership.
Warning
Debug drawing has significant performance overhead due to geometry generation and data gathering.
See also
Scene::GetDebugDraw, DebugDrawData

Definition at line 33 of file mochi_debug_draw.h.

Constructor & Destructor Documentation

◆ ~DebugDraw()

virtual superdex::DebugDraw::~DebugDraw ( )
protectedvirtualdefault

Member Function Documentation

◆ Enable()

virtual void superdex::DebugDraw::Enable ( bool enable)
pure virtual

Enable or disable debug drawing for the entire scene.

Parameters
[in]enableTrue to enable, false to disable.
Note
This is a master switch that overrides all individual feature settings.
See also
IsEnabled

◆ EnableActor()

virtual void superdex::DebugDraw::EnableActor ( ActorHandle actor,
bool enable,
Error & error )
pure virtual

Enable or disable debug drawing for a specific actor.

Parameters
[in]actorHandle of the actor to enable or disable debug drawing for.
[in]enableTrue to enable, false to disable.
[in,out]errorError status. Check Error::IsOK for success.
Note
Enabled by default for all actors, including nested actors (child actors of articulated, soft-skinned and blended actors).
Debug draw data won't be generated for any actor if the master switch, i.e. IsEnabled, is false.

◆ EnableFeature()

virtual void superdex::DebugDraw::EnableFeature ( int index,
bool enable )
pure virtual

Enable or disable a specific feature.

Parameters
[in]indexFeature index in the range [0, GetNumFeatures).
[in]enableTrue to enable the feature, false to disable.
Note
No debug-draw data is generated while the master switch (IsEnabled) is false, but per-feature settings are remembered and take effect when the master switch is enabled.
See also
IsFeatureEnabled, Enable

◆ FindFeature()

virtual int superdex::DebugDraw::FindFeature ( std::string_view name) const
nodiscardpure virtual

Find a feature by name.

Parameters
[in]nameFeature name (case sensitive).
Returns
Feature index if found, or -1 if not found.
See also
GetFeatureName, EnableFeature

◆ GatherData()

virtual DebugDrawData superdex::DebugDraw::GatherData ( )
nodiscardpure virtual

Generate debug draw primitives for all currently enabled features.

Returns
Collection of primitives to be rendered by the client application. The returned DebugDrawData contains Spans that reference internal buffers.
Note
Data is valid only until the next call to GatherData or any modification to the Scene.
Returns empty data if IsEnabled is false.
See also
DebugDrawData

◆ GetFeatureDescription()

virtual std::string_view superdex::DebugDraw::GetFeatureDescription ( int index) const
nodiscardpure virtual

Get the description of a feature by index.

Parameters
[in]indexFeature index in the range [0, GetNumFeatures).
Returns
Human-readable description of the feature.
See also
GetNumFeatures, GetFeatureName

◆ GetFeatureName()

virtual std::string_view superdex::DebugDraw::GetFeatureName ( int index) const
nodiscardpure virtual

Get the name of a feature by index.

Parameters
[in]indexFeature index in the range [0, GetNumFeatures).
Returns
Name of the feature.
See also
GetNumFeatures, FindFeature

◆ GetNumFeatures()

virtual int superdex::DebugDraw::GetNumFeatures ( ) const
nodiscardpure virtual

Get the number of debug draw features available.

Returns
Number of features that can be individually enabled or disabled.
See also
FindFeature, GetFeatureName

◆ IsEnabled()

virtual bool superdex::DebugDraw::IsEnabled ( ) const
nodiscardpure virtual

Check if debug drawing is enabled for the scene.

Returns
True if debug drawing is enabled, false otherwise.
Note
When disabled, GatherData returns empty data regardless of feature settings.
See also
Enable

◆ IsFeatureEnabled()

virtual bool superdex::DebugDraw::IsFeatureEnabled ( int index) const
nodiscardpure virtual

Check if a feature is currently enabled.

Parameters
[in]indexFeature index in the range [0, GetNumFeatures).
Returns
True if the feature is enabled, false otherwise.
See also
EnableFeature

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