AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
agxCollide::Shape Class Referenceabstract

Base class for a shape. More...

#include <Shape.h>

+ Inheritance diagram for agxCollide::Shape:

Public Types

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

ShapeGroupasGroup ()
 Auto-cast shape to group.
 
const ShapeGroupasGroup () const
 Auto-cast shape to group.
 
virtual agx::Real calculateBoundingRadius (BoundingAABB &localAABB) const
 Calculate the bounding volume (AABB) into localAABB and calculate the bounding radius based on the new AABB size.
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const =0
 Calculate the inertia for the shape given a mass.
 
virtual BoundingAABB calculateLocalBound () const =0
 Calculate the bounding volume in the local coordinate system.
 
virtual Shapeclone () const
 Create a clone.
 
const BoundingAABBgetBoundingVolume () const
 
virtual agx::Vec3 getCenter () const
 
agx::Physics::Geometry::ShapePtr getEntity () const
 
GeometrygetGeometry ()
 
const GeometrygetGeometry () const
 
agx::AffineMatrix4x4 getLocalTransform () const
 
agx::UInt32 getModifiedCount () const
 
agxCollide::RenderDatagetRenderData ()
 
const agxCollide::RenderDatagetRenderData () const
 If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc.
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const
 Returns the support point on face of the shape.
 
agx::AffineMatrix4x4 getTransform () const
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
virtual agx::Real getVolume () const =0
 Return the volume of the shape.
 
virtual bool hasSupportFunction () const
 
bool isGroup () const
 
virtual void propagateTransform (const agx::AffineMatrix4x4 &transform)
 
virtual void setRenderData (agxCollide::RenderData *renderData)
 Store render data with the Shape.
 
virtual const BoundingAABBupdateBoundingVolume ()=0
 Calculate the bounding volume based on the current Shape parameters including transformation.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static 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

 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

agx::Physics::Geometry::ShapeRef m_entity
 
Geometrym_geometry
 
agx::ref_ptr< agx::Referencedm_internalData
 
ShapeGroupm_parent
 
agxCollide::RenderDataRef m_renderData
 
agx::Index m_shapeIndex
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Base class for a shape.

Definition at line 57 of file Shape.h.

Member Enumeration Documentation

◆ Type

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 62 of file Shape.h.

Constructor & Destructor Documentation

◆ Shape()

agxCollide::Shape::Shape ( Type  type,
agx::Physics::Geometry::ShapePtr  entity = agx::Physics::Geometry::ShapeModel::createInstance() 
)
protected

Constructor.

Parameters
type- Type of the Shape
entity- pointer to an entity. By default a new instance is created.

◆ ~Shape()

virtual agxCollide::Shape::~Shape ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ asGroup() [1/2]

ShapeGroup * agxCollide::Shape::asGroup ( )

Auto-cast shape to group.

Definition at line 404 of file Shape.h.

References agxAssert.

◆ asGroup() [2/2]

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

Auto-cast shape to group.

Definition at line 409 of file Shape.h.

◆ calculateBound()

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

Definition at line 436 of file Shape.h.

◆ calculateBoundingRadius()

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

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()

virtual agx::SPDMatrix3x3 agxCollide::Shape::calculateInertia ( agx::Real  mass) const
pure virtual

Calculate the inertia for the shape given a mass.

Returns
Matrix with inertia in shape coordinate system

Implemented in agxCollide::Box, agxCollide::Capsule, agxCollide::Cone, agxCollide::Cylinder, agxCollide::HollowCone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Mesh, agxCollide::Plane, and agxCollide::Sphere.

◆ calculateLocalBound()

virtual BoundingAABB agxCollide::Shape::calculateLocalBound ( ) const
pure virtual

Calculate the bounding volume in the local coordinate system.

Returns
the calculated bounding volume.

Implemented in agxCollide::Box, agxCollide::Capsule, agxCollide::Cone, agxCollide::Cylinder, agxCollide::HollowCone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Mesh, agxCollide::Plane, agxCollide::Sphere, and agxCollide::WireShape.

◆ clone()

◆ getBoundingVolume()

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

Definition at line 431 of file Shape.h.

◆ getCenter()

agx::Vec3 agxCollide::Shape::getCenter ( ) const
inlinevirtual
Returns
the center (local, relative to the Shape) of the shape. This is in most cases 0,0,0 - but can have other positions, e.g. in Convex shapes.

Reimplemented in agxCollide::Cone, agxCollide::HollowCone, and agxCollide::Mesh.

Definition at line 522 of file Shape.h.

◆ getEntity()

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

Definition at line 414 of file Shape.h.

◆ getGeometry() [1/2]

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

Definition at line 418 of file Shape.h.

◆ getGeometry() [2/2]

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

Definition at line 422 of file Shape.h.

◆ getLocalTransform()

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

◆ getModifiedCount()

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

Definition at line 473 of file Shape.h.

◆ getRenderData() [1/2]

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

◆ getRenderData() [2/2]

const agxCollide::RenderData * agxCollide::Shape::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.

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

Returns
the render data stored with the shape.

◆ getSupportPoint()

agx::Vec3 agxCollide::Shape::getSupportPoint ( const agx::Vec3 supportDirection) const
inlinevirtual

Returns the support point on face of the shape.

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

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

Definition at line 517 of file Shape.h.

◆ getTransform()

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

Definition at line 426 of file Shape.h.

◆ getType()

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

Definition at line 396 of file Shape.h.

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

◆ getTypeName() [1/2]

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

◆ getTypeName() [2/2]

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

◆ getVolume()

virtual agx::Real agxCollide::Shape::getVolume ( ) const
pure virtual

◆ hasSupportFunction()

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

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

Definition at line 512 of file Shape.h.

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

◆ incrementModifiedCount()

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

Increment the number of times the shape have been modified.

Returns
the incremented value.

Definition at line 478 of file Shape.h.

Referenced by agxCollide::Mesh::setBottomMargin().

◆ isGroup()

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

Definition at line 400 of file Shape.h.

◆ propagateTransform()

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

◆ setRenderData()

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

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.

◆ syncronizeShapeIndex()

void agxCollide::Shape::syncronizeShapeIndex ( )
protected

◆ updateBoundingVolume()

virtual const BoundingAABB & agxCollide::Shape::updateBoundingVolume ( )
pure virtual

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

Returns
new calculated bounding volume

Implemented in agxCollide::Box, agxCollide::Capsule, agxCollide::Cone, agxCollide::Cylinder, agxCollide::HollowCone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Mesh, agxCollide::Plane, agxCollide::Sphere, and agxCollide::WireShape.

Member Data Documentation

◆ m_entity

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

◆ m_geometry

Geometry* agxCollide::Shape::m_geometry
protected

Definition at line 283 of file Shape.h.

◆ m_internalData

agx::ref_ptr<agx::Referenced> agxCollide::Shape::m_internalData
protected

Definition at line 289 of file Shape.h.

◆ m_parent

ShapeGroup* agxCollide::Shape::m_parent
protected

Definition at line 287 of file Shape.h.

◆ m_renderData

agxCollide::RenderDataRef agxCollide::Shape::m_renderData
protected

Definition at line 284 of file Shape.h.

◆ m_shapeIndex

agx::Index agxCollide::Shape::m_shapeIndex
protected

Definition at line 285 of file Shape.h.


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