VR-Engage  2.3
Loading...
Searching...
No Matches
vortexUtil.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexUtil.h
7//! \brief Utility functions for coordinate conversion and geometry operations with Vortex
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
14#include <VxMath/VxMath.h>
15#include <geometry/point.h>
16#include <matrix/vlVector.h>
17#include <geometry/extent.h>
18
19class DtLocalObject;
20
21namespace makVre
22{
23//! \brief Converts a vector from Vortex (NWU) coordinates to flat earth coordinates
24//!
25//! \param input The input vector in Vortex coordinates
26//! \param output The output vector in flat earth coordinates
27void VREVRFVORTEX_DLL ConvertVortexToFlatEarth(const DtVector& input, DtVector& output);
28
29//! \brief Converts a vector from Vortex (NWU) coordinates to DIS body coordinates (NED)
30//!
31//! \param input The input vector in Vortex coordinates
32//! \param output The output vector in DIS body coordinates
33void VREVRFVORTEX_DLL ConvertVortexToDISBody(const DtVector& input, DtVector& output);
34
35//! \brief Converts a vector from flat earth coordinates to Vortex (NWU) coordinates
36//!
37//! \param input The input vector in flat earth coordinates
38//! \param output The output vector in Vortex coordinates
39void VREVRFVORTEX_DLL ConvertFlatEarthToVortex(const DtVector& input, DtVector& output);
40
41//! \brief Converts a vector from DIS body coordinates (NED) to Vortex (NWU) coordinates
42//!
43//! \param input The input vector in DIS body coordinates
44//! \param output The output vector in Vortex coordinates
45void VREVRFVORTEX_DLL ConvertDISBodyToVortex(const DtVector& input, DtVector& output);
46
47//! \brief Converts a Vortex Vector3 to a DtVector
48//!
49//! \param input The input Vortex Vector3
50//! \param output The output DtVector
51void VREVRFVORTEX_DLL ConvertVxVector3ToDtVector(const VxMath::Vector3& input, DtVector& output);
52
53//! \brief Converts a DtVector to a Vortex Vector3
54//!
55//! \param input The input DtVector
56//! \param output The output Vortex Vector3
57void VREVRFVORTEX_DLL ConvertDtVectorToVxVector3(const DtVector& input, VxMath::Vector3& output);
58
59//! \brief Checks if one bounding box fully includes another
60//!
61//! Does not check the Z dimension, only X and Y.
62//!
63//! \param bbOne The first bounding box
64//! \param bbTwo The second bounding box to check if it's included
65//! \return True if bbOne fully includes bbTwo in X and Y dimensions
66bool VREVRFVORTEX_DLL doesBoundingBoxInclude(const VxMath::BoundingBox& bbOne, VxMath::BoundingBox& bbTwo);
67
68//! \brief Checks if a bounding box contains a DtVector point
69//!
70//! \param bb The bounding box
71//! \param vec The vector to check
72//! \return True if the point is inside the bounding box
73bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const DtVector& vec);
74
75//! \brief Checks if a bounding box contains a DtPoint
76//!
77//! \param bb The bounding box
78//! \param vec The point to check
79//! \return True if the point is inside the bounding box
80bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const DtPoint& vec);
81
82//! \brief Checks if a bounding box contains a Vortex Vector3 point
83//!
84//! \param bb The bounding box
85//! \param vec The vector to check
86//! \return True if the point is inside the bounding box
87bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const VxMath::Vector3& vec);
88
89//! \brief Checks if an extent contains a DtVector point
90//!
91//! \param ext The extent
92//! \param vec The vector to check
93//! \return True if the point is inside the extent
94bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const DtVector& vec);
95
96//! \brief Checks if an extent contains a DtPoint
97//!
98//! \param ext The extent
99//! \param vec The point to check
100//! \return True if the point is inside the extent
101bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const DtPoint& vec);
102
103//! \brief Checks if an extent contains a Vortex Vector3 point
104//!
105//! \param ext The extent
106//! \param vec The vector to check
107//! \return True if the point is inside the extent
108bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const VxMath::Vector3& vec);
109
110//! \brief Creates a DtVector from a Vortex Vector3
111//!
112//! \param input The input Vortex Vector3
113//! \return A new DtVector with the same values
114DtVector getDtVector(const VxMath::Vector3& input);
115
116//! \brief Creates a Vortex Vector3 from a DtVector
117//!
118//! \param input The input DtVector
119//! \return A new Vortex Vector3 with the same values
120VxMath::Vector3 getVxVector(const DtVector& input);
121
122//! \brief Returns whether or not a local object is a valid vortex entity.
123//! \param obj The Local object
124//! \return True if the local object is vortex
125bool isValidVortexLocalObject(DtLocalObject* obj);
126
127std::string formatVxVector(const VxMath::Vector3& vec);
128std::string formatDtVector(const DtVector& vec);
129std::string formatTransform(const Vx::VxTransform& transform);
130
131//! \brief Returns the Vortex name for a given global ID.
132//!
133//! Replaces `:` characters in the ID string with `_` to produce a name
134//! that is safe to use as a Vortex object/file identifier.
135//!
136//! \param globalId The global ID of the simulation object.
137//! \return The corresponding Vortex name as a string.
138std::string VREVRFVORTEX_DLL vortexName(const DtString& globalId);
139}
140
141//! \brief Coercion macros for efficient memory access without copying
142//!
143//! Since both VxVector and DtVector/DtPoint are simply 3 doubles in memory,
144//! we can coerce one to be the other by doing pointer casting and dereferencing
145//! which avoids making any copies.
146
147//! \brief Converts a Vortex vector to a DtVector without copying memory
148#define CoerceToDtVector(x) *((DtVector*)(&x[0]))
149
150//! \brief Converts a DtVector to a Vx::VxReal3 without copying memory
151#define CoerceToVxReal3(x) *((Vx::VxReal3*)(&x[0]))
152
153//! \brief Converts a DtVector to a VxMath::Vector3 without copying memory
154#define CoerceToVxVector(x) *((VxMath::Vector3*)(&x[0]))
155
156//! \brief Profiler macros for performance monitoring with color-coding
157//! @{
158
159//! \brief Defines a profiler zone with a specific color
160#define PROFILER_ZONE_COLOR(color) ZoneNamedC(___tracy_scoped_zone, color, makVrf::DtProfiler::collectTracyStats());
161
162//! \brief Defines a profiler section with text and color
163#define PROFILER_SECTION_COLOR(text, color) \
164 { \
165 ZoneNamedNC(___tracy_scoped_zone, text, color, makVrf::DtProfiler::collectTracyStats());
166
167//! \brief Application profiling color (Dark Green)
168#define APPLICATION_COLOR_PROFILE 0x006400
169
170//! \brief Application profiling zone
171#define PROFILE_VX_APPLICATION_ZONE PROFILER_ZONE_COLOR(APPLICATION_COLOR_PROFILE);
172
173//! \brief Application profiling section with text
174#define PROFILE_VX_APPLICATION_SECTION(text) PROFILER_SECTION_COLOR(text, APPLICATION_COLOR_PROFILE);
175
176//! \brief End of application profiling section
177#define PROFILE_VX_APPLICATION_SECTION_END DtPROFILE_SECTION_END
178
179//! \brief Terrain profiling color (DodgerBlue3)
180#define TERRAIN_COLOR_PROFILE tracy::Color::DodgerBlue3
181
182//! \brief Terrain profiling zone
183#define PROFILE_VX_TERRAIN_ZONE PROFILER_ZONE_COLOR(TERRAIN_COLOR_PROFILE);
184
185//! \brief Terrain profiling section with text
186#define PROFILE_VX_TERRAIN_SECTION(text) PROFILER_SECTION_COLOR(text, TERRAIN_COLOR_PROFILE);
187
188//! \brief End of terrain profiling section
189#define PROFILE_VX_TERRAIN_SECTION_END DtPROFILE_SECTION_END
190
191//! \brief Dynamic terrain profiling color (LightSalmon4)
192#define DYNAMIC_TERRAIN_COLOR_PROFILE tracy::Color::LightSalmon4
193
194//! \brief Dynamic terrain profiling zone
195#define PROFILE_VX_DYNAMIC_TERRAIN_ZONE PROFILER_ZONE_COLOR(DYNAMIC_TERRAIN_COLOR_PROFILE);
196
197//! \brief Dynamic terrain profiling section with text
198#define PROFILE_VX_DYNAMIC_TERRAIN_SECTION(text) PROFILER_SECTION_COLOR(text, DYNAMIC_TERRAIN_COLOR_PROFILE);
199
200//! \brief End of dynamic terrain profiling section
201#define PROFILE_VX_DYNAMIC_TERRAIN_SECTION_END DtPROFILE_SECTION_END
202
203//! \brief Actuator profiling color (DarkOliveGreen3)
204#define ACTUATOR_COLOR_PROFILE tracy::Color::DarkOliveGreen3
205
206//! \brief Actuator profiling zone
207#define PROFILE_VX_ACTUATOR_ZONE PROFILER_ZONE_COLOR(ACTUATOR_COLOR_PROFILE);
208
209//! \brief Actuator profiling section with text
210#define PROFILE_VX_ACTUATOR_SECTION(text) PROFILER_SECTION_COLOR(text, ACTUATOR_COLOR_PROFILE);
211
212//! \brief End of actuator profiling section
213#define PROFILE_VX_ACTUATOR_SECTION_END DtPROFILE_SECTION_END
214//! @}
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
std::string formatVxVector(const VxMath::Vector3 &vec)
void VREVRFVORTEX_DLL ConvertFlatEarthToVortex(const DtVector &input, DtVector &output)
Converts a vector from flat earth coordinates to Vortex (NWU) coordinates.
DtVector getDtVector(const VxMath::Vector3 &input)
Creates a DtVector from a Vortex Vector3.
VxMath::Vector3 getVxVector(const DtVector &input)
Creates a Vortex Vector3 from a DtVector.
std::string formatDtVector(const DtVector &vec)
std::string formatTransform(const Vx::VxTransform &transform)
void VREVRFVORTEX_DLL ConvertDISBodyToVortex(const DtVector &input, DtVector &output)
Converts a vector from DIS body coordinates (NED) to Vortex (NWU) coordinates.
bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent &ext, const DtVector &vec)
Checks if an extent contains a DtVector point.
void VREVRFVORTEX_DLL ConvertVortexToDISBody(const DtVector &input, DtVector &output)
Converts a vector from Vortex (NWU) coordinates to DIS body coordinates (NED)
void VREVRFVORTEX_DLL ConvertVxVector3ToDtVector(const VxMath::Vector3 &input, DtVector &output)
Converts a Vortex Vector3 to a DtVector.
void VREVRFVORTEX_DLL ConvertDtVectorToVxVector3(const DtVector &input, VxMath::Vector3 &output)
Converts a DtVector to a Vortex Vector3.
std::string VREVRFVORTEX_DLL vortexName(const DtString &globalId)
Returns the Vortex name for a given global ID.
bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox &bb, const DtVector &vec)
Checks if a bounding box contains a DtVector point.
bool isValidVortexLocalObject(DtLocalObject *obj)
Returns whether or not a local object is a valid vortex entity.
void VREVRFVORTEX_DLL ConvertVortexToFlatEarth(const DtVector &input, DtVector &output)
Converts a vector from Vortex (NWU) coordinates to flat earth coordinates.
bool VREVRFVORTEX_DLL doesBoundingBoxInclude(const VxMath::BoundingBox &bbOne, VxMath::BoundingBox &bbTwo)
Checks if one bounding box fully includes another.