AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
TerrainMassOccupancyController.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20#include <agxTerrain/export.h>
22#include <agx/Referenced.h>
23#include <agx/Vec3.h>
24
25namespace 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 solidOccupancy);
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 float removeOccupancyFromColumn(const agx::Vec2i& terrainIndex, float occupancy);
213
221 float addSolidMassKgToColumn(const agx::Vec2i& terrainIndex, float massKg, float compaction);
222
230 bool dilateOccupancyInColumn(const agx::Vec3i& bottomVoxel, agx::Vec3i& newSurfaceVoxel);
231
238 float convertCompactedSolidOccupancyToNominal(const agx::Vec3i& voxelIndex, float compactedOccupancy) const;
239
246
254 bool verifyOccupancyColumnIntegrity(const agx::Vec2i& terrainIndex ) const;
255
262 void setGridColumnOccupancy(const agx::Vec2i terrainIndex, int voxelZ, float occupancy);
263
269 void setOccupancyInSurfaceVoxel(const agx::Vec2i terrainIndex, float occupancy);
270
276 int getSurfaceHeightIndex(const agx::Vec2i terrainIndex) const;
277
283 agx::Real getOccupancyInTerrain( TerrainDataAtlas::MassType massType ) const;
284
285
287
288 public:
292
293 protected:
294
296
297 TerrainDataAtlas* getData() const;
298
299 private:
300 Terrain* m_terrain;
301 agx::HashTable<agx::Vec3i, float> m_occupancyModifiers;
302 };
303}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Class that handles and sanity checks the mass logic in the terrain.
GridElement getVoxelZAndOccupancyFromLocalHeight(agx::Real height)
float getCompaction(const agx::Vec3i &voxelIndex) const
Get compaction in a voxel.
void setFluidOccupancy(const agx::Vec3i &voxelIndex, float fluidMass)
int getSurfaceHeightIndex(const agx::Vec2i terrainIndex) const
Get Z value of the surface voxel in the voxel grid structure.
float getParticleOccupancy(const agx::Vec3i &voxelIndex) const
Get particle mass in a voxel.
TerrainMassOccupancyController(Terrain *terrain)
Construct given terrain instance.
void setCompaction(const agx::Vec3i &voxelIndex, float compaction, bool scaleMass=false)
Set compaction on a voxel.
float addSolidMassKgToColumn(const agx::Vec2i &terrainIndex, float massKg, float compaction)
Add solid mass (in kg) column wise on the surface of the terrain using the specified compaction.
bool verifyOccupancyColumnIntegrity(const agx::Vec2i &terrainIndex) const
Verify that a mass column in the terrain grid is properly filled, i.e that all submerged voxels under...
float addSolidOccupancyToColumn(const agx::Vec2i &terrainIndex, float occupancy, float compaction)
Add solid mass with given compaction column wise on the surface of the terrain and return the amount ...
float addFluidOccupancy(const agx::Vec3i &voxelIndex, float fluidMass)
Add fluid mass in a voxel and return the rest mass if the voxel was filled.
agx::Real getOccupancyInTerrain(TerrainDataAtlas::MassType massType) const
Get the total mass in the terrain of a specific mass type.
float addSolidOccupancy(const agx::Vec3i &voxelIndex, float solidOccupancy, float compaction, float occupancyLimit=1.0)
Add solid mass with a given compaction to a voxel and return the rest mass that could not fit.
float getCompactedSolidOccupancy(const agx::Vec3i &voxelIndex) const
Get the compacted mass in a voxel.
bool dilateOccupancyInColumn(const agx::Vec3i &bottomVoxel, agx::Vec3i &newSurfaceVoxel)
Dilate material in a column from a bottom index up to surface.
float removeOccupancyFromColumn(const agx::Vec2i &terrainIndex, float occupancy)
Remove solid mass (in kg) column wise from the surface of the terrain.
void setOccupancyInSurfaceVoxel(const agx::Vec2i terrainIndex, float occupancy)
Set occupancy in surface voxel.
float removeFluidOccupancy(const agx::Vec3i &voxelIndex, float fluidMass)
Add fluid mass in a voxel and return the rest mass if the voxel was filled.
float getSolidOccupancy(const agx::Vec3i &voxelIndex) const
Get the solid mass from a voxel.
float getFluidOccupancy(const agx::Vec3i &voxelIndex) const
Get fluid mass in a voxel given an index.
float getOccupancyModifier(agx::Vec3i voxelIndex) const
float convertCompactedSolidOccupancyToNominal(const agx::Vec3i &voxelIndex, float compactedOccupancy) const
Converts compacted mass to regular non-compacted mass given the specified voxel compaction.
void setGridColumnOccupancy(const agx::Vec2i terrainIndex, int voxelZ, float occupancy)
Set the which voxel is the surface voxel and what the occupancy is in that voxel.
bool isTotalOccupancyOverNominalThreshold(const agx::Vec3i &voxelIndex) const
Checks if the total mass in the specified voxel exceeds the allowed nominal threshold.
float addFluidOccupancyToColumn(const agx::Vec2i &terrainIndex, float mass)
Add fluid mass column wise on the surface of the terrain.
float removeSolidOccupancyFromColumn(const agx::Vec2i &terrainIndex, float mass)
Remove solid mass column wise from surface of the terrain and return the amount of mass that was succ...
void setParticleOccupancy(const agx::Vec3i &voxelIndex, float particleMass)
Set particle mass in a voxel.
float addSolidOccupancyToColumn(const agx::Vec3i &surfaceVoxelIndex, float occupancy, float compaction)
Add solid mass with given compaction column wise on the surface of the terrain and return the amount ...
float removeSolidOccupancyFromColumn(const agx::Vec3i &surfaceVoxelIndex, float mass)
Remove solid mass column wise from surface of the terrain and return the amount of mass that was succ...
float removeSolidOccupancy(const agx::Vec3i &voxelIndex, float solidOccupancy)
Remove solid mass from a voxel and return the amount of mass that could not be removed,...
float removeFluidOccupancyFromColumn(const agx::Vec2i &terrainIndex, float mass)
Remove fluid mass column wise from the surface of the terrain.
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
Base class providing referencing counted objects.
Definition: Referenced.h:120
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41