AGX Dynamics 2.37.3.4
|
A HeightField is a collision shape that can be created from a grid structure, like an image. More...
#include <HeightField.h>
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 Shape * | clone () const override |
Create a clone. | |
HeightField * | deepCopy () 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 HeightFieldMeshData * | getHeightFieldMeshData () 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). | |
HeightField * | shallowCopy () 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 BoundingAABB & | getLocalBound () const |
const CollisionMeshData * | getMeshData () 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 BoundingAABB & | updateBoundingVolume () override |
Calculate the bounding volume based on the current Shape parameters including transformation. | |
Public Member Functions inherited from agxCollide::Shape | |
ShapeGroup * | asGroup () |
Auto-cast shape to group. | |
const ShapeGroup * | asGroup () 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 Shape * | clone () const |
Create a clone. | |
const BoundingAABB & | getBoundingVolume () const |
virtual agx::Vec3 | getCenter () const |
agx::Physics::Geometry::ShapePtr | getEntity () const |
Geometry * | getGeometry () |
const Geometry * | getGeometry () const |
agx::AffineMatrix4x4 | getLocalTransform () const |
agx::UInt32 | getModifiedCount () const |
agxCollide::RenderData * | getRenderData () |
const agxCollide::RenderData * | getRenderData () 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 BoundingAABB & | updateBoundingVolume ()=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. | |
Referenced & | operator= (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::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 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 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 |
Geometry * | m_geometry |
ShapeGroup * | m_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< TriangleLineSegmentResult > | TriangleLineSegmentResultVector |
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 DeleteHandler * | getDeleteHandler () |
static void | setDeleteHandler (DeleteHandler *handler) |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
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.
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.
resolutionX | The number of sample points in dimension x. |
resolutionY | The number of sample points in dimension y. |
sizeX | The physical size in dimension x. |
sizeY | The physical size in dimension y. |
bottomMargin | How deep is the HeightField under its lowest point? Positive value. |
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.
resolutionX | The number of sample points in dimension x. |
resolutionY | The number of sample points in dimension y. |
sizeX | The physical size in dimension x. |
sizeY | The 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. |
bottomMargin | How deep is the HeightField under its lowest point? Positive value. |
|
protectedvirtual |
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).
|
overridevirtual |
Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
segmentStartLocal | The segment starting point in heightfield coordinates. |
segmentEndLocal | The segment ending point in heightfield coordinates. |
triangleIndices | A vector of triangle indices. It will be emptied before writing to it. |
Implements agxCollide::Mesh.
|
overridevirtual |
Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
segmentStartLocal | The segment starting point in heightfield coordinates. |
segmentEndLocal | The segment ending point in heightfield coordinates. |
triangleIndices | A vector of triangle indices. It will be emptied before writing to it. |
Implements agxCollide::Mesh.
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.
vertexIndex | The global vertex index. |
vertexIndexX | A return value: The vertex index's x component. |
vertexIndexY | A return value: The vertex index's y component. |
Definition at line 451 of file agxCollide/HeightField.h.
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.
volume | The bounding box in its local coordinates. |
meshToWorld | A transformation from the mesh's local frame to world coordinates. |
volumeToWorld | A transformation from the volume's local frame to world coordinates. |
gridMin | The minimum vertex index x and y values. |
gridMax | The maximum vertex index x and y values. |
Does | the volume have any overlap with the grid? |
|
overridevirtual |
Create a clone.
Reimplemented from agxCollide::Shape.
|
static |
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 |
bottomMargin | How deep is the HeightField under its lowest point? |
|
static |
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.
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.
agx::Real agxCollide::HeightField::getHeight | ( | size_t | x, |
size_t | y | ||
) | const |
Gets the height at a grid point.
x | x coordinate on grid. |
y | y coordinate on grid. |
height | at this position. |
Definition at line 433 of file agxCollide/HeightField.h.
const HeightFieldMeshData * agxCollide::HeightField::getHeightFieldMeshData | ( | ) | const |
Definition at line 500 of file agxCollide/HeightField.h.
agx::Real agxCollide::HeightField::getMaxHeight | ( | ) | const |
Returns the (global) maximum height of the HeightField.
Definition at line 415 of file agxCollide/HeightField.h.
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.
agx::Real agxCollide::HeightField::getMinHeight | ( | ) | const |
Returns the (global) minimum height of the HeightField.
Definition at line 409 of file agxCollide/HeightField.h.
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.
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.
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.
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.
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.
size_t agxCollide::HeightField::getTriangleIndex | ( | size_t | indexX, |
size_t | indexY, | ||
uint_fast8_t | upper | ||
) | const |
Computes the global triangle index within the HeightField.
indexX | The triangle's x index (valid values: 0 to (getResolutionX() - 2)). |
indexY | The triangle's y index (valid values: 0 to (getResolutionY() - 2)). |
upper | Is it a lower left triangle (0) or upper right triangle (1)? |
Definition at line 459 of file agxCollide/HeightField.h.
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.
Projects a point in local HeightField coordinate system to the HeightField grid (which is moved to the first quadrant).
point | Point in height field coordinate system (height field center in origin). |
Point | in 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.
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.
void agxCollide::HeightField::setHeight | ( | size_t | xIndex, |
size_t | yIndex, | ||
agx::Real | height | ||
) |
Sets the height at a specific grid node.
xIndex | The index of the grid node in dimension x. |
yIndex | The index of the grid node in dimension y. |
height | The 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).
void agxCollide::HeightField::setHeights | ( | const agx::RealVector & | heights, |
bool | flipY = false |
||
) |
Set height values of all sampled points.
heights | - must be a row major matrix with dimensions (resolutionX, resolutionY). |
flipY | - set to true if y decreases with increasing indices in heights. |
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.
heights | A vector of size (maxVertexX + 1 - minVertexX) * (maxVertexY + 1 - minVertexY), giving the heights for the rectangle. |
minVertexX | The minimum vertex x index. |
minVertexY | The minimum vertex y index. |
maxVertexX | The maximum vertex x index. |
maxVertexY | The maximum vertex y index. |
true | of 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). |
void agxCollide::HeightField::setHeightsFromList | ( | const agx::Vec2uVector & | indices, |
const agx::RealVector & | heights | ||
) |
Set height values given a list of terrain indices and corresponding heights.
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. |
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.
minAllowedHeight | The new minimum height. |
Definition at line 472 of file agxCollide/HeightField.h.
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.
|
protected |
Definition at line 402 of file agxCollide/HeightField.h.