VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVortexPagedTerrainInterface Class Reference

Detailed Description

This class facilitates the communication between VR-Forces terrain system and the Vortex physics engine. It handles the conversion of terrain data, processes terrain generation requests, creates collision geometries, and manages dynamic terrain modifications. The class implements the VxPagedTerrainInterface to interact with the Vortex paged terrain system.

#include <vortexPagedTerrain.h>

Inheritance diagram for makVre::DtVortexPagedTerrainInterface:
[legend]

Classes

struct  VortexCellToInsert
 
struct  VortexCellToModify
 
struct  VortexNewTerrainRequest
 

Public Types

using NewTerrainRequestQueue = std::list<VortexNewTerrainRequest>
 

Public Member Functions

 DtVortexPagedTerrainInterface ()
 
virtual ~DtVortexPagedTerrainInterface () override
 
virtual void step (VxTerrain::VxPagedTerrainProducer *producer) override
 
virtual void produce (const std::vector< VxTerrain::VxTerrainRequest > &request, VxTerrain::VxPagedTerrainProducer *producer) override
 
virtual void update (const std::vector< VxTerrain::VxTerrainRequest > &request, VxTerrain::VxPagedTerrainProducer *producer) override
 
virtual std::shared_ptr< DtSurfaceToVxMaterialMappermaterialMapper () const
 
virtual void setMaterialMapper (std::shared_ptr< DtSurfaceToVxMaterialMapper > val)
 
virtual void queueNewTerrainRequests (const std::vector< VxTerrain::VxTerrainRequest > &requests)
 
virtual void queueTerrainRegenerationRequests ()
 
virtual double terrainHeightToleranceCheck () const
 
virtual void setTerrainHeightToleranceCheck (double val)
 

Protected Member Functions

virtual int generateSourceID (double minXCoordinate, double minYCoordinate)
 
virtual void processQueuedCollisionGeometries ()
 
virtual bool processTerrainRegenerationRequest (const std::pair< int, Vx::VxTriangleMeshBVTree * > &regenerationData)
 
virtual void processNewTerrainRequest (VxTerrain::VxTerrainRequest req, Vx::VxTriangleMeshBVTree *triMesh=nullptr)
 
virtual Vx::VxCollisionGeometry * createVortexCollisionGeometry (DtVortexTriangleOutputInterface &outputInterface, Vx::VxTriangleMeshBVTree *triMeshParam=nullptr)
 
virtual void buildTriangleMesh (const std::shared_ptr< DtVortexTriangleOutputInterface > outputInterface, Vx::VxTriangleMeshBVTree *triMesh)
 
virtual Vx::VxTriangleMeshBVTree * createVortexTriangleMesh (DtVortexTriangleOutputInterface &outputInterface)
 
virtual DtTerrainProcessPolygonsBox getTerrainProcessBox (const Vx::VxBoundingBox &bb)
 
virtual bool modifyTriangleMesh (Vx::VxTriangleMeshBVTree *currentMesh, const Vx::VxTriangleMeshBVTree *newMesh, const int upAxis, double tolerance=0.1)
 
virtual bool areTriangleMeshesDifferent (Vx::VxTriangleMeshBVTree *meshOne, Vx::VxTriangleMeshBVTree *meshTwo, double tolerance=0.1)
 
void fixTriangleMeshOrphanEdges (Vx::VxTriangleMeshBVTree *triMesh)
 

Protected Attributes

DtVortexPhysicalWorldmyPhysicalWorld
 
DtTerrainImplementation * myTerrainImplementation
 
DtVortexPagedTerrainProducermyTerrainProducer
 
std::weak_ptr< DtVortexDynamicTerrainHandlermyDynamicTerrainHandler
 
std::shared_ptr< DtSurfaceToVxMaterialMappermyMaterialMapper
 
std::unique_ptr< tbb::task_arena > myDynamicTerrainTaskArena
 
double myTerrainHeightToleranceCheck
 
double myDynamicTerrainRegenerationRetryInterval
 
int myDynamicTerrainRegenerationFailureCount
 
unsigned int myInitialTriangleVectorSize
 
bool myWaitForFutureRequests
 
NewTerrainRequestQueue myNewTerrainRequests
 
tbb::concurrent_vector< VortexCellToInsertmyCellsToInsert
 
tbb::concurrent_vector< VortexCellToModifymyCellsToModify
 
tbb::spin_mutex myCellsToInsertSwapMutex
 
tbb::spin_mutex myCellsToModifySwapMutex
 

Member Typedef Documentation

◆ NewTerrainRequestQueue

Constructor & Destructor Documentation

◆ DtVortexPagedTerrainInterface()

makVre::DtVortexPagedTerrainInterface::DtVortexPagedTerrainInterface ( )

Default constructor.

Initializes the paged terrain interface with default settings, sets up the material mapper, and retrieves configuration parameters from the Vortex physical world. Also initializes the terrain implementation and coordinate conversion system.

◆ ~DtVortexPagedTerrainInterface()

virtual makVre::DtVortexPagedTerrainInterface::~DtVortexPagedTerrainInterface ( )
overridevirtual

Destructor.

Performs cleanup of resources owned by this interface.

Member Function Documentation

◆ step()

virtual void makVre::DtVortexPagedTerrainInterface::step ( VxTerrain::VxPagedTerrainProducer * producer)
overridevirtual

Called every frame from within the vortex application while running.

Reorganizes requests based on priority, processes queued collision geometries, and manages the terrain regeneration queue. Also handles the completion of asynchronous terrain generation tasks.

Parameters
producerThe current terrain producer

◆ produce()

virtual void makVre::DtVortexPagedTerrainInterface::produce ( const std::vector< VxTerrain::VxTerrainRequest > & request,
VxTerrain::VxPagedTerrainProducer * producer )
overridevirtual

Called when new requests for terrain arise.

Processes and queues new terrain generation requests by calling queueNewTerrainRequests. These requests are then processed asynchronously by the terrain system.

Parameters
requestA list of requests to queue up for terrain generation
producerThe current terrain producer

◆ update()

virtual void makVre::DtVortexPagedTerrainInterface::update ( const std::vector< VxTerrain::VxTerrainRequest > & request,
VxTerrain::VxPagedTerrainProducer * producer )
overridevirtual

Called when pending requests for terrain get higher priority.

Updates the priority of existing terrain requests to ensure that urgent requests are processed first during the next update cycle.

Parameters
requestA list of requests to update priority for
producerThe current terrain producer

◆ materialMapper()

virtual std::shared_ptr< DtSurfaceToVxMaterialMapper > makVre::DtVortexPagedTerrainInterface::materialMapper ( ) const
virtual

Gets the material mapper.

Returns the current material mapper used for translating terrain surface types to Vortex material properties.

Returns
The current material mapper

◆ setMaterialMapper()

virtual void makVre::DtVortexPagedTerrainInterface::setMaterialMapper ( std::shared_ptr< DtSurfaceToVxMaterialMapper > val)
virtual

Sets the material mapper.

Updates the material mapper used for translating terrain surface types to Vortex material properties.

Parameters
valThe new material mapper to use

◆ queueNewTerrainRequests()

virtual void makVre::DtVortexPagedTerrainInterface::queueNewTerrainRequests ( const std::vector< VxTerrain::VxTerrainRequest > & requests)
virtual

Sort the incoming requests to have the highest priority ones first.

Prioritizes terrain requests based on their priority level and submits them as asynchronous jobs to the thread pool. This ensures that more important terrain cells are generated first.

Parameters
requestsList of requests to queue up

◆ queueTerrainRegenerationRequests()

virtual void makVre::DtVortexPagedTerrainInterface::queueTerrainRegenerationRequests ( )
virtual

Queues up and manages any new dynamic terrain or terrain regeneration requests.

Processes terrain modification requests from the dynamic terrain handler. This includes creating new triangle meshes for modified terrain areas and queuing them for integration in the next update cycle.

◆ terrainHeightToleranceCheck()

virtual double makVre::DtVortexPagedTerrainInterface::terrainHeightToleranceCheck ( ) const
virtual

Gets the maximum terrain height tolerance check value.

Returns the tolerance value used to determine how far above/below the terrain to check for collisions.

Returns
The current terrain height tolerance check value in meters

◆ setTerrainHeightToleranceCheck()

virtual void makVre::DtVortexPagedTerrainInterface::setTerrainHeightToleranceCheck ( double val)
virtual

Sets the maximum terrain height tolerance check value.

Updates the tolerance value used to determine how far above/below the terrain to check for collisions. This value can be configured through vortexConfig.lua.

Parameters
valThe new terrain height tolerance check value in meters

◆ generateSourceID()

virtual int makVre::DtVortexPagedTerrainInterface::generateSourceID ( double minXCoordinate,
double minYCoordinate )
protectedvirtual

Generates a source ID given the minimum x and y coordinate of a request.

Creates a unique identifier for a terrain cell based on its position. The ID is calculated using the cell's row and column in the terrain grid, and is guaranteed to be positive and within a valid range.

Parameters
minXCoordinateThe minimum X coordinate of the request
minYCoordinateThe minimum Y coordinate of the request
Returns
A unique source ID for the terrain cell

◆ processQueuedCollisionGeometries()

virtual void makVre::DtVortexPagedTerrainInterface::processQueuedCollisionGeometries ( )
protectedvirtual

Helper function for processing queued collision geometries.

Processes collision geometries contained in myCellsToInsert and myCellsToModify. This includes creating new collision geometries, integrating them into the Vortex system, and handling dynamic terrain modifications.

◆ processTerrainRegenerationRequest()

virtual bool makVre::DtVortexPagedTerrainInterface::processTerrainRegenerationRequest ( const std::pair< int, Vx::VxTriangleMeshBVTree * > & regenerationData)
protectedvirtual

Processes all dynamic terrain events that have been queued up for regeneration.

Handles the regeneration of terrain cells that have been modified by dynamic terrain events. This includes modifying existing triangle meshes, updating collision geometries, and managing affected simulation objects.

Parameters
regenerationDataPair containing the source ID and new triangle mesh
Returns
True if the regeneration was successful, false otherwise

◆ processNewTerrainRequest()

virtual void makVre::DtVortexPagedTerrainInterface::processNewTerrainRequest ( VxTerrain::VxTerrainRequest req,
Vx::VxTriangleMeshBVTree * triMesh = nullptr )
protectedvirtual

Processes a terrain request and builds a collision geometry for Vortex.

Creates a new terrain cell from a terrain request, extracting triangles from the terrain implementation and building a collision geometry for use in Vortex. The resulting cell is then queued for insertion in the next update cycle.

Parameters
reqThe VxTerrainRequest that has been queued for generation
triMeshOptional pre-created triangle mesh to use

◆ createVortexCollisionGeometry()

virtual Vx::VxCollisionGeometry * makVre::DtVortexPagedTerrainInterface::createVortexCollisionGeometry ( DtVortexTriangleOutputInterface & outputInterface,
Vx::VxTriangleMeshBVTree * triMeshParam = nullptr )
protectedvirtual

Creates a collision geometry based on the vertices and the surface.

Generates a Vortex collision geometry from a triangle output interface, either using a provided triangle mesh or creating a new one. The collision geometry is configured with appropriate material properties and settings.

Parameters
outputInterfaceThe information of the terrain cell that has been generated
triMeshParamOptional triangle mesh to use for the collision geometry
Returns
The created collision geometry

◆ buildTriangleMesh()

virtual void makVre::DtVortexPagedTerrainInterface::buildTriangleMesh ( const std::shared_ptr< DtVortexTriangleOutputInterface > outputInterface,
Vx::VxTriangleMeshBVTree * triMesh )
protectedvirtual

Fills out a triangle mesh based on all the triangles from the output interface.

Populates a Vortex triangle mesh with vertices, triangles, and material properties from a triangle output interface. Handles coordinate conversion between VR-Forces and Vortex coordinate systems.

Parameters
outputInterfaceThe information of the terrain cell that has been generated
triMeshThe triangle mesh to input all the triangles in

◆ createVortexTriangleMesh()

virtual Vx::VxTriangleMeshBVTree * makVre::DtVortexPagedTerrainInterface::createVortexTriangleMesh ( DtVortexTriangleOutputInterface & outputInterface)
protectedvirtual

Creates a triangle mesh based on the output interface.

Creates and initializes a new Vortex triangle mesh from a triangle output interface. The mesh is configured with appropriate settings and then populated with triangles by calling buildTriangleMesh.

Parameters
outputInterfaceThe information of the terrain cell that has been generated
Returns
A triangle mesh created based on the information

◆ getTerrainProcessBox()

virtual DtTerrainProcessPolygonsBox makVre::DtVortexPagedTerrainInterface::getTerrainProcessBox ( const Vx::VxBoundingBox & bb)
protectedvirtual

Gets the terrain process box in terms of geocentric/local terrain.

Converts a Vortex bounding box to a terrain process box that can be used with the terrain implementation to extract triangles. Handles the conversion between Vortex and VR-Forces coordinate systems.

Parameters
bbVortex request bounds
Returns
A terrain process box translated for use in getting triangles

◆ modifyTriangleMesh()

virtual bool makVre::DtVortexPagedTerrainInterface::modifyTriangleMesh ( Vx::VxTriangleMeshBVTree * currentMesh,
const Vx::VxTriangleMeshBVTree * newMesh,
const int upAxis,
double tolerance = 0.1 )
protectedvirtual

Modifies a triangle mesh with z values from a new mesh.

Updates the heights (z-values) of vertices in an existing triangle mesh based on a new mesh. Only applies changes if the difference exceeds the specified tolerance.

Parameters
currentMeshThe existing mesh to be modified with updated height values
newMeshThe new mesh to get the updated triangles
upAxisThe axis representing the up direction
toleranceThe tolerance for z-value differences
Returns
True if there were deformations, false otherwise

◆ areTriangleMeshesDifferent()

virtual bool makVre::DtVortexPagedTerrainInterface::areTriangleMeshesDifferent ( Vx::VxTriangleMeshBVTree * meshOne,
Vx::VxTriangleMeshBVTree * meshTwo,
double tolerance = 0.1 )
protectedvirtual

Compares each triangle from both meshes and checks if they are equal.

Determines if two triangle meshes are different by comparing their vertices. Vertices are considered equal if their positions differ by less than the specified tolerance.

Parameters
meshOneFirst triangle mesh to compare
meshTwoSecond triangle mesh to compare
toleranceThe tolerance for considering vertices equal
Returns
True if the meshes are different, false if they are the same

◆ fixTriangleMeshOrphanEdges()

void makVre::DtVortexPagedTerrainInterface::fixTriangleMeshOrphanEdges ( Vx::VxTriangleMeshBVTree * triMesh)
protected

Sets the orphan edges of the triangle mesh to not have an invalid angle between meshes.

Fixes orphan edges in a triangle mesh to ensure valid angles between connected triangles. This addresses an issue in the Vortex code that can cause incorrect edge handling.

Parameters
triMeshThe triangle mesh to fix orphan edges for

Member Data Documentation

◆ myPhysicalWorld

DtVortexPhysicalWorld* makVre::DtVortexPagedTerrainInterface::myPhysicalWorld
protected

Pointer to the physical world.

◆ myTerrainImplementation

DtTerrainImplementation* makVre::DtVortexPagedTerrainInterface::myTerrainImplementation
protected

Pointer to the terrain implementation.

◆ myTerrainProducer

DtVortexPagedTerrainProducer* makVre::DtVortexPagedTerrainInterface::myTerrainProducer
protected

Pointer to the terrain producer.

◆ myDynamicTerrainHandler

std::weak_ptr<DtVortexDynamicTerrainHandler> makVre::DtVortexPagedTerrainInterface::myDynamicTerrainHandler
protected

Pointer to the dynamic terrain handler.

◆ myMaterialMapper

std::shared_ptr<DtSurfaceToVxMaterialMapper> makVre::DtVortexPagedTerrainInterface::myMaterialMapper
protected

Material mapper for surface to Vortex material conversion.

◆ myDynamicTerrainTaskArena

std::unique_ptr<tbb::task_arena> makVre::DtVortexPagedTerrainInterface::myDynamicTerrainTaskArena
protected

Task arena for dynamic terrain processing.

◆ myTerrainHeightToleranceCheck

double makVre::DtVortexPagedTerrainInterface::myTerrainHeightToleranceCheck
protected

Height tolerance for terrain checks.

◆ myDynamicTerrainRegenerationRetryInterval

double makVre::DtVortexPagedTerrainInterface::myDynamicTerrainRegenerationRetryInterval
protected

Interval for retrying dynamic terrain regeneration.

◆ myDynamicTerrainRegenerationFailureCount

int makVre::DtVortexPagedTerrainInterface::myDynamicTerrainRegenerationFailureCount
protected

Maximum number of failures before giving up on regeneration.

◆ myInitialTriangleVectorSize

unsigned int makVre::DtVortexPagedTerrainInterface::myInitialTriangleVectorSize
protected

Initial size for triangle vectors.

◆ myWaitForFutureRequests

bool makVre::DtVortexPagedTerrainInterface::myWaitForFutureRequests
protected

Whether to wait for future requests to complete.

◆ myNewTerrainRequests

NewTerrainRequestQueue makVre::DtVortexPagedTerrainInterface::myNewTerrainRequests
protected

Queue of new terrain requests.

◆ myCellsToInsert

tbb::concurrent_vector<VortexCellToInsert> makVre::DtVortexPagedTerrainInterface::myCellsToInsert
protected

Cells to insert on the next update.

◆ myCellsToModify

tbb::concurrent_vector<VortexCellToModify> makVre::DtVortexPagedTerrainInterface::myCellsToModify
protected

Cells to modify on the next step.

◆ myCellsToInsertSwapMutex

tbb::spin_mutex makVre::DtVortexPagedTerrainInterface::myCellsToInsertSwapMutex
protected

Protects swap operation on myCellsToInsert (push_back is thread-safe)

◆ myCellsToModifySwapMutex

tbb::spin_mutex makVre::DtVortexPagedTerrainInterface::myCellsToModifySwapMutex
protected

Protects swap operation on myCellsToModify (push_back is thread-safe)


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