AGX Dynamics 2.37.3.4
Loading...
Searching...
No Matches
agxCollide::HeightField Class Reference

A HeightField is a collision shape that can be created from a grid structure, like an image. More...

#include <HeightField.h>

+ Inheritance diagram for agxCollide::HeightField:

Public Member Functions

 HeightField (size_t resolutionX, size_t resolutionY, agx::Real sizeX, agx::Real sizeY, agx::Real bottomMargin=agx::Real(1))
 Constructor for the HeightField class.
 
 HeightField (size_t resolutionX, size_t resolutionY, agx::Real sizeX, agx::Real sizeY, const agx::RealVector &heights, bool flipY=false, agx::Real bottomMargin=agx::Real(1))
 Constructor for the HeightField class.
 
void calculateMassProperties ()
 Calculates "mass properties" such as volume, unscaled inertia tensor and center.
 
virtual void calculatePossibleTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, agx::UInt32Vector &triangleIndices) const override
 Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
 
virtual void calculatePossibleTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, agxData::LocalVector< agx::UInt32 > &triangleIndices) const override
 Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
 
void calculateVertexCoordinates (size_t vertexIndex, size_t &vertexIndexX, size_t &vertexIndexY) const
 Calculates the vertex indices for x and y given a global vertex index.
 
bool calculateVertexIndicesTouchedByAABB (const BoundingAABB &volume, const agx::AffineMatrix4x4 &meshToWorld, const agx::AffineMatrix4x4 &volumeToWorld, agx::Vec2i &gridMin, agx::Vec2i &gridMax) const
 Calculates the minimum and maximum vertex indices of the square that a bounding box resides in.
 
virtual Shapeclone () const override
 Create a clone.
 
HeightFielddeepCopy () const
 Creates a new HeightField which copies data from this one.
 
bool getDynamic () const
 Return if the HeightField is dynamic, which means if it should keep its MassProperties updated.
 
agx::Real getHeight (size_t x, size_t y) const
 Gets the height at a grid point.
 
const HeightFieldMeshDatagetHeightFieldMeshData () const
 
agx::Real getMaxHeight () const
 Returns the (global) maximum height of the HeightField.
 
agx::Real getMinAllowedHeight () const
 Returns the minimum allowed height, which is at the same time the lower bound for a dynamic HeightField (for volume computation).
 
agx::Real getMinHeight () const
 Returns the (global) minimum height of the HeightField.
 
size_t getResolutionX () const
 Returns the resolution (the number of height values) in dimension x.
 
size_t getResolutionY () const
 Returns the resolution (the number of height values) in dimension y.
 
agx::Vec2 getScale () const
 Returns the scaling factor for a single cell in the HeightField (in dimension x and y).
 
agx::Vec2 getSize () const
 Returns the size of the HeightField (in dimension x and y).
 
Mesh::Triangle getTriangleFromPoint (const agx::Vec3 &point) const
 Returns a triangle given the 2D-projection of a point on the xy-plane in the grid.
 
size_t getTriangleIndex (size_t indexX, size_t indexY, uint_fast8_t upper) const
 Computes the global triangle index within the HeightField.
 
agx::Vec3 getVertexFromGrid (size_t xIndex, size_t yIndex) const
 Returns the vertex at a grid position.
 
agx::Vec2 projectPointToGrid (const agx::Vec3 &point) const
 Projects a point in local HeightField coordinate system to the HeightField grid (which is moved to the first quadrant).
 
void setDynamic (bool dynamic)
 Sets if the HeightField is dynamic, which means if it should keep its MassProperties updated.
 
void setHeight (size_t xIndex, size_t yIndex, agx::Real height)
 Sets the height at a specific grid node.
 
void setHeights (const agx::RealVector &heights, bool flipY=false)
 Set height values of all sampled points.
 
bool setHeights (const agx::RealVector &heights, size_t minVertexX, size_t maxVertexX, size_t minVertexY, size_t maxVertexY)
 Set height values of all grid nodes within a rectangle.
 
void setHeightsFromList (const agx::Vec2uVector &indices, const agx::RealVector &heights)
 Set height values given a list of terrain indices and corresponding heights.
 
void setMinAllowedHeight (agx::Real minAllowedHeight)
 Sets the new minAllowedHeight, which is at the same time the lower bound for a dynamic HeightField (for volume computation).
 
HeightFieldshallowCopy () const
 Creates a new HeightField which shares data with this one.
 
- Public Member Functions inherited from agxCollide::Mesh
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const override
 Returns the inertia of the shape, scaled with the mass. Inherited from class Shape.
 
virtual BoundingAABB calculateLocalBound () const override
 Calculate the bounding volume in the local coordinate system.
 
virtual void calculatePossibleTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, agx::UInt32Vector &triangleIndices) const =0
 Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
 
virtual void calculatePossibleTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, agxData::LocalVector< agx::UInt32 > &triangleIndices) const =0
 Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
 
void calculateTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, TriangleLineSegmentResultVector &triangleResults) const
 Calculates all triangle overlaps of a line segment with the mesh.
 
void calculateTrianglesInVolume (const BoundingAABB &volume, const agx::AffineMatrix4x4 &meshToWorld, const agx::AffineMatrix4x4 &volumeToWorld, agx::UInt32Vector &triangleIndices) const
 Calculates an array of triangle indices of the triangles that are within a bounding volume.
 
void calculateTrianglesInVolume (const BoundingAABB &volume, const agx::AffineMatrix4x4 &meshToWorld, const agx::AffineMatrix4x4 &volumeToWorld, agxData::LocalVector< agx::UInt32 > &triangleIndices) const
 
FaceEdgeCirculator createFaceEdgeCirculator (size_t triangleIndex) const
 Creates an FaceEdgeCirculator pointing to this Triangle and a Voronoi region.
 
VertexEdgeCirculator createVertexEdgeCirculator (size_t triangleIndex, uint_fast8_t localVertexIndex) const
 Creates an VertexEdgeCirculator pointing to this Triangle and a Voronoi region.
 
agx::Real getBottomMargin () const
 
const AabbTree * getBvhTree () const
 
virtual agx::Vec3 getCenter () const override
 
size_t getGlobalVertexIndex (size_t triangleIndex, uint_fast8_t localVertexIndex) const
 Returns the global index of one of the three vertices in a triangle.
 
uint32_t getHalfEdgePartnerEdge (size_t globalEdgeIndex) const
 
const BoundingAABBgetLocalBound () const
 
const CollisionMeshDatagetMeshData () const
 
size_t getNumTriangles () const
 
size_t getNumVertices () const
 
agx::Real getTotalMaximumEdgeLength () const
 
const Triangle getTriangle (size_t triangleIndex) const
 
agx::Real getTriangleMaximumEdgeLength (size_t triangleIndex) const
 
agx::Vec3 getTriangleNormal (size_t triangleIndex) const
 
agx::Vec3 getTriangleVertex (size_t triangleIndex, uint_fast8_t localVertexIndex) const
 Returns one of the three vertices in a triangle.
 
agx::Vec3 getVertex (size_t globalVertexIndex) const
 
virtual agx::Real getVolume () const override
 
bool hasHalfEdge () const
 
bool hasInternalCenterPoint () const
 
bool isConvexEdge (size_t globalEdgeIndex) const
 Is an edge convex? Returns always true if half edge information is missing on this edge/the whole mesh.
 
bool isConvexVertex (size_t triangleIndex, size_t localVertexIndex) const
 Is an vertex convex? Returns always true if half edge information is missing on this vertex/the whole mesh.
 
bool isTerrain () const
 
bool isValid () const
 
bool isValidAndClosed () const
 
bool isValidEdgeIndex (size_t globalEdgeIndex) const
 
bool isValidTriangleIndex (size_t globalTriangleIndex) const
 
void setBottomMargin (agx::Real newMargin)
 Sets the depth that is added below the lowest point in the terrain in local z direction, to prevent tunneling in this direction.
 
virtual const BoundingAABBupdateBoundingVolume () override
 Calculate the bounding volume based on the current Shape parameters including transformation.
 
- Public Member Functions inherited from agxCollide::Shape
ShapeGroupasGroup ()
 Auto-cast shape to group.
 
const ShapeGroupasGroup () const
 Auto-cast shape to group.
 
virtual agx::Real calculateBoundingRadius (BoundingAABB &localAABB) const
 Calculate the bounding volume (AABB) into localAABB and calculate the bounding radius based on the new AABB size.
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const =0
 Calculate the inertia for the shape given a mass.
 
virtual BoundingAABB calculateLocalBound () const =0
 Calculate the bounding volume in the local coordinate system.
 
virtual Shapeclone () const
 Create a clone.
 
const BoundingAABBgetBoundingVolume () const
 
virtual agx::Vec3 getCenter () const
 
agx::Physics::Geometry::ShapePtr getEntity () const
 
GeometrygetGeometry ()
 
const GeometrygetGeometry () const
 
agx::AffineMatrix4x4 getLocalTransform () const
 
agx::UInt32 getModifiedCount () const
 
agxCollide::RenderDatagetRenderData ()
 
const agxCollide::RenderDatagetRenderData () const
 If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc.
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const
 Returns the support point on face of the shape.
 
agx::AffineMatrix4x4 getTransform () const
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
virtual agx::Real getVolume () const =0
 Return the volume of the shape.
 
virtual bool hasSupportFunction () const
 
bool isGroup () const
 
virtual void propagateTransform (const agx::AffineMatrix4x4 &transform)
 
virtual void setRenderData (agxCollide::RenderData *renderData)
 Store render data with the Shape.
 
virtual const BoundingAABBupdateBoundingVolume ()=0
 Calculate the bounding volume based on the current Shape parameters including transformation.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static agxCollide::HeightFieldcreateFromFile (const agx::String &filename, agx::Real sizeX, agx::Real sizeY, agx::Real low, agx::Real high, agx::Real bottomMargin=agx::Real(1))
 
static agxCollide::HeightFieldcreateFromImage (agxIO::Image *image, agx::Real sizeX, agx::Real sizeY, agx::Real low, agx::Real high, agx::Real bottomMargin=agx::Real(1))
 
- Static Public Member Functions inherited from agxCollide::Mesh
static size_t getGlobalEdgeIndex (size_t triangleIndex, uint_fast8_t localEdgeIndex)
 Computes the global edge index from a given triangle index and the local edge index within this triangle.
 
static size_t getGlobalTriangleIndex (size_t globalEdgeIndex)
 
static size_t getLocalEdgeIndex (size_t globalEdgeIndex)
 
- Static Public Member Functions inherited from agxCollide::Shape
static BoundingAABB calculateBound (const agx::AffineMatrix4x4 &transform, const BoundingAABB &localBound)
 
static const char * getTypeName (agx::UInt8 type)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 

Protected Member Functions

virtual ~HeightField ()
 
- Protected Member Functions inherited from agxCollide::Mesh
 Mesh (Shape::Type type, agx::Physics::Geometry::ShapePtr entity)
 Hidden, should only be called by child classes.
 
virtual ~Mesh ()
 Hide destructor.
 
void restore (class agxStream::InputArchive &in) override
 
void store (class agxStream::OutputArchive &out) const override
 
virtual void updateBvhTree ()=0
 
- Protected Member Functions inherited from agxCollide::Shape
 Shape (Type type, agx::Physics::Geometry::ShapePtr entity=agx::Physics::Geometry::ShapeModel::createInstance())
 Constructor.
 
virtual ~Shape ()
 Destructor.
 
agx::UInt32 incrementModifiedCount ()
 Increment the number of times the shape have been modified.
 
void syncronizeShapeIndex ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Protected Attributes

HeightFieldMeshDataRef m_heightFieldData
 
- Protected Attributes inherited from agxCollide::Mesh
AabbTreeRef m_aabbTree
 
CollisionMeshDataRef m_collisionMeshData
 
BoundingAABB m_localBound
 
- Protected Attributes inherited from agxCollide::Shape
agx::Physics::Geometry::ShapeRef m_entity
 
Geometrym_geometry
 
ShapeGroupm_parent
 
agxCollide::RenderDataRef m_renderData
 
agx::Index m_shapeIndex
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Public Types inherited from agxCollide::Mesh
typedef agx::Vector< TriangleLineSegmentResultTriangleLineSegmentResultVector
 
- Public Types inherited from agxCollide::Shape
enum  Type {
  GROUP , BOX , CAPSULE , CYLINDER ,
  LINE , PLANE , SPHERE , TRIMESH ,
  HEIGHT_FIELD , CONVEX , WIRE_SHAPE , CONE ,
  HOLLOW_CONE , HOLLOW_CYLINDER , NUM_TYPES
}
 Define the type of a Shape. More...
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

A HeightField is a collision shape that can be created from a grid structure, like an image.

Each grid point defines a height, and the difference in height between the grid points is interpolated by triangles which are then used for collision detection. Each (rectangular) grid cell is divided in a lower left and an upper right triangle. The grid is assumed to be in dimension x and y, and z is assumed to be upwards in positive height. In the x and y dimension, the grid is centered at the origin in its local frame. The grid is stored internally in row major order.

Definition at line 51 of file agxCollide/HeightField.h.

Constructor & Destructor Documentation

◆ HeightField() [1/2]

agxCollide::HeightField::HeightField ( size_t  resolutionX,
size_t  resolutionY,
agx::Real  sizeX,
agx::Real  sizeY,
agx::Real  bottomMargin = agx::Real(1) 
)

Constructor for the HeightField class.

This will create a HeightField with height 0 everywhere. Use setHeights to set the heights at all points at once, or setHeight to set it at especially defined positions.

Parameters
resolutionXThe number of sample points in dimension x.
resolutionYThe number of sample points in dimension y.
sizeXThe physical size in dimension x.
sizeYThe physical size in dimension y.
bottomMarginHow deep is the HeightField under its lowest point? Positive value.

◆ HeightField() [2/2]

agxCollide::HeightField::HeightField ( size_t  resolutionX,
size_t  resolutionY,
agx::Real  sizeX,
agx::Real  sizeY,
const agx::RealVector heights,
bool  flipY = false,
agx::Real  bottomMargin = agx::Real(1) 
)

Constructor for the HeightField class.

This will create a HeightField with height 0 everywhere. Use setHeights to set the heights at all points at once, or setHeight to set it at especially defined positions.

Parameters
resolutionXThe number of sample points in dimension x.
resolutionYThe number of sample points in dimension y.
sizeXThe physical size in dimension x.
sizeYThe physical size in dimension y.
heights- must be a row major matrix with dimensions (resolutionX, resolutionY).
flipY- set to true if y decreases with increasing indices in heights.
bottomMarginHow deep is the HeightField under its lowest point? Positive value.

◆ ~HeightField()

virtual agxCollide::HeightField::~HeightField ( )
protectedvirtual

Member Function Documentation

◆ calculateMassProperties()

void agxCollide::HeightField::calculateMassProperties ( )

Calculates "mass properties" such as volume, unscaled inertia tensor and center.

Will give standard values for non-dynamic HeightFields. For dynamic HeightFields, the mass properties will be recalculated per triangle which is expensive in large HeightFields (linear in number of triangles).

◆ calculatePossibleTriangleOverlapsAlongLineSegment() [1/2]

virtual void agxCollide::HeightField::calculatePossibleTriangleOverlapsAlongLineSegment ( const agx::Vec3 segmentStartLocal,
const agx::Vec3 segmentEndLocal,
agx::UInt32Vector triangleIndices 
) const
overridevirtual

Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.

Parameters
segmentStartLocalThe segment starting point in heightfield coordinates.
segmentEndLocalThe segment ending point in heightfield coordinates.
triangleIndicesA vector of triangle indices. It will be emptied before writing to it.

Implements agxCollide::Mesh.

◆ calculatePossibleTriangleOverlapsAlongLineSegment() [2/2]

virtual void agxCollide::HeightField::calculatePossibleTriangleOverlapsAlongLineSegment ( const agx::Vec3 segmentStartLocal,
const agx::Vec3 segmentEndLocal,
agxData::LocalVector< agx::UInt32 > &  triangleIndices 
) const
overridevirtual

Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.

Parameters
segmentStartLocalThe segment starting point in heightfield coordinates.
segmentEndLocalThe segment ending point in heightfield coordinates.
triangleIndicesA vector of triangle indices. It will be emptied before writing to it.

Implements agxCollide::Mesh.

◆ calculateVertexCoordinates()

void agxCollide::HeightField::calculateVertexCoordinates ( size_t  vertexIndex,
size_t &  vertexIndexX,
size_t &  vertexIndexY 
) const

Calculates the vertex indices for x and y given a global vertex index.

Parameters
vertexIndexThe global vertex index.
vertexIndexXA return value: The vertex index's x component.
vertexIndexYA return value: The vertex index's y component.

Definition at line 451 of file agxCollide/HeightField.h.

◆ calculateVertexIndicesTouchedByAABB()

bool agxCollide::HeightField::calculateVertexIndicesTouchedByAABB ( const BoundingAABB volume,
const agx::AffineMatrix4x4 meshToWorld,
const agx::AffineMatrix4x4 volumeToWorld,
agx::Vec2i gridMin,
agx::Vec2i gridMax 
) const

Calculates the minimum and maximum vertex indices of the square that a bounding box resides in.

Parameters
volumeThe bounding box in its local coordinates.
meshToWorldA transformation from the mesh's local frame to world coordinates.
volumeToWorldA transformation from the volume's local frame to world coordinates.
gridMinThe minimum vertex index x and y values.
gridMaxThe maximum vertex index x and y values.
Return values
Doesthe volume have any overlap with the grid?

◆ clone()

virtual Shape * agxCollide::HeightField::clone ( ) const
overridevirtual

Create a clone.

Reimplemented from agxCollide::Shape.

◆ createFromFile()

static agxCollide::HeightField * agxCollide::HeightField::createFromFile ( const agx::String filename,
agx::Real  sizeX,
agx::Real  sizeY,
agx::Real  low,
agx::Real  high,
agx::Real  bottomMargin = agx::Real(1) 
)
static
Parameters
filename- Path to an image which will be read as a height map.
sizeX- World size in the x dimension
sizeY- World size in the y dimension
low- The lowest height in the z dimension, maps to the lowest value in the image
high- The highest height in the z dimension, maps to the highest value in the image
bottomMarginHow deep is the HeightField under its lowest point?
Returns
a HeightField shape with extents in X/Y and height values along Z

◆ createFromImage()

static agxCollide::HeightField * agxCollide::HeightField::createFromImage ( agxIO::Image image,
agx::Real  sizeX,
agx::Real  sizeY,
agx::Real  low,
agx::Real  high,
agx::Real  bottomMargin = agx::Real(1) 
)
static

◆ deepCopy()

HeightField * agxCollide::HeightField::deepCopy ( ) const

Creates a new HeightField which copies data from this one.

(modifying one's data will not modify the other's). Less quick to create than shallowCopy (but faster than creating mesh from input data), double memory usage. The caller takes over possession of the pointer.

◆ getDynamic()

bool agxCollide::HeightField::getDynamic ( ) const

Return if the HeightField is dynamic, which means if it should keep its MassProperties updated.

Definition at line 487 of file agxCollide/HeightField.h.

◆ getHeight()

agx::Real agxCollide::HeightField::getHeight ( size_t  x,
size_t  y 
) const

Gets the height at a grid point.

Parameters
xx coordinate on grid.
yy coordinate on grid.
Return values
heightat this position.

Definition at line 433 of file agxCollide/HeightField.h.

◆ getHeightFieldMeshData()

const HeightFieldMeshData * agxCollide::HeightField::getHeightFieldMeshData ( ) const
Returns
a const pointer to the mesh data specific for this height field.

Definition at line 500 of file agxCollide/HeightField.h.

◆ getMaxHeight()

agx::Real agxCollide::HeightField::getMaxHeight ( ) const

Returns the (global) maximum height of the HeightField.

Definition at line 415 of file agxCollide/HeightField.h.

◆ getMinAllowedHeight()

agx::Real agxCollide::HeightField::getMinAllowedHeight ( ) const

Returns the minimum allowed height, which is at the same time the lower bound for a dynamic HeightField (for volume computation).

Definition at line 481 of file agxCollide/HeightField.h.

◆ getMinHeight()

agx::Real agxCollide::HeightField::getMinHeight ( ) const

Returns the (global) minimum height of the HeightField.

Definition at line 409 of file agxCollide/HeightField.h.

◆ getResolutionX()

size_t agxCollide::HeightField::getResolutionX ( ) const

Returns the resolution (the number of height values) in dimension x.

Definition at line 421 of file agxCollide/HeightField.h.

◆ getResolutionY()

size_t agxCollide::HeightField::getResolutionY ( ) const

Returns the resolution (the number of height values) in dimension y.

Definition at line 427 of file agxCollide/HeightField.h.

◆ getScale()

agx::Vec2 agxCollide::HeightField::getScale ( ) const

Returns the scaling factor for a single cell in the HeightField (in dimension x and y).

Definition at line 445 of file agxCollide/HeightField.h.

◆ getSize()

agx::Vec2 agxCollide::HeightField::getSize ( ) const

Returns the size of the HeightField (in dimension x and y).

Definition at line 439 of file agxCollide/HeightField.h.

◆ getTriangleFromPoint()

Mesh::Triangle agxCollide::HeightField::getTriangleFromPoint ( const agx::Vec3 point) const

Returns a triangle given the 2D-projection of a point on the xy-plane in the grid.

The triangle will be invalid if the point's projection is outside the grid.

◆ getTriangleIndex()

size_t agxCollide::HeightField::getTriangleIndex ( size_t  indexX,
size_t  indexY,
uint_fast8_t  upper 
) const

Computes the global triangle index within the HeightField.

Parameters
indexXThe triangle's x index (valid values: 0 to (getResolutionX() - 2)).
indexYThe triangle's y index (valid values: 0 to (getResolutionY() - 2)).
upperIs it a lower left triangle (0) or upper right triangle (1)?

Definition at line 459 of file agxCollide/HeightField.h.

◆ getVertexFromGrid()

agx::Vec3 agxCollide::HeightField::getVertexFromGrid ( size_t  xIndex,
size_t  yIndex 
) const

Returns the vertex at a grid position.

Definition at line 466 of file agxCollide/HeightField.h.

◆ projectPointToGrid()

agx::Vec2 agxCollide::HeightField::projectPointToGrid ( const agx::Vec3 point) const

Projects a point in local HeightField coordinate system to the HeightField grid (which is moved to the first quadrant).

Parameters
pointPoint in height field coordinate system (height field center in origin).
Return values
Pointin height field grid. Will be on grid if values are between (0, 0) and (getResolutionX() - 1, getResolutionY() - 1). Drop decimals for lower lower grid coordinates, round upwards for higher ones.

Definition at line 506 of file agxCollide/HeightField.h.

◆ setDynamic()

void agxCollide::HeightField::setDynamic ( bool  dynamic)

Sets if the HeightField is dynamic, which means if it should keep its MassProperties updated.

Definition at line 493 of file agxCollide/HeightField.h.

◆ setHeight()

void agxCollide::HeightField::setHeight ( size_t  xIndex,
size_t  yIndex,
agx::Real  height 
)

Sets the height at a specific grid node.

Parameters
xIndexThe index of the grid node in dimension x.
yIndexThe index of the grid node in dimension y.
heightThe desired height at this position.

This method will recompute all adjacent triangles (up to 6). If several adjacent heights of are changed, it can be more efficient to call setHeights for the (rectangular) part of the grid that should be changed.

For dynamic HeightFields, only the volume and center of mass of the HeightField will be updated automatically, the unscaled inertia will remain the same. (Call the potentially costly calculateMassProperties after all desired heights have been set in order to calculate the new mass properties including inertia, if a correctly updated inertia is important).

◆ setHeights() [1/2]

void agxCollide::HeightField::setHeights ( const agx::RealVector heights,
bool  flipY = false 
)

Set height values of all sampled points.

Parameters
heights- must be a row major matrix with dimensions (resolutionX, resolutionY).
flipY- set to true if y decreases with increasing indices in heights.

◆ setHeights() [2/2]

bool agxCollide::HeightField::setHeights ( const agx::RealVector heights,
size_t  minVertexX,
size_t  maxVertexX,
size_t  minVertexY,
size_t  maxVertexY 
)

Set height values of all grid nodes within a rectangle.

All triangles which belong to any of the points will be recalculated. This is cheaper than calling setHeight(...) for all points in the rectangle, since all triangles have to be computed just once instead of up to 6 times.

Parameters
heightsA vector of size (maxVertexX + 1 - minVertexX) * (maxVertexY + 1 - minVertexY), giving the heights for the rectangle.
minVertexXThe minimum vertex x index.
minVertexYThe minimum vertex y index.
maxVertexXThe maximum vertex x index.
maxVertexYThe maximum vertex y index.
Return values
trueof succeeded (parameters within bounds and heights has correct size). For dynamic HeightFields, only the volume and center of mass of the HeightField will be updated automatically, the unscaled inertia will remain the same. (Call the potentially costly calculateMassProperties after all desired heights have been set in order to calculate the new mass properties including inertia, if a correctly updated inertia is important).

◆ setHeightsFromList()

void agxCollide::HeightField::setHeightsFromList ( const agx::Vec2uVector indices,
const agx::RealVector heights 
)

Set height values given a list of terrain indices and corresponding heights.

Parameters
indices- list of indices to be updated. Must be of the same dimensions as the height vector.
heights- list of heights belonging to the indices to be updated. Must be of the same dimensions as the indices vector.

◆ setMinAllowedHeight()

void agxCollide::HeightField::setMinAllowedHeight ( agx::Real  minAllowedHeight)

Sets the new minAllowedHeight, which is at the same time the lower bound for a dynamic HeightField (for volume computation).

If the new minAllowedHeight is larger than the smallest existing height, it will be set to the smallest existing height. If the HeightField is dynamic, the mass properties will be recalculated, which is expensive in large HeightFields (linear in number of triangles). This function will not change existing height values, so that there might be heights below the minimum allowed heights if the the minimum allowed height is increased.

Parameters
minAllowedHeightThe new minimum height.

Definition at line 472 of file agxCollide/HeightField.h.

◆ shallowCopy()

HeightField * agxCollide::HeightField::shallowCopy ( ) const

Creates a new HeightField which shares data with this one.

(should not be used for data which will be changed afterwards). Quick to create, minimum memory overhead. The caller takes over possession of the pointer.

Member Data Documentation

◆ m_heightFieldData

HeightFieldMeshDataRef agxCollide::HeightField::m_heightFieldData
protected

Definition at line 402 of file agxCollide/HeightField.h.


The documentation for this class was generated from the following file: