17 #ifndef AGXMODEL_TERRAIN_UTILS_H 18 #define AGXMODEL_TERRAIN_UTILS_H 41 class ImpactVolumeData;
52 : m_localHeightUpdate(false), m_lockBorders(false), m_avalancheMassLoss(true), m_heightField(heightField)
55 : m_localHeightUpdate(false), m_lockBorders(false), m_avalancheMassLoss(true), m_heightField(nullptr)
59 m_avalancheMassLoss = avalancheMassLoss;
62 return m_avalancheMassLoss;
68 m_heightField->calculateMassProperties();
70 void setHeight(
size_t x,
size_t y,
agx::Real height );
72 return std::max(globalX, m_minX) - m_minX;
75 return std::max(globalY, m_minY) - m_minY;
78 return (m_maxX - m_minX + 1) * getLocalY(globalY) + getLocalX(globalX);
80 agx::Real getHeight(
size_t x,
size_t y )
const;
81 void startLocalHeightUpdate(
size_t minX = 0,
size_t maxX = 0,
size_t minY = 0,
size_t maxY = 0);
82 void endLocalHeightUpdate();
85 return m_localHeightUpdate;
96 bool m_localHeightUpdate;
98 bool m_avalancheMassLoss;
131 : m_particleResolutionX(1), m_particleResolutionY(1), m_scale(1), m_heightFieldToParticleCoordinateMultiplier(1)
137 void updateResolution(
const agx::Real& particleRadius,
const size_t& heightFieldResolutionX,
const size_t& heightFieldResolutionY,
const agx::Real& scale );
139 enum DirectionFCC {
VERTEX_POS, POS_X_NEG_Z, POS_Y_NEG_Z, NEG_X_NEG_Z, NEG_Y_NEG_Z, POS_X_POS_Y, NEG_X_POS_Y, NEG_X_NEG_Y, POS_X_NEG_Y, POS_X_POS_Z, POS_Y_POS_Z, NEG_X_POS_Z, NEG_Y_POS_Z };
150 agx::Real findParticleCoordinateHeight(
const size_t pcsX,
const size_t pcsY,
Terrain* terrain );
157 agx::Vec3 getHeightFieldPositionFromFCCIndex(
size_t fccIndex,
const agx::Real minZ,
size_t& pcsX,
size_t& pcsY );
163 void getParentHeightFieldVertex(
const size_t& pcsX,
const size_t& pcsY,
size_t& hfX,
size_t& hfY );
169 void collectCloseParticleCoordinates(
const size_t& hfX,
const size_t& hfY,
agx::Vec2iVector& particleCoordinates );
176 void collectCloseParticleLowerXYCoordinatesWithHeight(
const agxCollide::HeightField* hf,
const size_t& hfX,
const size_t& hfY,
183 size_t indexForFCCLattice(
size_t pcsX,
size_t pcsY,
size_t pcsZ,
DirectionFCC dir );
194 agx::Vec2 getHeightFieldPosition(
const size_t pcsX,
const size_t pcsY,
const size_t dX = 0,
const size_t dY = 0 );
197 size_t m_particleResolutionX;
198 size_t m_particleResolutionY;
202 agx::Real m_heightFieldToParticleCoordinateMultiplier;
218 this->getSimulation()->getSpace()->addGeometryContacts(m_localContacts);
279 return m_dynamicHeightFieldParticleCoordinateSystem;
283 return m_contactGenerator;
287 m_particleRadius = radius;
291 return m_particleRadius;
295 return m_uniqueParticleId;
317 : m_geometryContact(gc), m_index(index) {
323 return m_geometry1->getEnable() && m_geometry2->getEnable() && (m_geometry1->getRigidBody() ==
nullptr || m_geometry1->getRigidBody()->getEnable() ) && (m_geometry2->getRigidBody() ==
nullptr || m_geometry2->getRigidBody()->getEnable());
327 m_impactVolumeDataVector.push_back(ivd);
340 m_impactVolumeDataVector.clear();
344 return m_geometryContact;
347 return m_impactVolumeDataVector;
368 if ( m_heightField ==
nullptr )
370 size_t vectorIndex = m_heightField->getResolutionX() * y + x;
371 agxAssert( !getLocalHeightUpdate() || m_tempHeights.size() > vectorIndex);
373 if ( getLocalHeightUpdate() && m_tempHeights[vectorIndex] != -
agx::Infinity )
374 return m_tempHeights[vectorIndex];
376 return m_heightField->getHeight(x, y);
381 if ( m_heightField ==
nullptr )
384 if ( m_lockBorders && ( x == 0 || y == 0 || x + 1 >= m_heightField->getResolutionX() || y + 1 >= m_heightField->getResolutionY() ) )
386 if ( getLocalHeightUpdate() )
387 m_tempHeights[getLocalVectorIndex(x, y)] = height;
389 m_heightField->setHeight(x, y, height);
405 void initialize(
Terrain* terrain);
416 void extractGeometryProperties(
Terrain* terrain);
agx::Real getHeight(size_t x, size_t y) const
AGXTERRAIN_EXPORT void clear()
void setHeight(size_t x, size_t y, agx::Real height)
agx::ref_ptr< GeometryContactInfo > GeometryContactInfoRef
Derive from this class to implement a listener for simulation step events.
ParticleCoordinateSystem m_dynamicHeightFieldParticleCoordinateSystem
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
void setParticleRadius(agx::Real radius)
bool getEnabledLockedBorders() const
Triggered just AFTER a Dynamics stepForward step is taken.
Triggered just BEFORE a Dynamics stepForward step is taken.
HeightController(agxCollide::HeightField *heightField)
ParticleCoordinateSystem()
size_t getLocalX(size_t globalX)
#define AGX_DECLARE_POINTER_TYPES(type)
agx::Vector< GeometryContactInfoRef > GeometryContactInfoRefVector
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
agx::ref_ptr< HeightController > HeightControllerRef
const agxCollide::HeightField * getHeightField() const
Base class providing referencing counted objects.
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
The geometry representation used by the collision detection engine.
ParticleCoordinateSystem & getParticleCoordinateSystem()
agx::Real getParticleRadius()
agx::Real m_particleRadius
agx::UInt32 getParticleUniqueId() const
agx::UInt32 m_uniqueParticleId
AGXCORE_EXPORT const Real Infinity
size_t getLocalVectorIndex(size_t globalX, size_t globalY)
Inherit from this class and implement the render() method to make it it self during debug rendering...
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.
void setEnableLockedBorders(bool lock, bool avalancheMassLoss=true)
agx::RealVector m_heights
agx::Vector< std::pair< agx::RigidBodyObserver, agx::Vec3 > > RigidBodyObserverVec3PairVector
First Normal equation is calculated in the DIRECT solver, then in a second pass the normal and the fr...
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Iterative Projected Cone Friction (IPC friction) model.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
bool getLocalHeightUpdate() const
agx::ref_ptr< ContactGenerator > ContactGeneratorRef
void calculateMassProperties()
ContactGenerator * getContactGenerator()
Buffer is maintained (normal stl behavior).
agx::ref_ptr< DynamicHeightFieldSimulation > DynamicHeightFieldSimulationRef
RigidBodyObserverVec3PairVector m_bodiesAndDir
size_t getLocalY(size_t globalY)
A HeightField is a collision shape that can be created from a grid structure, like an image...
bool getEnabledAvalancheMassLoss() const
agx::observer_ptr< agxRender::HeightFieldProxy > m_proxy
ContactGeneratorRef m_contactGenerator