19#include <agx/config/AGX_USE_AGXTERRAIN.h>
321 inline bool getDeformable()
const;
380 size_t getResolutionX()
const;
386 size_t getResolutionY()
const;
1080 size_t getNumActiveVoxels() const;
1083 size_t getNumModifiedVoxels() const;
1092 bool verifyMassColumnIntegrity(const
agx::Vec2i& terrainIndex) const;
1097 bool isVoxelIndexBelowMaximumDepth(const
agx::Vec3i& index) const;
1105 agx::Line transformLineToTerrain(const
agx::Line& line) const;
1113 agx::Line transformLineToVoxelSpace( const
agx::Line& line ) const;
1121 agx::Line transformLineToWorld(const
agx::Line& line) const;
1126 bool isVoxelIndexInsideGeometryBound(const
agx::Vec3i& index) const;
1131 agx::AffineMatrix4x4 getVoxelSpaceTransform() const;
1136 bool isBorderIndexAndBordersLocked(const
agx::Vec2i& terrainIndex) const;
1140 TerrainDataAtlas* getTerrainDataAtlas() const;
1143 virtual
void runBuildIslandsTask() override;
1145 void clearAllSoilParticles();
1154 float addFluidMassToColumn(const
agx::Vec2i& terrainIndex,
float fluidMass) const;
1163 float removeFluidMassFromColumn(const
agx::Vec2i& terrainIndex,
float fluidMass);
1172 float addFluidMass(const
agx::Vec3i& voxelIndex,
float fluidMass) const;
1181 float removeFluidMass(const
agx::Vec3i& voxelIndex,
float fluidMass);
1189 agx::Real calculateFluidOccupancy() const;
1197 agx::Real getTotalSoilParticleOccupancy() const;
1204 agx::Vec3 getLocalPositionFromVoxelIndex(const
agx::Vec3i& voxelIndex) const;
1211 agx::Vec3 getWorldPositionFromVoxelIndex(const
agx::Vec3i& voxelIndex) const;
1218 agx::Vec3i getVoxelIndexFromLocalPosition(const
agx::Vec3& position) const;
1225 inline
agx::Vec3i getVoxelIndexFromGridPosition(
agx::Vec3 position)
const
1227 return VoxelGridUtils::getVoxelIndexFromGridPosition(position, m_voxelSize);
1237 agx::Vec3i vi = getVoxelIndexFromGridPosition(position);
1261 void setForbiddenVoxelsForDynamicMass(
const agx::Vec3iVector& voxelIndices);
1268 bool getForbiddenVoxelsForDynamicMass(
agx::Vec3iVector& voxelIndices)
const;
1276 bool isForbiddenVoxelsForDynamicMass(
const agx::Vec3i& voxelIndex)
const;
1283 bool voxelContainsShovel(
const agx::Vec3i& voxelIndex)
const;
1307 TerrainMassOccupancyController* getMassOccupancyController()
const;
1314 TerrainMaterialController* getMaterialController()
const;
1316 void adjustFluidMassInGrid(
agx::Vec3i binIndex,
int binVoxels,
float availableFluidMass,
float remainingFluidMass);
1318 agx::Vec3iVector getVoxelsOccupiedByShovel(TerrainToolCollection *collection)
const;
1320 bool isPointSubmerged(
const agx::Vec3& point )
const;
1322 bool voxelHasParticles(
const agx::Vec3i& voxelIndex)
const;
1324 bool isForbiddenIndex(
const agx::Vec3i& index);
1326 void addTerrainIndexToAvalanche(
const agx::Vec2i& index);
1328 int getLowestAllowableVoxelIndexZ()
const;
1330 agx::Vec3 constructVoxelFieldOffset()
const;
1332 void setIsTerrainPagerTile(
bool isPagerTile);
1334 bool getIsTerrainPagerTile()
const;
1336 bool hasEnabledToolCollections()
const;
1338 bool shouldUpdateTerrain()
const;
1340 bool hasParticlesInTerrain()
const;
1342 void debugRenderFluidMass();
1346 bool isSolidVoxel(
const agx::Vec3i& index )
const;
1348 bool isActiveSolidVoxel(
const agx::Vec3i& index )
const;
1350 void markIndexAsModified(
const agx::Vec2i& terrainIndex );
1363 virtual
void addNotification() override;
1368 virtual
void removeNotification() override;
1373 virtual
void preCollide() override;
1378 virtual
void pre() override;
1383 virtual
void post() override;
1388 virtual
void last() override;
1446 bool isOccupied =
true)
const;
1458 agx::HashTable <agx::Vec2i, agx::Vec4>& contactPositionTable,
1460 bool parallelExecute);
1570 friend class AvalancheController;
1576 friend class TerrainMaterialController;
1596 float m_nominalSoilParticleRadius;
1605 TerrainDataAtlasRef m_terrainDataAtlas;
1607 TerrainMaterialControllerRef m_materialController;
1610 AvalancheControllerRef m_avalancheController;
1622 AvalancheController::TerrainIndexSet m_terrainIndicesToAvalanche;
1625 size_t m_noMergeEdgeMargin;
1642 size_t m_numCreatedParticles;
1643 float m_averageSoilParticleRadius;
1651 agx::HashTable <agx::Vec2i, agx::Vec4> m_contactPositionTable;
1661 bool m_isTerrainPagerTile;
1679 agx::Job m_updateHeightfieldsJobs[2];
1683 bool m_enableFluidMerge;
1689 inline TerrainDataAtlas* Terrain::getTerrainDataAtlas()
const
1691 return m_terrainDataAtlas;
1696 return m_materialController->getDefaultTerrainMaterial();
1702 return m_materialController->getDefaultTerrainMaterial();
1708 auto voxelIndex = getVoxelIndexFromWorldPosition(position);
1709 return m_materialController->getTerrainMaterial(voxelIndex);
1715 return m_surfaceHeightField->getResolutionX();
1721 return m_surfaceHeightField->getResolutionY();
1734 return m_voxelSpaceTransform;
1741 return m_invVoxelSpaceTransform;
1755 return m_invTransform;
1759 inline agx::Vec3i Terrain::getSurfaceVoxelIndexFromTerrainIndex(
const agx::Vec2i& terrainIndex)
const
1761 auto solidGrid =
static_cast<ColumnHeightGrid*
>(m_terrainDataAtlas->getGridMassOccupancyData(TerrainDataAtlas::MassType::SOLID));
1764 return agx::Vec3i( terrainIndex.
x(), terrainIndex.
y(), voxelHeight);
1767 inline bool Terrain::getIsTerrainPagerTile()
const
1769 return m_isTerrainPagerTile;
1774 return m_properties->getEnableDeformation();
#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)
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.
Only use as member allocated variable.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
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.
Class implementing the BasicGrid interface.
int getSurfaceHeightIndex(const agx::Vec2i terrainIndex)
Controller that handles compaction in the terrain from generated terrain contacts in TerrainContactGe...
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
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 initializeFromHeightField()
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.
void sanitizeMaxDepthData(agx::Real maximumDepth)
const agx::AffineMatrix4x4 & _getTransform() const
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
bool addNoMergeZoneToGeometry(agxCollide::Geometry *geometry, agx::Real extensionDistance)
Add disable merge and avalanche inside geometry bound with added extension distance.
float getParticleNominalRadius() const
Get the soil particle nominal radius from the simulation.
AvalancheController * getAvalancheController() const
void convertVoxelsInActiveZonesToDynamicMass()
bool getDeformable() const
Gets whether or not deformations are enabled for this terrain.
agx::Real getInnerVolume(const Shovel *shovel) const
void moveParticlesToSurface(agx::Vec3iVector changedVoxelIndices)
agx::Real getLastDeadLoadFraction(const Shovel *shovel) const
Get the last computed dead load fraction of the shovel, i.e how much of it's inner volume that is fil...
bool remove(Shovel *shovel)
Removes a shovel object in the terrain, if it exists.
void convertToDynamicMassInShape(agxCollide::Shape *shape)
Converts the terrain occupancy that overlaps the specified shape into dynamic mass.
bool contains(const Shovel *shovel) const
Check is a shovel object is registered in the terrain.
bool loadLibraryMaterial(const agx::String &materialName)
Loads a TerrainMaterial preset in the TerrainMaterialLibrary that contains calibrated bulk and contac...
void sortParticlesIntoVoxels()
agx::HashVector< agx::Vec2i, agx::Int > getShovelHeightPerColumn()
agx::Vec3 getAggregateTerrainTangentialForce(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the aggregate tangential force with the terrain given an excavation mode and a shovel.
agxCollide::GeometryContactPtrVector getShovelAggregateContacts(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the shovel <-> aggregate contacts with the terrain given an excavation mode and a shovel.
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)
agx::ContactMaterial * getShovelAggregateContactMaterial(const Shovel *shovel, Shovel::ExcavationMode mode=Shovel::ExcavationMode::PRIMARY) const
Get the explicitly set contact material in a shovel-aggregate contact corresponding to a specified ex...
void initVoxelStructureFromHeightField(bool adjustForCompaction=false)
static agx::StringVector getAvailableLibraryMaterials()
Get the available TerrainMaterial presets from the TerrainMaterialLibrary that contains calibrated bu...
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.
agx::Vec3 getDeformationContactForce(const Shovel *shovel) const
Given geometry contacts exists and the solver has solved them - calculates total contact force betwee...
void calculateShovelVoxelIntersection()
const agx::AffineMatrix4x4 & _getInverseTransform() const
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.
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.
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)
agx::Vec3 getExcavationModeContactForce(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
calculates total contact force between the soil aggregate associated with the specified excavation mo...
void mergeSoilToCuttingEdge()
agx::Quat generateRandomSoilParticleRotation()
void toolCollectionsPreCollide()
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 calculateVolume()
agx::Vec3 getSeparationFrictionForce(const Shovel *shovel) const
Given geometry contacts exists and the solver has solved them - calculates total contact friction for...
agx::Real getVoxelArea() const
void preUpdateTerrainContacts()
agx::Real getDynamicMass(const Shovel *shovel) const
bool isSolidBoundaryVoxel(const agx::Vec3i &index) const
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()
const TerrainToolCollectionRefVector & getToolCollections() const
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...
bool shouldPrimaryActiveZoneRemoveMass(TerrainToolCollection *toolCollection)
float getDynamicMassCompaction(const agx::Vec3i &voxelIndex) const
void debugRenderShovelForbiddenBounds()
bool removeNoMergeZoneToGeometry(agxCollide::Geometry *geometry)
remove disable merge and avalanche inside geometry bound with added extension distance
void moveEntityDataToCurrentThread()
agx::Real getAggregateTerrainContactArea(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the aggregate <-> terrain contact area given an excavation mode and a shovel.
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()
agx::Real getElementSize() const
Returns the element size of a cell in agxTerrain, which is incidentally the distance between the cent...
TerrainMaterial * getTerrainMaterial() const
Returns the default terrain material which is used to derive material and contact material parameters...
bool shouldDeformerActiveZoneRemoveMass(TerrainToolCollection *toolCollection, DeformerCollection *deformerCollection)
void updateSurfaceHeightFieldFromVoxelIndices(const agx::Vec3iVector &updateIndices)
agx::Real calculateTotalDynamicMass() const
bool isGeometryShovel(const agxCollide::Geometry *geometry) const
Checks if the specified geometry's rigid body is contained in any of the terrain object's registered ...
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 add(Shovel *shovel)
Adds a shovel object in the terrain.
bool hasVoxelCompaction(const agx::Vec3i &index) const
size_t getMemoryUsage()
Returns the memory usage in bytes in agxTerrain.
agx::Real getVoxelVolume() const
bool getPenetrationForce(const Shovel *shovel, agx::Vec3 &force, agx::Vec3 &torque) const
The result includes the active force and torque from the penetration resistance from the terrain on t...
const ModifiedVerticesVector & getModifiedParticleVertices() const
Returns the modified terrain height field (including particles) vertices during the last time step.
const agx::AffineMatrix4x4 & _getInvVoxelSpaceTransform() 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()
bool isDigging(const Shovel *shovel) const
Check if the specified shovel is currently in digging mode with the terrain, i.e if the cutting edge ...
bool isOfHomogeneousTerrainMaterial() const
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
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.
agx::Real getSoilAggregateMass(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Returns the total soil aggregate mass in a terrain given a shovel and a specific excavation mode.
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.
agx::Vec3 getAggregateTerrainContactForce(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the aggregate contact force with the terrain given an excavation mode and a shovel.
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()
agx::Vec3 getContactForce(const Shovel *shovel) const
Given geometry contacts exists and the solver has solved them - calculates total shovel contact force...
void applyFluidMassChanges(agx::HashTable< agx::Vec3i, float > &fluidMassTable)
void computeForbiddenBounds()
agx::Vec3f getVoxelVelocity(const agx::Vec3i &voxelIndex, agx::HashTable< agx::Vec3i, size_t > &shovelVoxels)
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)
const agx::AffineMatrix4x4 & _getVoxelSpaceTransform() const
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()
void updateOccupancyFromHeightChange(const agx::Vec2i &heightFieldIndex)
bool loadMaterialFile(const agx::String &filename)
Load a TerrainMaterial from a specification file in JSON data format.
ShovelRefVector getShovels() const
Return the shovels currently added in the terrain.
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)
agxCollide::GeometryContactPtrVector getAggregateTerrainContacts(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the aggregate <-> terrain geometry contacts given an excavation mode and a shovel.
void debugRenderForbiddenBounds()
void createSoilParticles()
agx::Vec3 getSurfacePositionWorld(const agx::Vec2i &terrainIndex, bool includeSurfaceParticles=false) const
Finds the terrain surface world position for a specified terrain index.
agx::Vec3 getSeparationContactForce(const Shovel *shovel) const
Given geometry contacts exists and the solver has solved them - calculates total contact force betwee...
std::function< bool(const agx::Vec3i &index)> GoToStopCondition
static Terrain * find(const agxSDK::Simulation *simulation, const agx::Uuid &uuid)
Find terrain with given UUID.
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.
bool getIntersectingActiveGridElements(agxCollide::Geometry *geometry, agx::Vec3iVector &gridPoints, MassType massType) const
Get intersecting 3D grid element with specified geometry that is active/occupied with a specified mas...
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)
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.
size_t getResolutionY() const
agx::Vec3 getSeparationNormalForce(const Shovel *shovel) const
Given geometry contacts exists and the solver has solved them - calculates total contact normal force...
void traceGridSurfaceVoxel(const agx::Vec2i &terrainIndex, agx::Vec3i &surfaceVoxel) const
void mergeSoilParticlesAndFluidMass()
void updateSurfaceHeightFieldFromVoxelIndex(const agx::Vec3i &voxelIndex)
agx::Vec3iVector mergeCuttingEdgeColumn(agx::Vec3i cuttingEdgeVoxel, size_t numVoxelsToSurfaceThreshold, agx::Plane cuttingPlane)
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)
agx::Real generateRandomNumber()
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.
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.
TerrainMaterial * getDefaultTerrainMaterial() const
Returns the default terrain material which is used to derive material and contact material parameters...
bool isSurfaceVoxel(const agx::Vec3i &index) const
Surface voxel functions.
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.
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)
TerrainToolCollection * getToolCollection(const Shovel *shovel) const
Terrain(agxCollide::HeightField *heightField, agx::Real maximumDepth)
size_t getNumSoilParticles() const
Return the number of soil particles active in the simulation.
bool isRigidBodyShovel(const agx::RigidBody *body) const
Checks if a specified rigid body is contained in any of the terrain object's registered shovels.
void growLargeParticlesFromParticleMass(ParticleDeltaVector &particles, float particleRadiusUpperLimit)
virtual agxCollide::Geometry * getGeometry() const override
bool _getIntersectingGridElements(BasicGrid *grid, agxCollide::Geometry *geometry, agx::Vec3iVector &gridPoints, bool isOccupied=true) const
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.
agx::Bool isIndexWithinBoundsIssueWarning(const agx::Vec2i &terrainIndex) const
size_t getResolutionX() const
agx::Vec3 getAggregateTerrainNormalForce(const Shovel *shovel, Shovel::ExcavationMode excavationMode) const
Get the aggregate normal force with the terrain given an excavation mode and a shovel.
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.
bool setShovelAggregateContactMaterial(const Shovel *shovel, agx::ContactMaterial *contactMaterial, Shovel::ExcavationMode mode=Shovel::ExcavationMode::PRIMARY)
Explicitly set contact material properties in a shovel-aggregate contact for a specific excavation mo...
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...
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks.
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 DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
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