17 #ifndef AGXCOLLIDE_HEIGHTFIELD_H 18 #define AGXCOLLIDE_HEIGHTFIELD_H 27 #include <GIMPACT/AabbTree.h> 146 size_t minVertexX,
size_t maxVertexX,
147 size_t minVertexY,
size_t maxVertexY);
167 void setHeight(
size_t xIndex,
size_t yIndex,
agx::Real height);
175 agx::Real getHeight(
size_t x,
size_t y)
const;
178 size_t getResolutionX()
const;
181 size_t getResolutionY()
const;
212 agx::Vec3 getVertexFromGrid(
size_t xIndex,
size_t yIndex)
const;
226 void setMinAllowedHeight(
agx::Real minAllowedHeight);
238 void setDynamic(
bool dynamic);
244 bool getDynamic()
const;
256 bool calculateVertexIndicesTouchedByAABB(
270 virtual void calculatePossibleTriangleOverlapsAlongLineSegment(
283 virtual void calculatePossibleTriangleOverlapsAlongLineSegment(
294 void calculateVertexCoordinates(
296 size_t& vertexIndexX,
size_t& vertexIndexY)
const;
304 size_t getTriangleIndex(
305 size_t indexX,
size_t indexY,
306 uint_fast8_t upper)
const;
331 void calculateMassProperties();
338 virtual Shape* clone()
const override;
350 virtual void updateBvhTree()
override;
358 void updateTriangle(
size_t triangleIndex,
bool shouldUpdateBvhNode =
true);
360 void addQuadrantVolume(
int xIndex,
int yIndex,
agx::Real factor);
379 void finalize(
bool updateMassProperties,
const agx::RealVector& heights,
bool flipY =
false);
387 void setHeights(
bool shouldUpdateMassProperties,
const agx::RealVector& heights,
bool flipY =
false);
411 return m_localBound.min().z() + m_collisionMeshData->m_bottomMargin;
417 return m_localBound.max().z();
423 return m_heightFieldData->m_resolutionX;
429 return m_heightFieldData->m_resolutionY;
435 return m_collisionMeshData->m_vertices[x + y * m_heightFieldData->m_resolutionX][2];
441 return m_heightFieldData->m_size;
447 return m_heightFieldData->m_scale;
452 size_t& vertexIndexX,
size_t& vertexIndexY)
const 454 vertexIndexX = vertexIndex % m_heightFieldData->m_resolutionX;
455 vertexIndexY = vertexIndex / m_heightFieldData->m_resolutionX;
459 AGX_FORCE_INLINE size_t HeightField::getTriangleIndex(
size_t indexX,
size_t indexY, uint_fast8_t upper)
const 461 return 2 * (indexX + indexY * (m_heightFieldData->m_resolutionX - 1)) + upper;
468 return getVertex(yIndex * m_heightFieldData->m_resolutionX + xIndex);
475 m_heightFieldData->m_minAllowedHeight =
std::min( minAllowedHeight, m_localBound.min().z() + m_collisionMeshData->m_bottomMargin );
476 if (m_heightFieldData->m_dynamic)
477 calculateMassProperties();
483 return m_heightFieldData->m_minAllowedHeight;
489 return m_heightFieldData->m_dynamic;
495 m_heightFieldData->m_dynamic = dynamic;
496 calculateMassProperties();
502 return m_heightFieldData;
509 const agx::Vec2 pointInGrid(projectedPoint[0] * m_heightFieldData->m_invScale[0], projectedPoint[1] * m_heightFieldData->m_invScale[1]);
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
The agxIO namespace contains classes for reading, writing and finding files.
This namespace consists of a set of classes for handling geometric intersection tests including boole...
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Class for data sharing only to be used by HeightField.
Vec2T< Real > Vec2
The object holding 2 dimensional vectors and providing basic arithmetic.
Class for more intuitive access to the Mesh's mesh data.
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Axis aligned bounding box implementation.
Class to represent Images.
A HeightField is a collision shape that can be created from a grid structure, like an image...
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
HeightFieldMeshDataRef m_heightFieldData