AGX Dynamics  2.37.3.2
TerrainMassOccupancyController.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>
22 #include <agx/Referenced.h>
23 #include <agx/Vec3.h>
24 
25 namespace agxTerrain
26 {
27  class Terrain;
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 setFluidOccupancy(const agx::Vec3i& voxelIndex, float fluidMass);
56 
63  float addFluidOccupancy(const agx::Vec3i& voxelIndex, float fluidMass);
64 
71  float removeFluidOccupancy(const agx::Vec3i& voxelIndex, float fluidMass);
72 
78  float getFluidOccupancy(const agx::Vec3i& voxelIndex) const;
79 
90  float addSolidOccupancy(const agx::Vec3i& voxelIndex, float solidOccupancy, float compaction, float occupancyLimit = 1.0);
91 
99  float removeSolidOccupancy(const agx::Vec3i& voxelIndex, float solidMass);
100 
106  float getSolidOccupancy(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 getParticleOccupancy(const agx::Vec3i& voxelIndex) const;
133 
139  void setParticleOccupancy(const agx::Vec3i& voxelIndex, float particleMass);
140 
147  float getCompactedSolidOccupancy(const agx::Vec3i& voxelIndex) const;
148 
155  float addFluidOccupancyToColumn(const agx::Vec2i& terrainIndex, float mass);
156 
163  float removeFluidOccupancyFromColumn(const agx::Vec2i& terrainIndex, float mass);
164 
173  float addSolidOccupancyToColumn(const agx::Vec2i& terrainIndex, float occupancy, float compaction);
174 
184  float addSolidOccupancyToColumn(const agx::Vec3i& surfaceVoxelIndex, float occupancy, float compaction);
185 
193  float removeSolidOccupancyFromColumn(const agx::Vec2i& terrainIndex, float mass);
194 
203  float removeSolidOccupancyFromColumn(const agx::Vec3i& surfaceVoxelIndex, float mass);
204 
212  bool dilateOccupancyInColumn(const agx::Vec3i& bottomVoxel, agx::Vec3i& newSurfaceVoxel);
213 
220  float convertCompactedSolidOccupancyToNominal(const agx::Vec3i& voxelIndex, float compactedOccupancy) const;
221 
227  bool isTotalOccupancyOverNominalThreshold(const agx::Vec3i& voxelIndex) const;
228 
236  bool verifyOccupancyColumnIntegrity(const agx::Vec2i& terrainIndex ) const;
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) const;
259 
265  agx::Real getOccupancyInTerrain( TerrainDataAtlas::MassType massType ) const;
266 
267 
268  std::pair<int, float> getVoxelZAndOccupancyFromLocalHeight(agx::Real height, agx::Real voxelSize);
269 
270  public:
274 
275  protected:
276 
278 
279  TerrainDataAtlas* getData() const;
280 
281  private:
282  Terrain* m_terrain;
283  agx::HashTable<agx::Vec3i, float> m_occupancyModifiers;
284  };
285 }
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
Class that handles and sanity checks the mass logic in the terrain.
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
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