VR-Engage  2.3
Loading...
Searching...
No Matches
vortexDebug.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexDebug.h
7//! \brief Provides debugging functionality for the Vortex physics engine integration
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
15
17
18#include <Vx/VxMessage.h>
19
20#include <deque>
21#include <memory>
22
23class DtSimulationServices;
24
25namespace makVre
26{
27class DtInitializer;
31
32//! \brief Provides debugging capabilities for Vortex physics engine
33//!
34//! This class manages various debugging features for the Vortex physics integration,
35//! including visualization of physics objects, collision triangles, and performance metrics.
36//! It also handles configuration of the Vortex logging system and remote debugging.
38{
39public:
40 //! \brief Custom log handler for Vortex physics engine messages
41 //!
42 //! Intercepts log messages from the Vortex physics engine and
43 //! redirects them to the VR-Forces logging system, applying
44 //! proper formatting and log level translation.
46 {
47 public:
48 //! \brief Default constructor
49 LogHandler() = default;
50
51 //! \brief Destructor
52 //!
53 //! Resets the log handler if it wasn't already reset.
54 virtual ~LogHandler();
55
56 //! \brief Sets this handler as the active Vortex log handler
57 //!
58 //! Stores the previous log handler and installs this handler
59 //! as the new Vortex log handler.
60 virtual void setLogHandler();
61
62 //! \brief Restores the original Vortex log handler
63 //!
64 //! Returns control to the previous log handler that was active
65 //! before this handler was installed.
66 virtual void resetLogHandler();
67
68 protected:
69 //! \brief Static callback function registered with Vortex
70 //!
71 //! This function is called by Vortex when log messages are generated.
72 //! It formats the message and forwards it to the appropriate VR-Forces log.
73 //!
74 //! \param level The severity level of the log message
75 //! \param format The format string for the log message
76 //! \param ap Variable argument list containing values for the format string
77 static void vortexLogHandler(Vx::eLogLevel level, const char* const format, va_list ap);
78
79 protected:
80 Vx::LogHandler myOldLongHandler; //!< The previous log handler that was active
81 };
82
83public:
84 //! \brief Constructor
85 //!
86 //! Initializes the debug system with the provided simulation services.
87 //! Sets up default debug values and loads the debug configuration file.
88 //!
89 //! \param services Pointer to the simulation services
90 explicit DtVortexDebug(const DtSimulationServices* services);
91
92 //! \brief Destructor
93 //!
94 //! Performs cleanup of debug resources. Defined out of line because the
95 //! material debug helper is forward declared in this header.
96 virtual ~DtVortexDebug();
97
98 //! \brief Updates the debug state and visuals
99 //!
100 //! Called each simulation frame to update debug visualizations and process
101 //! any pending debug operations.
102 //!
103 //! \param dt Time step in seconds since the last update
104 virtual void tick(double dt);
105
106 //! \brief Renders debug information using ImGui
107 //!
108 //! Displays debug information and controls in an ImGui interface.
109 virtual void renderImgui();
110
111 //! \brief Initializes Vortex debugging functionality
112 //!
113 //! Sets up the log handler and registers debug values with the debug manager.
114 //! This makes the debugging options visible in the user interface.
116
117 //! \brief Shuts down Vortex debugging functionality
118 //!
119 //! Unregisters debug values and cleans up resources.
121
122 //! \brief Checks if debugging is active
123 //!
124 //! \return True if debugging is active, false otherwise
125 virtual bool active() const;
126
127 //! \brief Checks if art parts debugging is enabled
128 //!
129 //! \return True if art parts debugging is enabled, false otherwise
130 virtual bool debugArtParts() const;
131
132 //! \brief Checks if contact point debugging is enabled
133 //!
134 //! \return True if contact point debugging is enabled, false otherwise
135 virtual bool debugContacts() const;
136
137 //! \brief Updates the Vortex remote debugging connection
138 //!
139 //! Enables or disables the Vortex remote debugger based on the current setting.
141
142 //! \brief Checks if request bounds debugging is enabled
143 //!
144 //! \return True if request bounds debugging is enabled, false otherwise
145 bool debugRequestBounds() const;
146
147 //! \brief Checks if collision triangle debugging is enabled
148 //!
149 //! \return True if collision triangle debugging is enabled, false otherwise
151
152 //! \brief Checks if dynamic terrain debugging is enabled
153 //!
154 //! \return True if dynamic terrain debugging is enabled, false otherwise
156
157 //! \brief Checks if pager timing debugging is enabled
158 //!
159 //! \return True if pager timing debugging is enabled, false otherwise
160 bool debugPagerTimes() const;
161
162 //! \brief Gets the timeout time for pager timing debugging
163 //!
164 //! \return The timeout time in seconds
165 double debugPagerTimeoutTime() const;
166
167 //! \brief Gets the Vortex log handler
168 //!
169 //! \return Shared pointer to the log handler
170 std::shared_ptr<DtVortexDebug::LogHandler> logHandler();
171
172protected:
173 //! \brief Gets the debug initializer
174 //!
175 //! \return Pointer to the debug initializer
177
178 //! \brief Handles debug messages from the debug manager
179 //!
180 //! Processes debug enable/disable messages and other control messages.
181 //!
182 //! \param msg The message to handle
183 //! \return The result of handling the message
185
186 //! \brief Registers debug values with the debug manager
187 //!
188 //! Makes debug options visible in the user interface and sets up message handlers.
189 virtual void registerDebugValues();
190
191 //! \brief Re-publishes debug registration messages without re-installing handlers
192 //!
193 //! Called by registerDebugValues() and in response to a REQUEST action so that
194 //! a late-joining frontend discovers available debug capabilities.
196
197 //! \brief Unregisters debug values from the debug manager
198 //!
199 //! Removes debug options from the user interface and cleans up message handlers.
200 virtual void unregisterDebugValues();
201
202 //! \brief Sets the Vortex logging level
203 //!
204 //! Translates the VR-Forces notification level to the appropriate Vortex log level.
205 //!
206 //! \param notifyLevel The VR-Forces notification level
207 static void setVortexLogLevel(DtNotifyLevelType notifyLevel);
208
209protected:
210 makVre::DtInitializer* myDebugInitializer; //!< Initializer for debug configuration
211
212 DtSimulationAddress mySimAddress; //!< Address of the simulation
213 DebugMetaRegisterMessage::Process myProcessType; //!< Type of process (VRF or VRE)
214
215 bool myActive; //!< Flag indicating if debugging is active
216
217 bool myDebugRequestBounds; //!< Flag for debug request bounds visualization
218 bool myDebugPagerTimes; //!< Flag for pager timing debug output
219 bool myDebugPrintDynamicTerrain; //!< Flag for dynamic terrain debug output
220 double myDebugTerrainPageoutTime; //!< Timeout for terrain paging
221 bool myDebugArtParts; //!< Flag for art parts visualization
222 bool myDebugContacts; //!< Flag for contact points visualization
223 bool myDebugRemoteEnabled; //!< Flag for remote debugging
224
225 bool myDebugCollisionTriangles; //!< Flag for collision triangle visualization
226 double myDebugCollisionTrianglesInterval; //!< Time interval between triangle updates
227 unsigned int myDebugCollisionTrianglesMaxRequestCount; //!< Counter for triangle requests
228 double myCollisionTrianglesLastDtSent; //!< Time of last triangle data sent
229
230 std::shared_ptr<DtVortexDebug::LogHandler> myVortexLogHandler; //!< Log handler for Vortex messages
231
232 //! \brief Renderer and selection-state owner for material and contact diagnostics
233 //!
234 //! Kept as an incomplete type to isolate the material-debug implementation
235 //! from this primary Vortex debug interface.
236 std::unique_ptr<DtVortexMaterialDebugHelpers> myMaterialDebugHelpers;
237
238 std::deque<std::pair<int, std::vector<DtVector>>> myCollisionGeometryDeque; //!< Queue of collision geometries for
239 //!< visualization
240
241 std::deque<std::pair<unsigned int, std::vector<DtVector>>> myArtPartsGeometryDeque;
242 double myDebugArtPartsGeometryInterval; //!< Time interval between part geometry updates
243 unsigned int myDebugArtPartsGeometryMaxRequestCount; //!< Counter for geometry requests
245};
246} // namespace makVre
Process
Process enumeration.
Definition debugMetaRegister.h:46
Class for converting between different coordinate systems.
Definition coordConverter.h:31
Configuration initializer for VREngage components.
Definition initializer.h:80
Manages collision detection and handling between Vortex physics objects and non-Vortex simulated obje...
Definition vortexCollisionProxyGenerator.h:55
virtual void setLogHandler()
Sets this handler as the active Vortex log handler.
virtual ~LogHandler()
Destructor.
Vx::LogHandler myOldLongHandler
The previous log handler that was active.
Definition vortexDebug.h:80
static void vortexLogHandler(Vx::eLogLevel level, const char *const format, va_list ap)
Static callback function registered with Vortex.
LogHandler()=default
Default constructor.
virtual void resetLogHandler()
Restores the original Vortex log handler.
virtual ~DtVortexDebug()
Destructor.
makVre::DtInitializer * myDebugInitializer
Initializer for debug configuration.
Definition vortexDebug.h:210
DtVortexDebug(const DtSimulationServices *services)
Constructor.
bool debugPrintDynamicTerrain() const
Checks if dynamic terrain debugging is enabled.
double myDebugArtPartsGeometryLastDtSent
Definition vortexDebug.h:244
bool debugPagerTimes() const
Checks if pager timing debugging is enabled.
bool debugRequestBounds() const
Checks if request bounds debugging is enabled.
virtual bool active() const
Checks if debugging is active.
double myCollisionTrianglesLastDtSent
Time of last triangle data sent.
Definition vortexDebug.h:228
makVre::DtInitializer * debugInitializer() const
Gets the debug initializer.
virtual void initializeVortexDebugging()
Initializes Vortex debugging functionality.
virtual bool debugArtParts() const
Checks if art parts debugging is enabled.
virtual void registerDebugValues()
Registers debug values with the debug manager.
virtual void shutdownVortexDebugging()
Shuts down Vortex debugging functionality.
bool myActive
Flag indicating if debugging is active.
Definition vortexDebug.h:215
double myDebugCollisionTrianglesInterval
Time interval between triangle updates.
Definition vortexDebug.h:226
bool myDebugPagerTimes
Flag for pager timing debug output.
Definition vortexDebug.h:218
double myDebugTerrainPageoutTime
Timeout for terrain paging.
Definition vortexDebug.h:220
DebugMetaRegisterMessage::Process myProcessType
Type of process (VRF or VRE)
Definition vortexDebug.h:213
virtual void renderImgui()
Renders debug information using ImGui.
unsigned int myDebugCollisionTrianglesMaxRequestCount
Counter for triangle requests.
Definition vortexDebug.h:227
virtual void updateVortexRemoteDebugging()
Updates the Vortex remote debugging connection.
bool myDebugCollisionTriangles
Flag for collision triangle visualization.
Definition vortexDebug.h:225
bool myDebugPrintDynamicTerrain
Flag for dynamic terrain debug output.
Definition vortexDebug.h:219
std::deque< std::pair< unsigned int, std::vector< DtVector > > > myArtPartsGeometryDeque
Definition vortexDebug.h:241
bool myDebugRemoteEnabled
Flag for remote debugging.
Definition vortexDebug.h:223
virtual bool debugContacts() const
Checks if contact point debugging is enabled.
static void setVortexLogLevel(DtNotifyLevelType notifyLevel)
Sets the Vortex logging level.
double myDebugArtPartsGeometryInterval
Time interval between part geometry updates.
Definition vortexDebug.h:242
DtSimulationAddress mySimAddress
Address of the simulation.
Definition vortexDebug.h:212
double debugPagerTimeoutTime() const
Gets the timeout time for pager timing debugging.
unsigned int myDebugArtPartsGeometryMaxRequestCount
Counter for geometry requests.
Definition vortexDebug.h:243
std::unique_ptr< DtVortexMaterialDebugHelpers > myMaterialDebugHelpers
Renderer and selection-state owner for material and contact diagnostics.
Definition vortexDebug.h:236
bool debugCollisionTriangles() const
Checks if collision triangle debugging is enabled.
std::shared_ptr< DtVortexDebug::LogHandler > myVortexLogHandler
Log handler for Vortex messages.
Definition vortexDebug.h:230
bool myDebugContacts
Flag for contact points visualization.
Definition vortexDebug.h:222
bool myDebugArtParts
Flag for art parts visualization.
Definition vortexDebug.h:221
std::deque< std::pair< int, std::vector< DtVector > > > myCollisionGeometryDeque
Queue of collision geometries for visualization.
Definition vortexDebug.h:238
std::shared_ptr< DtVortexDebug::LogHandler > logHandler()
Gets the Vortex log handler.
virtual void unregisterDebugValues()
Unregisters debug values from the debug manager.
makVre::DtVreMessageResult handleDebugMessage(makVre::DtVreMessage *msg)
Handles debug messages from the debug manager.
virtual void tick(double dt)
Updates the debug state and visuals.
void publishDebugRegistrations()
Re-publishes debug registration messages without re-installing handlers.
bool myDebugRequestBounds
Flag for debug request bounds visualization.
Definition vortexDebug.h:217
Renders Vortex material and dynamics-contact diagnostics.
Definition vortexMaterialDebugHelpers.h:33
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.