|
VR-Engage
2.3
|
This class tracks VR-Forces (non-Vortex) vehicles using proxy representations and creates corresponding collision geometries in the Vortex physics universe. It maintains lists of nearby vehicles for each Vortex-simulated vehicle, updates their positions, and processes collision events between Vortex and non-Vortex objects.
#include <vortexCollisionProxyGenerator.h>
Classes | |
| struct | ProxyRecord |
Public Member Functions | |
| DtVortexCollisionProxyGenerator (DtVortexPhysicalWorld *world, DtCgf *cgf) | |
| virtual | ~DtVortexCollisionProxyGenerator () |
| DtVortexCollisionProxyGenerator ()=delete | |
| DtVortexCollisionProxyGenerator (const DtVortexCollisionProxyGenerator &)=delete | |
| DtVortexCollisionProxyGenerator & | operator= (const DtVortexCollisionProxyGenerator &)=delete |
| virtual void | update () |
| virtual void | addVortexVehicle (const DtUUID &uuid) |
| virtual bool | isVortexVehicle (const DtUUID &uuid) |
| virtual void | removeVortexVehicle (const DtUUID &uuid) |
| std::vector< const DtSimObject * > | findClosestSimObjects (const DtUUID &vortexVehicleUUID, const DtVector &searchCenter) |
| void | cleanupMissingVehicle (const DtUUID &uuid) |
| virtual void | setTypesToCollideWith (std::vector< DtEntityType > entityTypes) |
| virtual void | setMaxNumProxyVehicles (int numProxyVehicles) |
| virtual void | setSearchRadius (double searchRadius) |
| virtual void | setDefaultProxyMass (double defaultMass) |
| virtual void | setMaxKinematicUpdateVelocity (double maxVel) |
| void | rewindCallback () |
| virtual void | renderImgui () |
| virtual void | clearDataStructures () |
Protected Member Functions | |
| void | createProxy (const DtSimObject &obj) |
| void | createBoxProxy (ProxyRecord &record, Vx::VxTransform &transform) |
| void | destroyProxy (const DtUUID &vrfUuid) |
| void | updateProxyTransform (const DtUUID &vrfUuid) |
| void | updateVortexProxy (ProxyRecord &record, Vx::VxTransform transform, double vel, double dt) |
| void | updateArtPart (const makVrf::DtArticulatedPartStateRepository *partInfo, ProxyRecord &record, std::map< int, Vx::VxTransform > &knownTransforms, double dt) |
| Vx::VxPart * | findTargetPartFromArtPart (const makVrf::DtArticulatedPartStateRepository *partInfo, ProxyRecord &record) |
| Vx::VxTransform | getArtPartTransform (const makVrf::DtArticulatedPartStateRepository *partInfo) |
| virtual void | updateClosestVehicleList (const DtUUID &uuid) |
| void | disassociateStaleProxies (std::set< DtUUID > ¤tAssociations, const std::vector< const DtSimObject * > &closestObjects) |
| void | createOrUpdateProxies (std::set< DtUUID > ¤tAssociations, const std::vector< const DtSimObject * > &closestObjects) |
| void | releaseProxyAssociation (const DtUUID &proxyUuid) |
| virtual void | collectNearbySimObjects (const DtVector &searchCenter, std::vector< const DtSimObject * > &results) |
| bool | retagPartsIfNecessary (const ProxyRecord &record) |
| Vx::VxPart * | createWheelProxy (ProxyRecord &record, int partType, std::string name, double radius, double width) |
| bool | instantiateMechanismParts (ProxyRecord &record, const DtFilename &filename, Vx::VxTransform &transform) |
| virtual void | handleVortexCollision (Vx::VxDynamicsContact *collision) |
| virtual bool | isPlayerControlled (const DtSimObject &vehicle) const |
| virtual VxMath::Vector3 | toVxCoords (const DtVector &vec) |
Protected Attributes | |
| int | myNumProxyVehicles |
| double | mySearchRadius |
| double | myDefaultVrfVehicleMass |
| double | myMaxKinematicUpdateVelocity |
| DtVortexObjectLoadManager | loadManager |
| std::map< std::pair< DtUUID, DtUUID >, double > | myLastCollisionInteractionTimes |
| bool | myTerrainIsGeocentric |
| DtCoordinateConvert * | myCoordConverter |
| std::set< DtUUID > | myVortexVehicles |
| std::map< DtUUID, ProxyRecord > | myProxyRegistry |
| unsigned long long | myUpdateGeneration = 0 |
| std::unordered_map< Vx::VxPart *, DtUUID > | myPartIndex |
| std::map< DtUUID, std::set< DtUUID > > | myVortexToProxyAssociations |
| DtVortexPhysicalWorld * | myVortexPhysicalWorld |
| std::vector< DtEntityType > | myObjectTypesToCollideWith |
| DtCompositePredicate | myCollideableObjectTypesPredicate |
| tbb::spin_mutex | myMutex |
| makVre::DtVortexCollisionProxyGenerator::DtVortexCollisionProxyGenerator | ( | DtVortexPhysicalWorld * | world, |
| DtCgf * | cgf ) |
Constructor.
Initializes the collision proxy generator with the provided physical world and CGF instance. Sets up default values for proxy count, search radius, and vehicle mass.
| world | Pointer to the Vortex physical world |
| cgf | Pointer to the CGF instance for callback registration |
Referenced by DtVortexCollisionProxyGenerator(), and operator=().
|
virtual |
Destructor.
Cleans up all proxy vehicles from the Vortex universe and clears data structures.
|
delete |
Default constructor, copy constructor, and copy assignment operator not allowed.
|
delete |
References DtVortexCollisionProxyGenerator().
|
delete |
References DtVortexCollisionProxyGenerator().
|
virtual |
Updates lists of nearest vehicles and checks for collisions.
Called each simulation frame to update the positions of proxy vehicles in the Vortex universe and process any collisions that occurred.
|
virtual |
Adds a Vortex vehicle to the tracked vehicles list.
Registers a new Vortex-simulated vehicle by its UUID for collision handling.
| uuid | The UUID of the Vortex vehicle to track |
|
virtual |
Checks if a UUID corresponds to a tracked Vortex vehicle.
| uuid | The UUID to check |
|
virtual |
Removes a Vortex vehicle from the tracked vehicles list.
Unregisters a Vortex-simulated vehicle and removes its associated proxy vehicles.
| uuid | The UUID of the Vortex vehicle to stop tracking |
| std::vector< const DtSimObject * > makVre::DtVortexCollisionProxyGenerator::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 vehicles.
Collects sim objects within mySearchRadius of searchCenter, filters out the calling Vortex vehicle and any other known Vortex vehicles, then partitions to the K closest (myNumProxyVehicles) via std::nth_element. Result is unordered among the K.
| vortexVehicleUUID | UUID of the Vortex vehicle whose own UUID is excluded from results. |
| searchCenter | Center point in local coordinates to search around. |
| void makVre::DtVortexCollisionProxyGenerator::cleanupMissingVehicle | ( | const DtUUID & | uuid | ) |
Cleans up any proxy vehicles associated with a missing Vortex vehicle.
| uuid | The UUID of the missing Vortex vehicle |
|
virtual |
Sets the entity types that Vortex vehicles will collide with.
Updates the filter for determining which object types should be considered for collision detection with Vortex-simulated vehicles.
| entityTypes | Vector of entity types to consider for collision detection |
|
virtual |
Sets the maximum number of proxy vehicles to generate per Vortex vehicle.
Updates the maximum number of proxy vehicles that can be generated for each Vortex vehicle.
| numProxyVehicles | Maximum number of proxy vehicles to generate per Vortex vehicle |
|
virtual |
Sets the search radius for nearby vehicles.
Updates the maximum distance in meters to search for nearby vehicles for collision detection.
| searchRadius | Maximum distance in meters to search for nearby vehicles |
|
virtual |
Sets the default mass for proxy vehicles.
Updates the default mass in kilograms for proxy vehicles in the Vortex universe.
| defaultMass | Default mass in kilograms |
|
virtual |
Sets the maximum kinematic update velocity.
Updates the velocity at which we consider a proxies motion in a single tick to be instantaneous
| maxVel | Maximum velocity to be used for updates. |
| void makVre::DtVortexCollisionProxyGenerator::rewindCallback | ( | ) |
Callback executed when a scenario is rewound.
Clears all vehicle lists and mappings to prevent accessing invalid data after a scenario rewind operation.
|
virtual |
Renders ImGui debug interface for collision proxy visualization.
Provides a graphical user interface for debugging and monitoring the collision proxy generator's state, including tracked vehicles and active proxies. Override this method to customize debug visualization.
|
virtual |
Clears all internal data structures.
Removes all tracked Vortex vehicles and destroys all proxy VxParts from the Vortex universe. Called during destruction and scenario rewind to ensure clean state and prevent accessing invalidated data.
|
protected |
Creates a proxy VxPart for the given VRF object and registers it.
If a proxy for the given object already exists in the registry (because another Vortex vehicle is already tracking it), its association count is incremented instead of creating a duplicate.
| obj | The VR-Forces simulation object to create a proxy for |
|
protected |
Creates a box-shaped proxy VxPart for the given VRF object record and transform.
| record | The proxy record to populate with the new VxPart |
| transform | The transform to apply to the new VxPart in the Vortex |
|
protected |
Removes a proxy from the Vortex universe and cleans all registry entries.
| vrfUuid | UUID of the VRF object whose proxy should be destroyed |
|
protected |
Updates the position and heading of an existing proxy to match its VRF object.
| vrfUuid | UUID of the VRF object whose proxy transform should be refreshed |
|
protected |
Updates the Vortex proxy representation for a given proxy record.
| record | The proxy record to update |
| transform | The world transform to apply to the proxy |
| vel | The velocity derived from the change in position this step |
| dt | The timestep |
|
protected |
Updates the transforms of articulated parts for a given proxy record.
| partInfo | Articulated part state repository containing the current transforms of the parts |
| record | The proxy record this part belongs to |
| knownTransforms | Map of already-applied world transforms keyed by part type; seeded with chassis at key -1 |
| dt | Time step for the update |
|
protected |
Finds the VxPart corresponding to an articulated part type for a given proxy record.
| partInfo | Articulated part state repository containing the current transforms of the parts |
| record | The proxy record this part belongs to |
|
protected |
Computes the transform for an articulated part based on its state info.
| partInfo | Articulated part state repository containing the current transforms of the parts |
|
protectedvirtual |
Updates the set of active proxy associations for a given Vortex vehicle.
Finds the nearest non-Vortex vehicles within the collision range threshold and creates, updates, or removes proxy representations using reference-counted ownership.
| uuid | The UUID of the Vortex vehicle to update proxies for |
|
protected |
Disassociates proxies from a Vortex vehicle that are no longer in its closest set.
Iterates currentAssociations, drops any entry whose UUID is not present in closestObjects, decrements the corresponding proxy's associationCount, and destroys the proxy if it reaches zero.
| currentAssociations | Mutable set of proxy UUIDs currently associated with the caller's Vortex vehicle. |
| closestObjects | K closest sim objects the caller wishes to keep associated. |
|
protected |
Creates proxies for new candidates, shares existing ones, and refreshes transforms for existing associations.
For each object in closestObjects: if not yet associated, inserts the association and either increments the existing proxy's associationCount (shared with another Vortex vehicle) or creates a new proxy. If already associated, refreshes the proxy's transform.
| currentAssociations | Mutable set of proxy UUIDs currently associated with the caller's Vortex vehicle. |
| closestObjects | K closest sim objects to associate or update. |
|
protected |
Decrements a proxy's association count and destroys it if no Vortex vehicle references it anymore.
Does not touch any myVortexToProxyAssociations set � the caller is expected to remove proxyUuid from the appropriate subscriber set (or clear the set entirely) if needed.
| proxyUuid | UUID of the proxy whose association count should be decremented. |
|
protectedvirtual |
Collects nearby simulation objects around a search center.
Finds all simulated objects of appropriate types within the search radius of the specified position.
| searchCenter | The center point for the search |
| results | Vector to be filled with pointers to nearby objects |
|
protected |
Destroys and re-creates a proxy when its VortexActive state has changed.
Snapshots pre-destroy subscribers and restores their associations + associationCount after re-creation, so the new proxy is not double-counted and can still be freed when it eventually falls out of range.
| record | Proxy record to inspect. Invalidated on true-return. |
|
protected |
Creates a cylinder VxPart standing in for a wheel that has no corresponding part in the loaded Vortex mechanism.
Cylinder is oriented so its axis lies along part-local Y (wheel spin axis). Added directly to the universe and to record.fakeWheelParts; destroyProxy() owns cleanup.
| record | Proxy record that will own the new part. |
| partType | Articulated part type (for rest-position lookup). |
| name | Vortex part name. |
| radius | Wheel radius (m). |
| width | Wheel width (m). |
|
protected |
Loads a Vortex mechanism file and instantiates its assemblies into record.vxObject.
Tags each part's collision geometries as sensor (when record.vortexActive) or proxy. On success, ownership of record.vxObject transfers to the caller, which must add it to vortexApplication before returning.
| record | Proxy record to populate. |
| filename | Mechanism file path (resolved via loadManager). |
| transform | Root transform applied to each assembly. |
|
protectedvirtual |
Handles a collision between two Vortex parts.
Processes a collision detected by the Vortex physics engine and generates an appropriate VR-Forces collision event.
| collision | Non-null contact containing both parts involved in the collision |
|
protectedvirtual |
Checks if a vehicle is player controlled.
Determines if a given vehicle is currently being controlled by a player as a driver.
| vehicle | The vehicle to check |
|
protectedvirtual |
Converts from VR-Forces coordinates to Vortex coordinates.
Translates position vectors between coordinate systems based on whether the terrain is geocentric or local/flat.
| vec | Position vector in VR-Forces coordinates |
|
protected |
Number of nearby non-Vortex vehicles to consider for each Vortex vehicle.
|
protected |
Maximum distance in meters to search for nearby vehicles.
|
protected |
Default mass in kg for non-Vortex vehicles.
This value is used when creating collision proxies in the Vortex universe. It's deliberately set high to make the vehicles behave as heavy objects.
|
protected |
Maximum velocity at which proxies are updated kinematically (Such that they have a velocity) (m/s)
|
protected |
Manager for loading and caching Vortex mechanisms for proxy vehicle part instantiation.
|
protected |
Last-emitted collision-event timestamp per (proxy, vortex) UUID pair.
Rate-limits collision events to at most one per pair per second. Keys are always ordered (proxy first) so a pair produces a single entry regardless of detection order.
|
protected |
Flag indicating if the terrain uses geocentric coordinates.
|
protected |
Coordinate converter for geocentric/local transformations.
|
protected |
Set of UUIDs for all Vortex vehicles currently being tracked.
|
protected |
Primary registry mapping each VRF UUID to its proxy state.
Single source of truth for all active proxies in the Vortex universe.
|
protected |
Monotonically increasing counter incremented once per update() pass.
Used to update each shared proxy's transform exactly once per pass, regardless of how many Vortex vehicles reference it.
|
protected |
Reverse lookup from Vortex part pointer to VRF UUID.
Used during collision handling to identify which VRF object was hit.
|
protected |
Per-Vortex-vehicle set of currently associated proxy UUIDs.
Enables reference-counted proxy ownership: a proxy is destroyed only when all Vortex vehicles that reference it have disassociated from it.
|
protected |
Pointer to the Vortex physical world.
|
protected |
List of entity types that Vortex vehicles will collide with.
|
protected |
Predicate for filtering objects by their types.
|
protected |
Mutex for thread-safe access to data structures.