VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtVortexCollisionProxyGenerator Class Reference

Detailed Description

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 > &currentAssociations, const std::vector< const DtSimObject * > &closestObjects)
 
void createOrUpdateProxies (std::set< DtUUID > &currentAssociations, 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
 

Constructor & Destructor Documentation

◆ DtVortexCollisionProxyGenerator() [1/3]

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.

Parameters
worldPointer to the Vortex physical world
cgfPointer to the CGF instance for callback registration

Referenced by DtVortexCollisionProxyGenerator(), and operator=().

◆ ~DtVortexCollisionProxyGenerator()

virtual makVre::DtVortexCollisionProxyGenerator::~DtVortexCollisionProxyGenerator ( )
virtual

Destructor.

Cleans up all proxy vehicles from the Vortex universe and clears data structures.

◆ DtVortexCollisionProxyGenerator() [2/3]

makVre::DtVortexCollisionProxyGenerator::DtVortexCollisionProxyGenerator ( )
delete

Default constructor, copy constructor, and copy assignment operator not allowed.

◆ DtVortexCollisionProxyGenerator() [3/3]

makVre::DtVortexCollisionProxyGenerator::DtVortexCollisionProxyGenerator ( const DtVortexCollisionProxyGenerator & )
delete

Member Function Documentation

◆ operator=()

DtVortexCollisionProxyGenerator & makVre::DtVortexCollisionProxyGenerator::operator= ( const DtVortexCollisionProxyGenerator & )
delete

◆ update()

virtual void makVre::DtVortexCollisionProxyGenerator::update ( )
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.

◆ addVortexVehicle()

virtual void makVre::DtVortexCollisionProxyGenerator::addVortexVehicle ( const DtUUID & uuid)
virtual

Adds a Vortex vehicle to the tracked vehicles list.

Registers a new Vortex-simulated vehicle by its UUID for collision handling.

Parameters
uuidThe UUID of the Vortex vehicle to track

◆ isVortexVehicle()

virtual bool makVre::DtVortexCollisionProxyGenerator::isVortexVehicle ( const DtUUID & uuid)
virtual

Checks if a UUID corresponds to a tracked Vortex vehicle.

Parameters
uuidThe UUID to check
Returns
True if the UUID corresponds to a tracked Vortex vehicle, false otherwise

◆ removeVortexVehicle()

virtual void makVre::DtVortexCollisionProxyGenerator::removeVortexVehicle ( const DtUUID & uuid)
virtual

Removes a Vortex vehicle from the tracked vehicles list.

Unregisters a Vortex-simulated vehicle and removes its associated proxy vehicles.

Parameters
uuidThe UUID of the Vortex vehicle to stop tracking

◆ findClosestSimObjects()

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.

Parameters
vortexVehicleUUIDUUID of the Vortex vehicle whose own UUID is excluded from results.
searchCenterCenter point in local coordinates to search around.
Returns
Vector of up to K closest const DtSimObject pointers, in arbitrary order.

◆ cleanupMissingVehicle()

void makVre::DtVortexCollisionProxyGenerator::cleanupMissingVehicle ( const DtUUID & uuid)

Cleans up any proxy vehicles associated with a missing Vortex vehicle.

Parameters
uuidThe UUID of the missing Vortex vehicle

◆ setTypesToCollideWith()

virtual void makVre::DtVortexCollisionProxyGenerator::setTypesToCollideWith ( std::vector< DtEntityType > entityTypes)
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.

Parameters
entityTypesVector of entity types to consider for collision detection

◆ setMaxNumProxyVehicles()

virtual void makVre::DtVortexCollisionProxyGenerator::setMaxNumProxyVehicles ( int numProxyVehicles)
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.

Parameters
numProxyVehiclesMaximum number of proxy vehicles to generate per Vortex vehicle

◆ setSearchRadius()

virtual void makVre::DtVortexCollisionProxyGenerator::setSearchRadius ( double searchRadius)
virtual

Sets the search radius for nearby vehicles.

Updates the maximum distance in meters to search for nearby vehicles for collision detection.

Parameters
searchRadiusMaximum distance in meters to search for nearby vehicles

◆ setDefaultProxyMass()

virtual void makVre::DtVortexCollisionProxyGenerator::setDefaultProxyMass ( double defaultMass)
virtual

Sets the default mass for proxy vehicles.

Updates the default mass in kilograms for proxy vehicles in the Vortex universe.

Parameters
defaultMassDefault mass in kilograms

◆ setMaxKinematicUpdateVelocity()

virtual void makVre::DtVortexCollisionProxyGenerator::setMaxKinematicUpdateVelocity ( double maxVel)
virtual

Sets the maximum kinematic update velocity.

Updates the velocity at which we consider a proxies motion in a single tick to be instantaneous

Parameters
maxVelMaximum velocity to be used for updates.

◆ rewindCallback()

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.

◆ renderImgui()

virtual void makVre::DtVortexCollisionProxyGenerator::renderImgui ( )
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.

◆ clearDataStructures()

virtual void makVre::DtVortexCollisionProxyGenerator::clearDataStructures ( )
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.

◆ createProxy()

void makVre::DtVortexCollisionProxyGenerator::createProxy ( const DtSimObject & obj)
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.

Parameters
objThe VR-Forces simulation object to create a proxy for

◆ createBoxProxy()

void makVre::DtVortexCollisionProxyGenerator::createBoxProxy ( ProxyRecord & record,
Vx::VxTransform & transform )
protected

Creates a box-shaped proxy VxPart for the given VRF object record and transform.

Parameters
recordThe proxy record to populate with the new VxPart
transformThe transform to apply to the new VxPart in the Vortex

◆ destroyProxy()

void makVre::DtVortexCollisionProxyGenerator::destroyProxy ( const DtUUID & vrfUuid)
protected

Removes a proxy from the Vortex universe and cleans all registry entries.

Parameters
vrfUuidUUID of the VRF object whose proxy should be destroyed

◆ updateProxyTransform()

void makVre::DtVortexCollisionProxyGenerator::updateProxyTransform ( const DtUUID & vrfUuid)
protected

Updates the position and heading of an existing proxy to match its VRF object.

Parameters
vrfUuidUUID of the VRF object whose proxy transform should be refreshed

◆ updateVortexProxy()

void makVre::DtVortexCollisionProxyGenerator::updateVortexProxy ( ProxyRecord & record,
Vx::VxTransform transform,
double vel,
double dt )
protected

Updates the Vortex proxy representation for a given proxy record.

Parameters
recordThe proxy record to update
transformThe world transform to apply to the proxy
velThe velocity derived from the change in position this step
dtThe timestep

◆ updateArtPart()

void makVre::DtVortexCollisionProxyGenerator::updateArtPart ( const makVrf::DtArticulatedPartStateRepository * partInfo,
ProxyRecord & record,
std::map< int, Vx::VxTransform > & knownTransforms,
double dt )
protected

Updates the transforms of articulated parts for a given proxy record.

Parameters
partInfoArticulated part state repository containing the current transforms of the parts
recordThe proxy record this part belongs to
knownTransformsMap of already-applied world transforms keyed by part type; seeded with chassis at key -1
dtTime step for the update
Note
Uses bodyPosition() (static attach-point chain) + translation() (dynamic displacement) for current chassis-local position.

◆ findTargetPartFromArtPart()

Vx::VxPart * makVre::DtVortexCollisionProxyGenerator::findTargetPartFromArtPart ( const makVrf::DtArticulatedPartStateRepository * partInfo,
ProxyRecord & record )
protected

Finds the VxPart corresponding to an articulated part type for a given proxy record.

Parameters
partInfoArticulated part state repository containing the current transforms of the parts
recordThe proxy record this part belongs to
Returns
Pointer to the corresponding VxPart, or nullptr if not found

◆ getArtPartTransform()

Vx::VxTransform makVre::DtVortexCollisionProxyGenerator::getArtPartTransform ( const makVrf::DtArticulatedPartStateRepository * partInfo)
protected

Computes the transform for an articulated part based on its state info.

Parameters
partInfoArticulated part state repository containing the current transforms of the parts
Returns
The computed VxTransform for the articulated part. Compound with the chassis world transform to get the part's world transform.

◆ updateClosestVehicleList()

virtual void makVre::DtVortexCollisionProxyGenerator::updateClosestVehicleList ( const DtUUID & uuid)
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.

Parameters
uuidThe UUID of the Vortex vehicle to update proxies for

◆ disassociateStaleProxies()

void makVre::DtVortexCollisionProxyGenerator::disassociateStaleProxies ( std::set< DtUUID > & currentAssociations,
const std::vector< const DtSimObject * > & closestObjects )
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.

Parameters
currentAssociationsMutable set of proxy UUIDs currently associated with the caller's Vortex vehicle.
closestObjectsK closest sim objects the caller wishes to keep associated.

◆ createOrUpdateProxies()

void makVre::DtVortexCollisionProxyGenerator::createOrUpdateProxies ( std::set< DtUUID > & currentAssociations,
const std::vector< const DtSimObject * > & closestObjects )
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.

Parameters
currentAssociationsMutable set of proxy UUIDs currently associated with the caller's Vortex vehicle.
closestObjectsK closest sim objects to associate or update.

◆ releaseProxyAssociation()

void makVre::DtVortexCollisionProxyGenerator::releaseProxyAssociation ( const DtUUID & proxyUuid)
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.

Parameters
proxyUuidUUID of the proxy whose association count should be decremented.

◆ collectNearbySimObjects()

virtual void makVre::DtVortexCollisionProxyGenerator::collectNearbySimObjects ( const DtVector & searchCenter,
std::vector< const DtSimObject * > & results )
protectedvirtual

Collects nearby simulation objects around a search center.

Finds all simulated objects of appropriate types within the search radius of the specified position.

Parameters
searchCenterThe center point for the search
resultsVector to be filled with pointers to nearby objects

◆ retagPartsIfNecessary()

bool makVre::DtVortexCollisionProxyGenerator::retagPartsIfNecessary ( const ProxyRecord & record)
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.

Parameters
recordProxy record to inspect. Invalidated on true-return.
Returns
True if retagged (record invalidated); false otherwise.

◆ createWheelProxy()

Vx::VxPart * makVre::DtVortexCollisionProxyGenerator::createWheelProxy ( ProxyRecord & record,
int partType,
std::string name,
double radius,
double width )
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.

Parameters
recordProxy record that will own the new part.
partTypeArticulated part type (for rest-position lookup).
nameVortex part name.
radiusWheel radius (m).
widthWheel width (m).
Returns
The new VxPart.

◆ instantiateMechanismParts()

bool makVre::DtVortexCollisionProxyGenerator::instantiateMechanismParts ( ProxyRecord & record,
const DtFilename & filename,
Vx::VxTransform & transform )
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.

Parameters
recordProxy record to populate.
filenameMechanism file path (resolved via loadManager).
transformRoot transform applied to each assembly.
Returns
True if at least one assembly instantiated.

◆ handleVortexCollision()

virtual void makVre::DtVortexCollisionProxyGenerator::handleVortexCollision ( Vx::VxDynamicsContact * collision)
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.

Parameters
collisionNon-null contact containing both parts involved in the collision

◆ isPlayerControlled()

virtual bool makVre::DtVortexCollisionProxyGenerator::isPlayerControlled ( const DtSimObject & vehicle) const
protectedvirtual

Checks if a vehicle is player controlled.

Determines if a given vehicle is currently being controlled by a player as a driver.

Parameters
vehicleThe vehicle to check
Returns
True if the vehicle is player controlled, false otherwise

◆ toVxCoords()

virtual VxMath::Vector3 makVre::DtVortexCollisionProxyGenerator::toVxCoords ( const DtVector & vec)
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.

Parameters
vecPosition vector in VR-Forces coordinates
Returns
Equivalent position vector in Vortex coordinates

Member Data Documentation

◆ myNumProxyVehicles

int makVre::DtVortexCollisionProxyGenerator::myNumProxyVehicles
protected

Number of nearby non-Vortex vehicles to consider for each Vortex vehicle.

◆ mySearchRadius

double makVre::DtVortexCollisionProxyGenerator::mySearchRadius
protected

Maximum distance in meters to search for nearby vehicles.

◆ myDefaultVrfVehicleMass

double makVre::DtVortexCollisionProxyGenerator::myDefaultVrfVehicleMass
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.

◆ myMaxKinematicUpdateVelocity

double makVre::DtVortexCollisionProxyGenerator::myMaxKinematicUpdateVelocity
protected

Maximum velocity at which proxies are updated kinematically (Such that they have a velocity) (m/s)

◆ loadManager

DtVortexObjectLoadManager makVre::DtVortexCollisionProxyGenerator::loadManager
protected

Manager for loading and caching Vortex mechanisms for proxy vehicle part instantiation.

◆ myLastCollisionInteractionTimes

std::map<std::pair<DtUUID, DtUUID>, double> makVre::DtVortexCollisionProxyGenerator::myLastCollisionInteractionTimes
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.

◆ myTerrainIsGeocentric

bool makVre::DtVortexCollisionProxyGenerator::myTerrainIsGeocentric
protected

Flag indicating if the terrain uses geocentric coordinates.

◆ myCoordConverter

DtCoordinateConvert* makVre::DtVortexCollisionProxyGenerator::myCoordConverter
protected

Coordinate converter for geocentric/local transformations.

◆ myVortexVehicles

std::set<DtUUID> makVre::DtVortexCollisionProxyGenerator::myVortexVehicles
protected

Set of UUIDs for all Vortex vehicles currently being tracked.

◆ myProxyRegistry

std::map<DtUUID, ProxyRecord> makVre::DtVortexCollisionProxyGenerator::myProxyRegistry
protected

Primary registry mapping each VRF UUID to its proxy state.

Single source of truth for all active proxies in the Vortex universe.

◆ myUpdateGeneration

unsigned long long makVre::DtVortexCollisionProxyGenerator::myUpdateGeneration = 0
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.

◆ myPartIndex

std::unordered_map<Vx::VxPart*, DtUUID> makVre::DtVortexCollisionProxyGenerator::myPartIndex
protected

Reverse lookup from Vortex part pointer to VRF UUID.

Used during collision handling to identify which VRF object was hit.

◆ myVortexToProxyAssociations

std::map<DtUUID, std::set<DtUUID> > makVre::DtVortexCollisionProxyGenerator::myVortexToProxyAssociations
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.

◆ myVortexPhysicalWorld

DtVortexPhysicalWorld* makVre::DtVortexCollisionProxyGenerator::myVortexPhysicalWorld
protected

Pointer to the Vortex physical world.

◆ myObjectTypesToCollideWith

std::vector<DtEntityType> makVre::DtVortexCollisionProxyGenerator::myObjectTypesToCollideWith
protected

List of entity types that Vortex vehicles will collide with.

◆ myCollideableObjectTypesPredicate

DtCompositePredicate makVre::DtVortexCollisionProxyGenerator::myCollideableObjectTypesPredicate
protected

Predicate for filtering objects by their types.

◆ myMutex

tbb::spin_mutex makVre::DtVortexCollisionProxyGenerator::myMutex
protected

Mutex for thread-safe access to data structures.


The documentation for this class was generated from the following file: