189 void setCompaction(
agx::Real compaction,
bool replaceCompactedSoil=
true )
const;
212 void setEnable(
bool enable );
218 bool getEnable()
const;
224 void setPosition(
const agx::Vec3& position);
235 void setRotation(
const agx::Quat& rotation);
297 void setNoMergeEdgeMargin(
size_t noMergeEdgeMargin);
302 void setNoMerge(
bool noMerge);
344 void removeModifiedParticleVertice(
agx::Vec2i terrainIndex);
360 size_t getResolutionX()
const;
365 size_t getResolutionY()
const;
377 size_t getMemoryUsage();
382 agx::Real getMinimumAllowedHeight()
const;
390 agx::Vec3 getSurfacePosition(
const agx::Vec2i& terrainIndex,
bool includeSurfaceParticles =
false)
const;
398 agx::Vec3 getSurfacePositionWorld(
const agx::Vec2i& terrainIndex,
bool includeSurfaceParticles =
false)
const;
406 agx::Vec2i getClosestGridPoint(
const agx::Vec3& worldPosition,
bool clampToBound=
false)
const;
422 bool isBorderIndex(
const agx::Vec2i& terrainIndex)
const;
429 bool isIndexWithinBounds(
const agx::Vec2i& terrainIndex)
const;
436 bool isWorldPositionWithinBounds(
const agx::Vec3& position)
const;
443 bool isLocalPositionWithinBounds(
const agx::Vec3& position)
const;
458 agx::Real getHeight(
const agx::Vec2i& terrainIndex,
bool includeSurfaceParticles =
false)
const;
468 agx::Real calculateTotalSolidMass()
const;
473 agx::Real calculateTotalFluidMass()
const;
478 agx::Real calculateTotalDynamicMass()
const;
498 bool remove(
Shovel* shovel);
503 const TerrainToolCollectionRefVector& getToolCollections()
const;
514 ShovelRefVector getShovels()
const;
590 agx::Real getLastExcavatedVolume()
const;
597 bool isDigging(
const Shovel* shovel)
const;
620 bool contains(
const Shovel* shovel)
const;
694 bool loadLibraryMaterial(
const agx::String materialName );
708 bool loadMaterialFile(
const agx::String& filename );
720 bool setShovelAggregateContactMaterial(
const Shovel* shovel,
744 bool setHeights(
const agx::RealVector& heights,
bool flipY =
false,
bool resetCompaction =
true );
750 void triggerForceAvalancheAll();
759 agx::RealVector getResizedHeightField(
size_t factorX,
size_t factorY)
const;
780 agx::Real getTotalSoilParticleMass()
const;
790 const TerrainContactRefVector& getTerrainContacts()
const;
822 MassType massType )
const;
841 float getParticleNominalRadius();
846 size_t getNumSoilParticles()
const;
852 size_t getNumCreatedParticles()
const;
874 size_t getNumActiveVoxels();
877 size_t getNumModifiedVoxels();
886 bool verifyMassColumnIntegrity(const agx::
Vec2i& terrainIndex);
891 bool isVoxelIndexBelowMaximumDepth(const agx::
Vec3i& index) const;
899 agx::
Line transformLineToTerrain(const agx::
Line& line) const;
907 agx::
Line transformLineToWorld(const agx::
Line& line) const;
912 bool isVoxelIndexInsideGeometryBound(const agx::
Vec3i& index) const;
917 bool isBorderIndexAndBordersLocked(const agx::
Vec2i& terrainIndex) const;
923 virtual
void runBuildIslandsTask() override;
925 void clearAllSoilParticles();
934 float addFluidMassToColumn(const agx::
Vec2i& terrainIndex,
float fluidMass) const;
943 float removeFluidMassFromColumn(const agx::
Vec2i& terrainIndex,
float fluidMass);
952 float addFluidMass(const agx::
Vec3i& voxelIndex,
float fluidMass) const;
961 float removeFluidMass(const agx::
Vec3i& voxelIndex,
float fluidMass);
969 agx::
Real calculateFluidOccupancy() const;
977 agx::
Real getTotalSoilParticleOccupancy() const;
984 agx::
Vec3 getLocalPositionFromVoxelIndex(const agx::
Vec3i& voxelIndex) const;
991 agx::
Vec3 getWorldPositionFromVoxelIndex(const agx::
Vec3i& voxelIndex) const;
998 agx::
Vec3i getVoxelIndexFromLocalPosition(agx::
Vec3 position) const;
1005 agx::
Vec3i getVoxelIndexFromWorldPosition(const agx::
Vec3& position) const;
1012 agx::
Vec3i getSurfaceVoxelIndexFromTerrainIndex(const agx::
Vec2i& terrainIndex) const;
1019 agx::
Vec3 getSurfacePositionFromVoxelXY(const agx::
Vec2i& voxelXY) const;
1026 agx::
Vec3 getSurfacePositionWorldFromVoxelXY(const agx::
Vec2i& voxelXY) const;
1033 agx::
Vec2i getTerrainIndexFromVoxelIndexXY(const agx::
Vec2i& voxelXY) const;
1040 agx::
Vec2i getVoxelIndexXYFromTerrainIndex(const agx::
Vec2i& terrainIndex) const;
1047 agx::
Vec3i getSurfaceVoxelIndexFromVoxelXY(const agx::
Vec2i& voxelXY) const;
1054 bool voxelContainsShovel(const agx::
Vec3i& voxelIndex) const;
1062 bool hasCreatedParticle( agx::Physics::ParticlePtr particle ) const;
1071 bool hasSameParticleMaterial(agx::Physics::ParticlePtr particle) const;
1107 void adjustFluidMassInGrid(agx::
Vec3i binIndex,
int binVoxels,
float availableFluidMass,
float remainingFluidMass);
1111 bool voxelHasParticles(const agx::
Vec3i& voxelIndex) const;
1113 bool isForbiddenIndex(const agx::
Vec3i& index);
1115 void addTerrainIndexToAvalanche(const agx::
Vec2i& index);
1117 int getLowestAllowableVoxelIndexZ() const;
1119 agx::
Vec3 constructHeightFieldOffset() const;
1121 void setIsTerrainPagerTile(
bool isPagerTile);
1123 bool getIsTerrainPagerTile() const;
1125 bool hasEnabledToolCollections() const;
1127 bool shouldUpdateTerrain() const;
1129 bool hasParticlesInTerrain() const;
1131 void debugRenderFluidMass();
1144 virtual
void addNotification() override;
1149 virtual
void removeNotification() override;
1154 virtual
void preCollide() override;
1159 virtual
void pre() override;
1164 virtual
void post() override;
1169 virtual
void last() override;
1185 bool isSurfaceVoxel(
const agx::Vec3i& index)
const;
1186 bool isSolidBoundaryVoxel(
const agx::Vec3i& index)
const;
1187 bool isSubmergedVoxel(
const agx::Vec3i& index)
const;
1188 bool isSolidVoxel(
const agx::Vec3i& index)
const;
1189 bool isActiveSolidVoxel(
const agx::Vec3i& index)
const;
1190 bool hasVoxelCompaction(
const agx::Vec3i& index)
const;
1191 bool isVoxelWithinTerrainIndexBounds(
const agx::Vec3i& index)
const;
1193 bool findPathToSurfaceVoxel(
const agx::Vec3i& startVoxel, std::deque<agx::Vec3i>& result);
1198 void updateSurfaceHeightFieldFromDirtyVoxels();
1199 void updateSurfaceHeightFieldFromVoxelIndices(
const agx::Vec3iVector& updateIndices);
1201 void updateSurfaceHeightFieldFromVoxelIndex(
const agx::Vec3i& voxelIndex);
1202 void updateSurfaceHeightFieldFromHeightsTable(
agx::HashTable<
agx::Vec2i, std::pair<agx::Vec3i, agx::Real> >& table );
1204 agx::Real traceGridSurfaceHeightFromVoxelIndex(
const agx::Vec3i& index,
bool globalSearch =
false);
1206 void initializeSurfaceHeightFieldFromVoxelGrid();
1207 void initVoxelStructureFromHeightField(
bool adjustForCompaction =
false );
1208 void convertVoxelsInActiveZonesToDynamicMass();
1211 void convertRemovedOccupancyToDynamicMass();
1212 void createSoilParticles();
1214 void addDirtyVoxelsToAvalanche();
1215 void removeSoilParticlesOutsideTerrainBounds();
1216 void updateTransformationFromParentBody();
1217 void storeModifiedTerrainIndex(
const agx::Vec2i& terrainVertex );
1218 void addModifiedParticleTerrainIndex(
const agx::Vec2i& terrainIndex);
1224 bool _getIntersectingGridElements(
1228 bool isOccupied =
true)
const;
1230 void sortParticlesIntoVoxels();
1231 void sortParticlesIntoColumns();
1234 void preSortSynchronizeParticleHeightField();
1235 void postSortSynchronizeParticleHeightField();
1238 void sampleParticleMassVelocity();
1240 void preUpdateTerrainContacts();
1241 void postUpdateCompaction();
1243 void markVoxelToAvalanche(
const agx::Vec3i& changedVoxel);
1244 void postSolveShovels();
1245 void updateOccupancyFromHeightChange(
const agx::Vec2i& heightFieldIndex);
1247 void computeForbiddenBounds();
1248 void initializeFromHeightField();
1251 void resizeSoilParticles();
1254 void growSmallParticlesFromParticleMass(
ParticleDeltaVector& particles,
float particleRadiusUpperLimit);
1255 void growLargeParticlesFromParticleMass(
ParticleDeltaVector& particles,
float particleRadiusUpperLimit);
1258 void mergeSoilParticlesAndFluidMass();
1260 bool mergeFluidMass();
1267 void mergeSoilToCuttingEdge();
1273 void stepFluidMass();
1276 void enforceIncompressibilityColumnwise();
1279 void createFluidMassOnTerrainSurface(
const agx::Vec2i& terrainIndex,
int surfaceVoxelOffset,
agx::Real32 amount);
1282 float convertParticleRadiusToOccupancy(
float radius)
const;
1283 float convertOccupancyToParticleRadius(
float occupancy)
const;
1284 float getDynamicMassCompaction()
const;
1286 bool particleIslandShouldMerge(
const agx::Vector<std::pair<agx::Vec3i, offsetIndexInfo>>& island);
1287 bool voxelColumnHasParticles(
const agx::Vec2i& vertex)
const;
1289 void calculateShovelVoxelIntersection();
1298 agx::Quat generateRandomSoilParticleRotation();
1300 void debugRenderForbiddenBounds();
1301 void debugRenderShovelForbiddenBounds();
1309 void toolCollectionsPreCollide();
1311 void initBuildIslandTask();
1316 void moveEntityDataToCurrentThread();
1343 float m_nominalSoilParticleRadius;
1349 agx::Vec2i m_voxelToHeightFieldIndexSpaceOffset;
1368 TerrainToolCollectionRefVector m_toolCollections;
1372 size_t m_noMergeEdgeMargin;
1387 size_t m_numCreatedParticles;
1388 float m_averageSoilParticleRadius;
1403 bool m_isTerrainPagerTile;
1421 agx::Job m_updateHeightfieldsJobs[2];
1424 bool m_enableFluidMerge;
1430 position *= (1.0 / m_voxelSize);
1433 (
agx::Int)std::floor(position.
y() + 0.5),
1434 (
agx::Int)std::floor(position.
z() + 0.5));
1438 inline TerrainDataAtlas* Terrain::getTerrainDataAtlas()
const
1440 return m_terrainDataAtlas;
1446 return m_terrainMaterial;
1452 return m_surfaceHeightField->getResolutionX();
1458 return m_surfaceHeightField->getResolutionY();
1470 return voxelXY + m_voxelToHeightFieldIndexSpaceOffset;
1474 inline agx::Vec2i Terrain::getVoxelIndexXYFromTerrainIndex(
const agx::Vec2i& terrainIndex)
const
1476 return terrainIndex - m_voxelToHeightFieldIndexSpaceOffset;
1489 return m_invTransform;
1493 inline agx::Vec3i Terrain::getSurfaceVoxelIndexFromTerrainIndex(
const agx::Vec2i& terrainIndex)
const
1499 inline agx::Vec3 Terrain::getSurfacePositionFromVoxelXY(
const agx::Vec2i& voxelXY )
const
1505 inline agx::Vec3 Terrain::getSurfacePositionWorldFromVoxelXY(
const agx::Vec2i& voxelXY )
const
1511 inline bool Terrain::getIsTerrainPagerTile()
const
1513 return m_isTerrainPagerTile;
agxTerrain::Terrain instance in a simulation, receiving step and contact callbacks in a controllable ...
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Interface class for accessing and manipulating the underlying 3D grid data in the terrain using terra...
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Pointer to a entity instance of type Physics.GranularBody.
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks...
A class holding 4 dimensional vectors and providing basic arithmetic.
VectorPOD< Vec3i > Vec3iVector
Class for containing and managing the different agxTerrain::Terrain settings.
agx::Physics::GranularBodyPtrVector SoilParticlePtrVector
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
agx::VectorPOD< GeometryContact * > GeometryContactPtrVector
agx::Vector< agx::Vec2i > ModifiedVerticesVector
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...
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
#define AGX_DECLARE_POINTER_TYPES(type)
TerrainMaterial * getTerrainMaterial() const
Returns the terrain material which is used to derive material and contact material parameters...
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Representation of a name string.
agx::UInt groundParticleIndex
Class representing the mathematical concept of a plane, also called a half- space.
Pure virtual interface class for the data storage grid classes we have.
std::function< bool(const agx::Vec3i &index)> GoToStopCondition
This class is used to describe the general material properties of the Terrain.
agx::Physics::GranularBodyPtr SoilParticlePtr
agx::Vec3 getSurfacePositionWorld(const agx::Vec2i &terrainIndex, bool includeSurfaceParticles=false) const
Finds the terrain surface world position for a specified terrain index.
The geometry representation used by the collision detection engine.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Class that handles and sanity checks the mass logic in the terrain.
size_t getResolutionY() const
Returns the element resolution of the terrain in the local Y-axis.
Vector containing 'raw' data.
std::pair< SoilParticlePtr, agx::Real > ParticleWeightPair
The TerrainCache is used internally by the TerrainPager to provide requested terrain tiles...
agx::Real getElementSize() const
Returns the element size of a cell in agxTerrain, which is incidentally the distance between the cent...
agx::Vector< ParticleWeightPair > ParticleWeightPairVector
Controller that handles compaction in the terrain from generated terrain contacts in TerrainContactGe...
Utility class where most of the physics calculation used in agxTerrain is gathered.
size_t getResolutionX() const
Returns the element resolution of the terrain in the local X-axis.
agx::Vector< std::pair< SoilParticlePtr, float > > ParticleDeltaVector
const agx::AffineMatrix4x4 & _getTransform() const
#define AGXTERRAIN_EXPORT
The rigid body class, combining a geometric model and a frame of reference.
Main material class which acts as a holder of a Surface Material and a Bulk material.
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Interface class for accessing data and functions for the internal soil particle simulation used in ag...
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
agx::HashSet< agx::Vec3i > VoxelIndexSet
const agx::AffineMatrix4x4 & _getInverseTransform() const
static agx::Vec3 transformVectorToWorld(const agx::Vec3 &v, const agxCollide::Geometry *g)
Transforms a vector given in shape coordinates to world coordinates given geometry g...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
AGX_DECLARE_VECTOR_TYPES(ActiveZone)
agx::UInt shovelParticleIndex
agx::HashTable< agx::Vec3i, ParticleWeightPairVector > IndexToParticleWeightPairVector
static agx::Vec3 transformPointToWorld(const agx::Vec3 &p, const agxCollide::Geometry *g)
Transforms a point given in shape coordinates to world given geometry g.
Inheritance with partial specialization due to bug with ref_ptr containers.
agx::SetVector< agx::Vec2i > ModifiedVerticesSetVector
A HeightField is a collision shape that can be created from a grid structure, like an image...
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()