 |
AGXDynamics
2.35.0.3
|
Go to the documentation of this file.
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)
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 };
197 size_t m_particleResolutionX;
198 size_t m_particleResolutionY;
202 agx::Real m_heightFieldToParticleCoordinateMultiplier;
218 this->getSimulation()->getSpace()->addGeometryContacts(m_localContacts);
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());
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;
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() ) )
389 m_heightField->setHeight(x, y, height);
405 void initialize(
Terrain* terrain);
const agxCollide::HeightField * getHeightField() const
size_t getLocalY(size_t globalY)
agx::Real findParticleCoordinateHeight(const size_t pcsX, const size_t pcsY, Terrain *terrain)
Calculate the height of a particle position.
agx::ref_ptr< DynamicHeightFieldSimulation > DynamicHeightFieldSimulationRef
ParticleCoordinateSystem & getParticleCoordinateSystem()
size_t indexForFCCLattice(size_t pcsX, size_t pcsY, size_t pcsZ, DirectionFCC dir)
hfX, hfY are index in height field.
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Derive from this class to implement a listener for simulation step events.
DynamicHeightFieldSimulation()
agx::Real getHeight(size_t x, size_t y) const
The rigid body class, combining a geometric model and a frame of reference.
agx::ref_ptr< ContactGenerator > ContactGeneratorRef
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...
agx::Vec3 getHeightFieldPositionFromFCCIndex(size_t fccIndex, const agx::Real minZ, size_t &pcsX, size_t &pcsY)
Translates a position in the imaginary FCC 3 dimensional grid to a world position Returns positions i...
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
agx::ref_ptr< GeometryContactInfo > GeometryContactInfoRef
agx::Real m_particleRadius
bool getEnabledAvalancheMassLoss() const
A HeightField is a collision shape that can be created from a grid structure, like an image.
agx::Vector< GeometryContactInfoRef > GeometryContactInfoRefVector
agx::observer_ptr< agxRender::HeightFieldProxy > m_proxy
void setHeight(size_t x, size_t y, agx::Real height)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
TerrainDebugRenderer(agxModel::Terrain *terrain)
ContactGeneratorRef m_contactGenerator
void getParentHeightFieldVertex(const size_t &pcsX, const size_t &pcsY, size_t &hfX, size_t &hfY)
To find what hf vertex position For example needed when we need to know which material a particle sho...
void updateResolution(const agx::Real &particleRadius, const size_t &heightFieldResolutionX, const size_t &heightFieldResolutionY, const agx::Real &scale)
If the particle radius is changed, we must update our resolution for the particle coordinate system.
ParticleCoordinateSystem()
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements, optionally with maintained buffer allocation.
RigidBodyObserverVec3PairVector m_bodiesAndDir
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
const AGXCORE_EXPORT Real Infinity
ParticleCoordinateSystem m_dynamicHeightFieldParticleCoordinateSystem
@ PRE_STEP
Triggered just BEFORE a Dynamics stepForward step is taken.
agx::ref_ptr< HeightController > HeightControllerRef
void setParticleRadius(agx::Real radius)
The geometry representation used by the collision detection engine.
void setEnableLockedBorders(bool lock, bool avalancheMassLoss=true)
void calculateMassProperties()
size_t getLocalX(size_t globalX)
@ POST_STEP
Triggered just AFTER a Dynamics stepForward step is taken.
ContactGenerator * getContactGenerator()
agx::RealVector m_heights
Base class providing referencing counted objects.
#define AGX_DECLARE_POINTER_TYPES(type)
virtual ~TerrainDebugRenderer()
agx::Real findFccHeight(agx::Real heightAtVertexPos, agx::Real dX, agx::Real dY, DirectionFCC fccLocalPos)
Calculate height of height field fcc position, given x and y derivatives and the height of the middle...
agx::Real getParticleRadius()
bool getLocalHeightUpdate() const
Inherit from this class and implement the render() method to make it it self during debug rendering.
void render(agxRender::RenderManager *mgr)
Pure virtual method that should implemented to render a derived class during debug rendering.
bool getEnabledLockedBorders() const
agx::Vec2 getHeightFieldPosition(const size_t pcsX, const size_t pcsY, const size_t dX=0, const size_t dY=0)
Get 2D position on the height field in length units.
agx::Vector< std::pair< agx::RigidBodyObserver, agx::Vec3 > > RigidBodyObserverVec3PairVector
HeightController(agxCollide::HeightField *heightField)
Main material class which acts as a holder of a Surface Material and a Bulk material.
@ MAINTAIN_BUFFER
Buffer is maintained (normal stl behavior).
void collectCloseParticleLowerXYCoordinatesWithHeight(const agxCollide::HeightField *hf, const size_t &hfX, const size_t &hfY, Vec2iHeightDataPairVector &particleCoordinatesWithHeight, Terrain *terrain)
Given one vertex in the height field (that has changed height for example) we get all surrounding par...
size_t getLocalVectorIndex(size_t globalX, size_t globalY)
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
@ SPLIT
First Normal equation is calculated in the DIRECT solver, then in a second pass the normal and the fr...
agx::UInt32 getParticleUniqueId() const
agx::Real scaleDepth(const agx::Real &depth, const size_t pcsX, const size_t pcsY, const agx::Vec2 &hf2Dpos)
Given the changed height (depth) of a height field vertex, we get the height change at the particle c...
agx::UInt32 m_uniqueParticleId
void collectCloseParticleCoordinates(const size_t &hfX, const size_t &hfY, agx::Vec2iVector &particleCoordinates)
Given one vertex in the height field (that has changed height for example) we get all surrounding par...
void push_back(const T2 &value)