AGX Dynamics  2.37.3.2
CompactionController.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/config/AGX_USE_AGXTERRAIN.h>
20 #include <agxTerrain/export.h>
21 #include <agx/Referenced.h>
23 #include <agx/Vec3.h>
24 
25 namespace agxCollide
26 {
27  class Geometry;
28 }
29 
30 namespace agxTerrain
31 {
32  class Terrain;
33  class TerrainDataAtlas;
35 
38 
41 
49  {
50  public:
52  {
54  UNIFORM_DISK
55  };
56 
58  {
60  VOID_RATIO_LN
61  };
62 
63  public:
67  CompactionController(Terrain* terrain);
68 
75 
79  void onPost();
80 
85  void setStressMethod(StressCalculationMethod stressMethod);
86 
90  StressCalculationMethod getStressMethod() const;
91 
95  void setCompactionMethod(CompactionMethod compactionMethod);
96 
100  CompactionMethod getCompactionMethod() const;
101 
109  bool applyCompactionFromSurfaceForce(const agx::Vec2i& terrainIndex, agx::Real surfaceForce, agx::Real contactTime);
110 
116  agx::Real getStressInVoxel(const agx::Vec3i& voxelIndex) const;
117 
121  const agx::HashSet<agx::Vec2i>& getCompressedTerrainIndices() const;
122 
123  public:
127 
128  protected:
129  virtual ~CompactionController();
130 
134  void updateCompactionFromTerrainContacts(const TerrainContactRefVector& contacts);
135 
136  // Compact the terrain using the uniform disk method
137  void handleCompactionFromTerrainContactsUniformDisk(const TerrainContactRefVector& contacts);
138 
139  // Compact the terrain using the uniform disk method
140  agx::Bool compactColumnWithPointForcesUniformDiskLoad(
141  const agx::Vec2i& terrainIndex, agx::Real surfaceStress, agx::Real loadRadius, agx::Real currentContactTime);
142 
143  // Compact the terrain using the BOUSSINESQ method
144  void handleCompactionFromTerrainContactsBoussinesq(const TerrainContactRefVector& contacts);
145 
146  // Compact the terrain using the BOUSSINESQ method
147  agx::Bool compactColumnWithPointForces(const agx::Vec2i& terrainIndex,
148  const TerrainContact::SurfaceForceVector& pointForces,
149  agx::Real surfaceStress,
150  bool voxelSurfacecIsInContactArea,
151  agx::Real minDepth,
152  agx::Real maxDepth,
153  agx::Real currentContactTime);
154 
155  // Calculate compaction in voxel given a compaction stress and time factor
156  bool doCompactionInVoxel(const agx::Vec3i& voxelIndex, agx::Real compactionStress, agx::Real timeFactor);
157 
158  // Calculate subsoil stress in the BOUSSINESQ method
159  agx::Real calculateTotalSubSoilStress(const agx::Vec3& voxelPoint,
160  bool voxelSurfacecIsInContactArea,
161  const TerrainContact::SurfaceForceVector& pointForces) const;
162 
163  void debugRenderStressInNode(const agx::Vec3& position, agx::Real stress) const;
164 
165  TerrainMassOccupancyController* getMassOccupancyController() const;
166 
167  friend class Terrain;
168 
169  private:
170  Terrain* m_terrain;
171  VoxelStressTable m_voxelIndexToStress;
172  agx::HashSet<agx::Vec2i> m_compressedTerrainIndices;
173  StressCalculationMethod m_stressMethod;
174  CompactionMethod m_compactionMethod;
175  };
176 }
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
Class that handles and sanity checks the mass logic in the terrain.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agx::HashTable< agx::Vec3i, agx::Real > VoxelStressTable
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
bool Bool
Definition: Integer.h:48
agx::HashTable< agxCollide::Geometry *, agx::Real > GeometryContactTimeTable
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes...
Definition: Geometry.h:59
Class that contains information about a terrain contact between an external object and the terrain ge...
Vec2T< Int > Vec2i
Definition: Vec2.h:40
Base class providing referencing counted objects.
Definition: Referenced.h:119
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Controller that handles compaction in the terrain from generated terrain contacts in TerrainContactGe...
Vec3T< Int > Vec3i
Definition: Vec3.h:43
#define AGXTERRAIN_EXPORT
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
Inheritance with partial specialization due to bug with ref_ptr containers.
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
AGX_DECLARE_POINTER_TYPES(SpaceListener)