|
AGXDynamics
2.31.1.0
|
Class that handles and sanity checks the mass logic in the terrain. More...
#include <TerrainMassController.h>
Inheritance diagram for agxTerrain::TerrainMassController:Public Member Functions | |
| TerrainMassController (Terrain *terrain) | |
| Construct given terrain instance. More... | |
| TerrainMassController () | |
| float | addFluidMass (const agx::Vec3i &voxelIndex, float fluidMass) |
| Add fluid mass in a voxel and return the rest mass if the voxel was filled. More... | |
| float | addFluidMassToColumn (const agx::Vec2i &voxelIndexXY, float mass) |
| Add fluid mass column wise on the surface of the terrain. More... | |
| float | addSolidMass (const agx::Vec3i &voxelIndex, float solidMass, 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. More... | |
| float | addSolidMassToColumn (const agx::Vec2i &voxelIndexXY, float mass, float compaction, agx::Vec3i &newSurfaceVoxel) |
| Add solid mass with given compaction column wise on the surface of the terrain and return the amount of mass that was successfully added. More... | |
| float | addSolidMassToColumn (const agx::Vec3i &surfaceVoxelIndex, float mass, float compaction, agx::Vec3i &newSurfaceVoxel) |
| Add solid mass with given compaction column wise on the surface of the terrain and return the amount of mass that was successfully added. More... | |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| float | convertCompactedSolidMassToNominal (const agx::Vec3i &voxelIndex, float compactedOccupancy) const |
| Converts compacted mass to regular non-compacted mass given the specified voxel compaction. More... | |
| bool | dilateMassInColumn (const agx::Vec3i &bottomVoxel, agx::Vec3i &newSurfaceVoxel) |
| Dilate material in a column from a bottom index up to surface. More... | |
| float | getCompactedSolidMass (const agx::Vec3i &voxelIndex) const |
| Get the compacted mass in a voxel. More... | |
| float | getCompaction (const agx::Vec3i &voxelIndex) const |
| Get compaction in a voxel. More... | |
| float | getFluidMass (const agx::Vec3i &voxelIndex) const |
| Get fluid mass in a voxel given an index. More... | |
| float | getParticleMass (const agx::Vec3i &voxelIndex) const |
| Get particle mass in a voxel. More... | |
| int | getReferenceCount () const |
| float | getSolidMass (const agx::Vec3i &voxelIndex) const |
| Get the solid mass from a voxel. More... | |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| bool | isTotalMassOverNominalThreshold (const agx::Vec3i &voxelIndex) |
| Checks if the total mass in the specified voxel exceeds the allowed nominal threshold. More... | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| float | removeFluidMass (const agx::Vec3i &voxelIndex, float fluidMass) |
| Add fluid mass in a voxel and return the rest mass if the voxel was filled. More... | |
| float | removeFluidMassFromColumn (const agx::Vec2i &voxelIndexXY, float mass) |
| Remove fluid mass column wise from the surface of the terrain. More... | |
| float | removeSolidMass (const agx::Vec3i &voxelIndex, float solidMass) |
| 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. More... | |
| float | removeSolidMassFromColumn (const agx::Vec2i &voxelIndexXY, float mass, agx::Vec3i &newSurfaceVoxel) |
| Remove solid mass column wise from surface of the terrain and return the amount of mass that was successfully added. More... | |
| float | removeSolidMassFromColumn (const agx::Vec3i &surfaceVoxelIndex, float mass, agx::Vec3i &newSurfaceVoxel) |
| Remove solid mass column wise from surface of the terrain and return the amount of mass that was successfully added. More... | |
| void | setCompaction (const agx::Vec3i &voxelIndex, float compaction, bool scaleMass=false) |
| Set compaction on a voxel. More... | |
| void | setFluidMass (const agx::Vec3i &voxelIndex, float fluidMass) |
| void | setParticleMass (const agx::Vec3i &voxelIndex, float particleMass) |
| Set particle mass in a voxel. More... | |
| void | setSolidMass (const agx::Vec3i &voxelIndex, float solidMass, float compaction) |
| Set solid mass with a given compaction to a voxel. More... | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| bool | verifyMassColumnIntegrity (const agx::Vec2i &voxelIndexXY) |
| 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. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Protected Member Functions | |
| virtual | ~TerrainMassController () |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
| TerrainDataAtlas * | getData () const |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| 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 TerrainMassController.h.
| agxTerrain::TerrainMassController::TerrainMassController | ( | Terrain * | terrain | ) |
Construct given terrain instance.
| agxTerrain::TerrainMassController::TerrainMassController | ( | ) |
|
protectedvirtual |
| float agxTerrain::TerrainMassController::addFluidMass | ( | 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::TerrainMassController::addFluidMassToColumn | ( | const agx::Vec2i & | voxelIndexXY, |
| float | mass | ||
| ) |
Add fluid mass column wise on the surface of the terrain.
| voxelIndexXY | - The specified 2D voxel index |
| mass | - Amount of mass to be added |
| float agxTerrain::TerrainMassController::addSolidMass | ( | const agx::Vec3i & | voxelIndex, |
| float | solidMass, | ||
| 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 |
| solidMass | - The specified solid mass 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::TerrainMassController::addSolidMassToColumn | ( | const agx::Vec2i & | voxelIndexXY, |
| float | mass, | ||
| float | compaction, | ||
| agx::Vec3i & | newSurfaceVoxel | ||
| ) |
Add solid mass with given compaction column wise on the surface of the terrain and return the amount of mass that was successfully added.
| voxelIndexXY | - The specified 2D voxel index |
| mass | - the solid mass to add |
| compaction | - the compaction of the mass |
| newSurfaceVoxel | - Will give the new surface voxel index after all the mass has been added |
| float agxTerrain::TerrainMassController::addSolidMassToColumn | ( | const agx::Vec3i & | surfaceVoxelIndex, |
| float | mass, | ||
| float | compaction, | ||
| agx::Vec3i & | newSurfaceVoxel | ||
| ) |
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 |
| mass | - the solid mass to add |
| compaction | - the compaction of the mass |
| newSurfaceVoxel | - Will give the new surface voxel index after all the mass has been added |
|
protectedinherited |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
| float agxTerrain::TerrainMassController::convertCompactedSolidMassToNominal | ( | 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 |
|
protectedinherited |
| bool agxTerrain::TerrainMassController::dilateMassInColumn | ( | 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::TerrainMassController::getCompactedSolidMass | ( | 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::TerrainMassController::getCompaction | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get compaction in a voxel.
| voxelIndex | - The specified voxel index |
|
protected |
|
staticprotectedinherited |
| float agxTerrain::TerrainMassController::getFluidMass | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get fluid mass in a voxel given an index.
| voxelIndex | - The specified voxel index |
| float agxTerrain::TerrainMassController::getParticleMass | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get particle mass in a voxel.
| voxelIndex | - The specified voxel index |
|
inherited |
| float agxTerrain::TerrainMassController::getSolidMass | ( | const agx::Vec3i & | voxelIndex | ) | const |
Get the solid mass from a voxel.
| voxelIndex | - The specified voxel index |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::EntityStorage::getInstances(), and agx::Object::getResource().
| bool agxTerrain::TerrainMassController::isTotalMassOverNominalThreshold | ( | const agx::Vec3i & | voxelIndex | ) |
Checks if the total mass in the specified voxel exceeds the allowed nominal threshold.
| voxelIndex | - The specified voxel index to check |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
| float agxTerrain::TerrainMassController::removeFluidMass | ( | 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::TerrainMassController::removeFluidMassFromColumn | ( | const agx::Vec2i & | voxelIndexXY, |
| float | mass | ||
| ) |
Remove fluid mass column wise from the surface of the terrain.
| voxelIndexXY | - The specified 2D voxel index. |
| mass | - Amount of mass to be removed. |
| float agxTerrain::TerrainMassController::removeSolidMass | ( | const agx::Vec3i & | voxelIndex, |
| float | solidMass | ||
| ) |
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 |
| solidMass | - The specified solid mass to remove from a voxel |
| float agxTerrain::TerrainMassController::removeSolidMassFromColumn | ( | const agx::Vec2i & | voxelIndexXY, |
| float | mass, | ||
| agx::Vec3i & | newSurfaceVoxel | ||
| ) |
Remove solid mass column wise from surface of the terrain and return the amount of mass that was successfully added.
| voxelIndexXY | - The specified 2D voxel index |
| mass | - the solid mass to remove |
| newSurfaceVoxel | - Will give the new surface voxel after all the mass has been removed |
| float agxTerrain::TerrainMassController::removeSolidMassFromColumn | ( | const agx::Vec3i & | surfaceVoxelIndex, |
| float | mass, | ||
| agx::Vec3i & | newSurfaceVoxel | ||
| ) |
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 |
| newSurfaceVoxel | - Will give the new surface voxel after all the mass has been removed |
| void agxTerrain::TerrainMassController::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. |
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
| void agxTerrain::TerrainMassController::setFluidMass | ( | const agx::Vec3i & | voxelIndex, |
| float | fluidMass | ||
| ) |
| void agxTerrain::TerrainMassController::setParticleMass | ( | const agx::Vec3i & | voxelIndex, |
| float | particleMass | ||
| ) |
Set particle mass in a voxel.
| voxelIndex | - The specified voxel index |
| particleMass | - The particle mass to set |
| void agxTerrain::TerrainMassController::setSolidMass | ( | const agx::Vec3i & | voxelIndex, |
| float | solidMass, | ||
| float | compaction | ||
| ) |
Set solid mass with a given compaction to a voxel.
| voxelIndex | - The specified voxel index |
| solidMass | - The specified solid mass to set |
| compaction | - The compaction of the solid mass to set |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
|
staticinherited |
| bool agxTerrain::TerrainMassController::verifyMassColumnIntegrity | ( | const agx::Vec2i & | voxelIndexXY | ) |
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.
| voxelIndexXY | - The specified voxel index to check. |
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.