VR-Engage  2.2
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
22class DtSimulationServices;
23
24namespace makVre
25{
26class DtInitializer;
29
30//! \brief Provides debugging capabilities for Vortex physics engine
31//!
32//! This class manages various debugging features for the Vortex physics integration,
33//! including visualization of physics objects, collision triangles, and performance metrics.
34//! It also handles configuration of the Vortex logging system and remote debugging.
36{
37public:
38 //! \brief Custom log handler for Vortex physics engine messages
39 //!
40 //! Intercepts log messages from the Vortex physics engine and
41 //! redirects them to the VR-Forces logging system, applying
42 //! proper formatting and log level translation.
44 {
45 public:
46 //! \brief Default constructor
47 LogHandler() = default;
48
49 //! \brief Destructor
50 //!
51 //! Resets the log handler if it wasn't already reset.
52 virtual ~LogHandler();
53
54 //! \brief Sets this handler as the active Vortex log handler
55 //!
56 //! Stores the previous log handler and installs this handler
57 //! as the new Vortex log handler.
58 virtual void setLogHandler();
59
60 //! \brief Restores the original Vortex log handler
61 //!
62 //! Returns control to the previous log handler that was active
63 //! before this handler was installed.
64 virtual void resetLogHandler();
65
66 protected:
67 //! \brief Static callback function registered with Vortex
68 //!
69 //! This function is called by Vortex when log messages are generated.
70 //! It formats the message and forwards it to the appropriate VR-Forces log.
71 //!
72 //! \param level The severity level of the log message
73 //! \param format The format string for the log message
74 //! \param ap Variable argument list containing values for the format string
75 static void vortexLogHandler(Vx::eLogLevel level, const char* const format, va_list ap);
76
77 //! \brief Helper function to format a log message with variable arguments
78 //!
79 //! \param str String reference where the formatted output will be stored
80 //! \param fmt Format string
81 //! \param ap Variable argument list
82 //! \return True if formatting succeeded, false otherwise
83 static bool formatToString(std::string& str, const char* const fmt, va_list ap);
84
85 protected:
86 Vx::LogHandler myOldLongHandler; //!< The previous log handler that was active
87 };
88
89public:
90 //! \brief Constructor
91 //!
92 //! Initializes the debug system with the provided simulation services.
93 //! Sets up default debug values and loads the debug configuration file.
94 //!
95 //! \param services Pointer to the simulation services
96 explicit DtVortexDebug(const DtSimulationServices* services);
97
98 //! \brief Destructor
99 //!
100 //! Performs cleanup of debug resources.
101 virtual ~DtVortexDebug() = default;
102
103 //! \brief Updates the debug state and visuals
104 //!
105 //! Called each simulation frame to update debug visualizations and process
106 //! any pending debug operations.
107 //!
108 //! \param dt Time step in seconds since the last update
109 virtual void tick(double dt);
110
111 //! \brief Renders debug information using ImGui
112 //!
113 //! Displays debug information and controls in an ImGui interface.
114 virtual void renderImgui();
115
116 //! \brief Initializes Vortex debugging functionality
117 //!
118 //! Sets up the log handler and registers debug values with the debug manager.
119 //! This makes the debugging options visible in the user interface.
121
122 //! \brief Shuts down Vortex debugging functionality
123 //!
124 //! Unregisters debug values and cleans up resources.
126
127 //! \brief Checks if debugging is active
128 //!
129 //! \return True if debugging is active, false otherwise
130 virtual bool active() const;
131
132 //! \brief Checks if art parts debugging is enabled
133 //!
134 //! \return True if art parts debugging is enabled, false otherwise
135 virtual bool debugArtParts() const;
136
137 //! \brief Checks if contact point debugging is enabled
138 //!
139 //! \return True if contact point debugging is enabled, false otherwise
140 virtual bool debugContacts() const;
141
142 //! \brief Updates the Vortex remote debugging connection
143 //!
144 //! Enables or disables the Vortex remote debugger based on the current setting.
146
147 //! \brief Checks if request bounds debugging is enabled
148 //!
149 //! \return True if request bounds debugging is enabled, false otherwise
150 bool debugRequestBounds() const;
151
152 //! \brief Checks if collision triangle debugging is enabled
153 //!
154 //! \return True if collision triangle debugging is enabled, false otherwise
156
157 //! \brief Checks if dynamic terrain debugging is enabled
158 //!
159 //! \return True if dynamic terrain debugging is enabled, false otherwise
161
162 //! \brief Checks if pager timing debugging is enabled
163 //!
164 //! \return True if pager timing debugging is enabled, false otherwise
165 bool debugPagerTimes() const;
166
167 //! \brief Gets the timeout time for pager timing debugging
168 //!
169 //! \return The timeout time in seconds
170 double debugPagerTimeoutTime() const;
171
172 //! \brief Gets the Vortex log handler
173 //!
174 //! \return Shared pointer to the log handler
175 std::shared_ptr<DtVortexDebug::LogHandler> logHandler();
176
177protected:
178 //! \brief Gets the debug initializer
179 //!
180 //! \return Pointer to the debug initializer
182
183 //! \brief Handles debug messages from the debug manager
184 //!
185 //! Processes debug enable/disable messages and other control messages.
186 //!
187 //! \param msg The message to handle
188 //! \return The result of handling the message
190
191 //! \brief Registers debug values with the debug manager
192 //!
193 //! Makes debug options visible in the user interface and sets up message handlers.
194 virtual void registerDebugValues();
195
196 //! \brief Unregisters debug values from the debug manager
197 //!
198 //! Removes debug options from the user interface and cleans up message handlers.
199 virtual void unregisterDebugValues();
200
201 //! \brief Sets the Vortex logging level
202 //!
203 //! Translates the VR-Forces notification level to the appropriate Vortex log level.
204 //!
205 //! \param notifyLevel The VR-Forces notification level
206 static void setVortexLogLevel(DtNotifyLevelType notifyLevel);
207
208protected:
209 makVre::DtInitializer* myDebugInitializer; //!< Initializer for debug configuration
210
211 DtSimulationAddress mySimAddress; //!< Address of the simulation
212 DebugMetaRegisterMessage::Process myProcessType; //!< Type of process (VRF or VRE)
213
214 bool myActive; //!< Flag indicating if debugging is active
215
216 bool myDebugRequestBounds; //!< Flag for debug request bounds visualization
217 bool myDebugPagerTimes; //!< Flag for pager timing debug output
218 bool myDebugPrintDynamicTerrain; //!< Flag for dynamic terrain debug output
219 double myDebugTerrainPageoutTime; //!< Timeout for terrain paging
220 bool myDebugArtParts; //!< Flag for art parts visualization
221 bool myDebugContacts; //!< Flag for contact points visualization
222 bool myDebugRemoteEnabled; //!< Flag for remote debugging
223
224 bool myDebugCollisionTriangles; //!< Flag for collision triangle visualization
225 double myDebugCollisionTrianglesInterval; //!< Time interval between triangle updates
226 unsigned int myDebugCollisionTrianglesMaxRequestCount; //!< Counter for triangle requests
227 double myCollisionTrianglesLastDtSent; //!< Time of last triangle data sent
228
229 std::shared_ptr<DtVortexDebug::LogHandler> myVortexLogHandler; //!< Log handler for Vortex messages
230
231 std::deque<std::pair<int, std::vector<DtVector>>> myCollisionGeometryDeque; //!< Queue of collision geometries for
232 //!< visualization
233
234 std::deque<std::pair<unsigned int, std::vector<DtVector>>> myArtPartsGeometryDeque;
235 double myDebugArtPartsGeometryInterval; //!< Time interval between part geometry updates
236 unsigned int myDebugArtPartsGeometryMaxRequestCount; //!< Counter for geometry requests
238};
239} // namespace makVre
Process
Definition debugMetaRegister.h:34
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:45
virtual void setLogHandler()
Sets this handler as the active Vortex log handler.
static bool formatToString(std::string &str, const char *const fmt, va_list ap)
Helper function to format a log message with variable arguments.
virtual ~LogHandler()
Destructor.
Vx::LogHandler myOldLongHandler
The previous log handler that was active.
Definition vortexDebug.h:86
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.
makVre::DtInitializer * myDebugInitializer
Initializer for debug configuration.
Definition vortexDebug.h:209
DtVortexDebug(const DtSimulationServices *services)
Constructor.
bool debugPrintDynamicTerrain() const
Checks if dynamic terrain debugging is enabled.
double myDebugArtPartsGeometryLastDtSent
Definition vortexDebug.h:237
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:227
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 ~DtVortexDebug()=default
Destructor.
virtual void shutdownVortexDebugging()
Shuts down Vortex debugging functionality.
bool myActive
Flag indicating if debugging is active.
Definition vortexDebug.h:214
double myDebugCollisionTrianglesInterval
Time interval between triangle updates.
Definition vortexDebug.h:225
bool myDebugPagerTimes
Flag for pager timing debug output.
Definition vortexDebug.h:217
double myDebugTerrainPageoutTime
Timeout for terrain paging.
Definition vortexDebug.h:219
DebugMetaRegisterMessage::Process myProcessType
Type of process (VRF or VRE)
Definition vortexDebug.h:212
virtual void renderImgui()
Renders debug information using ImGui.
unsigned int myDebugCollisionTrianglesMaxRequestCount
Counter for triangle requests.
Definition vortexDebug.h:226
virtual void updateVortexRemoteDebugging()
Updates the Vortex remote debugging connection.
bool myDebugCollisionTriangles
Flag for collision triangle visualization.
Definition vortexDebug.h:224
bool myDebugPrintDynamicTerrain
Flag for dynamic terrain debug output.
Definition vortexDebug.h:218
std::deque< std::pair< unsigned int, std::vector< DtVector > > > myArtPartsGeometryDeque
Definition vortexDebug.h:234
bool myDebugRemoteEnabled
Flag for remote debugging.
Definition vortexDebug.h:222
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:235
DtSimulationAddress mySimAddress
Address of the simulation.
Definition vortexDebug.h:211
double debugPagerTimeoutTime() const
Gets the timeout time for pager timing debugging.
unsigned int myDebugArtPartsGeometryMaxRequestCount
Counter for geometry requests.
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:229
bool myDebugContacts
Flag for contact points visualization.
Definition vortexDebug.h:221
bool myDebugArtParts
Flag for art parts visualization.
Definition vortexDebug.h:220
std::deque< std::pair< int, std::vector< DtVector > > > myCollisionGeometryDeque
Queue of collision geometries for visualization.
Definition vortexDebug.h:231
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.
bool myDebugRequestBounds
Flag for debug request bounds visualization.
Definition vortexDebug.h:216
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.