AGXDynamics  2.35.0.2
TerrainMassController.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 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>
22 #include <agx/Vec3.h>
23 
24 namespace agxTerrain
25 {
26  class Terrain;
27  class TerrainDataAtlas;
28 
31 
36  {
37  public:
42 
49 
50  /*
51  Set fluid mass in a voxel given an index
52  \param voxelIndex - The specified voxel index
53  \param fluidMass - the amount of fluid mass to set
54  */
55  void setFluidMass(const agx::Vec3i& voxelIndex, float fluidMass);
56 
63  float addFluidMass(const agx::Vec3i& voxelIndex, float fluidMass);
64 
71  float removeFluidMass(const agx::Vec3i& voxelIndex, float fluidMass);
72 
78  float getFluidMass(const agx::Vec3i& voxelIndex) const;
79 
90  float addSolidMass(const agx::Vec3i& voxelIndex, float solidMass, float compaction, float occupancyLimit = 1.0);
91 
99  float removeSolidMass(const agx::Vec3i& voxelIndex, float solidMass);
100 
106  float getSolidMass(const agx::Vec3i& voxelIndex) const;
107 
116  void setCompaction(const agx::Vec3i& voxelIndex, float compaction, bool scaleMass=false);
117 
123  float getCompaction(const agx::Vec3i& voxelIndex) const;
124 
125  float getOccupancyModifier(agx::Vec3i voxelIndex) const;
126 
132  float getParticleMass(const agx::Vec3i& voxelIndex) const;
133 
139  void setParticleMass(const agx::Vec3i& voxelIndex, float particleMass);
140 
147  float getCompactedSolidMass(const agx::Vec3i& voxelIndex) const;
148 
155  float addFluidMassToColumn(const agx::Vec2i& voxelIndexXY, float mass);
156 
163  float removeFluidMassFromColumn(const agx::Vec2i& voxelIndexXY, float mass);
164 
173  float addSolidMassToColumn(const agx::Vec2i& voxelIndexXY, float mass, float compaction);
174 
184  float addSolidMassToColumn(const agx::Vec3i& surfaceVoxelIndex, float mass, float compaction);
185 
193  float removeSolidMassFromColumn(const agx::Vec2i& voxelIndexXY, float mass);
194 
203  float removeSolidMassFromColumn(const agx::Vec3i& surfaceVoxelIndex, float mass);
204 
212  bool dilateMassInColumn(const agx::Vec3i& bottomVoxel, agx::Vec3i& newSurfaceVoxel);
213 
220  float convertCompactedSolidMassToNominal(const agx::Vec3i& voxelIndex, float compactedOccupancy) const;
221 
227  bool isTotalMassOverNominalThreshold(const agx::Vec3i& voxelIndex);
228 
236  bool verifyMassColumnIntegrity(const agx::Vec2i& voxelIndexXY);
237 
244  void setGridColumnOccupancy(const agx::Vec2i terrainIndex, int voxelZ, float occupancy);
245 
251  void setOccupancyInSurfaceVoxel(const agx::Vec2i terrainIndex, float occupancy);
252 
258  int getSurfaceHeightIndex(const agx::Vec2i terrainIndex);
259 
265  agx::Real getMassInTerrain(size_t massType);
266 
271  agx::Real getTotalMassInTerrain();
272 
273  std::pair<int, float> getVoxelZAndOccupancyFromLocalHeight(agx::Real height, agx::Real voxelSize);
274 
275  public:
279 
280  protected:
281 
282  virtual ~TerrainMassController();
283 
284  TerrainDataAtlas* getData() const;
285 
286  private:
287  Terrain* m_terrain;
288  agx::HashTable<agx::Vec3i, float> m_occupancyModifiers;
289  };
290 }
AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
Definition: agxTerrain/export.h:64
Referenced.h
agxTerrain::Terrain
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: agxTerrain/Terrain.h:85
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
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
export.h
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
Vec3.h
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:871
agx::Vec2T
Definition: Vec2Template.h:30
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
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::TerrainMassController
Class that handles and sanity checks the mass logic in the terrain.
Definition: TerrainMassController.h:35
agxTerrain::TerrainDataAtlas
Definition: TerrainDataAtlas.h:33