17 #ifndef AGXMODEL_TERRAIN_H
18 #define AGXMODEL_TERRAIN_H
133 #if TERRAIN_USE_PARTICLE_SYSTEM
312 #if TERRAIN_USE_PARTICLE_SYSTEM
356 #if defined(USE_SOIL_PARTICLE_SIMULATION) && USE_SOIL_PARTICLE_SIMULATION == 1
360 SoilParticleSimulation* getParticleSimulation();
389 agx::Vec3 inHfPlaneOrthoVector = inHfPlaneVector - (inHfPlaneVector*normal) * normal;
393 agx::Real percentOfActual = inHfPlaneOrthoVector[variable]/inHfPlaneOrthoVector[variable];
395 agx::Real actualHeight = inHfPlaneOrthoVector.
z() / percentOfActual;
402 agx::Real planePosAtCoordinates = getHeight(hfPos.
x(), hfPos.
y());
403 return hfPos.
z() > (planePosAtCoordinates + particleRadius);
408 void prepareForContactModification();
413 SoilParticle* createParticle(
agx::Real radius );
414 SoilParticle* getParticle(
const size_t& x,
const size_t& y,
agxSDK::Simulation* simulation,
bool forDynamicHeightField );
416 void createTerrain();
420 void replaceDynamicHeightFieldParticles();
430 void createProjectedGeometryContact(
432 const agx::Vec3 gravityDirection,
const bool inGravityDirection,
const bool useGravityDepth);
439 #if TERRAIN_USE_PARTICLE_SYSTEM
442 bool validateParticleToMerge(SoilParticle* particle)
const;
453 void resetNoGrowIndices();
455 void updateAvalanceIndices(
size_t minX,
size_t maxX,
size_t minY,
size_t maxY);
467 void spreadAvalanche(
size_t indexHF,
const size_t vertexDistance );
481 bool isInsideNonMergeArea(
agx::Vec2i* coordinates );
486 bool isInsideNonMergeArea(
agx::Vec2i& coordinates );
503 #if TERRAIN_USE_PARTICLE_SYSTEM
506 bool mergeParticle( SoilParticle* particle );
509 void addGeometryContactsForAddedParticles(
SizeTPairVector& bodyIndexContactPairs,
511 size_t localX,
size_t localY,
const size_t sizeX,
const size_t sizeY
523 void mergeParticles();
528 void collectContacts();
533 void clearContacts();
552 VolumeOverlap changeHeights(
agx::Vector< size_t >& changedVertices,
const bool shrink =
true,
const bool volumeCalculation =
false,
const agx::Real compressionPercent =
agx::Real(0),
const bool onlyCompression =
true);
563 agx::Real calculateVolumeDiffAroundOneVertex(
size_t vectorIndex,
agx::Real compression = 0 );
576 size_t accumulateVerticesX(
agx::Vec3& meanPos,
agx::Vec3Vector& vertices,
agx::Vector<agx::RangeReal>& localChangedHeights,
const size_t minX,
const size_t minY,
const size_t sizeX,
const size_t sizeY,
const size_t localX,
const size_t localY,
const size_t maxNum);
585 class GeometryContactInfo;
600 bool isVisited(
const size_t vertexIndex )
const;
605 void setVisited(
const size_t vertexIndex );
610 void enqueueNeighbors( std::queue<size_t>& queue,
int x,
int y );
612 void updateTempCompression(
const size_t vertexIndex,
agx::Real deltaCompression);
613 void setTempCompression(
const size_t vertexIndex ,
agx::Real compression);
614 agx::Real getTempCompression(
const size_t vertexIndex)
const;
616 void notifyModifiedIndex(
const size_t x,
const size_t y,
const size_t currentIndex,
agx::Real& depth);
641 void setModifiedIndex(
size_t x,
size_t y );
655 bool m_useDynamicHeightField;
658 agx::Real m_verticalYoungsModulusAreaScaler;
659 agx::Real m_horizontalYoungsModulusAreaScaler;
666 size_t m_avalancheStepLifeTime;
667 size_t m_avalanceVertexDistanceExtent;
672 agx::Real m_shovelMinAngleToHorizontalPlane;
674 ParticleAttributes m_particleAttribute;
675 ParticleCoordinateSystem m_particleCoordinateSystem;
677 #if defined(USE_SOIL_PARTICLE_SIMULATION) && USE_SOIL_PARTICLE_SIMULATION == 1
690 #if TERRAIN_USE_PARTICLE_SYSTEM
712 size_t m_particlesLost;
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
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.
This class implements an interface for how the terrain accesses the data it needs to access data item...
agxCollide::Geometry * getGeometry() const
agx::Real getDynamicHeightFieldParticleRadius() const
const ParticleAttributes & getParticleAttributes() const
bool getEnableDynamicHeightField() const
agx::Real getDynamicHeightFieldCutOffAngularVelocity() const
bool isGeometryShovel(const agxCollide::Geometry *otherGeometry) const
agx::Real getWetnessScale() const
void setEnableLockedBorders(bool enable, bool triggerAvalancheMassLoss=true)
Fixate the height of the height field borders.
agx::Vec3 transformPointToWorld(const agx::Vec3 point) const
virtual void post(const agx::TimeStamp &) override
Finds terrain vertices to shrink, and thereby introduce particles at the correct positions.
void avalancheAll(size_t iterations)
Goes through all vertices 'iterations' times and triggers avalanches.
agx::Real getMaximumParticleRadius() const
void setVerticalYoungsModulusAreaScaler(agx::Real scaler)
Set the vertical Young's modulus area scaler.
Terrain(agxCollide::HeightField *heightField)
Constructor.
const agxCollide::HeightField * getHeightField() const
ParticleAttributes & getParticleAttributes()
void set(agxModel::TerrainDataInterface *dtdc)
Set TerrainDataInterface.
agx::Vec3 transformVectorToWorld(const agx::Vec3 vector) const
const DynamicHeightFieldSimulation * getDynamicHeightFieldSimulation() const
void setWetnessScale(agx::Real wetnessScaler)
Set the wetness scale.
void setDynamicHeightFieldCutOffVelocity(agx::Real cutOffVelocity)
Set the cut off (threshold) velocity for an activation of the dynamic height field functionality at a...
void setAvalancheDecayPercent(agx::Real scaler)
Set the avalanche decay percent.
virtual void pre(const agx::TimeStamp &) override
Function below must be public. But should not be called from external functions.
const SoilParticleRefVector & getRemovedParticles() const
void setEnableDynamicHeightField(bool enable)
Use a particle simulation to deform the terrain (replaces pure compression).
void setShovelMinimumDigAngleToHorizontalPlane(agx::Real angle)
Set the angle between the Shovel forward vector and the height field "up" direction (gravitational di...
Terrain(agxCollide::Geometry *terrainGeometry)
Constructor.
agx::Vec3 pointRelativeVelocityLocal(const agxCollide::Geometry *shovelGeometry, const agx::Vec3 pointWorld) const
Returns the relative velocity between the terrain and a point on a geometry.
void setHorizontalYoungsModulusAreaScaler(agx::Real scaler)
Set the horizontal Young's modulus area scaler.
agx::Real getShovelMinimumDigAngleToHorizontalPlane() const
virtual void removeNotification() override
Removes terrain geometry from space, but not simulation.
Terrain(const Terrain &original)
agxModel::TerrainDataInterface * getDataInterface() const
agx::Vec3 transformVectorToTerrain(const agx::Vec3 vector) const
agx::Real getVerticalYoungsModulusAreaScaler() const
bool isGeometryShovelMovingForward(const agxCollide::Geometry *otherGeometry, agx::Vec3 &shovelForwardW) const
agx::Real calculateShovelContactDepth(const agxCollide::Geometry *shovelGeometry, const agx::Vec3 normalLocal, const agx::Vec3 pointWorld) const
Finds the relative velocity between a point on the shovel and the Terrain, along the normalLocal dire...
agx::Real getHorizontalYoungsModulusAreaScaler() const
virtual void addNotification() override
Adds terrain geometry to simulation.
size_t getAvalancheVertexDistanceExtent() const
void setDynamicHeightFieldCutOffAngularVelocity(agx::Real cutOffAngularVelocity)
Set the cut off (threshold) angular velocity for an activation of the dynamic height field functional...
agx::Real getAvalancheDecayPercent() const
agx::Vec3 transformPointToTerrain(const agx::Vec3 point) const
Transform positions/vectors to/from terrain/world.
size_t getAvalancheStepLifeTime() const
agx::Real getDynamicHeightFieldCutOffVelocity() const
const agxModel::HeightController * getHeightController() const
void setAvalancheVertexDistanceExtent(size_t numVertices)
Set how many vertices away from a geometry with deform property an avalanche could be triggered.
void setAvalancheStepLifeTime(size_t numSteps)
Set the number of time steps the avalanche will continue at a vertex after the last time it was defor...
const agx::Vec2iVector & getModifiedIndices() const
virtual void setMaterial(agx::Material *material)
Set a material to the terrain geometry, which will be used for non material-mapped grid points.
const SoilParticleObsVector & getCreatedParticles() const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Derive from this class to implement a listener for simulation step events.
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.
A basic particle system that contains all the storages and buffers required for basic operation and a...
Pointer to a entity instance of type Physics.Particle.
The rigid body class, combining a geometric model and a frame of reference.
Vector containing 'raw' data.
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
agx::Vector< SoilParticleRef > SoilParticleRefVector
agx::Vector< const agx::ContactMaterial * > ConstContactMaterialVector
agx::Vector< std::pair< agx::Real, size_t > > RealSizeTPairVector
agx::ref_ptr< HeightController > HeightControllerRef
agx::ref_ptr< Terrain > TerrainRef
agx::ref_ptr< DynamicHeightFieldSimulation > DynamicHeightFieldSimulationRef
agx::Vector< GeometryContactInfoRef > GeometryContactInfoRefVector
agx::Vector< std::pair< size_t, size_t > > SizeTPairVector
agx::Vector< SoilParticleObs > SoilParticleObsVector
agx::ref_ptr< ContactGenerator > ContactGeneratorRef
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
AGXPHYSICS_EXPORT agx::Bool equalsZero(const agx::AddedMassInteraction::Matrix6x6 &matrix, agx::Real eps=agx::RealEpsilon)