|
AGX Dynamics 2.42.3.0
|
Class that handles and sanity checks the mass logic in the terrain. More...
#include <TerrainMassOccupancyController.h>
Inheritance diagram for agxTerrain::TerrainMassOccupancyController:Public Member Functions | |
| TerrainMassOccupancyController () | |
| TerrainMassOccupancyController (Terrain *terrain) | |
| Construct given terrain instance. | |
| float | addFluidOccupancy (const agx::Vec3i &voxelIndex, float fluidMass) |
| Add fluid mass in a voxel and return the rest mass if the voxel was filled. | |
| float | addFluidOccupancyToColumn (const agx::Vec2i &terrainIndex, float mass) |
| Add fluid mass column wise on the surface of the terrain. | |
| 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. | |
| 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 | 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 of mass that was successfully added. | |
| 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 of mass that was successfully added. | |
| float | convertCompactedSolidOccupancyToNominal (const agx::Vec3i &voxelIndex, float compactedOccupancy) const |
| Converts compacted mass to regular non-compacted mass given the specified voxel compaction. | |
| bool | dilateOccupancyInColumn (const agx::Vec3i &bottomVoxel, agx::Vec3i &newSurfaceVoxel) |
| Dilate material in a column from a bottom index up to surface. | |
| float | getCompactedSolidOccupancy (const agx::Vec3i &voxelIndex) const |
| Get the compacted mass in a voxel. | |
| float | getCompaction (const agx::Vec3i &voxelIndex) const |
| Get compaction in a voxel. | |
| float | getFluidOccupancy (const agx::Vec3i &voxelIndex) const |
| Get fluid mass in a voxel given an index. | |
| agx::Real | getOccupancyInTerrain (TerrainDataAtlas::MassType massType) const |
| Get the total mass in the terrain of a specific mass type. | |
| float | getOccupancyModifier (agx::Vec3i voxelIndex) const |
| float | getParticleOccupancy (const agx::Vec3i &voxelIndex) const |
| Get particle mass in a voxel. | |
| float | getSolidOccupancy (const agx::Vec3i &voxelIndex) const |
| Get the solid mass from a voxel. | |
| int | getSurfaceHeightIndex (const agx::Vec2i terrainIndex) const |
| Get Z value of the surface voxel in the voxel grid structure. | |
| GridElement | getVoxelZAndOccupancyFromLocalHeight (agx::Real height) |
| bool | isTotalOccupancyOverNominalThreshold (const agx::Vec3i &voxelIndex) const |
| Checks if the total mass in the specified voxel exceeds the allowed nominal threshold. | |
| 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 | removeFluidOccupancyFromColumn (const agx::Vec2i &terrainIndex, float mass) |
| Remove fluid mass column wise from the surface of the terrain. | |
| float | removeOccupancyFromColumn (const agx::Vec2i &terrainIndex, float occupancy) |
| Remove solid mass (in kg) column wise from the surface of the terrain. | |
| 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, i.e the rest if the voxel was emptied. | |
| 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 successfully added. | |
| 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 successfully added. | |
| void | setCompaction (const agx::Vec3i &voxelIndex, float compaction, bool scaleMass=false) |
| Set compaction on a voxel. | |
| void | setFluidOccupancy (const agx::Vec3i &voxelIndex, float fluidMass) |
| 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. | |
| void | setOccupancyInSurfaceVoxel (const agx::Vec2i terrainIndex, float occupancy) |
| Set occupancy in surface voxel. | |
| void | setParticleOccupancy (const agx::Vec3i &voxelIndex, float particleMass) |
| Set particle mass in a voxel. | |
| 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 the surface holds the maximum allowed mass given by the voxel compaction. | |
Public Member Functions inherited from agx::Referenced | |
| Referenced () | |
| Default constructor. | |
| Referenced (const Referenced &) | |
| template<typename T > | |
| T * | as () |
| Subclass casting. | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. | |
| template<typename T > | |
| const T * | asSafe () const |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. | |
| Referenced & | operator= (const Referenced &) |
| Assignment operator. Will increment the number of references to the referenced object. | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
Protected Member Functions | |
| virtual | ~TerrainMassOccupancyController () |
| TerrainDataAtlas * | getData () const |
Protected Member Functions inherited from agx::Referenced | |
| virtual | ~Referenced () |
| Destructor. | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
Additional Inherited Members | |
Static Public Member Functions inherited from agx::Referenced | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Static Protected Member Functions inherited from agx::Referenced | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
Protected Attributes inherited from agx::Referenced | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
Class that handles and sanity checks the mass logic in the terrain.
Every mass operation on the terrain grid should go through here.
Definition at line 35 of file TerrainMassOccupancyController.h.
| agxTerrain::TerrainMassOccupancyController::TerrainMassOccupancyController | ( | Terrain * | terrain | ) |
Construct given terrain instance.
| agxTerrain::TerrainMassOccupancyController::TerrainMassOccupancyController | ( | ) |
|
protectedvirtual |
| float agxTerrain::TerrainMassOccupancyController::addFluidOccupancy | ( | const agx::Vec3i & | voxelIndex, |
| float | fluidMass | ||
| ) |
Add fluid mass in a voxel and return the rest mass if the voxel was filled.
| voxelIndex | - The voxel index |
| fluidMass | - the amount of fluid mass to add |
| float agxTerrain::TerrainMassOccupancyController::addFluidOccupancyToColumn | ( | const agx::Vec2i & | terrainIndex, |
| float | mass | ||
| ) |
Add fluid mass column wise on the surface of the terrain.
| terrainIndex | - The specified 2D voxel index |
| mass | - Amount of mass to be added |
| float agxTerrain::TerrainMassOccupancyController::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.
| terrainIndex | - The specified 2D voxel index |
| massKg | - The mass in kg to add |
| compaction | - The compaction state to deposit mass at |
| float agxTerrain::TerrainMassOccupancyController::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.
| voxelIndex | - The specified voxel index |
| solidOccupancy | - The specified solid mass occupancy to add to a voxel |
| compaction | - The compaction of the mass to add |
| occupancyLimit | - The nominal occupancy limit in to fill in the voxel. NOTE - cannot be higher than the voxel max nominal occupancy |
| float agxTerrain::TerrainMassOccupancyController::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 of mass that was successfully added.
| terrainIndex | - The specified 2D voxel index |
| occupancy | - the solid mass occupancy to add |
| compaction | - the compaction of the mass |
| float agxTerrain::TerrainMassOccupancyController::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 of mass that was successfully added.
Unless needed, prefer to use the addSolidMassToColumn that uses just (x,y) to index the voxel instead of this version that has (x,y,z).
| surfaceVoxelIndex | - Current surface voxel in column |
| occupancy | - the solid mass occupancy to add |
| compaction | - the compaction of the mass |
| float agxTerrain::TerrainMassOccupancyController::convertCompactedSolidOccupancyToNominal | ( | const agx::Vec3i & | voxelIndex, |
| float | compactedOccupancy | ||
| ) | const |
Converts compacted mass to regular non-compacted mass given the specified voxel compaction.
| voxelIndex | - The voxel index where the compaction value will be used for conversion |
| compactedOccupancy | - The compacted mass to convert |
| bool agxTerrain::TerrainMassOccupancyController::dilateOccupancyInColumn | ( | const agx::Vec3i & | bottomVoxel, |
| agx::Vec3i & | newSurfaceVoxel | ||
| ) |
Dilate material in a column from a bottom index up to surface.
This is used when the compaction data in the grid has been updated (eg. through compaction) and the compacted mass needs redistributed to account for the changed volume.
| bottomVoxel | - The bottom voxel index where dilation will begin |
| newSurfaceVoxel | - Will give the new surface voxel index after all the mass has been dilated |
| float agxTerrain::TerrainMassOccupancyController::getCompactedSolidOccupancy | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get the compacted mass in a voxel.
This is the solid mass divided by the compaction in the specified voxel. This will normalize the solid mass to nominal occupancy, i.e how much space the compacted solid mass takes in the voxel (0.0 - 1.0).
| voxelIndex | - The specified voxel index |
| float agxTerrain::TerrainMassOccupancyController::getCompaction | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get compaction in a voxel.
| voxelIndex | - The specified voxel index |
|
protected |
| float agxTerrain::TerrainMassOccupancyController::getFluidOccupancy | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get fluid mass in a voxel given an index.
| voxelIndex | - The specified voxel index |
| agx::Real agxTerrain::TerrainMassOccupancyController::getOccupancyInTerrain | ( | TerrainDataAtlas::MassType | massType | ) | const |
Get the total mass in the terrain of a specific mass type.
| massType | - The mass type. |
| float agxTerrain::TerrainMassOccupancyController::getOccupancyModifier | ( | agx::Vec3i | voxelIndex | ) | const |
| float agxTerrain::TerrainMassOccupancyController::getParticleOccupancy | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get particle mass in a voxel.
| voxelIndex | - The specified voxel index |
| float agxTerrain::TerrainMassOccupancyController::getSolidOccupancy | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get the solid mass from a voxel.
| voxelIndex | - The specified voxel index |
| int agxTerrain::TerrainMassOccupancyController::getSurfaceHeightIndex | ( | const agx::Vec2i | terrainIndex | ) | const |
Get Z value of the surface voxel in the voxel grid structure.
| terrainIndex | - Terrain index of the column. |
| GridElement agxTerrain::TerrainMassOccupancyController::getVoxelZAndOccupancyFromLocalHeight | ( | agx::Real | height | ) |
| bool agxTerrain::TerrainMassOccupancyController::isTotalOccupancyOverNominalThreshold | ( | const agx::Vec3i & | voxelIndex | ) | const |
Checks if the total mass in the specified voxel exceeds the allowed nominal threshold.
| voxelIndex | - The specified voxel index to check |
| float agxTerrain::TerrainMassOccupancyController::removeFluidOccupancy | ( | const agx::Vec3i & | voxelIndex, |
| float | fluidMass | ||
| ) |
Add fluid mass in a voxel and return the rest mass if the voxel was filled.
| voxelIndex | - The voxel index. |
| fluidMass | - the amount of fluid mass to remove. |
| float agxTerrain::TerrainMassOccupancyController::removeFluidOccupancyFromColumn | ( | const agx::Vec2i & | terrainIndex, |
| float | mass | ||
| ) |
Remove fluid mass column wise from the surface of the terrain.
| terrainIndex | - The specified 2D voxel index. |
| mass | - Amount of mass to be removed. |
| float agxTerrain::TerrainMassOccupancyController::removeOccupancyFromColumn | ( | const agx::Vec2i & | terrainIndex, |
| float | occupancy | ||
| ) |
Remove solid mass (in kg) column wise from the surface of the terrain.
The removed mass is accumulated per-voxel using actual voxel density, so multi-voxel removals are computed correctly.
| terrainIndex | - The specified 2D voxel index |
| occupancy | - The solid occupancy to remove |
| float agxTerrain::TerrainMassOccupancyController::removeSolidOccupancy | ( | const agx::Vec3i & | voxelIndex, |
| float | solidOccupancy | ||
| ) |
Remove solid mass from a voxel and return the amount of mass that could not be removed, i.e the rest if the voxel was emptied.
| voxelIndex | - The specified voxel index |
| solidOccupancy | - The specified solid occupancy to remove from a voxel |
| float agxTerrain::TerrainMassOccupancyController::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 successfully added.
| terrainIndex | - The specified 2D voxel index |
| mass | - the solid mass to remove |
| float agxTerrain::TerrainMassOccupancyController::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 successfully added.
Unless needed, prefer to use the removeSolidMassFromColumn that uses (x,y) to index the voxel instead of this version with (x,y,z).
| surfaceVoxelIndex | - Current surface voxel index |
| mass | - the solid mass to remove |
| void agxTerrain::TerrainMassOccupancyController::setCompaction | ( | const agx::Vec3i & | voxelIndex, |
| float | compaction, | ||
| bool | scaleMass = false |
||
| ) |
Set compaction on a voxel.
| voxelIndex | - The specified voxel index |
| compaction- | The compaction to set |
| scaleMass | - True if the existing occupancy in the voxel should be scaled so that the compacted solid occupancy is the same as before compaction was set. This will effectively increase the total mass in the terrain. |
| void agxTerrain::TerrainMassOccupancyController::setFluidOccupancy | ( | const agx::Vec3i & | voxelIndex, |
| float | fluidMass | ||
| ) |
| void agxTerrain::TerrainMassOccupancyController::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.
| terrainIndex | - Terrain index of the column. |
| voxelZ | - Z value of the surface voxel in the voxel grid structure. |
| occupancy | - Occupancy in the surface voxel. |
| void agxTerrain::TerrainMassOccupancyController::setOccupancyInSurfaceVoxel | ( | const agx::Vec2i | terrainIndex, |
| float | occupancy | ||
| ) |
Set occupancy in surface voxel.
| terrainIndex | - Terrain index of the column. |
| occupancy | - Occupancy in the surface voxel. |
| void agxTerrain::TerrainMassOccupancyController::setParticleOccupancy | ( | const agx::Vec3i & | voxelIndex, |
| float | particleMass | ||
| ) |
Set particle mass in a voxel.
| voxelIndex | - The specified voxel index |
| particleMass | - The particle mass to set |
| bool agxTerrain::TerrainMassOccupancyController::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 the surface holds the maximum allowed mass given by the voxel compaction.
There should not be any "holes" in the terrain.
| terrainIndex | - The specified voxel index to check. |