AGX Dynamics  2.37.2.0
TerrainGridControl.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 <agxTerrain/export.h>
20 #include <agx/Vec3.h>
22 
23 namespace agxTerrain
24 {
25  class Terrain;
26 
29 
46  {
47  public:
52  TerrainGridControl(Terrain* terrain);
53 
60 
67  float getOccupancy(const agx::Vec2i& terrainIndex, int z) const;
68 
74  float getOccupancy(const agx::Vec3i& voxelIndex) const;
75 
82  float getMass(const agx::Vec2i& terrainIndex, int z) const;
83 
89  float getMass(const agx::Vec3i& voxelIndex) const;
90 
91 
98  float getCompaction(const agx::Vec2i& terrainIndex, int z) const;
99 
105  float getCompaction(const agx::Vec3i& terrainIndex) const;
106 
112  float getSurfaceOccupancy(const agx::Vec2i& terrainIndex) const;
113 
119  float getSurfaceCompaction(const agx::Vec2i& terrainIndex) const;
120 
135  void setSurfaceCompaction(
136  const agx::Vec2i& terrainIndex, float compaction, bool compressOccupancy = false, bool compressToBottom = false);
137 
149  void setSurfaceCompactionToDepth(const agx::Vec2i& terrainIndex, float compaction, float depth);
150 
165  void setCompaction(const agx::Vec2i& terrainIndex, int z, float compaction, bool compressOccupancy = false);
166 
178  void setCompaction(const agx::Vec3i& terrainIndex, float compaction, bool compressOccupancy = false);
179 
186  void setTerrainMaterial(const agx::Vec2i& terrainIndex, int z, TerrainMaterial* terrainMaterial);
192  void setTerrainMaterial(const agx::Vec3i& terrainIndex, TerrainMaterial* terrainMaterial);
203  float addSolidOccupancyInColumn(
204  const agx::Vec2i& terrainIndex, float mass, float compaction, bool shouldAvalanche = true);
205 
214  void addSolidOccupancyInColumns(agx::HashTable<agx::Vec2i, std::pair<float, float>> table, bool shouldAvalanche = true);
215 
224  float removeSolidOccupancyInColumn(const agx::Vec2i& terrainIndex, float occupancy, bool shouldAvalanche = true);
225 
239  float addSolidOccupancyLayerInColum(const agx::Vec2i& terrainIndex, agx::Real layerHeight, float compaction, bool shouldAvalanche = true);
240 
254  float addSolidOccupancyInColumnToHeight(const agx::Vec2i& terrainIndex, agx::Real height, float compaction, bool shouldAvalanche = true);
255 
262  float removeFluidOccupancy(const agx::Vec3i& terrainIndex, float fluidOccupancy);
263 
270  agx::Real getLocalAngleOfRepose(const agx::Vec3i& voxelIndex) const;
271 
278  agx::Real getSurfaceAngleOfRepose(const agx::Vec2i& terrainIndex) const;
279 
295  bool applySurfaceForce(const agx::Vec2i& terrainIndex, agx::Real surfaceForce, agx::Real contactTime=-1);
296 
310  bool applySurfaceStress(const agx::Vec2i& terrainIndex, agx::Real surfaceStress, agx::Real contactTime = -1);
311 
317  bool isIndexValid(const agx::Vec3i& terrainIndex) const;
318 
324  agx::Real getCurrentStressInTerrainIndex(const agx::Vec3i& terrainIndex) const;
325 
335  agx::Real getLocalPreconsolidationStress(const agx::Vec3i& terrainIndex) const;
336 
346  agx::Real getSurfacePreconsolidationStress(const agx::Vec2i& terrainIndex) const;
347 
353  agx::Vec3 getGridElementPositionWorld(const agx::Vec3i& terrainIndex) const;
354 
362  agx::Real getSurfaceHardnessMultiplier(const agx::Vec2i& terrainIndex) const;
363 
371  agx::Real getLocalHardnessMultiplier(const agx::Vec3i& voxelIndex) const;
372 
378  int findSurfaceIndex(const agx::Vec2i& terrainIndex) const;
379 
386  int findIndexFromSurfaceDepth(const agx::Vec2i& terrainIndex, agx::Real depth) const;
387 
391  int getLowestAllowableDepthIndex() const;
392 
396  agx::Real convertOccupancyToMassKg(float occupancy) const;
397 
401  agx::Real convertFluidMassKgToOccupancy(float mass) const;
402 
403  public:
407 
408  protected:
409  agx::Vec3i convertSurfaceTerrainIndex(const agx::Vec2i& terrainIndex) const;
410 
411  virtual ~TerrainGridControl();
412 
413  private:
414  Terrain* m_terrain;
415  };
416 }
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
Interface class for accessing and manipulating the underlying 3D grid data in the terrain using terra...
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes...
Definition: Geometry.h:59
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
This class is used to describe the general material properties of the Terrain.
Base class providing referencing counted objects.
Definition: Referenced.h:119
#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