VR-Engage  2.3
Loading...
Searching...
No Matches
vortexCollisionProxyGenerator.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexCollisionProxyGenerator.h
7//! \brief Manages collisions between Vortex-simulated vehicles and non-Vortex vehicles
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
15
17
18#include <VxMath/VxMath.h>
19#include <Vx/VxDynamicsContact.h>
20
21#include <matrix/vlVector.h>
22
23#include <vrfobjcore/simObjectReference.h>
24#include <vrfobjcore/compositePredicate.h>
25#include <vrfobjcore/simObject.h>
26
27#include <tbb/spin_mutex.h>
28
29#include <set>
30#include <unordered_map>
31#include <vector>
32
33class DtCgf;
34
35namespace Vx
36{
37class VxPart;
38}
39namespace makVrf
40{
41class DtArticulatedPartStateRepository;
42}
43namespace makVre
44{
45// fwd declarations
47
48//! \brief Manages collision detection and handling between Vortex physics objects and non-Vortex simulated objects
49//!
50//! This class tracks VR-Forces (non-Vortex) vehicles using proxy representations and creates
51//! corresponding collision geometries in the Vortex physics universe. It maintains lists of
52//! nearby vehicles for each Vortex-simulated vehicle, updates their positions, and processes
53//! collision events between Vortex and non-Vortex objects.
55{
56public:
57 //! \brief Constructor
58 //!
59 //! Initializes the collision proxy generator with the provided physical world and CGF instance.
60 //! Sets up default values for proxy count, search radius, and vehicle mass.
61 //!
62 //! \param world Pointer to the Vortex physical world
63 //! \param cgf Pointer to the CGF instance for callback registration
65
66 //! \brief Destructor
67 //!
68 //! Cleans up all proxy vehicles from the Vortex universe and clears data structures.
70
71 //! \brief Default constructor, copy constructor, and copy assignment operator not allowed
75
76 //! \brief Updates lists of nearest vehicles and checks for collisions
77 //!
78 //! Called each simulation frame to update the positions of proxy vehicles
79 //! in the Vortex universe and process any collisions that occurred.
80 virtual void update();
81
82 //! \brief Adds a Vortex vehicle to the tracked vehicles list
83 //!
84 //! Registers a new Vortex-simulated vehicle by its UUID for collision handling.
85 //!
86 //! \param uuid The UUID of the Vortex vehicle to track
87 virtual void addVortexVehicle(const DtUUID& uuid);
88
89 //! \brief Checks if a UUID corresponds to a tracked Vortex vehicle
90 //!
91 //! \param uuid The UUID to check
92 //! \return True if the UUID corresponds to a tracked Vortex vehicle, false otherwise
93 virtual bool isVortexVehicle(const DtUUID& uuid);
94
95 //! \brief Removes a Vortex vehicle from the tracked vehicles list
96 //!
97 //! Unregisters a Vortex-simulated vehicle and removes its associated proxy vehicles.
98 //!
99 //! \param uuid The UUID of the Vortex vehicle to stop tracking
100 virtual void removeVortexVehicle(const DtUUID& uuid);
101
102 //! \brief Finds up to K closest sim objects around a search center, excluding the given UUID and other Vortex vehicles.
103 //!
104 //! Collects sim objects within `mySearchRadius` of `searchCenter`, filters out the calling Vortex vehicle
105 //! and any other known Vortex vehicles, then partitions to the K closest (`myNumProxyVehicles`) via
106 //! `std::nth_element`. Result is unordered among the K.
107 //!
108 //! \param vortexVehicleUUID UUID of the Vortex vehicle whose own UUID is excluded from results.
109 //! \param searchCenter Center point in local coordinates to search around.
110 //! \return Vector of up to K closest const DtSimObject pointers, in arbitrary order.
111 std::vector<const DtSimObject*> findClosestSimObjects(const DtUUID& vortexVehicleUUID, const DtVector& searchCenter);
112
113 //! \brief Cleans up any proxy vehicles associated with a missing Vortex vehicle
114 //!
115 //! \param uuid The UUID of the missing Vortex vehicle
116 void cleanupMissingVehicle(const DtUUID& uuid);
117
118 //! \brief Sets the entity types that Vortex vehicles will collide with
119 //!
120 //! Updates the filter for determining which object types should be considered
121 //! for collision detection with Vortex-simulated vehicles.
122 //!
123 //! \param entityTypes Vector of entity types to consider for collision detection
124 virtual void setTypesToCollideWith(std::vector<DtEntityType> entityTypes);
125
126 //! \brief Sets the maximum number of proxy vehicles to generate per Vortex vehicle
127 //!
128 //! Updates the maximum number of proxy vehicles that can be generated for each Vortex vehicle.
129 //!
130 //! \param numProxyVehicles Maximum number of proxy vehicles to generate per Vortex vehicle
131 virtual void setMaxNumProxyVehicles(int numProxyVehicles);
132
133 //! \brief Sets the search radius for nearby vehicles
134 //!
135 //! Updates the maximum distance in meters to search for nearby vehicles for collision detection.
136 //!
137 //! \param searchRadius Maximum distance in meters to search for nearby vehicles
138 virtual void setSearchRadius(double searchRadius);
139
140 //! \brief Sets the default mass for proxy vehicles
141 //!
142 //! Updates the default mass in kilograms for proxy vehicles in the Vortex universe.
143 //!
144 //! \param defaultMass Default mass in kilograms
145 virtual void setDefaultProxyMass(double defaultMass);
146
147 //! \brief Sets the maximum kinematic update velocity
148 //!
149 //! Updates the velocity at which we consider a proxies motion in a single tick to be instantaneous
150 //!
151 //! \param maxVel Maximum velocity to be used for updates.
152 virtual void setMaxKinematicUpdateVelocity(double maxVel);
153
154 //! \brief Callback executed when a scenario is rewound
155 //!
156 //! Clears all vehicle lists and mappings to prevent accessing invalid data
157 //! after a scenario rewind operation.
159
160 //! \brief Renders ImGui debug interface for collision proxy visualization
161 //!
162 //! Provides a graphical user interface for debugging and monitoring the collision
163 //! proxy generator's state, including tracked vehicles and active proxies.
164 //! Override this method to customize debug visualization.
165 virtual void renderImgui();
166
167 //! \brief Clears all internal data structures
168 //!
169 //! Removes all tracked Vortex vehicles and destroys all proxy VxParts from the
170 //! Vortex universe. Called during destruction and scenario rewind to ensure clean
171 //! state and prevent accessing invalidated data.
172 virtual void clearDataStructures();
173
174protected:
175 //! \brief Long-term state for a single VRF proxy in the Vortex universe.
176 //!
177 //! Stores the VR-Forces object reference, its last known position and heading,
178 //! and the number of Vortex vehicles that currently reference it. A proxy is
179 //! removed from the Vortex universe only when its association count drops to zero,
180 //! preventing premature removal when multiple Vortex vehicles share a nearby proxy.
182 {
183 struct Common // Common data shared between all proxy records
184 {
185 DtSimObjectReference vrfObject; //!< Reference to the VR-Forces simulation object
186 DtUUID vrfUuid; //!< Cached VRF UUID for lookup after object expiry
187 DtVector location; //!< Last known location in local Dt coordinates
188 double heading = 0.0; //!< Last known heading in radians
189 int associationCount = 0; //!< Number of Vortex vehicles referencing this proxy
190 bool vortexActive = false; //!< True if the proxy represents an actively simulated Vortex vehicle
191 unsigned long long lastUpdateGeneration =
192 0; //!< update() pass in which this proxy's transform was last advanced; prevents redundant re-updates when shared by multiple Vortex vehicles
193 };
194 struct VortexParts // Vortex-specific data for the proxy record
195 {
196 Vx::VxPart* vxPart = nullptr; //!< Vortex physics part; non-null when box and added to universe
197 VxSim::VxObject* vxObject = nullptr; //!< Vortex Object for loaded Vx Proxies
198 std::vector<Vx::VxPart*> vxObjectParts; //!< Parts belonging to a loaded Vortex object proxy
199 std::vector<Vx::VxPart*> fakeWheelParts; //!< Fake cylinder wheel parts that are directly created
200 std::vector<Vx::VxTransform> vxPartLocalTransforms; //!< Per-part local transform relative to proxy root
201 };
202 struct ArtPartData // Articulated part data for the proxy record
203 {
204 std::map<int, std::string> artPartMap; //!< Map from art part type to Vortex part name to update transforms;
205 std::map<std::string, int> partMap; //!< Map from Vortex part name to vxObjectParts index
206 std::map<int, double> radiusMap; //!< Map from art part type to radius for wheels
207 std::map<int, double> widthMap; //!< Map from art part type to width for wheels
208 std::map<int, DtVector> restPositionMap; //!< Map from art part type to rest position for wheels
209 };
210
214 };
215
216 //! \brief Number of nearby non-Vortex vehicles to consider for each Vortex vehicle
218
219 //! \brief Maximum distance in meters to search for nearby vehicles
221
222 //! \brief Default mass in kg for non-Vortex vehicles
223 //!
224 //! This value is used when creating collision proxies in the Vortex universe.
225 //! It's deliberately set high to make the vehicles behave as heavy objects.
227
228 //! \brief Maximum velocity at which proxies are updated kinematically (Such that they have a velocity) (m/s)
230
231 //! \brief Manager for loading and caching Vortex mechanisms for proxy vehicle part instantiation
233
234 //! \brief Creates a proxy VxPart for the given VRF object and registers it
235 //!
236 //! If a proxy for the given object already exists in the registry (because another
237 //! Vortex vehicle is already tracking it), its association count is incremented
238 //! instead of creating a duplicate.
239 //!
240 //! \param obj The VR-Forces simulation object to create a proxy for
241 void createProxy(const DtSimObject& obj);
242
243 //! \brief Creates a box-shaped proxy VxPart for the given VRF object record and transform
244 //!
245 //! \param record The proxy record to populate with the new VxPart
246 //! \param transform The transform to apply to the new VxPart in the Vortex
247 void createBoxProxy(ProxyRecord& record, Vx::VxTransform& transform);
248
249 //! \brief Removes a proxy from the Vortex universe and cleans all registry entries
250 //!
251 //! \param vrfUuid UUID of the VRF object whose proxy should be destroyed
252 void destroyProxy(const DtUUID& vrfUuid);
253
254 //! \brief Updates the position and heading of an existing proxy to match its VRF object
255 //!
256 //! \param vrfUuid UUID of the VRF object whose proxy transform should be refreshed
257 void updateProxyTransform(const DtUUID& vrfUuid);
258
259 //! \brief Updates the Vortex proxy representation for a given proxy record
260 //!
261 //! \param record The proxy record to update
262 //! \param transform The world transform to apply to the proxy
263 //! \param vel The velocity derived from the change in position this step
264 //! \param dt The timestep
265 void updateVortexProxy(ProxyRecord& record, Vx::VxTransform transform, double vel, double dt);
266
267 //! \brief Updates the transforms of articulated parts for a given proxy record
268 //!
269 //! \param partInfo Articulated part state repository containing the current transforms of the parts
270 //! \param record The proxy record this part belongs to
271 //! \param knownTransforms Map of already-applied world transforms keyed by part type; seeded with chassis at key -1
272 //! \param dt Time step for the update
273 //! \note Uses bodyPosition() (static attach-point chain) + translation() (dynamic displacement) for current chassis-local position.
274 void updateArtPart(const makVrf::DtArticulatedPartStateRepository* partInfo,
275 ProxyRecord& record,
276 std::map<int, Vx::VxTransform>& knownTransforms,
277 double dt);
278
279 //! \brief Finds the VxPart corresponding to an articulated part type for a given proxy record
280 //!
281 //! \param partInfo Articulated part state repository containing the current transforms of the parts
282 //! \param record The proxy record this part belongs to
283 //! \return Pointer to the corresponding VxPart, or nullptr if not found
284 Vx::VxPart* findTargetPartFromArtPart(const makVrf::DtArticulatedPartStateRepository* partInfo, ProxyRecord& record);
285
286 //! \brief Computes the transform for an articulated part based on its state info.
287 //!
288 //! \param partInfo Articulated part state repository containing the current transforms of the parts
289 //! \return The computed VxTransform for the articulated part. Compound with the chassis world transform to get the part's world transform.
290 Vx::VxTransform getArtPartTransform(const makVrf::DtArticulatedPartStateRepository* partInfo);
291
292 //! \brief Updates the set of active proxy associations for a given Vortex vehicle
293 //!
294 //! Finds the nearest non-Vortex vehicles within the collision range threshold and
295 //! creates, updates, or removes proxy representations using reference-counted ownership.
296 //!
297 //! \param uuid The UUID of the Vortex vehicle to update proxies for
298 virtual void updateClosestVehicleList(const DtUUID& uuid);
299
300 //! \brief Disassociates proxies from a Vortex vehicle that are no longer in its closest set.
301 //!
302 //! Iterates `currentAssociations`, drops any entry whose UUID is not present in `closestObjects`,
303 //! decrements the corresponding proxy's associationCount, and destroys the proxy if it reaches zero.
304 //!
305 //! \param currentAssociations Mutable set of proxy UUIDs currently associated with the caller's Vortex vehicle.
306 //! \param closestObjects K closest sim objects the caller wishes to keep associated.
307 void disassociateStaleProxies(std::set<DtUUID>& currentAssociations,
308 const std::vector<const DtSimObject*>& closestObjects);
309
310 //! \brief Creates proxies for new candidates, shares existing ones, and refreshes transforms for existing associations.
311 //!
312 //! For each object in `closestObjects`: if not yet associated, inserts the association and either
313 //! increments the existing proxy's associationCount (shared with another Vortex vehicle) or creates
314 //! a new proxy. If already associated, refreshes the proxy's transform.
315 //!
316 //! \param currentAssociations Mutable set of proxy UUIDs currently associated with the caller's Vortex vehicle.
317 //! \param closestObjects K closest sim objects to associate or update.
318 void createOrUpdateProxies(std::set<DtUUID>& currentAssociations,
319 const std::vector<const DtSimObject*>& closestObjects);
320
321 //! \brief Decrements a proxy's association count and destroys it if no Vortex vehicle references it anymore.
322 //!
323 //! Does not touch any `myVortexToProxyAssociations` set � the caller is expected to remove
324 //! `proxyUuid` from the appropriate subscriber set (or clear the set entirely) if needed.
325 //!
326 //! \param proxyUuid UUID of the proxy whose association count should be decremented.
327 void releaseProxyAssociation(const DtUUID& proxyUuid);
328
329 //! \brief Collects nearby simulation objects around a search center
330 //!
331 //! Finds all simulated objects of appropriate types within the search radius
332 //! of the specified position.
333 //!
334 //! \param searchCenter The center point for the search
335 //! \param results Vector to be filled with pointers to nearby objects
336 virtual void collectNearbySimObjects(const DtVector& searchCenter, std::vector<const DtSimObject*>& results);
337
338 //! \brief Destroys and re-creates a proxy when its VortexActive state has changed.
339 //!
340 //! Snapshots pre-destroy subscribers and restores their associations + associationCount
341 //! after re-creation, so the new proxy is not double-counted and can still be freed
342 //! when it eventually falls out of range.
343 //!
344 //! \param record Proxy record to inspect. Invalidated on true-return.
345 //! \return True if retagged (record invalidated); false otherwise.
347
348 //! \brief Creates a cylinder VxPart standing in for a wheel that has no corresponding
349 //! part in the loaded Vortex mechanism.
350 //!
351 //! Cylinder is oriented so its axis lies along part-local Y (wheel spin axis).
352 //! Added directly to the universe and to record.fakeWheelParts; destroyProxy() owns cleanup.
353 //!
354 //! \param record Proxy record that will own the new part.
355 //! \param partType Articulated part type (for rest-position lookup).
356 //! \param name Vortex part name.
357 //! \param radius Wheel radius (m).
358 //! \param width Wheel width (m).
359 //! \return The new VxPart.
360 Vx::VxPart* createWheelProxy(ProxyRecord& record, int partType, std::string name, double radius, double width);
361
362 //! \brief Loads a Vortex mechanism file and instantiates its assemblies into record.vxObject.
363 //!
364 //! Tags each part's collision geometries as sensor (when record.vortexActive) or proxy.
365 //! On success, ownership of record.vxObject transfers to the caller, which must add it
366 //! to vortexApplication before returning.
367 //!
368 //! \param record Proxy record to populate.
369 //! \param filename Mechanism file path (resolved via loadManager).
370 //! \param transform Root transform applied to each assembly.
371 //! \return True if at least one assembly instantiated.
372 bool instantiateMechanismParts(ProxyRecord& record, const DtFilename& filename, Vx::VxTransform& transform);
373
374 //! \brief Handles a collision between two Vortex parts
375 //!
376 //! Processes a collision detected by the Vortex physics engine and generates
377 //! an appropriate VR-Forces collision event.
378 //!
379 //! \param collision Non-null contact containing both parts involved in the collision
380 virtual void handleVortexCollision(Vx::VxDynamicsContact* collision);
381
382 //! \brief Checks if a vehicle is player controlled
383 //!
384 //! Determines if a given vehicle is currently being controlled by a player
385 //! as a driver.
386 //!
387 //! \param vehicle The vehicle to check
388 //! \return True if the vehicle is player controlled, false otherwise
389 virtual bool isPlayerControlled(const DtSimObject& vehicle) const;
390
391 //! \brief Converts from VR-Forces coordinates to Vortex coordinates
392 //!
393 //! Translates position vectors between coordinate systems based on
394 //! whether the terrain is geocentric or local/flat.
395 //!
396 //! \param vec Position vector in VR-Forces coordinates
397 //! \return Equivalent position vector in Vortex coordinates
398 virtual VxMath::Vector3 toVxCoords(const DtVector& vec);
399
400 //! \brief Last-emitted collision-event timestamp per (proxy, vortex) UUID pair.
401 //!
402 //! Rate-limits collision events to at most one per pair per second. Keys are always
403 //! ordered (proxy first) so a pair produces a single entry regardless of detection order.
404 std::map<std::pair<DtUUID, DtUUID>, double> myLastCollisionInteractionTimes;
405
406 //! \brief Flag indicating if the terrain uses geocentric coordinates
408
409 //! \brief Coordinate converter for geocentric/local transformations
411
412 //! \brief Set of UUIDs for all Vortex vehicles currently being tracked
413 std::set<DtUUID> myVortexVehicles;
414
415 //! \brief Primary registry mapping each VRF UUID to its proxy state
416 //!
417 //! Single source of truth for all active proxies in the Vortex universe.
418 std::map<DtUUID, ProxyRecord> myProxyRegistry;
419
420 //! \brief Monotonically increasing counter incremented once per update() pass
421 //!
422 //! Used to update each shared proxy's transform exactly once per pass, regardless
423 //! of how many Vortex vehicles reference it.
424 unsigned long long myUpdateGeneration = 0;
425
426 //! \brief Reverse lookup from Vortex part pointer to VRF UUID
427 //!
428 //! Used during collision handling to identify which VRF object was hit.
429 std::unordered_map<Vx::VxPart*, DtUUID> myPartIndex;
430
431 //! \brief Per-Vortex-vehicle set of currently associated proxy UUIDs
432 //!
433 //! Enables reference-counted proxy ownership: a proxy is destroyed only when
434 //! all Vortex vehicles that reference it have disassociated from it.
435 std::map<DtUUID, std::set<DtUUID>> myVortexToProxyAssociations;
436
437 //! \brief Pointer to the Vortex physical world
439
440 //! \brief List of entity types that Vortex vehicles will collide with
441 std::vector<DtEntityType> myObjectTypesToCollideWith;
442
443 //! \brief Predicate for filtering objects by their types
445
446 //! \brief Mutex for thread-safe access to data structures
447 tbb::spin_mutex myMutex;
448};
449
450} // namespace makVre
Class for converting between different coordinate systems.
Definition coordConverter.h:31
DtVortexCollisionProxyGenerator(const DtVortexCollisionProxyGenerator &)=delete
Vx::VxPart * createWheelProxy(ProxyRecord &record, int partType, std::string name, double radius, double width)
Creates a cylinder VxPart standing in for a wheel that has no corresponding part in the loaded Vortex...
DtVortexCollisionProxyGenerator()=delete
Default constructor, copy constructor, and copy assignment operator not allowed.
virtual void setDefaultProxyMass(double defaultMass)
Sets the default mass for proxy vehicles.
bool retagPartsIfNecessary(const ProxyRecord &record)
Destroys and re-creates a proxy when its VortexActive state has changed.
bool myTerrainIsGeocentric
Flag indicating if the terrain uses geocentric coordinates.
Definition vortexCollisionProxyGenerator.h:407
virtual bool isPlayerControlled(const DtSimObject &vehicle) const
Checks if a vehicle is player controlled.
std::vector< DtEntityType > myObjectTypesToCollideWith
List of entity types that Vortex vehicles will collide with.
Definition vortexCollisionProxyGenerator.h:441
DtCoordinateConvert * myCoordConverter
Coordinate converter for geocentric/local transformations.
Definition vortexCollisionProxyGenerator.h:410
void releaseProxyAssociation(const DtUUID &proxyUuid)
Decrements a proxy's association count and destroys it if no Vortex vehicle references it anymore.
void updateVortexProxy(ProxyRecord &record, Vx::VxTransform transform, double vel, double dt)
Updates the Vortex proxy representation for a given proxy record.
void updateArtPart(const makVrf::DtArticulatedPartStateRepository *partInfo, ProxyRecord &record, std::map< int, Vx::VxTransform > &knownTransforms, double dt)
Updates the transforms of articulated parts for a given proxy record.
tbb::spin_mutex myMutex
Mutex for thread-safe access to data structures.
Definition vortexCollisionProxyGenerator.h:447
double myMaxKinematicUpdateVelocity
Maximum velocity at which proxies are updated kinematically (Such that they have a velocity) (m/s)
Definition vortexCollisionProxyGenerator.h:229
void destroyProxy(const DtUUID &vrfUuid)
Removes a proxy from the Vortex universe and cleans all registry entries.
void createProxy(const DtSimObject &obj)
Creates a proxy VxPart for the given VRF object and registers it.
double myDefaultVrfVehicleMass
Default mass in kg for non-Vortex vehicles.
Definition vortexCollisionProxyGenerator.h:226
virtual void removeVortexVehicle(const DtUUID &uuid)
Removes a Vortex vehicle from the tracked vehicles list.
unsigned long long myUpdateGeneration
Monotonically increasing counter incremented once per update() pass.
Definition vortexCollisionProxyGenerator.h:424
Vx::VxTransform getArtPartTransform(const makVrf::DtArticulatedPartStateRepository *partInfo)
Computes the transform for an articulated part based on its state info.
virtual void setMaxNumProxyVehicles(int numProxyVehicles)
Sets the maximum number of proxy vehicles to generate per Vortex vehicle.
virtual void addVortexVehicle(const DtUUID &uuid)
Adds a Vortex vehicle to the tracked vehicles list.
virtual void handleVortexCollision(Vx::VxDynamicsContact *collision)
Handles a collision between two Vortex parts.
std::set< DtUUID > myVortexVehicles
Set of UUIDs for all Vortex vehicles currently being tracked.
Definition vortexCollisionProxyGenerator.h:413
std::vector< const DtSimObject * > findClosestSimObjects(const DtUUID &vortexVehicleUUID, const DtVector &searchCenter)
Finds up to K closest sim objects around a search center, excluding the given UUID and other Vortex v...
double mySearchRadius
Maximum distance in meters to search for nearby vehicles.
Definition vortexCollisionProxyGenerator.h:220
DtVortexCollisionProxyGenerator(DtVortexPhysicalWorld *world, DtCgf *cgf)
Constructor.
virtual VxMath::Vector3 toVxCoords(const DtVector &vec)
Converts from VR-Forces coordinates to Vortex coordinates.
Vx::VxPart * findTargetPartFromArtPart(const makVrf::DtArticulatedPartStateRepository *partInfo, ProxyRecord &record)
Finds the VxPart corresponding to an articulated part type for a given proxy record.
std::map< DtUUID, ProxyRecord > myProxyRegistry
Primary registry mapping each VRF UUID to its proxy state.
Definition vortexCollisionProxyGenerator.h:418
void cleanupMissingVehicle(const DtUUID &uuid)
Cleans up any proxy vehicles associated with a missing Vortex vehicle.
std::map< DtUUID, std::set< DtUUID > > myVortexToProxyAssociations
Per-Vortex-vehicle set of currently associated proxy UUIDs.
Definition vortexCollisionProxyGenerator.h:435
virtual void collectNearbySimObjects(const DtVector &searchCenter, std::vector< const DtSimObject * > &results)
Collects nearby simulation objects around a search center.
std::map< std::pair< DtUUID, DtUUID >, double > myLastCollisionInteractionTimes
Last-emitted collision-event timestamp per (proxy, vortex) UUID pair.
Definition vortexCollisionProxyGenerator.h:404
DtVortexPhysicalWorld * myVortexPhysicalWorld
Pointer to the Vortex physical world.
Definition vortexCollisionProxyGenerator.h:438
DtCompositePredicate myCollideableObjectTypesPredicate
Predicate for filtering objects by their types.
Definition vortexCollisionProxyGenerator.h:444
virtual void setTypesToCollideWith(std::vector< DtEntityType > entityTypes)
Sets the entity types that Vortex vehicles will collide with.
void createOrUpdateProxies(std::set< DtUUID > &currentAssociations, const std::vector< const DtSimObject * > &closestObjects)
Creates proxies for new candidates, shares existing ones, and refreshes transforms for existing assoc...
DtVortexCollisionProxyGenerator & operator=(const DtVortexCollisionProxyGenerator &)=delete
virtual void update()
Updates lists of nearest vehicles and checks for collisions.
virtual bool isVortexVehicle(const DtUUID &uuid)
Checks if a UUID corresponds to a tracked Vortex vehicle.
DtVortexObjectLoadManager loadManager
Manager for loading and caching Vortex mechanisms for proxy vehicle part instantiation.
Definition vortexCollisionProxyGenerator.h:232
virtual void setMaxKinematicUpdateVelocity(double maxVel)
Sets the maximum kinematic update velocity.
virtual void setSearchRadius(double searchRadius)
Sets the search radius for nearby vehicles.
virtual void renderImgui()
Renders ImGui debug interface for collision proxy visualization.
bool instantiateMechanismParts(ProxyRecord &record, const DtFilename &filename, Vx::VxTransform &transform)
Loads a Vortex mechanism file and instantiates its assemblies into record.vxObject.
std::unordered_map< Vx::VxPart *, DtUUID > myPartIndex
Reverse lookup from Vortex part pointer to VRF UUID.
Definition vortexCollisionProxyGenerator.h:429
void updateProxyTransform(const DtUUID &vrfUuid)
Updates the position and heading of an existing proxy to match its VRF object.
virtual void updateClosestVehicleList(const DtUUID &uuid)
Updates the set of active proxy associations for a given Vortex vehicle.
void rewindCallback()
Callback executed when a scenario is rewound.
virtual ~DtVortexCollisionProxyGenerator()
Destructor.
void disassociateStaleProxies(std::set< DtUUID > &currentAssociations, const std::vector< const DtSimObject * > &closestObjects)
Disassociates proxies from a Vortex vehicle that are no longer in its closest set.
virtual void clearDataStructures()
Clears all internal data structures.
void createBoxProxy(ProxyRecord &record, Vx::VxTransform &transform)
Creates a box-shaped proxy VxPart for the given VRF object record and transform.
int myNumProxyVehicles
Number of nearby non-Vortex vehicles to consider for each Vortex vehicle.
Definition vortexCollisionProxyGenerator.h:217
Definition vortexObjectLoadManager.h:23
Main class responsible for managing the Vortex physics simulation environment.
Definition vortexPhysicalWorld.h:65
Provides coordinate conversion functionality between different coordinate systems.
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
Wheel articulated part IDs used in the system.
Definition surfaceToVxMaterialMapper.h:20
!
Definition glsVreMessageUtil.h:50
Definition connectorAccessory.h:38
Definition vortexCollisionProxyGenerator.h:203
std::map< int, std::string > artPartMap
Map from art part type to Vortex part name to update transforms;.
Definition vortexCollisionProxyGenerator.h:204
std::map< int, double > widthMap
Map from art part type to width for wheels.
Definition vortexCollisionProxyGenerator.h:207
std::map< int, DtVector > restPositionMap
Map from art part type to rest position for wheels.
Definition vortexCollisionProxyGenerator.h:208
std::map< int, double > radiusMap
Map from art part type to radius for wheels.
Definition vortexCollisionProxyGenerator.h:206
std::map< std::string, int > partMap
Map from Vortex part name to vxObjectParts index.
Definition vortexCollisionProxyGenerator.h:205
Definition vortexCollisionProxyGenerator.h:184
DtSimObjectReference vrfObject
Reference to the VR-Forces simulation object.
Definition vortexCollisionProxyGenerator.h:185
unsigned long long lastUpdateGeneration
update() pass in which this proxy's transform was last advanced; prevents redundant re-updates when s...
Definition vortexCollisionProxyGenerator.h:191
double heading
Last known heading in radians.
Definition vortexCollisionProxyGenerator.h:188
DtUUID vrfUuid
Cached VRF UUID for lookup after object expiry.
Definition vortexCollisionProxyGenerator.h:186
bool vortexActive
True if the proxy represents an actively simulated Vortex vehicle.
Definition vortexCollisionProxyGenerator.h:190
int associationCount
Number of Vortex vehicles referencing this proxy.
Definition vortexCollisionProxyGenerator.h:189
DtVector location
Last known location in local Dt coordinates.
Definition vortexCollisionProxyGenerator.h:187
Definition vortexCollisionProxyGenerator.h:195
VxSim::VxObject * vxObject
Vortex Object for loaded Vx Proxies.
Definition vortexCollisionProxyGenerator.h:197
Vx::VxPart * vxPart
Vortex physics part; non-null when box and added to universe.
Definition vortexCollisionProxyGenerator.h:196
std::vector< Vx::VxPart * > vxObjectParts
Parts belonging to a loaded Vortex object proxy.
Definition vortexCollisionProxyGenerator.h:198
std::vector< Vx::VxPart * > fakeWheelParts
Fake cylinder wheel parts that are directly created.
Definition vortexCollisionProxyGenerator.h:199
std::vector< Vx::VxTransform > vxPartLocalTransforms
Per-part local transform relative to proxy root.
Definition vortexCollisionProxyGenerator.h:200
Long-term state for a single VRF proxy in the Vortex universe.
Definition vortexCollisionProxyGenerator.h:182
Common common
Definition vortexCollisionProxyGenerator.h:211
ArtPartData artParts
Definition vortexCollisionProxyGenerator.h:213
VortexParts vortex
Definition vortexCollisionProxyGenerator.h:212
Extension for Processing Vortex Collisions.
Declares Vortex object load manager interfaces.