17 #ifndef AGXMODEL_TERRAIN_H
18 #define AGXMODEL_TERRAIN_H
111 agx::Real getMaximumParticleRadius()
const;
116 void setDynamicHeightFieldCutOffVelocity(
agx::Real cutOffVelocity );
121 agx::Real getDynamicHeightFieldCutOffVelocity()
const;
126 void setDynamicHeightFieldCutOffAngularVelocity(
agx::Real cutOffAngularVelocity );
130 agx::Real getDynamicHeightFieldCutOffAngularVelocity()
const;
133 #if TERRAIN_USE_PARTICLE_SYSTEM
149 void setEnableDynamicHeightField(
bool enable );
154 bool getEnableDynamicHeightField()
const;
169 void setEnableLockedBorders(
bool enable,
bool triggerAvalancheMassLoss =
true );
178 void setVerticalYoungsModulusAreaScaler(
agx::Real scaler );
183 agx::Real getVerticalYoungsModulusAreaScaler()
const;
193 void setHorizontalYoungsModulusAreaScaler(
agx::Real scaler );
198 agx::Real getHorizontalYoungsModulusAreaScaler()
const;
204 void avalancheAll(
size_t iterations );
213 void setWetnessScale(
agx::Real wetnessScaler );
226 void setAvalancheDecayPercent(
agx::Real scaler );
231 agx::Real getAvalancheDecayPercent()
const;
236 void setAvalancheStepLifeTime(
size_t numSteps );
241 size_t getAvalancheStepLifeTime()
const;
246 void setAvalancheVertexDistanceExtent(
size_t numVertices );
251 size_t getAvalancheVertexDistanceExtent()
const;
259 void setShovelMinimumDigAngleToHorizontalPlane(
agx::Real angle );
264 agx::Real getShovelMinimumDigAngleToHorizontalPlane()
const;
292 agx::Real getDynamicHeightFieldParticleRadius()
const;
312 #if TERRAIN_USE_PARTICLE_SYSTEM
349 virtual void addNotification()
override;
354 virtual void removeNotification()
override;
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;