AGXDynamics  2.31.1.0
agxCollide::Trimesh Class Reference

Triangle mesh for geometric intersection tests. More...

#include <Trimesh.h>

+ Inheritance diagram for agxCollide::Trimesh:

Public Types

typedef agx::Vector< TriangleLineSegmentResult > TriangleLineSegmentResultVector
 
enum  TrimeshOptionsFlags {
  CLOCKWISE_ORIENTATION = 0x1, NO_WARNINGS = 0x10, TERRAIN = 0x20, REMOVE_DUPLICATE_VERTICES = 0x40,
  RECALCULATE_NORMALS_GIVEN_FIRST_TRIANGLE = 0x80
}
 Parameters for trimesh creation from data set. More...
 
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...
 

Public Member Functions

 Trimesh (const agx::Vec3Vector *vertices, const agx::UInt32Vector *indices, const char *sourceName, uint32_t optionsMask=Trimesh::REMOVE_DUPLICATE_VERTICES, agx::Real bottomMargin=0)
 Constructs a new Trimesh object from a vector of vertices and indices each. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
ShapeGroup * asGroup ()
 Auto-cast shape to group. More...
 
const ShapeGroup * asGroup () const
 Auto-cast shape to group. More...
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
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. More...
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const override
 Returns the inertia of the shape, scaled with the mass. Inherited from class Shape. More...
 
virtual BoundingAABB calculateLocalBound () const override
 Calculate the bounding volume in the local coordinate system. More...
 
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. More...
 
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. More...
 
void calculateTriangleOverlapsAlongLineSegment (const agx::Vec3 &segmentStartLocal, const agx::Vec3 &segmentEndLocal, TriangleLineSegmentResultVector &triangleResults) const
 Calculates all triangle overlaps of a line segment with the mesh. More...
 
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. More...
 
void calculateTrianglesInVolume (const BoundingAABB &volume, const agx::AffineMatrix4x4 &meshToWorld, const agx::AffineMatrix4x4 &volumeToWorld, agxData::LocalVector< agx::UInt32 > &triangleIndices) const
 
virtual Shape * clone () const override
 Create a clone. More...
 
FaceEdgeCirculator createFaceEdgeCirculator (size_t triangleIndex) const
 Creates an FaceEdgeCirculator pointing to this Triangle and a Voronoi region. More...
 
VertexEdgeCirculator createVertexEdgeCirculator (size_t triangleIndex, uint_fast8_t localVertexIndex) const
 Creates an VertexEdgeCirculator pointing to this Triangle and a Voronoi region. More...
 
Trimesh * deepCopy () const
 Creates a new Trimesh which copies data from this one. More...
 
agx::Real getBottomMargin () const
 
const BoundingAABB & getBoundingVolume () const
 
const AabbTree * getBvhTree () const
 
virtual agx::Vec3 getCenter () const override
 
const char * getClassName () const override
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::Physics::Geometry::ShapePtr getEntity () const
 
Geometry * getGeometry ()
 
const Geometry * getGeometry () const
 
size_t getGlobalVertexIndex (size_t triangleIndex, uint_fast8_t localVertexIndex) const
 Returns the global index of one of the three vertices in a triangle. More...
 
uint32_t getHalfEdgePartnerEdge (size_t globalEdgeIndex) const
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
const BoundingAABB & getLocalBound () const
 
agx::AffineMatrix4x4 getLocalTransform () const
 
const CollisionMeshData * getMeshData () const
 
agx::UInt32 getModifiedCount () const
 
size_t getNumTriangles () const
 
size_t getNumVertices () const
 
uint32_t getOptionsMask () const
 Gets option mask used when creating (can be interesting for debugging meshes). More...
 
int getReferenceCount () const
 
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. More...
 
const agx::String & getSourceName () const
 Gets source name used when creating (can be interesting for debugging meshes). More...
 
agxStream::StorageAgent * getStorageAgent () const override
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const
 Returns the support point on face of the shape. More...
 
agx::Real getTotalMaximumEdgeLength () const
 
agx::AffineMatrix4x4 getTransform () 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. More...
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
agx::Uuid getUuid () const
 
agx::Vec3 getVertex (size_t globalVertexIndex) const
 
virtual agx::Real getVolume () const override
 
const agx::String & getWarnings () const
 Gets warnings occurring when creating (can be interesting for debugging meshes). More...
 
bool hasHalfEdge () const
 
bool hasInternalCenterPoint () const
 
virtual bool hasSupportFunction () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
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. More...
 
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. More...
 
bool isFinished () const
 
bool isGroup () const
 
bool isTerrain () const
 
bool isValid () const
 
bool isValidAndClosed () const
 
bool isValidEdgeIndex (size_t globalEdgeIndex) const
 
bool isValidTriangleIndex (size_t globalTriangleIndex) const
 
virtual void propagateTransform (const agx::AffineMatrix4x4 &transform)
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
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. More...
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
virtual void setRenderData (agxCollide::RenderData *renderData)
 Store render data with the Shape. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
Trimesh * shallowCopy () const
 Creates a new Trimesh which shares data with this one. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
virtual const BoundingAABB & updateBoundingVolume () override
 Calculate the bounding volume based on the current Shape parameters including transformation. More...
 
void updateMeshGeometry (bool showWarnings, bool recalculateMassProperties=true)
 Updates the mesh geometry data like normals or edge convexity. More...
 

Static Public Member Functions

static BoundingAABB calculateBound (const agx::AffineMatrix4x4 &transform, const BoundingAABB &localBound)
 
static agxStream::Serializable * create ()
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static const char * getConstructClassId ()
 
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. More...
 
static size_t getGlobalTriangleIndex (size_t globalEdgeIndex)
 
static size_t getLocalEdgeIndex (size_t globalEdgeIndex)
 
static const char * getTypeName (agx::UInt8 type)
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

 Trimesh (Type type, agx::Physics::Geometry::ShapePtr entity, const agx::Vec3Vector *vertices, const agx::UInt32Vector *indices, const char *sourceName, uint32_t optionsMask=0)
 Hidden, should only be called by child classes. More...
 
 Trimesh (Type type, agx::Physics::Geometry::ShapePtr entity)
 Hiding default constructor for child classes. More...
 
virtual ~Trimesh ()
 Hiding destructor. More...
 
void allocateObserverVector () const
 
void calculateMassProperties (bool showWarnings)
 Calculates mass properties. More...
 
void deleteUsingDeleteHandler () const
 
void finalizeMeshTopology (bool showWarnings, uint32_t optionsMask)
 Finalizes the mesh topology, including mesh legality checks as well as normal and maximum error bound calculation. More...
 
void generateUuid ()
 
agx::UInt32 incrementModifiedCount ()
 Increment the number of times the shape have been modified. More...
 
void setValuesAsShallowCopy (const Trimesh *other)
 
void syncronizeShapeIndex ()
 
virtual void updateBvhTree () override
 Update the bounding volume hierarchy. Internal method. More...
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

AabbTreeRef m_aabbTree
 
CollisionMeshDataRef m_collisionMeshData
 
agx::Physics::Geometry::ShapeRef m_entity
 
Geometry * m_geometry
 
BoundingAABB m_localBound
 
Mutex m_mutex
 
ObserverContainer m_observers
 
uint32_t m_optionsMask
 
ShapeGroup * m_parent
 
AtomicValue m_refCount
 
agxCollide::RenderDataRef m_renderData
 
agx::ref_ptr< const Trimesh > m_shallowCopySource
 
agx::Index m_shapeIndex
 
agx::String m_sourceName
 
agx::String m_warnings
 

Detailed Description

Triangle mesh for geometric intersection tests.

More detailed ways of creating it can be found in agxUtil::TrimeshReaderWriter.

Definition at line 42 of file Trimesh.h.

Member Typedef Documentation

◆ TriangleLineSegmentResultVector

Member Enumeration Documentation

◆ TrimeshOptionsFlags

Parameters for trimesh creation from data set.

Enumerator
CLOCKWISE_ORIENTATION 

Counterclockwise orientation is standard, set this flag in order to change to clockwise orientation.

NO_WARNINGS 

Deactivates warnings about flaws in the mesh topology which will lead to bad simulation results.

Error warnings about illegal mesh data will still be issued. If trimesh data which will lead to warnings has to be used, it can be a good idea to use this flag for performance reasons:

  1. This will avoid having to send warning strings to LOGGER_WARNING
  2. It will also avoid having to store them, increasing memory footprint and serialization file size. However, the best alternative is to avoid/fix the warnings, since they indicate that the mesh might behave badly in the simulation!
TERRAIN 

Set this flag in order to have the mesh to behave as a terrain, with z up as the terrain up normal.

REMOVE_DUPLICATE_VERTICES 

Removes exactly identical duplicates in the vertices, as well as (resulting or previously existing) triangles which use the same vertex more than once.

RECALCULATE_NORMALS_GIVEN_FIRST_TRIANGLE 

Tries to rearrange indices for all triangles so that normals for neighboring triangles (that share edges) use the edges in the same direction.

Definition at line 49 of file Trimesh.h.

◆ Type

enum agxCollide::Shape::Type
inherited

Define the type of a Shape.

Enumerator
GROUP 
BOX 
CAPSULE 
CYLINDER 
LINE 
PLANE 
SPHERE 
TRIMESH 
HEIGHT_FIELD 
CONVEX 
WIRE_SHAPE 
CONE 
HOLLOW_CONE 
HOLLOW_CYLINDER 
NUM_TYPES 

Definition at line 58 of file Shape.h.

Constructor & Destructor Documentation

◆ Trimesh() [1/3]

agxCollide::Trimesh::Trimesh ( const agx::Vec3Vector *  vertices,
const agx::UInt32Vector *  indices,
const char *  sourceName,
uint32_t  optionsMask = Trimesh::REMOVE_DUPLICATE_VERTICES,
agx::Real  bottomMargin = 0 
)

Constructs a new Trimesh object from a vector of vertices and indices each.

The Trimesh should either be a manifold or a terrain. If it is a terrain, this should be specified in the optionsMask. A terrain trimesh should be used only for static objects. The terrain mesh should not contain holes except the outer bounds, and it should be oriented towards the normal [0 0 1] (z up). The constructor can result in warnings of two different types: 'Trimesh creation error' will be printed to LOGGER_WARNING. They indicate that the trimesh will not be usable due to corrupt input data. 'Trimesh creation warning' will be printed to LOGGER_WARNING by default, but this can be turned off by setting the NO_WARNINGS-flag in the optionsMask. The warnings in this category can be obtained later by the getWarnings()-method (if warnings have not been turned off). The warnings of this category warn that the data for this trimesh has severe shortcomings and might not behave well in the simulation. General hints when creating trimeshes: Triangle meshes for collision detection should be closed/manifolds. Consider merging close vertices. Consider also closing holes in the mesh. Consider orienting all triangle faces outwards. Try modeling in way that lets the trimesh represent a closed volume, with a clearly defined inside and outside (given by winding). For simulating terrain, please use the appropriate constructor.

Parameters
verticesPointer to a Vector of vertices. Vertices should not be duplicates of each other. Has to have at least size 1. All content will be copied. No ownership will be taken.
indicesPointer to a Vector of size_t indicating the vertices for each triangle by referring to the vertices parameter. All triangles described by a set of 3 indices each have to have counter-clockwise winding (all-clockwise-winding can be specified in TrimeshOptionsFlags). Has to have at least size 3. All content will be copied. No ownership will be taken.
sourceNameName of the data source for debugging.
optionsMaskOptions can be set as in enum TrimeshOptionsFlags.
bottomMarginA safety threshold for catching collisions below the terrain surface, in the terrain case.

◆ Trimesh() [2/3]

agxCollide::Trimesh::Trimesh ( Type  type,
agx::Physics::Geometry::ShapePtr  entity,
const agx::Vec3Vector *  vertices,
const agx::UInt32Vector *  indices,
const char *  sourceName,
uint32_t  optionsMask = 0 
)
protected

Hidden, should only be called by child classes.

◆ Trimesh() [3/3]

agxCollide::Trimesh::Trimesh ( Type  type,
agx::Physics::Geometry::ShapePtr  entity 
)
protected

Hiding default constructor for child classes.

◆ ~Trimesh()

virtual agxCollide::Trimesh::~Trimesh ( )
protectedvirtual

Hiding destructor.

Member Function Documentation

◆ allocateObserverVector()

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited

◆ as() [1/2]

template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().

◆ as() [2/2]

template<typename T >
const T* agx::Referenced::as ( ) const
inherited

◆ asGroup() [1/2]

ShapeGroup * agxCollide::Shape::asGroup ( )
inherited

Auto-cast shape to group.

Definition at line 385 of file Shape.h.

References agxAssert.

◆ asGroup() [2/2]

const ShapeGroup * agxCollide::Shape::asGroup ( ) const
inherited

Auto-cast shape to group.

Definition at line 390 of file Shape.h.

◆ asSafe() [1/2]

template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

◆ asSafe() [2/2]

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited

◆ calculateBound()

BoundingAABB agxCollide::Shape::calculateBound ( const agx::AffineMatrix4x4 &  transform,
const BoundingAABB &  localBound 
)
staticinherited
Returns
a bounding box calculated from a transformed (transform) AABB (localBound)

Definition at line 417 of file Shape.h.

References AGX_FORCE_INLINE, and agxData::getEntity().

◆ calculateBoundingRadius()

virtual agx::Real agxCollide::Shape::calculateBoundingRadius ( BoundingAABB &  localAABB) const
virtualinherited

Calculate the bounding volume (AABB) into localAABB and calculate the bounding radius based on the new AABB size.

Returns
the radius of the bounding sphere surrounding the AABB.

Reimplemented in agxCollide::Sphere.

◆ calculateInertia()

agx::SPDMatrix3x3 agxCollide::Mesh::calculateInertia ( agx::Real  mass) const
overridevirtualinherited

Returns the inertia of the shape, scaled with the mass. Inherited from class Shape.

Implements agxCollide::Shape.

Definition at line 825 of file Mesh.h.

◆ calculateLocalBound()

virtual BoundingAABB agxCollide::Mesh::calculateLocalBound ( ) const
overridevirtualinherited

Calculate the bounding volume in the local coordinate system.

Returns
the calculated bounding volume.

Implements agxCollide::Shape.

◆ calculateMassProperties()

void agxCollide::Trimesh::calculateMassProperties ( bool  showWarnings)
protected

Calculates mass properties.

Should only be called within finalize.

◆ calculatePossibleTriangleOverlapsAlongLineSegment() [1/2]

void agxCollide::Trimesh::calculatePossibleTriangleOverlapsAlongLineSegment ( const agx::Vec3 &  segmentStartLocal,
const agx::Vec3 &  segmentEndLocal,
agx::UInt32Vector &  triangleIndices 
) const
inlineoverridevirtual

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

Parameters
segmentStartLocalThe segment starting point in trimesh coordinates.
segmentEndLocalThe segment ending point in trimesh coordinates.
triangleIndicesA vector of triangle indices. It will be emptied before being written to.

Implements agxCollide::Mesh.

Definition at line 304 of file Trimesh.h.

◆ calculatePossibleTriangleOverlapsAlongLineSegment() [2/2]

void agxCollide::Trimesh::calculatePossibleTriangleOverlapsAlongLineSegment ( const agx::Vec3 &  segmentStartLocal,
const agx::Vec3 &  segmentEndLocal,
agxData::LocalVector< agx::UInt32 > &  triangleIndices 
) const
inlineoverridevirtual

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

Parameters
segmentStartLocalThe segment starting point in trimesh coordinates.
segmentEndLocalThe segment ending point in trimesh coordinates.
triangleIndicesA vector of triangle indices. It will be emptied before being written to.

Implements agxCollide::Mesh.

Definition at line 314 of file Trimesh.h.

◆ calculateTriangleOverlapsAlongLineSegment()

void agxCollide::Mesh::calculateTriangleOverlapsAlongLineSegment ( const agx::Vec3 &  segmentStartLocal,
const agx::Vec3 &  segmentEndLocal,
TriangleLineSegmentResultVector &  triangleResults 
) const
inherited

Calculates all triangle overlaps of a line segment with the mesh.

Tries to fix some corner cases such as:

  • A line segment tangent to a mesh edge should get 2 contacts (one for each triangle).
  • A line segment intersecting through a mesh edge should get 1 contact (for one of the triangles).
  • Vertices will be treated as several edges (with 1-2 contacts per edge, see above).
    Parameters
    segmentStartLocalThe segment starting point in mesh coordinates.
    segmentEndLocalThe segment ending point in mesh coordinates.
    triangleResults- Vector of resulting overlapped triangles

◆ calculateTrianglesInVolume() [1/2]

void agxCollide::Mesh::calculateTrianglesInVolume ( const BoundingAABB &  volume,
const agx::AffineMatrix4x4 &  meshToWorld,
const agx::AffineMatrix4x4 &  volumeToWorld,
agx::UInt32Vector &  triangleIndices 
) const
inherited

Calculates an array of triangle indices of the triangles that are within a bounding volume.

Parameters
volumeThe bounding box.
meshToWorldA transformation from the mesh's local frame to world coordinates.
volumeToWorldA transformation from the volume's local frame to world coordinates.
triangleIndicesA vector of triangle indices. It will be emptied before writing to it.

Definition at line 995 of file Mesh.h.

◆ calculateTrianglesInVolume() [2/2]

void agxCollide::Mesh::calculateTrianglesInVolume ( const BoundingAABB &  volume,
const agx::AffineMatrix4x4 &  meshToWorld,
const agx::AffineMatrix4x4 &  volumeToWorld,
agxData::LocalVector< agx::UInt32 > &  triangleIndices 
) const
inherited

Definition at line 1004 of file Mesh.h.

◆ clone()

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

Create a clone.

Reimplemented from agxCollide::Shape.

Reimplemented in agxCollide::Convex.

◆ create() [1/2]

static agxStream::Serializable* agxCollide::Trimesh::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 208 of file Trimesh.h.

◆ create() [2/2]

static agxStream::Serializable* agxCollide::Trimesh::create ( )
inlinestatic

Definition at line 208 of file Trimesh.h.

◆ createFaceEdgeCirculator()

Mesh::FaceEdgeCirculator agxCollide::Mesh::createFaceEdgeCirculator ( size_t  triangleIndex) const
inlineinherited

Creates an FaceEdgeCirculator pointing to this Triangle and a Voronoi region.

Returns
The created FaceEdgeCirculator

Definition at line 1084 of file Mesh.h.

◆ createVertexEdgeCirculator()

Mesh::VertexEdgeCirculator agxCollide::Mesh::createVertexEdgeCirculator ( size_t  triangleIndex,
uint_fast8_t  localVertexIndex 
) const
inlineinherited

Creates an VertexEdgeCirculator pointing to this Triangle and a Voronoi region.

Parameters
triangleIndex- Index of the triangle
localVertexIndexThe local index of the vertex that the VertexEdgeCirculator should point to.
Returns
The created VertexEdgeCirculator

Definition at line 1012 of file Mesh.h.

Referenced by agxSDK::findMostParallelEdgeAmongNeighboringTriangles().

◆ deepCopy()

Trimesh* agxCollide::Trimesh::deepCopy ( ) const

Creates a new Trimesh 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. Will only copy members from Mesh/Trimesh, not Shape (such as RenderData). The caller takes over possession of the pointer.

◆ deleteUsingDeleteHandler()

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited

◆ finalizeMeshTopology()

void agxCollide::Trimesh::finalizeMeshTopology ( bool  showWarnings,
uint32_t  optionsMask 
)
protected

Finalizes the mesh topology, including mesh legality checks as well as normal and maximum error bound calculation.

Should only be called within finalize.

Parameters
showWarnings- write warnings to output
optionsMask- TrimeshOptionsFlags

◆ generateUuid()

void agxStream::Serializable::generateUuid ( )
protectedinherited

◆ getBottomMargin()

agx::Real agxCollide::Mesh::getBottomMargin ( ) const
inherited
Returns
Bottom safety margin. This is the depth that is added below the lowest point in the terrain in local z direction, to prevent tunneling in this direction.

Definition at line 842 of file Mesh.h.

◆ getBoundingVolume()

const BoundingAABB & agxCollide::Shape::getBoundingVolume ( ) const
inherited
Returns
the bounding volume of the shape, in global coordinates.

Definition at line 412 of file Shape.h.

◆ getBvhTree()

const AabbTree * agxCollide::Mesh::getBvhTree ( ) const
inherited
Returns
The Trimesh's bounding volume hierarchy.

Definition at line 882 of file Mesh.h.

◆ getCenter()

agx::Vec3 agxCollide::Mesh::getCenter ( ) const
overridevirtualinherited
Returns
The center of the Mesh. Inherited from class Shape.

Reimplemented from agxCollide::Shape.

Definition at line 813 of file Mesh.h.

◆ getClassName()

const char* agxCollide::Trimesh::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agxStream::Serializable.

Definition at line 208 of file Trimesh.h.

◆ getConstructClassId()

static const char* agxCollide::Trimesh::getConstructClassId ( )
inlinestatic

Definition at line 208 of file Trimesh.h.

◆ getDeleteHandler()

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.

◆ getEnableSerialization()

bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

◆ getEnableUuidGeneration()

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object

◆ getEntity()

agx::Physics::Geometry::ShapePtr agxCollide::Shape::getEntity ( ) const
inlineinherited

◆ getGeometry() [1/2]

Geometry * agxCollide::Shape::getGeometry ( )
inherited
Returns
pointer to the associated Geometry, null if none.

Definition at line 399 of file Shape.h.

◆ getGeometry() [2/2]

const Geometry * agxCollide::Shape::getGeometry ( ) const
inherited
Returns
pointer to the associated Geometry, null if none.

Definition at line 403 of file Shape.h.

◆ getGlobalEdgeIndex()

size_t agxCollide::Mesh::getGlobalEdgeIndex ( size_t  triangleIndex,
uint_fast8_t  localEdgeIndex 
)
staticinherited

Computes the global edge index from a given triangle index and the local edge index within this triangle.

Mesh class.

Parameters
triangleIndexThe global triangle index.
localEdgeIndexThe local edge index within this triangle.
Returns
The global edge index.

Definition at line 724 of file Mesh.h.

Referenced by agxCollide::Mesh::Triangle::getHalfEdgePartnerGlobalEdgeIndex().

◆ getGlobalTriangleIndex()

size_t agxCollide::Mesh::getGlobalTriangleIndex ( size_t  globalEdgeIndex)
staticinherited
Parameters
globalEdgeIndexThe global edge index.
Returns
The global Triangle index which the edge (given as a global index) corresponds to.

Definition at line 742 of file Mesh.h.

◆ getGlobalVertexIndex()

size_t agxCollide::Mesh::getGlobalVertexIndex ( size_t  triangleIndex,
uint_fast8_t  localVertexIndex 
) const
inherited

Returns the global index of one of the three vertices in a triangle.

Parameters
triangleIndexIndex of the triangle the vertex belongs to.
localVertexIndexThe vertex's index within the triangle (0 to 2).
Returns
The global index of the vertex specified by the parameters.

Definition at line 778 of file Mesh.h.

◆ getHalfEdgePartnerEdge()

uint32_t agxCollide::Mesh::getHalfEdgePartnerEdge ( size_t  globalEdgeIndex) const
inherited
Returns
The global edge index of an edge's half edge partner

Definition at line 796 of file Mesh.h.

◆ getIndex()

agx::UInt32 agxStream::Serializable::getIndex ( ) const
inherited

This index is given at creation of this object.

It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.

Returns
an instance index of this object. This is unique for the lifetime of this library instance.

Definition at line 247 of file Serializable.h.

◆ getLocalBound()

const BoundingAABB & agxCollide::Mesh::getLocalBound ( ) const
inherited

Definition at line 1096 of file Mesh.h.

◆ getLocalEdgeIndex()

size_t agxCollide::Mesh::getLocalEdgeIndex ( size_t  globalEdgeIndex)
staticinherited
Parameters
globalEdgeIndexThe global edge index.
Returns
The local edge index which the edge (given as a global index) corresponds to.

Definition at line 736 of file Mesh.h.

◆ getLocalTransform()

agx::AffineMatrix4x4 agxCollide::Shape::getLocalTransform ( ) const
inherited
Returns
the transform relative to its parent (Geometry) of this Shape

◆ getMeshData()

const CollisionMeshData * agxCollide::Mesh::getMeshData ( ) const
inherited
Returns
The CollisionMeshData containing all the mesh information.

Definition at line 870 of file Mesh.h.

◆ getModifiedCount()

agx::UInt32 agxCollide::Shape::getModifiedCount ( ) const
inherited
Returns
number of times the shape have been modified. Increments at every set method.

Definition at line 454 of file Shape.h.

◆ getNumTriangles()

size_t agxCollide::Mesh::getNumTriangles ( ) const
inherited
Returns
The number of Triangles in the mesh data.

Definition at line 760 of file Mesh.h.

Referenced by agxWire::getNode().

◆ getNumVertices()

size_t agxCollide::Mesh::getNumVertices ( ) const
inherited
Returns
The number of vertices in the mesh data.

Definition at line 748 of file Mesh.h.

◆ getOptionsMask()

uint32_t agxCollide::Trimesh::getOptionsMask ( ) const

Gets option mask used when creating (can be interesting for debugging meshes).

◆ getReferenceCount()

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.

◆ getRenderData()

const agxCollide::RenderData* agxCollide::Shape::getRenderData ( ) const
inherited

If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc.

shapes) You need to go through each child and access the render data from those.

Returns
the render data stored with the shape.

◆ getSourceName()

const agx::String& agxCollide::Trimesh::getSourceName ( ) const

Gets source name used when creating (can be interesting for debugging meshes).

◆ getStorageAgent()

agxStream::StorageAgent* agxCollide::Trimesh::getStorageAgent ( ) const
inlineoverridevirtual
Returns
the storage agent

Implements agxStream::Serializable.

Definition at line 208 of file Trimesh.h.

◆ getSupportPoint()

agx::Vec3 agxCollide::Shape::getSupportPoint ( const agx::Vec3 &  supportDirection) const
inlinevirtualinherited

Returns the support point on face of the shape.

Parameters
supportDirection- Direction in shape coords where to find a support point

Reimplemented in agxCollide::HollowCone, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::Convex, agxCollide::Box, and agxCollide::Sphere.

Definition at line 498 of file Shape.h.

◆ getTotalMaximumEdgeLength()

agx::Real agxCollide::Mesh::getTotalMaximumEdgeLength ( ) const
inherited
Returns
The maximum length of all triangle edges.

Definition at line 790 of file Mesh.h.

◆ getTransform()

agx::AffineMatrix4x4 agxCollide::Shape::getTransform ( ) const
inherited
Returns
the transform of this Shape

Definition at line 407 of file Shape.h.

◆ getTriangle()

const Mesh::Triangle agxCollide::Mesh::getTriangle ( size_t  triangleIndex) const
inlineinherited
Parameters
triangleIndexThe index of the triangle.
Returns
Triangle

Definition at line 730 of file Mesh.h.

Referenced by agxSDK::calculateMeshOffset(), agxSDK::findMostParallelEdgeAmongNeighboringTriangles(), and agxWire::getNode().

◆ getTriangleMaximumEdgeLength()

agx::Real agxCollide::Mesh::getTriangleMaximumEdgeLength ( size_t  triangleIndex) const
inherited
Parameters
triangleIndexThe index of the Triangle.
Returns
The length of the longest edge in the Triangle.

Definition at line 784 of file Mesh.h.

◆ getTriangleNormal()

agx::Vec3 agxCollide::Mesh::getTriangleNormal ( size_t  triangleIndex) const
inherited
Parameters
triangleIndexThe index of the Triangle.
Returns
The normal of the Triangle.

Definition at line 772 of file Mesh.h.

◆ getTriangleVertex()

agx::Vec3 agxCollide::Mesh::getTriangleVertex ( size_t  triangleIndex,
uint_fast8_t  localVertexIndex 
) const
inherited

Returns one of the three vertices in a triangle.

Parameters
triangleIndexIndex of the triangle the vertex belongs to.
localVertexIndexThe vertex's index within the triangle (0 to 2).
Returns
The vertex specified by the parameters.

Definition at line 766 of file Mesh.h.

Referenced by agxSDK::findMostParallelEdgeAmongNeighboringTriangles().

◆ getType()

agx::UInt8 agxCollide::Shape::getType ( ) const
inherited
Returns
The shape type.

Definition at line 377 of file Shape.h.

Referenced by agxCollide::ColliderTable::getCollider().

◆ getTypeName() [1/2]

static const char* agxCollide::Shape::getTypeName ( agx::UInt8  type)
staticinherited
Returns
a string name for the given Type type

◆ getTypeName() [2/2]

const char* agxCollide::Shape::getTypeName ( ) const
inherited
Returns
The shape type name.

◆ getUuid()

agx::Uuid agxStream::Serializable::getUuid ( ) const
inherited
Returns
a unique id for this instance.

Definition at line 268 of file Serializable.h.

Referenced by agxSDK::UuidHashCollisionFilter::match().

◆ getVertex()

agx::Vec3 agxCollide::Mesh::getVertex ( size_t  globalVertexIndex) const
inherited
Parameters
globalVertexIndexIndex of the vertex in the MeshData's vertices array.
Returns
Vertex specified by globalVertexIndex

Definition at line 754 of file Mesh.h.

◆ getVolume()

agx::Real agxCollide::Mesh::getVolume ( ) const
overridevirtualinherited
Returns
The volume of the Mesh. Inherited from class Shape.

Implements agxCollide::Shape.

Definition at line 819 of file Mesh.h.

◆ getWarnings()

const agx::String& agxCollide::Trimesh::getWarnings ( ) const

Gets warnings occurring when creating (can be interesting for debugging meshes).

Will be empty if there where no warnings, or if warnings have been deactivated (see getOptionsMask()).

◆ hasHalfEdge()

bool agxCollide::Mesh::hasHalfEdge ( ) const
inherited
Returns
True if the Mesh has a half edge structure.

Definition at line 876 of file Mesh.h.

◆ hasInternalCenterPoint()

bool agxCollide::Mesh::hasInternalCenterPoint ( ) const
inherited
Returns
True if the center point of the mesh is inside the mesh, eg false for torus

Definition at line 836 of file Mesh.h.

◆ hasSupportFunction()

bool agxCollide::Shape::hasSupportFunction ( ) const
inlinevirtualinherited
Returns
true if the shape implements its own support function, used by Minkowski difference based collision algorithms.

Reimplemented in agxCollide::HollowCone, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::Convex, agxCollide::Box, and agxCollide::Sphere.

Definition at line 493 of file Shape.h.

Referenced by agxCollide::FallbackConvexCollider< ShapeType1, ShapeType2 >::_calculateContacts().

◆ incrementModifiedCount()

agx::UInt32 agxCollide::Shape::incrementModifiedCount ( )
protectedinherited

Increment the number of times the shape have been modified.

Returns
the incremented value.

Definition at line 459 of file Shape.h.

References AGX_FORCE_INLINE, and agxAssert.

◆ is()

template<typename T >
bool agx::Referenced::is ( ) const
inherited

◆ isConvexEdge()

bool agxCollide::Mesh::isConvexEdge ( size_t  globalEdgeIndex) const
inherited

Is an edge convex? Returns always true if half edge information is missing on this edge/the whole mesh.

Exactly straight edges will also be considered convex.

Parameters
globalEdgeIndex
Return values
Isthe edge convex?

◆ isConvexVertex()

bool agxCollide::Mesh::isConvexVertex ( size_t  triangleIndex,
size_t  localVertexIndex 
) const
inherited

Is an vertex convex? Returns always true if half edge information is missing on this vertex/the whole mesh.

Exactly straight edges will also be considered convex. Saddle points will return false. When encountering a hole, the edges until the whole will be considered.

Parameters
triangleIndexThe global index of the triangle
localVertexIndexThe local index of the vertex in the triangle
Return values
Isthe edge convex?

◆ isFinished()

bool agxStream::Serializable::isFinished ( ) const
inherited
Returns
true if this class is restored correctly and should not be deleted during destruction of an Archive.

Definition at line 252 of file Serializable.h.

References AGX_FORCE_INLINE.

◆ isGroup()

bool agxCollide::Shape::isGroup ( ) const
inherited
Returns
True if the shape is a group.

Definition at line 381 of file Shape.h.

References agxData::getType().

◆ isTerrain()

bool agxCollide::Mesh::isTerrain ( ) const
inherited
Returns
True if Mesh is terrain (it will not be a Manifold/closed then).

Definition at line 831 of file Mesh.h.

◆ isValid()

bool agxCollide::Mesh::isValid ( ) const
inherited
Returns
True if the Mesh is valid and can be used for collision detection and other purposes; false otherwise.

Definition at line 802 of file Mesh.h.

◆ isValidAndClosed()

bool agxCollide::Mesh::isValidAndClosed ( ) const
inherited
Returns
True if the Mesh is valid and can be used for collision detection and other purposes, and if it is a Manifold; false otherwise.

Definition at line 808 of file Mesh.h.

◆ isValidEdgeIndex()

bool agxCollide::Mesh::isValidEdgeIndex ( size_t  globalEdgeIndex) const
inherited
Parameters
globalEdgeIndexThe global index to examine.
Returns
Is the given edge index a valid edge index within this Mesh?

Definition at line 858 of file Mesh.h.

◆ isValidTriangleIndex()

bool agxCollide::Mesh::isValidTriangleIndex ( size_t  globalTriangleIndex) const
inherited
Parameters
globalTriangleIndexThe global index to examine.
Returns
Is the given triangle index a valid edge index within this Mesh?

Definition at line 864 of file Mesh.h.

◆ propagateTransform()

virtual void agxCollide::Shape::propagateTransform ( const agx::AffineMatrix4x4 &  transform)
virtualinherited

◆ reference()

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

◆ restore()

virtual void agxCollide::Trimesh::restore ( agxStream::InputArchive &  in)
overridevirtual

Reimplemented in agxCollide::Convex.

◆ setBottomMargin()

void agxCollide::Mesh::setBottomMargin ( agx::Real  newMargin)
inherited

Sets the depth that is added below the lowest point in the terrain in local z direction, to prevent tunneling in this direction.

Will also update the bounding volume.

Parameters
newMarginThe desired depth. Negative values will be ignored.

Definition at line 848 of file Mesh.h.

◆ setDeleteHandler()

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

◆ setEnableSerialization()

void agxStream::Serializable::setEnableSerialization ( bool  flag)
inherited

Set to false to disable serialization of this object.

It will just be ignored during serialization (writing). It is still possible to restore TO this object.

◆ setEnableUuidGeneration()

static void agxStream::Serializable::setEnableUuidGeneration ( bool  flag)
staticinherited

Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.

◆ setFinished()

void agxStream::Serializable::setFinished ( )
inherited

Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.

◆ setRenderData()

virtual void agxCollide::Shape::setRenderData ( agxCollide::RenderData *  renderData)
virtualinherited

Store render data with the Shape.

If the shape is a Group, the render data will be stored in all the children and NOT in the actual ShapeGroup. It is better to actually access the actual primitives and store the render data there instead of the group.

◆ setUuid()

void agxStream::Serializable::setUuid ( const agx::Uuid &  uuid)
inherited

Explicitly set a Uuid on a serializable object.

Use this method with great care, as it can result in non-unique identifiers in the system!

◆ setValuesAsShallowCopy()

void agxCollide::Trimesh::setValuesAsShallowCopy ( const Trimesh *  other)
protected

◆ shallowCopy()

Trimesh* agxCollide::Trimesh::shallowCopy ( ) const

Creates a new Trimesh which shares data with this one.

(should not be used for data which will be changed afterwards). Quick to create, minimum memory overhead. Will only copy members from Mesh/Trimesh, not Shape (such as RenderData). The caller takes over possession of the pointer.

◆ store()

virtual void agxCollide::Trimesh::store ( agxStream::OutputArchive &  out) const
overridevirtual

Reimplemented in agxCollide::Convex.

◆ syncronizeShapeIndex()

void agxCollide::Shape::syncronizeShapeIndex ( )
protectedinherited

◆ unreference()

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().

◆ unreference_nodelete()

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

◆ updateBoundingVolume()

virtual const BoundingAABB& agxCollide::Mesh::updateBoundingVolume ( )
overridevirtualinherited

Calculate the bounding volume based on the current Shape parameters including transformation.

Returns
new calculated bounding volume

Implements agxCollide::Shape.

◆ updateBvhTree()

virtual void agxCollide::Trimesh::updateBvhTree ( )
overrideprotectedvirtual

Update the bounding volume hierarchy. Internal method.

Implements agxCollide::Mesh.

◆ updateMeshGeometry()

void agxCollide::Trimesh::updateMeshGeometry ( bool  showWarnings,
bool  recalculateMassProperties = true 
)

Updates the mesh geometry data like normals or edge convexity.

Will update mass properties, bounding box and bounding volume hierarchy. Will be called after construction. It should also be called if vertex positions get modified after construction.

Parameters
showWarningsShould warnings be printed out to cout?
recalculateMassPropertiesShould the mass properties be computed/recomputed?

◆ ValidateCast()

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

◆ m_aabbTree

AabbTreeRef agxCollide::Mesh::m_aabbTree
protectedinherited

Definition at line 633 of file Mesh.h.

◆ m_collisionMeshData

CollisionMeshDataRef agxCollide::Mesh::m_collisionMeshData
protectedinherited

Definition at line 632 of file Mesh.h.

◆ m_entity

agx::Physics::Geometry::ShapeRef agxCollide::Shape::m_entity
protectedinherited

Definition at line 265 of file Shape.h.

◆ m_geometry

Geometry* agxCollide::Shape::m_geometry
protectedinherited

Definition at line 266 of file Shape.h.

◆ m_localBound

BoundingAABB agxCollide::Mesh::m_localBound
protectedinherited

Definition at line 634 of file Mesh.h.

◆ m_mutex

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

◆ m_observers

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

◆ m_optionsMask

uint32_t agxCollide::Trimesh::m_optionsMask
protected

Definition at line 296 of file Trimesh.h.

◆ m_parent

ShapeGroup* agxCollide::Shape::m_parent
protectedinherited

Definition at line 270 of file Shape.h.

◆ m_refCount

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

◆ m_renderData

agxCollide::RenderDataRef agxCollide::Shape::m_renderData
protectedinherited

Definition at line 267 of file Shape.h.

◆ m_shallowCopySource

agx::ref_ptr<const Trimesh> agxCollide::Trimesh::m_shallowCopySource
protected

Definition at line 297 of file Trimesh.h.

◆ m_shapeIndex

agx::Index agxCollide::Shape::m_shapeIndex
protectedinherited

Definition at line 268 of file Shape.h.

◆ m_sourceName

agx::String agxCollide::Trimesh::m_sourceName
protected

Definition at line 294 of file Trimesh.h.

◆ m_warnings

agx::String agxCollide::Trimesh::m_warnings
protected

Definition at line 295 of file Trimesh.h.


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