|
AGX Dynamics 2.41.2.0
|
Triangle mesh for geometric intersection tests. More...
#include <Trimesh.h>
Inheritance diagram for agxCollide::Trimesh:Public Types | |
| 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... | |
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... | |
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. | |
| AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agxCollide::Trimesh) | |
| 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. | |
| virtual Shape * | clone () const override |
| Create a clone. | |
| Trimesh * | deepCopy () const |
| Creates a new Trimesh which copies data from this one. | |
| uint32_t | getOptionsMask () const |
| Gets option mask used when creating (can be interesting for debugging meshes). | |
| const Trimesh * | getShallowCopySource () |
| const agx::String & | getSourceName () const |
| Gets source name used when creating (can be interesting for debugging meshes). | |
| const agx::String & | getWarnings () const |
| Gets warnings occurring when creating (can be interesting for debugging meshes). | |
| bool | isShallowCopy () const |
| Trimesh * | shallowCopy () const |
| Creates a new Trimesh which shares data with this one. | |
| void | updateMeshGeometry (bool showWarnings, bool recalculateMassProperties=true) |
| Updates the mesh geometry data like normals or edge convexity. | |
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 a bottom safety margin that is added below the lowest point of the height field 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 agxStream::Serializable * | create (agxStream::InputArchive &) |
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 | |
| Trimesh (Type type, agx::Physics::Geometry::ShapePtr entity) | |
| Hiding default constructor for child classes. | |
| 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. | |
| virtual | ~Trimesh () |
| Hiding destructor. | |
| void | calculateMassProperties (bool showWarnings) |
| Calculates mass properties. | |
| void | finalizeMeshTopology (bool showWarnings, uint32_t optionsMask) |
| Finalizes the mesh topology, including mesh legality checks as well as normal and maximum error bound calculation. | |
| void | setValuesAsShallowCopy (const Trimesh *other) |
| virtual void | updateBvhTree () override |
| Update the bounding volume hierarchy. Internal method. | |
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 | |
| uint32_t | m_optionsMask |
| agx::ref_ptr< const Trimesh > | m_shallowCopySource |
| agx::String | m_sourceName |
| agx::String | m_warnings |
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 |
| agx::ref_ptr< agx::Referenced > | m_internalData |
| 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 | |
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. | |
Triangle mesh for geometric intersection tests.
More detailed ways of creating it can be found in agxUtil::TrimeshReaderWriter.
Parameters for trimesh creation from data set.
| 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.
| vertices | Pointer 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. |
| indices | Pointer 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. |
| sourceName | Name of the data source for debugging. |
| optionsMask | Options can be set as in enum TrimeshOptionsFlags. |
| bottomMargin | A safety threshold for catching collisions below the terrain surface, in the terrain case. |
|
protected |
Hidden, should only be called by child classes.
|
protected |
Hiding default constructor for child classes.
|
protectedvirtual |
Hiding destructor.
| agxCollide::Trimesh::AGXSTREAM_DECLARE_SERIALIZABLE_BASE | ( | agxCollide::Trimesh | ) |
|
protected |
Calculates mass properties.
Should only be called within finalize.
|
inlineoverridevirtual |
Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
| segmentStartLocal | The segment starting point in trimesh coordinates. |
| segmentEndLocal | The segment ending point in trimesh coordinates. |
| triangleIndices | A vector of triangle indices. It will be emptied before being written to. |
Implements agxCollide::Mesh.
Definition at line 313 of file Trimesh.h.
References agxCollide::Mesh::getBvhTree().
|
inlineoverridevirtual |
Calculates an array of triangle indices of the triangles whose bounding volumes get intersected by a line segment.
| segmentStartLocal | The segment starting point in trimesh coordinates. |
| segmentEndLocal | The segment ending point in trimesh coordinates. |
| triangleIndices | A vector of triangle indices. It will be emptied before being written to. |
Implements agxCollide::Mesh.
Definition at line 323 of file Trimesh.h.
References agxCollide::Mesh::getBvhTree().
|
overridevirtual |
|
inlinestatic |
| 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.
|
protected |
Finalizes the mesh topology, including mesh legality checks as well as normal and maximum error bound calculation.
Should only be called within finalize.
| showWarnings | - write warnings to output |
| optionsMask | - TrimeshOptionsFlags |
| uint32_t agxCollide::Trimesh::getOptionsMask | ( | ) | const |
Gets option mask used when creating (can be interesting for debugging meshes).
| const Trimesh * agxCollide::Trimesh::getShallowCopySource | ( | ) |
| const agx::String & agxCollide::Trimesh::getSourceName | ( | ) | const |
Gets source name used when creating (can be interesting for debugging meshes).
| 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()).
| bool agxCollide::Trimesh::isShallowCopy | ( | ) | const |
|
protected |
| 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.
|
overrideprotectedvirtual |
Update the bounding volume hierarchy. Internal method.
Implements agxCollide::Mesh.
| 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.
| showWarnings | Should warnings be printed out to cout? |
| recalculateMassProperties | Should the mass properties be computed/recomputed? |
|
protected |
|
protected |
|
protected |