AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
TerrainContactGenerator.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
17#pragma once
18
20#include <agxTerrain/export.h>
22#include <agx/Referenced.h>
23#include <agx/Vec3.h>
24#include <agx/Vec2.h>
26#include <agx/Material.h>
27#include <agx/HashSet.h>
28#include <agx/Material.h>
29#include <agx/Bound.h>
30#include <agxCollide/Contacts.h>
31#include <queue>
32
33namespace agxSDK
34{
35 class Simulation;
36}
37
38namespace agxCollide
39{
40 class Geometry;
41}
42
43namespace agxTerrain
44{
45 class Terrain;
46
47 typedef std::queue<agx::Vec2i> IndexQueue;
48
51
61 {
62 public:
67
74
80 void onPre(agxSDK::Simulation* simulation);
81
86 void onPost(agxSDK::Simulation* simulation);
87
91 void onRemove(agxSDK::Simulation* simulation);
92
97
102
104
105 public:
109
110 protected:
111
115 void buildTerrainContacts(agxSDK::Simulation* simulation);
116
120 void updateTerrainContactsWithForceData();
121
126 void modifyTerrainGeometryContacts();
127
131 void collectTerrainContacts(agxSDK::Simulation* simulation);
132
140 bool raycastTerrainVertexToGeometry(const agxCollide::Geometry* collider, const agx::Vec2i& hfIndex, agx::Real& depth);
141
147 std::tuple<TerrainIndexToDepthTable, agx::Bound3> findIntersectingIndexInContact(const agxCollide::GeometryContactPtrVector& contacts);
148
152 TerrainContact* generateTerrainContact(const agxCollide::GeometryContactPtrVector& contacts, agxSDK::Simulation* simulation);
153
157 const agxCollide::Geometry* getCollider(const agxCollide::GeometryContact* contact) const;
158
159 protected:
164
171 agx::Real getModifiedYoungsModuls(const agx::Vec3& position, const agx::ContactMaterial* existingContactMaterial) const;
172
173 void addNeighborIndex(
174 const agx::Vec2i& index, std::queue<agx::Vec2i>& indicesToCheck, agx::HashSet<agx::Vec2i>& visitedIndices) const;
175 void registerContactingGeometry(const agxCollide::Geometry* geometry, agxSDK::Simulation* simulation);
176 void unRegisterContactingGeometry(const agxCollide::Geometry* geometry);
177 void unRegisterGeometriesNotInContact(const agxCollide::GeometryHashSet& geometriesInContact);
178 agx::Real getCurrentContactTime(const agxCollide::Geometry* geometry) const;
179 bool isSoilAggregateContact(agxCollide::GeometryContact* gc) const;
180
181 private:
182 using GeometryContactTimeTable = agx::HashVector<const agxCollide::Geometry*, std::pair<agxCollide::GeometryConstObserver, agx::Real>>;
183
184 private:
185 Terrain* m_terrain {nullptr};
186 agxCollide::GeometryContactPtrVector m_currentContacts;
187 GeometryContactTimeTable m_geometryToContactTime;
188 TerrainContactRefVector m_currentTerrainContacts;
189 };
190}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
This class has two main responsibilities:
const TerrainContactRefVector & getTerrainContacts() const
void onPre(agxSDK::Simulation *simulation)
Do pre updates for the contact generator.
TerrainContactRefVector & getTerrainContacts()
void onRemove(agxSDK::Simulation *simulation)
Do cleanup when removed from the Simulation.
TerrainContactRefVector * getTerrainContactVector()
TerrainContactGenerator(Terrain *terrain)
Default constructor.
void onPost(agxSDK::Simulation *simulation)
Do post updates for the contact generator.
Class that contains information about a terrain contact between an external object and the terrain ge...
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
Inheritance with partial specialization due to bug with ref_ptr containers.
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
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
std::queue< agx::Vec2i > IndexQueue
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
STL namespace.