345 inline bool getDeformable()
const;
420 size_t getResolutionX()
const;
426 size_t getResolutionY()
const;
449 bool getEnableMinimumHeights()
const;
455 void setEnableMinimumHeights(
bool enable);
963 bool onlyMidpoint=
false)
const;
1047 deprecated::TerrainToolCollectionRefVector getToolCollections() const;
1055 deprecated::TerrainToolCollection* getToolCollection(const
Shovel* shovel) const;
1068 bool getPenetrationForce(const
Shovel* shovel,
agx::Vec3& force,
agx::Vec3& torque) const;
1079 agx::Vec3 getSeparationContactForce(const
Shovel* shovel) const;
1089 agx::Vec3 getSeparationNormalForce(const
Shovel* shovel) const;
1099 agx::Vec3 getSeparationFrictionForce(const
Shovel * shovel) const;
1111 agx::Vec3 getDeformationContactForce(const
Shovel* shovel) const;
1123 agx::Vec3 getExcavationModeContactForce(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1146 agxCollide::GeometryContactPtrVector getShovelAggregateContacts(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1156 agx::Real getLastDeadLoadFraction(const
Shovel* shovel) const;
1193 agx::Real getSoilAggregateMass(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1211 bool isRigidBodyShovel(const
agx::RigidBody* body) const;
1220 bool isGeometryShovel(const
agxCollide::Geometry* geometry) const;
1234 bool setShovelAggregateContactMaterial(
Shovel* shovel,
1235 agx::ContactMaterial* contactMaterial,
1236 Shovel::ExcavationMode mode =
Shovel::ExcavationMode::PRIMARY);
1249 agx::ContactMaterial* getShovelAggregateContactMaterial(const
Shovel* shovel,
1250 Shovel::ExcavationMode mode =
Shovel::ExcavationMode::PRIMARY) const;
1261 agx::Vec3 getAggregateTerrainContactForce(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1271 agx::Vec3 getAggregateTerrainNormalForce(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1281 agx::Vec3 getAggregateTerrainTangentialForce(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1291 agx::Real getAggregateTerrainContactArea(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1301 agxCollide::GeometryContactPtrVector getAggregateTerrainContacts(const
Shovel* shovel,
Shovel::ExcavationMode excavationMode) const;
1309 size_t getNumActiveVoxels() const;
1312 size_t getNumModifiedVoxels() const;
1321 bool verifyMassColumnIntegrity(const
agx::Vec2i& terrainIndex) const;
1326 bool isVoxelIndexBelowMaximumDepth(const
agx::Vec3i& index) const;
1331 bool isBoundaryDepthVoxel(const
agx::Vec3i& index) const;
1339 agx::Line transformLineToTerrain(const
agx::Line& line) const;
1347 agx::Line transformLineToVoxelSpace( const
agx::Line& line ) const;
1355 agx::Line transformLineToWorld(const
agx::Line& line) const;
1360 bool isVoxelIndexInsideGeometryBound(const
agx::Vec3i& index) const;
1365 agx::AffineMatrix4x4 getVoxelSpaceTransform() const;
1370 bool isBorderIndexAndBordersLocked(const
agx::Vec2i& terrainIndex) const;
1374 TerrainDataAtlas* getTerrainDataAtlas() const;
1376 virtual
void runBuildIslandsTask() override;
1378 void clearAllSoilParticles();
1383 agx::Real calculateTotalVoxelVolume() const;
1385 agx::Vec3 getNormalFromTerrainIndex( const
agx::Vec2i& terrainIndex ) const;
1394 float addFluidMassToColumn(const
agx::Vec2i& terrainIndex,
float fluidMass) const;
1403 float removeFluidMassFromColumn(const
agx::Vec2i& terrainIndex,
float fluidMass);
1412 float addFluidMass(const
agx::Vec3i& voxelIndex,
float fluidMass) const;
1421 float removeFluidMass(const
agx::Vec3i& voxelIndex,
float fluidMass);
1429 agx::Real calculateFluidOccupancy() const;
1437 agx::Real getTotalSoilParticleOccupancy() const;
1444 agx::Vec3 getLocalPositionFromVoxelIndex(const
agx::Vec3i& voxelIndex) const;
1451 agx::Vec3 getWorldPositionFromVoxelIndex(const
agx::Vec3i& voxelIndex) const;
1458 agx::Vec3i getVoxelIndexFromLocalPosition(const
agx::Vec3& position) const;
1465 inline
agx::Vec3i getVoxelIndexFromGridPosition(
agx::Vec3 position)
const
1467 return VoxelGridUtils::getVoxelIndexFromGridPosition(position, m_voxelSize);
1477 agx::Vec3i vi = getVoxelIndexFromGridPosition(position);
1501 void setForbiddenVoxelsForDynamicMass(
const agx::Vec3iVector& voxelIndices);
1508 bool getForbiddenVoxelsForDynamicMass(
agx::Vec3iVector& voxelIndices)
const;
1516 bool isForbiddenVoxelsForDynamicMass(
const agx::Vec3i& voxelIndex)
const;
1523 bool voxelContainsShovel(
const agx::Vec3i& voxelIndex)
const;
1547 TerrainMassOccupancyController* getMassOccupancyController()
const;
1554 TerrainMaterialController* getMaterialController()
const;
1557 GroundCollapse::GroundCollapseController* getGroundCollapseController()
const;
1560 void adjustFluidMassInGrid(
agx::Vec3i binIndex,
int binVoxels,
float availableFluidMass,
float remainingFluidMass);
1564 agx::Vec3iVector getVoxelsOccupiedByDeformer(ExternalDeformer* deformer)
const;
1566 bool isPointSubmerged(
const agx::Vec3& point )
const;
1568 bool voxelHasParticles(
const agx::Vec3i& voxelIndex)
const;
1570 bool isForbiddenIndex(
const agx::Vec3i& index);
1572 void addTerrainIndexToAvalanche(
const agx::Vec2i& index);
1575 int getLowestAllowableVoxelIndexZ()
const;
1578 int getMinimumHeightVoxelIndexZ(
const agx::Vec2i& index)
const;
1581 agx::Vec3 constructVoxelFieldOffset()
const;
1585 void setIsTerrainPagerTile(
bool isPagerTile);
1587 bool getIsTerrainPagerTile()
const;
1589 bool shouldUpdateTerrain()
const;
1591 bool hasEnabledShovels()
const;
1593 bool hasParticlesInTerrain()
const;
1595 void debugRenderFluidMass();
1597 bool isSolidVoxel(
const agx::Vec3i& index )
const;
1599 bool isActiveSolidVoxel(
const agx::Vec3i& index )
const;
1601 void markIndexAsModified(
const agx::Vec2i& terrainIndex );
1603 bool isSurfaceVoxel(
const agx::Vec3i& index)
const;
1613 void debugRenderParticleHeightField(
agx::Real sizeFactor = 0.8,
1616 bool isEdgeSubmerged(
const agx::Line& edge)
const;
1618 bool isEdgeSubmergedInSolid(
const agx::Line& edge)
const;
1628 void updateSurfaceHeightFieldFromTerrainIndices(
const agx::Vec2iVector& indices);
1641 virtual
void addNotification() override;
1646 virtual
void removeNotification() override;
1652 virtual
void preEveryStep() override;
1657 virtual
void preCollide() override;
1662 virtual
void pre() override;
1667 virtual
void post() override;
1672 virtual
void last() override;
1683 virtual
void syncIfPager() override;
1685 void resetIndices();
1748 bool isOccupied =
true,
1749 bool onlyMidpoint =
false)
const;
1761 agx::HashTable <agx::Vec2i, agx::Vec4>& contactPositionTable,
1763 bool parallelExecute);
1876 friend class AvalancheController;
1882 friend class TerrainMaterialController;
1899 friend class
agx::InternalData;
1903 agx::Referenced* getInternalData() const;
1908 void setInternalData(
agx::Referenced* data );
1912 agxCollide::HeightFieldRef m_surfaceHeightField;
1913 agxCollide::HeightFieldRef m_particleHeightField;
1914 agx::Real m_voxelSize;
1916 agx::UniformRealGenerator m_generator;
1917 float m_nominalSoilParticleRadius;
1920 agx::AffineMatrix4x4 m_transform;
1921 agx::AffineMatrix4x4 m_invTransform;
1922 agx::AffineMatrix4x4 m_voxelSpaceTransform;
1923 agx::AffineMatrix4x4 m_invVoxelSpaceTransform;
1924 agx::Vec3 m_voxelFieldOffset;
1926 TerrainDataAtlasRef m_terrainDataAtlas;
1928 TerrainMaterialControllerRef m_materialController;
1931 AvalancheControllerRef m_avalancheController;
1934 GroundCollapse::GroundCollapseControllerRef m_collapseController;
1936 agx::MaterialRef m_particleMaterial;
1937 agx::MaterialRef m_aggregateMaterial;
1939 agx::ContactMaterialRef m_terrainParticleContactMaterial;
1940 agx::ContactMaterialRef m_terrainAggregateContactMaterial;
1941 agx::ContactMaterialRef m_particleParticleContactMaterial;
1945 size_t m_noMergeEdgeMargin;
1948 agx::HashTable<
agx::Vec3i,
Shovel*> m_voxelIndexToShovelPtr;
1950 agx::HashTable<
Shovel*,
agx::Vec3iVector> m_voxelsInPrimaryActiveZoneLastTimeStep;
1951 agx::Vec3iVector m_dirtyVoxelIndices;
1952 agx::Real32Vector m_removedOccupancy;
1953 agx::Real m_lastRemovedVolume;
1962 size_t m_numCreatedParticles;
1963 float m_averageSoilParticleRadius;
1970 agx::IndexVector m_particlesInContactWithSurface;
1971 agx::HashTable <
agx::Vec2i,
agx::Vec4> m_contactPositionTable;
1976 agx::HashTable<
agx::Vec2i,
agx::Real> m_columnParticleHeight;
1977 agx::HighAccuracyTimer m_timer;
1979 agx::IndexLambdaKernelRef m_indexKernel;
1981 bool m_isTerrainPagerTile;
1985 agx::RealVector m_tanReposeAngles;
1994 agx::TaskRef m_buildIslandsTask;
1995 agx::TaskGroupRef m_preCollideUpdateTask;
1996 agx::TaskRef m_sortParticlesToVoxelsTask;
1997 agx::TaskRef m_sortParticlesToColumnsTask;
1998 agx::TaskRef m_calculateShovelVoxelIntersection;
1999 agx::TaskRef m_convertSolidToDynamicMassTask;
2001 agx::ParallelTaskRef m_updateHeightfieldsTask;
2002 agx::Job m_updateHeightfieldsJobs[2];
2003 agx::ParallelTaskRef m_voxelCollisionTask;
2004 agx::ParallelTaskRef m_geometryFilterTask;
2009 bool m_enableFluidMerge;
2013 agx::ref_ptr<
agx::Referenced> m_internalData;
2020 inline TerrainDataAtlas*
Terrain::getTerrainDataAtlas()
const
2022 return m_terrainDataAtlas;
2027 return m_materialController->getDefaultTerrainMaterial();
2033 return m_materialController->getDefaultTerrainMaterial();
2039 auto voxelIndex = getVoxelIndexFromWorldPosition(position);
2040 return m_materialController->getTerrainMaterial(voxelIndex);
2044 inline size_t Terrain::getResolutionX()
const
2046 return m_surfaceHeightField->getResolutionX();
2050 inline size_t Terrain::getResolutionY()
const
2052 return m_surfaceHeightField->getResolutionY();
2065 return m_voxelSpaceTransform;
2072 return m_invVoxelSpaceTransform;
2086 return m_invTransform;
2090 inline agx::Vec3i Terrain::getSurfaceVoxelIndexFromTerrainIndex(
const agx::Vec2i& terrainIndex)
const
2092 auto solidGrid =
static_cast<ColumnHeightGrid*
>(m_terrainDataAtlas->getGridMassOccupancyData(TerrainDataAtlas::MassType::SOLID));
2093 int voxelHeight = solidGrid->getSurfaceHeightIndex(terrainIndex);
2095 return agx::Vec3i( terrainIndex.
x(), terrainIndex.
y(), voxelHeight);
2098 inline bool Terrain::getIsTerrainPagerTile()
const
2100 return m_isTerrainPagerTile;
2103 inline bool Terrain::getDeformable()
const
2105 return m_properties->getEnableDeformation();
2110 inline bool Terrain::getEnableMinimumHeights()
const
2112 return m_terrainDataAtlas->getEnableMinimumHeights();
2116 inline void Terrain::setEnableMinimumHeights(
bool enable)
2118 m_terrainDataAtlas->setEnableMinimumHeights(enable);
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Axis aligned bounding box implementation.
The geometry representation used by the collision detection engine.
A HeightField is a collision shape that can be created from a grid structure, like an image.
Utility color class with "common colors".
static agxRender::Color White()
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
bool add(agx::Material *material)
Add a material to the simulation.
agxTerrain::Terrain instance in a simulation, receiving step and contact callbacks in a controllable ...
Pure virtual interface class for the data storage grid classes we have.
Controller that handles compaction in the terrain from generated terrain contacts in TerrainContactGe...
Class for specifying a 3D bound where terrain operations like merging and avalanching is forbbiden.
Base abstract class for specifying different types of bounds bound where terrain operations like merg...
Shovel object used to interact with a terrain via an active zone that converts solid terrain to dynam...
Interface class for accessing data and functions for the internal soil particle simulation used in ag...
The TerrainCache is used internally by the TerrainPager to provide requested terrain tiles.
Interface class for accessing and manipulating the underlying 3D grid data in the terrain using terra...
Class that handles and sanity checks the mass logic in the terrain.
This class is used to describe the general material properties of the Terrain.
Utility class where most of the physics calculation used in agxTerrain is gathered.
Class for containing and managing the different agxTerrain::Terrain settings.
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
void triggerForceAvalancheAll()
Triggers initial avalanching on all indices in the terrain.
bool exchangeTerrainMaterial(TerrainMaterial *oldTerrainMaterial, TerrainMaterial *newTerrainMaterial)
Exchange an already added TerrainMaterial with another TerrainMaterial without changing its associate...
void addModifiedParticleTerrainIndex(const agx::Vec2i &terrainIndex)
float convertParticlesToSolidMass(agx::Vec3i voxel, ParticleWeightPairVector particles, float occupancyToRemove, agx::Vec3iVector &changedIndices)
agx::ContactMaterial * getContactMaterial(Terrain::MaterialType type1, Terrain::MaterialType type2)
Returns one of the internal contact materials in agxTerrain.
void mergeSoilToExcavationEdge()
bool removeVolumeInShape(agxCollide::Shape *shape)
Instantly removes a terrain volume in the speficied shape.
void initializeFromHeightField()
bool getIntersectingActiveGridElements(agxCollide::Geometry *geometry, agx::Vec3iVector &gridPoints, MassType massType, bool onlyMidpoint=false) const
Get intersecting 3D grid element with specified geometry that is active/occupied with a specified mas...
float convertParticleRadiusToOccupancy(float radius) const
static TerrainPtrVector findAll(const agxSDK::Simulation *simulation)
Finds all terrains in the given simulation.
agx::Real convertFluidOccupancyToMass(agx::Real occupancy) const
agx::Vec3 getSurfacePosition(const agx::Vec2i &terrainIndex, bool includeSurfaceParticles=false) const
Finds the terrain surface position, given in local coordinate frame, for a specified terrain index.
bool getNoMerge()
Return whether this terrain is prevented from merging dynamic mass to it.
agx::Real convertFluidMassToOccupancy(agx::Real mass) const
void postUpdateCompaction()
void updateSurfaceHeightFieldFromVoxelIndices(const agxData::LocalVector< agx::Vec3i > &updateIndices)
void preSortSynchronizeParticleHeightField()
bool getSurfaceVoxel(const agx::Vec3i &voxelIndex, agx::Vec3i &result) const
float getParticleNominalRadius() const
Get the soil particle nominal radius from the simulation.
AvalancheController * getAvalancheController() const
agx::Bool projectPointToSurfaceInDirection(const agx::Vec3 &worldPosition, const agx::Vec3 &worldDirection, agx::Vec3 &result) const
Project a world point to the grid surface in a given direction.
void convertVoxelsInActiveZonesToDynamicMass()
agx::Real getTanReposeAngle(agx::Vec2i xy) const
Utility method for getting the tangent of the repose angle for a given terrain surface coordinate.
void moveParticlesToSurface(agx::Vec3iVector changedVoxelIndices)
agx::Vec3iVector mergeSoilInColumnToVoxel(agx::Vec3i topVoxel, size_t numVoxelsToSurfaceThreshold, agx::Plane cuttingPlane)
void setMinimumHeight(const agx::Vec2i &terrainIndex, agx::Real minimumHeight)
Set the minimum height allowed at the specified terrain index.
void convertToDynamicMassInShape(agxCollide::Shape *shape)
Converts the terrain occupancy that overlaps the specified shape into dynamic mass.
bool loadLibraryMaterial(const agx::String &materialName)
Loads a TerrainMaterial preset in the TerrainMaterialLibrary that contains calibrated bulk and contac...
bool hasMultipleTerrainMaterials() const
void sortParticlesIntoVoxels()
agx::HashVector< agx::Vec2i, agx::Int > getShovelHeightPerColumn()
float convertOccupancyToParticleRadius(float occupancy) const
static TerrainMaterial * getMaterialFromFile(const agx::String &filename)
Load a TerrainMaterial from a specification file in JSON data format.
agx::HashTable< agx::Vec3i, agx::UInt64Vector > sortParticlesIntoBins(int binVoxels)
void initVoxelStructureFromHeightField(bool adjustForCompaction=false)
static agx::StringVector getAvailableLibraryMaterials()
Get the available TerrainMaterial presets from the TerrainMaterialLibrary that contains calibrated bu...
bool indexIsInsideForbiddenBounds(const agx::Vec3i &terrainIndex, bool onlyUserDefined=false)
Check if the specified index is inside the forbidden bounds in the terrain.
bool setHeights(const agx::RealVector &heights, bool flipY=false, bool resetCompaction=true)
Set height values of all sampled points.
agx::Real calculateTotalMass() const
agx::RealVector getMaterialWeightsInGridPoints(const agx::Vec3iVector &gridPoints) const
Get the material weights in the terrain of the specified grid points.
bool _getIntersectingGridElements(BasicGrid *grid, agxCollide::Geometry *geometry, agx::Vec3iVector &gridPoints, bool isOccupied=true, bool onlyMidpoint=false) const
void calculateShovelVoxelIntersection()
agx::Vec3i goToSurfaceVoxel(const agx::Vec3i &start) const
agx::Real getLastExcavatedVolume() const
agx::Vec3 transformPointToVoxelSpace(const agx::Vec3 point) const
Transform point given in world coordinate frame to local coordinate frame of this terrain.
void setHeight(const agx::Vec2i &terrainIndex, agx::Real height)
Sets Terrain height at a specific terrain grid node.
bool removeForbiddenBound(IForbiddenBound *bound)
Remove a ForbiddenBound from a terrain that prevents merging and avalanching for the indices and posi...
agx::Vec3 generateRandomSoilParticlePositionPerturbation(agx::Real maxDelta)
agx::Bool projectPointToSurface(const agx::Vec3 &worldPosition, agx::Vec3 &result) const
Project a world point to the grid surface.
void setTransform(const agx::AffineMatrix4x4 &transform)
Set the transform of this terrain.
void updateCachedMassProperties()
float removeFluidMassInGeometry(agxCollide::Geometry *geometry, float fluidMass)
Remove fluid mass (in kg, NOT occupancy) in the intersecting 3D grid element with specified geometry.
agx::Real traceGridSurfaceHeightFromVoxelIndex(const agx::Vec3i &index)
SoilParticlePtrVector calculateParticlesInContactWithSurfaceGraph(agxCollide::GeometryPtrVector &contactGeometries)
Terrain(size_t resolutionX, size_t resolutionY, agx::Real elementSize, const agx::RealVector &heights, const agx::RealVector &minimumHeights)
Constructor.
bool pointIsInsideForbiddenBounds(const agx::Vec3 &positionWorld, bool onlyUserDefined=false)
Check if the specified points is inside the forbidden bounds in the terrain.
agx::Quat generateRandomSoilParticleRotation()
SoilSimulationInterface * getSoilSimulationInterface() const
Get the soil particle system interface used to represent the dynamic mass in the terrain.
static TerrainPtrVector findAll(const agxSDK::Simulation *simulation, const agx::Name &name)
Find all terrains with given name.
agx::Real getVoxelArea() const
void initializeTanReposeAngles()
void preUpdateTerrainContacts()
bool isSolidBoundaryVoxel(const agx::Vec3i &index) const
voxel functions
agx::RealVector getMaterialWeightsInLine(const agx::Line &line) const
Get the material weights in the terrain of the voxels that intersect the specified line.
bool isBorderIndex(const agx::Vec2i &terrainIndex) const
Checks if the specified index is at the border of the terrain.
void setCompaction(agx::Real compaction, bool replaceCompactedSoil=true) const
Set a compaction for all current active solid grid elements in the Terrain object.
agx::Vec3 getPosition() const
void updateInternalTransforms()
bool setMinimumHeights(const agx::RealVector &minimumHeights)
Set the minimum height values in the terrain grid.
void updateSurfaceHeightFieldFromIndicesAndHeights(agx::Vec2uVector &hfIndices, agx::RealVector &hfHeights)
bool isSubmergedVoxel(const agx::Vec3i &index) const
const agxCollide::HeightField * getSoilParticleBoundedHeightField() const
Get the soil particle height field consisting of the highest point of either the terrain surface or t...
void updateSurfaceHeightFieldFromVoxelIndices(const agx::Vec3iVector &updateIndices, bool updateParticleHeightField=true)
void updateTanReposeAngles()
float getDynamicMassCompaction(const agx::Vec3i &voxelIndex) const
void moveEntityDataToCurrentThread()
void debugRenderContactGeometryVoxels()
agx::AffineMatrix4x4 getInverseTransform() const
agx::Vec3i goToBoundaryVoxel(const agx::Vec3i &start) const
bool hasOverlap(const agxCollide::Geometry *geometry) const
Return true if the specified geometry bounding volume overlaps the terrain geometry bounding volume.
bool voxelColumnHasParticles(const agx::Vec2i &vertex) const
void sanityCheckHeightFieldAgainstMaxDepth()
void addDirtyVoxelsToAvalanche()
ForbiddenBound * addNoMergeZoneToGeometry(agxCollide::Geometry *geometry, const agxCollide::BoundingAABB &bound, const agx::AffineMatrix4x4 &localTransform)
Utility method for creating a forbidden bound that follow the transformation of a specified geometry.
agx::Real calculateTotalDynamicMass() const
void postUpdateGroundCollapse()
void createFluidMassOnTerrainSurface(const agx::Vec2i &terrainIndex, int surfaceVoxelOffset, agx::Real32 amount)
agx::Real getMinimumAllowedHeight() const
agx::Vec3 getValidParticlePosition(const agx::Real radius, const agx::Vec3i &index, const agx::Vec3 &pos)
agx::Vec3 getUpDirection() const
Returns the world up direction of the terrain.
agx::Vec3 transformVectorToTerrain(const agx::Vec3 vector) const
Transform vector given in world coordinate frame to local coordinate frame of this terrain.
const agxCollide::HeightField * getHeightField() const
bool isFilledSolidVoxel(const agx::Vec3i &index) const
bool hasVoxelCompaction(const agx::Vec3i &index) const
size_t getMemoryUsage()
Returns the memory usage in bytes in agxTerrain.
agx::Real getVoxelVolume() const
const ModifiedVerticesVector & getModifiedParticleVertices() const
Returns the modified terrain height field (including particles) vertices during the last time step.
agx::Real calculateVolume() const
void createParticleIslands(ParticleIslandVector &particleIslands)
void updateIndicesForAvalanche(TerrainIndexSet &forbiddenVertices)
agx::Real getMergeSpeedSquared() const
void resizeOrRemoveParticles(const agx::HashTable< SoilParticlePtr, std::array< agx::Real, 2 > > &particlesToUpdate)
void updateSurfaceHeightFieldFromDirtyVoxels()
void removeEmptyTerrainMaterialVoxels()
Removes terrain material info from the empty voxels that was modified during this pre step.
bool isIndexWithinBounds(const agx::Vec2i &terrainIndex) const
Checks if the specified index is within bound of the terrain [(0,0) -> (resolutionX,...
void storeModifiedTerrainIndex(const agx::Vec2i &terrainVertex)
void updateTransformationFromParentBody()
agx::Material * getAssociatedMaterial(TerrainMaterial *terrainMaterial) const
Returns the associated material with the given terrainMaterial.
void setTerrainMaterial(TerrainMaterial *terrainMaterial, agx::Material *material=nullptr)
Set the default terrain material for the bulk of the terrain which is used to derive material and con...
agx::Real findNewHeightFromVoxelIndex(const agx::Vec3i &index)
void removeModifiedParticleVertice(agx::Vec2i terrainIndex)
Removes a vertex from the vector with vertices that were modified during the last time step.
Terrain(size_t resolutionX, size_t resolutionY, agx::Real elementSize, const agx::RealVector &heights, bool flipY, agx::Real maximumDepth)
Constructor.
TerrainProperties * getProperties() const
TerrainIndexSet findTerrainIndices(agxTerrain::SoilParticlePtrVector &particles)
bool isWorldPositionWithinBounds(const agx::Vec3 &position) const
Checks whether the position is within terrain (x,y) position bounds in world space.
bool getIntersectingGridElements(agxCollide::Geometry *geometry, agx::Vec3iVector &gridPoints) const
Get intersecting 3D grid element with specified geometry.
void convertRemovedOccupancyToDynamicMass()
agx::Real calculateSurfaceHeightFromVoxelIndex(const agx::Vec3i &voxelIndex)
void postSortSynchronizeParticleHeightField()
agx::Real calculateTotalSolidMass() const
static agx::Real getTerrainParticlePackingRatio()
void applyFluidMassChanges(agx::HashTable< agx::Vec3i, float > &fluidMassTable)
void computeForbiddenBounds()
bool isVoxelWithinTerrainIndexBounds(const agx::Vec3i &index) const
void updateSurfaceHeightFieldFromHeightsTable(agx::HashTable< agx::Vec2i, std::pair< agx::Vec3i, agx::Real > > &table)
bool addTerrainMaterial(TerrainMaterial *terrainMaterial)
Add a non default TerrainMaterial to the terrain instance, without designating its domain.
agx::Real getTotalSoilParticleMass() const
Get the total mass (kg) of the active soil particles in the simulation.
void calculateFluidMassTransport(agx::HashTable< agx::Vec3i, float > &fluidMassTable)
void createFluidMassInVoxel(const agx::Vec3i &voxelIndex, agx::Real32 amount)
agx::Real calculateTotalFluidMass() const
int addTerrainMaterial(TerrainMaterial *terrainMaterial, agxCollide::Geometry *geometry)
Add a non default TerrainMaterial to the designated region bounded by the overlap between the terrain...
agx::TaskGroupRef createTask_preCollide()
void resizeSoilParticles()
ExternalDeformerPtrVector getExternalDeformers() const
Return the external deformers currently added in the simulation.
void updateOccupancyFromHeightChange(const agx::Vec2i &heightFieldIndex)
bool loadMaterialFile(const agx::String &filename)
Load a TerrainMaterial from a specification file in JSON data format.
TerrainProperties * getProperties()
size_t getNumCreatedParticles() const
Return the number of soil particles created during excavation this time step.
void renderVoxelAABB(agx::Vec3i index, agx::Vec4f color)
void setDeformable(bool deformable)
Sets if deformation should be enabled on this terrain.
void computeParticleGrowthTables(const agx::UInt64Vector &particleIndices, ParticleDeltaVector &particles)
TerrainContactPtrVector getTerrainContactsPtrVector() const
void debugRenderForbiddenBounds()
agx::Real getMinimumHeight(const agx::Vec2i &terrainIndex) const
Gets the minimum height allowed at the specific terrain index.
agx::Real getAverageSoilParticleRadius() const
void createSoilParticles()
agx::Vec3 getSurfacePositionWorld(const agx::Vec2i &terrainIndex, bool includeSurfaceParticles=false) const
Finds the terrain surface world position for a specified terrain index.
std::function< bool(const agx::Vec3i &index)> GoToStopCondition
static Terrain * find(const agxSDK::Simulation *simulation, const agx::Uuid &uuid)
Find terrain with given UUID.
bool shouldPrimaryActiveZoneRemoveMass(Shovel *shovel)
static TerrainMaterial * getLibraryMaterial(const agx::String &materialName)
Loads a TerrainMaterial preset in the TerrainMaterialLibrary that contains calibrated bulk and contac...
SoilParticleStatistics getSoilParticleStatistics() const
Get basic statistics of the soil particles active in the simulation.
Terrain(size_t resolutionX, size_t resolutionY, agx::Real elementSize, agx::Real maximumDepth)
Constructor.
const TerrainContactRefVector & getTerrainContacts() const
bool isLocalPositionWithinBounds(const agx::Vec3 &position) const
Checks whether the position is within terrain (x,y) position bounds in local space.
static Terrain * find(const agxSDK::Simulation *simulation, const agx::Name &name)
Find first terrain with given name.
void initializeSurfaceHeightFieldFromVoxelGrid()
void enforceIncompressibilityColumnwise()
void setNoMerge(bool noMerge)
Prevent merge of dynamic mass to this terrain.
agx::Vec3 transformVectorToWorld(const agx::Vec3 vector) const
Transform vector given in local coordinate frame of this terrain, to world coordinate frame.
agx::Material * getMaterial(Terrain::MaterialType type=Terrain::MaterialType::TERRAIN) const
Returns one of the internal materials in agxTerrain: MaterialType::TERRAIN - The internal material us...
bool particleIslandShouldMerge(const agx::Vector< std::pair< agx::Vec3i, offsetIndexInfo > > &island)
bool findSurfaceVoxel(const agx::Vec3i &index, agx::Vec3i &result) const
void mergeParticleIslands(const ParticleIslandVector &particleIslands, agxData::LocalVector< agx::Vec3i > &mergedParticleIndices)
void sampleParticleMassVelocity()
void clearTerrainMaterials(bool clearAddedMaterials=true)
Remove all traces of added terrain materials.
TerrainGridControl * getTerrainGridControl() const
Get control interface of the terrain grid data.
static agx::Bool getEnableKinematicForParticles(const agx::RigidBody *rb)
void removeSoilParticlesOutsideTerrainBounds()
void sortParticlesIntoColumns()
void markVoxelToAvalanche(const agx::Vec3i &changedVoxel)
agx::Quat getRotation() const
agx::Vec2 getSize() const
Returns the total surface size of he terrain in X Y coordinate system.
void sanitizeMaxDepthData()
void traceGridSurfaceVoxel(const agx::Vec2i &terrainIndex, agx::Vec3i &surfaceVoxel) const
void mergeSoilParticlesAndFluidMass()
void updateSurfaceHeightFieldFromVoxelIndex(const agx::Vec3i &voxelIndex)
static agx::Bool isTerrainGeometry(const agxCollide::Geometry *geometry)
bool shouldExternalDeformerActiveZoneRemoveMass(agx::RigidBody *deformerBody, DeformerCollection *deformerCollection)
void growSmallParticlesFromParticleMass(ParticleDeltaVector &particles, float particleRadiusUpperLimit)
static void setEnableKinematicForParticles(agx::RigidBody *rb, agx::Bool enable)
Enable/disable particles to see this rigid body as kinematic regardless of current motion control.
bool removeTerrainMaterial(TerrainMaterial *terrainMaterialToRemove)
Remove an added terrain material, its assigned domain will also be removed along with it.
agx::Real generateRandomNumber()
bool shouldDeformerActiveZoneRemoveMass(Shovel *shovel, DeformerCollection *deformerCollection)
void setRotation(const agx::Quat &rotation)
Set the rotation of this terrain.
void growParticlesFromFluidMass(agx::Vec3i binIndex, int binVoxels, float availableFluidMass, ParticleDeltaVector &particles)
const ModifiedVerticesVector & getModifiedVertices() const
Returns the modified terrain height field vertices during the last time step.
TerrainContactRefVector * getTerrainContactsVector() const
void filterParticlesAboveContactGeometryVoxels(agx::HashTable< agx::Vec2i, agx::Vec4 > &contactPositionTable, agxTerrain::SoilParticlePtrVector &particles)
bool findPathToSurfaceVoxel(const agx::Vec3i &startVoxel, std::deque< agx::Vec3i > &result)
agx::Vec3i goToVoxelKernel(const agx::Vec3i &start, const GoToStopCondition &stopCondition) const
void setPosition(const agx::Vec3 &position)
Set the position of this terrain.
const ModifiedVerticesVector & getParticleVertices() const
Returns the terrain vertices that contains soil particles during the last time step.
void setEnable(bool enable)
Set if terrain computations should be enabled.
IForbiddenBoundPtrVector getForbiddenBounds()
agx::Vec3 transformPointToTerrain(const agx::Vec3 point) const
Transform point given in world coordinate frame to local coordinate frame of this terrain.
bool setAssociatedMaterial(TerrainMaterial *terrainMaterial, agx::Material *material)
Set the associated material with the given TerrainMaterial.
void setProperties(TerrainProperties *properties)
Set the TerrainProperties of the Terrian object.
void iterateOverSolidVoxels(F &&func) const
Traverses all solid voxels in the terrain and invokes the provided callable once per voxel with its i...
agx::Vec3 transformPointToWorld(const agx::Vec3 point) const
Transform point given in local coordinate frame of this terrain, to world coordinate frame.
agx::RealVector getResizedHeightField(size_t factorX, size_t factorY) const
Calculate a reduced version of the height field structure.
static Terrain * createFromHeightField(const agxCollide::HeightField *heightField, agx::Real maximumDepth)
Creates a terrain object by using an existing height field as a basis.
void initBuildIslandTask()
void raytraceColumns(agxCollide::GeometryPtrVector geometries, agx::HashTable< agx::Vec2i, agx::Vec4 > &contactPositionTable, const TerrainIndexSet &columnTerrainIndices, bool parallelExecute)
void addNeighbours(agxData::LocalVector< agx::Vec3i > &indexQueue, agx::Vec3i index)
Terrain(agxCollide::HeightField *heightField, agx::Real maximumDepth)
size_t getNumSoilParticles() const
Return the number of soil particles active in the simulation.
bool addForbiddenBound(IForbiddenBound *bound)
Add a ForbiddenBound to a terrain that prevents mergining and avalanching for the indices and positio...
void growLargeParticlesFromParticleMass(ParticleDeltaVector &particles, float particleRadiusUpperLimit)
agx::RealVector getMinimumHeights() const
Return row major array with dimension (resolutionX * resolutionY) with the minimum height allowed in ...
virtual agxCollide::Geometry * getGeometry() const override
void setNoMergeEdgeMargin(size_t noMergeEdgeMargin)
Add disable merge and avalanche a number of indices from the terrain edge.
agx::Real getHeight(const agx::Vec2i &terrainIndex, bool includeSurfaceParticles=false) const
Gets the terrain height at a specific terrain grid node.
ShovelPtrVector getShovels() const
Return the shovels currently added in the simulation.
agx::Bool isIndexWithinBoundsIssueWarning(const agx::Vec2i &terrainIndex) const
void setMaterial(agx::Material *material, Terrain::MaterialType type=Terrain::MaterialType::TERRAIN)
Assign new material to this terrain.
agx::Vec2i getClosestGridPoint(const agx::Vec3 &worldPosition, bool clampToBound=false) const
Finds the closes terrain grid point given any point in world.
agx::AffineMatrix4x4 getTransform() const
Inheritance with partial specialization due to bug with ref_ptr containers.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Inheritance with partial specialization due to bug with ref_ptr containers.
Main material class which acts as a holder of a Surface Material and a Bulk material.
Representation of a name string.
Pointer to a entity instance of type Physics.GranularBody.
Pointer to a entity instance of type Physics.Particle.
Class representing the mathematical concept of a plane, also called a half- space.
The rigid body class, combining a geometric model and a frame of reference.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
A class holding 4 dimensional vectors and providing basic arithmetic.
Vector containing 'raw' data.
#define AGX_DEPRECATED(since)
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
#define AGX_DEPRECATED_FOR(since, replacement)
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
agx::SetVector< agx::Vec2i > ModifiedVerticesSetVector
agx::Physics::GranularBodyPtrVector SoilParticlePtrVector
std::pair< SoilParticlePtr, agx::Real > ParticleWeightPair
agx::Vector< ParticleWeightPair > ParticleWeightPairVector
agx::Vector< std::pair< SoilParticlePtr, float > > ParticleDeltaVector
agx::HashTable< agx::Vec3i, ParticleWeightPairVector > IndexToParticleWeightPairVector
agx::Physics::GranularBodyPtr SoilParticlePtr
agx::Vector< agx::Vec2i > ModifiedVerticesVector
agx::HashSet< agx::Vec3i > VoxelIndexSet
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::UInt groundParticleIndex