VR-Engage  2.2
Loading...
Searching...
No Matches
vreRtdTerrainQueryHighFidelity.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreRtdTerrainQueryHighFidelity.h
7//! \ingroup vreVrfRtd
8//! \brief High-fidelity terrain query implementation for VREngage
9//!
10//! This file defines the DtVreRtdTerrainQueryHighFidelity class, which provides
11//! high-fidelity terrain and object intersection queries for the VREngage
12//! Real-Time Dynamics system, supporting ground contact and collision detection.
13
14#pragma once
15
18#include <RTD/TraitGroundContact.h>
19
20namespace vreRtd
21{
22//! \brief High-fidelity terrain query implementation for VREngage
23//!
24//! This class provides high-fidelity terrain and object intersection queries
25//! for the VREngage Real-Time Dynamics system. It detects collisions with terrain
26//! and simulation objects, and provides detailed information about hits including
27//! position, normal vectors, velocity, and surface properties like friction.
28//! This is used primarily for ground contact detection in flight models.
29class RTD_VRF_BACKEND_PLUGIN_EXPORT DtVreRtdTerrainQueryHighFidelity : public RTD::TerrainQueryCallback,
31{
32public:
33 //! \brief Macro for common RTD type definitions
35
36 //! \brief Constructor
37 //! \param pw Pointer to the physical world instance to query against
38 //! \param blocking Whether terrain queries should block until completed
39 //!
40 //! Initializes a new high-fidelity terrain query handler with the specified
41 //! physical world and blocking behavior.
42 DtVreRtdTerrainQueryHighFidelity(DtPhysicalWorld* pw, bool blocking);
43
44 //! \brief Destructor
45 //!
46 //! Cleans up resources used by the terrain query handler.
48 //! \brief Performs a terrain query between two points
49 //! \param context The query context (ground contact, sensor, etc.)
50 //! \param contextData Additional context-specific data
51 //! \param userData User-provided terrain query data
52 //! \param start The start point of the query in world coordinates
53 //! \param end The end point of the query in world coordinates
54 //! \param hitXYZ Output parameter for the hit position
55 //! \param hitNormal Output parameter for the surface normal at the hit position
56 //! \param hitVelocity Output parameter for the velocity of the hit object (if moving)
57 //! \param frictionFactor Output parameter for the surface friction factor
58 //! \param isLiquid Output parameter indicating whether the hit surface is liquid
59 //! \param entity Output parameter for the entity that was hit (if any)
60 //! \return True if an intersection was found, false otherwise
61 //!
62 //! Performs a high-fidelity terrain query between the specified start and end points,
63 //! checking for intersections with both terrain and simulation objects. If an
64 //! intersection is found, the output parameters are populated with the hit details.
65 virtual bool query(QueryContext context, const void* contextData, const RTD::TerrainQueryUserData* userData,
66 const smVec3d& start, const smVec3d& end, smVec3d& hitXYZ, smVec3d& hitNormal, smVec3d& hitVelocity,
67 smReal& frictionFactor, bool& isLiquid, const RTD::EntityBase*& entity) override;
68
69protected:
70 //! \brief Updates and checks the position cache for queries
71 //! \param isectRecord Intersection record to populate
72 //! \param vehicleUuid UUID of the vehicle performing the query
73 //! \param contextData Additional context-specific data
74 //! \param coordSys Coordinate system for the query
75 //! \param startPoint Start point of the query in world coordinates
76 //! \param endPoint End point of the query in world coordinates
77 //! \return True if the cache was updated, false otherwise
78 //!
79 //! Updates the internal position cache and checks if it contains valid data
80 //! for the current query, which can be used to optimize repeated queries in similar locations.
81 bool updateAndCheckPositionCache(DtVrfChordIntersectionRecord& isectRecord, DtUUID& vehicleUuid,
82 const void* contextData, Coordinate_System* coordSys, DtPoint startPoint, DtPoint endPoint);
83
84 //! \brief Performs a terrain-only intersection test
85 //! \param isectRecord Intersection record to populate
86 //! \param startPoint Start point of the query in world coordinates
87 //! \param endPoint End point of the query in world coordinates
88 //! \return True if a terrain intersection was found, false otherwise
89 //!
90 //! Checks for intersections with the terrain database between the specified points.
91 bool terrainIntersect(DtVrfChordIntersectionRecord& isectRecord, DtPoint startPoint, DtPoint endPoint);
92
93 //! \brief Performs a simulation object intersection test
94 //! \param isectRecord Intersection record to populate
95 //! \param vehicleUuid UUID of the vehicle performing the query
96 //! \param contextData Additional context-specific data
97 //! \param startPoint Start point of the query in world coordinates
98 //! \param endPoint End point of the query in world coordinates
99 //! \return True if a simulation object intersection was found, false otherwise
100 //!
101 //! Checks for intersections with simulation objects between the specified points.
102 bool simObjectIntersect(DtVrfChordIntersectionRecord& isectRecord, DtUUID& vehicleUuid, const void* contextData,
103 DtPoint startPoint, DtPoint endPoint);
104
105 //! \brief Calculates hit details from an intersection record
106 //! \param isectRecord Intersection record containing raw intersection data
107 //! \param coordSys Coordinate system for the query
108 //! \param hitXYZ Output parameter for the hit position
109 //! \param hitNormal Output parameter for the surface normal at the hit position
110 //! \param hitVelocity Output parameter for the velocity of the hit object
111 //! \return True if hit details were successfully calculated, false otherwise
112 //!
113 //! Processes an intersection record to extract detailed hit information.
114 bool calculateHit(DtVrfChordIntersectionRecord& isectRecord, Coordinate_System* coordSys, smVec3d& hitXYZ,
115 smVec3d& hitNormal, smVec3d& hitVelocity);
116
117 //! \brief Handles the case where no terrain database is available
118 //! \param isectRecord Intersection record to populate
119 //! \param coordSys Coordinate system for the query
120 //! \param startLocal Start point of the query in local coordinates
121 //! \param endLocal End point of the query in local coordinates
122 //! \param hitXYZ Output parameter for the hit position
123 //! \param hitNormal Output parameter for the surface normal at the hit position
124 //! \param hitVelocity Output parameter for the velocity of the hit object
125 //! \return True if a fallback intersection was calculated, false otherwise
126 //!
127 //! Provides a fallback intersection calculation when no terrain database is available,
128 //! typically returning a flat ground plane intersection if appropriate.
129 bool noTerrainDBIntersect(DtVrfChordIntersectionRecord& isectRecord, Coordinate_System* coordSys,
130 DtVector startLocal, DtVector endLocal, smVec3d& hitXYZ, smVec3d& hitNormal, smVec3d& hitVelocity);
131
132 //! \brief Flag indicating whether terrain queries are blocking
133 //!
134 //! When true, terrain queries will block until completed. When false,
135 //! they will return immediately, potentially with cached or approximate results.
137};
138} // namespace vreRtd
virtual bool query(QueryContext context, const void *contextData, const RTD::TerrainQueryUserData *userData, const smVec3d &start, const smVec3d &end, smVec3d &hitXYZ, smVec3d &hitNormal, smVec3d &hitVelocity, smReal &frictionFactor, bool &isLiquid, const RTD::EntityBase *&entity) override
Performs a terrain query between two points.
bool noTerrainDBIntersect(DtVrfChordIntersectionRecord &isectRecord, Coordinate_System *coordSys, DtVector startLocal, DtVector endLocal, smVec3d &hitXYZ, smVec3d &hitNormal, smVec3d &hitVelocity)
Handles the case where no terrain database is available.
bool calculateHit(DtVrfChordIntersectionRecord &isectRecord, Coordinate_System *coordSys, smVec3d &hitXYZ, smVec3d &hitNormal, smVec3d &hitVelocity)
Calculates hit details from an intersection record.
bool myIsBlocking
Flag indicating whether terrain queries are blocking.
Definition vreRtdTerrainQueryHighFidelity.h:136
virtual ~DtVreRtdTerrainQueryHighFidelity() override
Destructor.
bool terrainIntersect(DtVrfChordIntersectionRecord &isectRecord, DtPoint startPoint, DtPoint endPoint)
Performs a terrain-only intersection test.
DtVreRtdTerrainQueryHighFidelity(DtPhysicalWorld *pw, bool blocking)
Constructor.
bool simObjectIntersect(DtVrfChordIntersectionRecord &isectRecord, DtUUID &vehicleUuid, const void *contextData, DtPoint startPoint, DtPoint endPoint)
Performs a simulation object intersection test.
bool updateAndCheckPositionCache(DtVrfChordIntersectionRecord &isectRecord, DtUUID &vehicleUuid, const void *contextData, Coordinate_System *coordSys, DtPoint startPoint, DtPoint endPoint)
Updates and checks the position cache for queries.
RTD_BASE_COMMON(vreRtd, DtVreRtdTerrainQueryHighFidelity)
Macro for common RTD type definitions.
DtVreRtdTraitTerrainQuery()
Constructor.
Definition vreRtdTraitTerrainQuery.h:34
Definition vreRtdConfigFileReader.h:18
Common definitions for the RTD backend library.
Terrain query trait for VREngage RTD components.