AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
RaytraceSystems.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
20
22
23#include <agxWire/Wire.h>
24
26
27#include <agxTerrain/Terrain.h>
29
30#include <memory>
31#include <vector>
32
33namespace agxSensor
34{
35 struct RtVec3fVector;
36
43 {
44 public:
46
47 virtual ~RtShapeCollisionShapeSystem() = default;
48
49 virtual bool onAdd( agx::Referenced& instance ) override;
50 virtual bool onRemove( agx::Referenced& instance ) override;
51 virtual void synchronize( const SystemNode::CallbackData& data ) override;
52 virtual void cleanup() override;
53
55
56 private:
57 struct RtShapeInstanceData
58 {
59 bool isValid() const
60 {
61 return shape != nullptr;
62 }
63
64 RtShapeInstance instance = { nullptr, nullptr, nullptr };
65 const agxCollide::Shape* shape = nullptr;
66 };
67
68 private:
69 using RtShapeInstanceDataVector = std::vector<RtShapeInstanceData>;
70
71 private:
72 bool contains( const agxCollide::Shape* shape ) const;
73
75
76 private:
77 RtShapeInstanceDataVector m_rtShapeInstances;
78 };
79
86 {
87 public:
89
90 virtual ~RtShapeLinkedStructureSystem() = default;
91
92 virtual bool onAdd( agx::Referenced& instance ) override;
93 virtual bool onRemove( agx::Referenced& instance ) override;
94 virtual void synchronize( const CallbackData& data ) override;
95 virtual void cleanup() override;
96
98
99 private:
100 struct LsData
101 {
102 struct RtShapeInstanceScale
103 {
104 RtShapeInstance instance;
105 agx::Vec3 scale;
106 };
107
108 using RtShapeInstanceScaleVector = std::vector<RtShapeInstanceScale>;
109
110 const agxSDK::LinkedStructure* linkedStructure = nullptr;
111 RtEntityId entityId{ NullRtEntityId };
112 RtMaterialInstance material{};
113 RtShapeInstanceScaleVector shapeData;
114 };
115
116 using LsDataVector = std::vector<LsData>;
117 using ShapeScaleRtShapeTable = agx::HashTable<agx::Vec3, RtShapeRef>;
118 using ShapeTypeShapeScaleRtShapeCache = std::array<ShapeScaleRtShapeTable, agxCollide::Shape::NUM_TYPES>;
119
120 private:
121 bool contains( const agxSDK::LinkedStructure* linkedStructure ) const;
122 void initialize( agxCollide::Shape& shape,
123 LsData::RtShapeInstanceScale& shapeScale,
124 RtInstanceData* shapeInstanceData );
125
127
128 private:
129 LsDataVector m_lsData;
130 ShapeTypeShapeScaleRtShapeCache m_shapeCache;
131 };
132
139 {
140 public:
142
143 static const agxCollide::MeshData* getMeshData( const agxModel::DeformableObject& deformable );
144
145 public:
147
148 public:
149 virtual ~RtShapeDeformableObjectSystem() = default;
150 virtual bool onAdd( agx::Referenced& instance ) override;
151 virtual bool onRemove( agx::Referenced& instance ) override;
152 virtual void synchronize( const SystemNode::CallbackData& cd ) override;
153 virtual void execute( const SystemNode::CallbackData& cd ) override;
154 virtual void cleanup() override;
155
157
158 private:
159 struct DeformableData
160 {
161 RtShapeInstance instance = { nullptr, nullptr, nullptr };
162 const agxModel::DeformableObject* deformable = nullptr;
163
164 agx::AffineMatrix4x4 synchronizedTransform;
165 agx::Vec3Vector synchronizedVertices;
166 };
167
168 using DeformableDataVector = std::vector<DeformableData>;
169
171
172 private:
173 DeformableDataVector m_data;
174 };
175
180 {
181 public:
183
185
186 public:
187 virtual ~RtShapeWireSystem() = default;
188
189 virtual bool onAdd( agx::Referenced& instance ) override;
190 virtual bool onRemove( agx::Referenced& instance ) override;
191 virtual void synchronize( const CallbackData& data ) override;
192 virtual void cleanup() override;
193
195
196 private:
197 struct WireSegmentData
198 {
199 RtShapeInstance halfSphere;
200 RtShapeInstance cylinder;
201 };
202 using WireSegmentDataBuffer = std::vector<WireSegmentData>;
203
204 struct WireData
205 {
206 const agxWire::Wire* wire = nullptr;
207 WireSegmentDataBuffer segmentDataBuffer;
208 RtMaterialInstance material{};
209 RtEntityId entityId{ NullRtEntityId };
210 size_t numSegments = 0;
211 };
212
213 using WireDataVector = std::vector<WireData>;
214
216
217 private:
218 bool contains( const agxWire::Wire* wire ) const;
219
220 private:
221 WireDataVector m_wireData;
222 RtShapeRef m_halfSphereMesh;
223 RtShapeRef m_cylinderMesh;
224 };
225
230 {
231 public:
233
234 virtual ~RtShapeTerrainSystemBase() = default;
235
236 protected:
237 struct ParticleTerrainId
238 {
239 RtMaterialInstance material{};
240 RtEntityId entityId{ NullRtEntityId };
241 };
243
244 struct RtTerrainData
245 {
246 RtTerrainData();
247 bool isValid() const
248 {
249 return terrain != nullptr;
250 }
251
252 RtShapeInstance instance = { nullptr, nullptr, nullptr };
253 const agxTerrain::Terrain* terrain = nullptr;
254 std::shared_ptr<RtVec3fVector> vertices;
255 };
256
257 static RtTerrainData create(RtSceneRef scene, agxTerrain::Terrain* terrain, RtInstanceData* rtData = nullptr);
258 static void updateHeights(RtTerrainData& terrainData);
259
260 protected:
261 void updateParticles( const agx::ParticleSystem* particleSystem,
262 const SurfaceMaterialTable& materialTable );
263
265
266 private:
267 using ParticleShapeInstances = std::vector<RtShapeInstance>;
268
269 private:
270 RtShapeRef m_sphereShape;
271 ParticleShapeInstances m_particleInstances;
272 };
273
278 {
279 public:
281
282 virtual bool onAdd(agx::Referenced& instance) override;
283 virtual bool onRemove(agx::Referenced& instance) override;
284 virtual void synchronize( const CallbackData& data ) override;
285 virtual void cleanup() override;
286
288
290
291 private:
292 bool contains(const agxTerrain::Terrain* terrain) const;
293
294 private:
295 using RtTerrainDataVector = std::vector<RtTerrainData>;
296 RtTerrainDataVector m_rtTerrainInstances;
297 };
298
303 {
304 public:
306
307 virtual bool onAdd(agx::Referenced& instance) override;
308 virtual bool onRemove(agx::Referenced& instance) override;
309 virtual void synchronize( const CallbackData& data ) override;
310 virtual void cleanup() override;
311
313
315
316 private:
317 struct RtTerrainPagerData
318 {
319 bool isValid() const
320 {
321 return terrainPager != nullptr;
322 }
323
325 const agxTerrain::TerrainPager* terrainPager = nullptr;
326 RtTerrainDataMap terrainData;
327 };
328
329 bool contains(const agxTerrain::TerrainPager* pager) const;
330 bool syncronizeTiles(RtTerrainPagerData& data, SurfaceMaterialTable& materialTable);
331
332 private:
333 using RtTerrainPagerDataVector = std::vector<RtTerrainPagerData>;
334 RtTerrainPagerDataVector m_rtTerrainPagerData;
335 };
336}
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXSENSOR_EXPORT
Stores triangle mesh data as triangle lists, i.e.
Definition: MeshData.h:39
Base class for a shape.
Definition: Shape.h:58
Deformable object containing a tetrahedron mesh and a set of algorithms.
Basic implementation of any structure where bodies are linked/constrained together in a well defined ...
Raytrace system representing agxCollide::Shape instances as mesh(es) in the raytrace environment.
Raytrace system representing agxModel::DeformableObject.
Raytrace system representing agxSDK::LinkedStructure (agxCable::Cable, agxVehicle::Track agxModel::Be...
Raytrace system handling paged agxTerrain::Terrain instances.
Base raytrace system handling ordinary and paged agxTerrain::Terrain instances.
Raytrace system handling agxTerrain::Terrain instances.
Raytrace system representing agxWire::Wire instances as meshes in the raytrace environment.
System node is a separate step/operation in an execution tree representing a sensor (or such) in a se...
Definition: SystemNode.h:44
A pager that will dynamically handle terrain tiles in a agxSDK::Simulation.
Definition: TerrainPager.h:100
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:62
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
Inheritance with partial specialization due to bug with ref_ptr containers.
A basic particle system that contains all the storages and buffers required for basic operation and a...
Base class providing referencing counted objects.
Definition: Referenced.h:120
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
std::shared_ptr< RtShape > RtShapeRef
constexpr RtEntityId NullRtEntityId
Null entity id.
RtEntityId
Entity id > 0 to access user data given raytrace results including ENTITY_ID_I32.
std::shared_ptr< RtScene > RtSceneRef
Material instance in the raytrace environment, containing handle and type.
Raytrace shape instance data with a handle to the dito on the GPU, data and shape (ref-counting so th...