AGXDynamics  2.35.0.3
TerrainDataAtlas.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 <agxTerrain/Grid.h>
21 #include <agx/StackArray.h>
22 
23 namespace agxTerrain
24 {
26 
28 
29  /*
30  Atlas for holding information about terrain mass in the grid system.
31  Is active in the same index space as the regular grid.
32  */
34  {
35  static constexpr float MAX_MASS = 1.0;
36 
37  public:
38  enum MassType
39  {
42  FLUID
43  };
44  struct MassTypeHash
45  {
47  {
48  return agx::hash((agx::UInt32)key);
49  }
50  };
51 
52  public:
59  TerrainDataAtlas(agx::Real voxelSize, size_t resolutionX, size_t resolutionY, agx::Int depth);
60 
67  float getMass(const Grid::GridCoord& coord, MassType massType) const;
68 
76  void setMass(const Grid::GridCoord& coord, MassType massType, float value);
77 
86  float addMass(const Grid::GridCoord& coord, MassType massType, float value);
87 
94  void setCompaction(const Grid::GridCoord& coord, float value);
95 
101  float getCompaction(const Grid::GridCoord& coord) const;
102 
110  float getCompactedSolidMass(const Grid::GridCoord& coord) const;
111 
117  float getMaximumAllowedSolidMassInVoxel(const Grid::GridCoord& coord) const;
118 
124  bool isActiveVoxel(const Grid::GridCoord& coord, MassType massType) const;
125 
131  agx::Vec3iVector getIndicesWithMass(MassType massType) const;
132 
133  float getTotalMassInVoxel(const Grid::GridCoord& coord) const;
134 
135  void setVelocity(const Grid::GridCoord& coord, const agx::Vec3f& value);
136  agx::Vec3f getVelocity(const Grid::GridCoord& coord) const;
137  void clearVelocityGrid();
138 
139  Grid* getSolidGridMassData() const;
140 
141  BasicGrid* getGridMassData(MassType massType) const;
142  BasicGrid* getCompactionGridData() const;
143 
144  size_t getTotalGridMemoryUsage() const;
145 
146  size_t getTotalActiveVoxels() const;
147 
148  void clearMassGrid(MassType massType);
149 
150  agx::Real getMassInTerrain(MassType massType) const;
151 
152  VoxelToVelocityTable& getVelocityTable();
153 
154  public:
158 
159  protected:
163  virtual ~TerrainDataAtlas();
164 
165  void fillGridVector();
166 
167  protected:
168  BasicGridRef m_solidMassGrid;
169  BasicGridRef m_fluidMassGrid;
170  BasicGridRef m_particleMassGrid;
171  BasicGridRef m_compactionGrid;
172 
173  VoxelToVelocityTable m_voxelToVelocityTable;
174 
175  agx::StackArray<BasicGrid*, 3> m_gridVector;
176 
177  Grid* m_rawSolidMassGrid; // alias for m_solidMassGrid
178  };
179 }
AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
Definition: agxTerrain/export.h:64
agxTerrain::VoxelToVelocityTable
agx::HashTable< agx::Vec3i, agx::Vec3f > VoxelToVelocityTable
Definition: TerrainDataAtlas.h:25
agx::Real
double Real
Definition: Real.h:42
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
agxTerrain::Grid
Extended pure virtual interface for Grid storage classes.
Definition: Grid.h:171
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agxTerrain::TerrainDataAtlas::MassType
MassType
Definition: TerrainDataAtlas.h:38
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxTerrain::TerrainDataAtlas::MassTypeHash
Definition: TerrainDataAtlas.h:44
agx::Int
int32_t Int
Definition: Integer.h:35
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
Grid.h
export.h
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxTerrain::TerrainDataAtlas::PARTICLE
@ PARTICLE
Definition: TerrainDataAtlas.h:41
agx::ref_ptr< BasicGrid >
agxTerrain::TerrainDataAtlas::MassTypeHash::operator()
agx::UInt32 operator()(TerrainDataAtlas::MassType key) const
Definition: TerrainDataAtlas.h:46
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:871
agxTerrain::BasicGrid
Pure virtual interface class for the data storage grid classes we have.
Definition: Grid.h:70
agx::hash
AGXCORE_EXPORT UInt32 hash(const T &key)
Definition: HashFunction.h:65
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
StackArray.h
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition: agxTerrain/export.h:41
agx::Vec3T< Int >
agxTerrain::TerrainDataAtlas::SOLID
@ SOLID
Definition: TerrainDataAtlas.h:40
agx::UInt32
uint32_t UInt32
Definition: Integer.h:40
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxTerrain::TerrainDataAtlas
Definition: TerrainDataAtlas.h:33