|
VR-Engage
2.2
|
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>
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< DtSurfaceToVxMaterialMapper > | materialMapper () 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 * > ®enerationData) |
| 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 | |
| DtVortexPhysicalWorld * | myPhysicalWorld |
| DtTerrainImplementation * | myTerrainImplementation |
| DtVortexPagedTerrainProducer * | myTerrainProducer |
| std::weak_ptr< DtVortexDynamicTerrainHandler > | myDynamicTerrainHandler |
| std::shared_ptr< DtSurfaceToVxMaterialMapper > | myMaterialMapper |
| std::unique_ptr< tbb::task_arena > | myDynamicTerrainTaskArena |
| double | myTerrainHeightToleranceCheck |
| double | myDynamicTerrainRegenerationRetryInterval |
| int | myDynamicTerrainRegenerationFailureCount |
| unsigned int | myInitialTriangleVectorSize |
| bool | myWaitForFutureRequests |
| NewTerrainRequestQueue | myNewTerrainRequests |
| tbb::concurrent_vector< VortexCellToInsert > | myCellsToInsert |
| tbb::concurrent_vector< VortexCellToModify > | myCellsToModify |
| tbb::spin_mutex | myCellsToInsertSwapMutex |
| tbb::spin_mutex | myCellsToModifySwapMutex |
| using makVre::DtVortexPagedTerrainInterface::NewTerrainRequestQueue = std::list<VortexNewTerrainRequest> |
| 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.
|
overridevirtual |
Destructor.
Performs cleanup of resources owned by this interface.
|
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.
| producer | The current terrain 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.
| request | A list of requests to queue up for terrain generation |
| producer | The current terrain 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.
| request | A list of requests to update priority for |
| producer | The current terrain producer |
|
virtual |
Gets the material mapper.
Returns the current material mapper used for translating terrain surface types to Vortex material properties.
|
virtual |
Sets the material mapper.
Updates the material mapper used for translating terrain surface types to Vortex material properties.
| val | The new material mapper to use |
|
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.
| requests | List of requests to queue up |
|
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.
|
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.
|
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.
| val | The new terrain height tolerance check value in meters |
|
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.
| minXCoordinate | The minimum X coordinate of the request |
| minYCoordinate | The minimum Y coordinate of the request |
|
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.
|
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.
| regenerationData | Pair containing the source ID and new triangle mesh |
|
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.
| req | The VxTerrainRequest that has been queued for generation |
| triMesh | Optional pre-created triangle mesh to use |
|
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.
| outputInterface | The information of the terrain cell that has been generated |
| triMeshParam | Optional triangle mesh to use for the collision geometry |
|
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.
| outputInterface | The information of the terrain cell that has been generated |
| triMesh | The triangle mesh to input all the triangles in |
|
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.
| outputInterface | The information of the terrain cell that has been generated |
|
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.
| bb | Vortex request bounds |
|
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.
| currentMesh | The existing mesh to be modified with updated height values |
| newMesh | The new mesh to get the updated triangles |
| upAxis | The axis representing the up direction |
| tolerance | The tolerance for z-value differences |
|
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.
| meshOne | First triangle mesh to compare |
| meshTwo | Second triangle mesh to compare |
| tolerance | The tolerance for considering vertices equal |
|
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.
| triMesh | The triangle mesh to fix orphan edges for |
|
protected |
Pointer to the physical world.
|
protected |
Pointer to the terrain implementation.
|
protected |
Pointer to the terrain producer.
|
protected |
Pointer to the dynamic terrain handler.
|
protected |
Material mapper for surface to Vortex material conversion.
|
protected |
Task arena for dynamic terrain processing.
|
protected |
Height tolerance for terrain checks.
|
protected |
Interval for retrying dynamic terrain regeneration.
|
protected |
Maximum number of failures before giving up on regeneration.
|
protected |
Initial size for triangle vectors.
|
protected |
Whether to wait for future requests to complete.
|
protected |
Queue of new terrain requests.
|
protected |
Cells to insert on the next update.
|
protected |
Cells to modify on the next step.
|
protected |
Protects swap operation on myCellsToInsert (push_back is thread-safe)
|
protected |
Protects swap operation on myCellsToModify (push_back is thread-safe)