AGX Dynamics  2.37.3.2
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

ShapeGroup * asGroup ()
 Auto-cast shape to group. More...
 
const ShapeGroup * asGroup () const
 Auto-cast shape to group. More...
 
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 =0
 Calculate the inertia for the shape given a mass. More...
 
virtual BoundingAABB calculateLocalBound () const =0
 Calculate the bounding volume in the local coordinate system. More...
 
virtual Shape * clone () const
 Create a clone. More...
 
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
 
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...
 
agxCollide::RenderData * getRenderData ()
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const
 Returns the support point on face of the shape. More...
 
agx::AffineMatrix4x4 getTransform () const
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
virtual agx::Real getVolume () const =0
 Return the volume of the shape. More...
 
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. More...
 
virtual const BoundingAABB & updateBoundingVolume ()=0
 Calculate the bounding volume based on the current Shape parameters including transformation. More...
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor. More...
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object. More...
 
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...
 
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...
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings. More...
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
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. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 

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. More...
 

Protected Member Functions

 Shape (Type type, agx::Physics::Geometry::ShapePtr entity=agx::Physics::Geometry::ShapeModel::createInstance())
 Constructor. More...
 
virtual ~Shape ()
 Destructor. More...
 
agx::UInt32 incrementModifiedCount ()
 Increment the number of times the shape have been modified. More...
 
void syncronizeShapeIndex ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor. More...
 
 Serializable (const Serializable &other)
 Copy constructor. More...
 
void generateUuid ()
 

Protected Attributes

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

- 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. More...
 

Detailed Description

Base class for a shape.

Definition at line 53 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 58 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 386 of file Shape.h.

References agxAssert.

◆ asGroup() [2/2]

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

Auto-cast shape to group.

Definition at line 391 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 418 of file Shape.h.

References AGX_FORCE_INLINE, and agxData::getEntity().

◆ 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::Mesh, agxCollide::HollowCone, agxCollide::Line, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Plane, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::Box, 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::Mesh, agxCollide::HollowCone, agxCollide::Cone, agxCollide::Line, agxCollide::HollowCylinder, agxCollide::Plane, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::WireShape, agxCollide::Box, and agxCollide::Sphere.

◆ clone()

◆ getBoundingVolume()

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

Definition at line 413 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::Mesh, agxCollide::HollowCone, and agxCollide::Cone.

Definition at line 504 of file Shape.h.

◆ getEntity()

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

◆ getGeometry() [1/2]

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

Definition at line 400 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 404 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 455 of file Shape.h.

◆ getRenderData() [1/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.

◆ getRenderData() [2/2]

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

◆ 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::HollowCone, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::Convex, agxCollide::Box, and agxCollide::Sphere.

Definition at line 499 of file Shape.h.

◆ getTransform()

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

Definition at line 408 of file Shape.h.

◆ getType()

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

Definition at line 378 of file Shape.h.

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

◆ getTypeName() [1/2]

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

◆ getTypeName() [2/2]

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

◆ 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::HollowCone, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::Convex, agxCollide::Box, and agxCollide::Sphere.

Definition at line 494 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 460 of file Shape.h.

References AGX_FORCE_INLINE, and agxAssert.

◆ isGroup()

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

Definition at line 382 of file Shape.h.

References agxData::getType().

◆ 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::Mesh, agxCollide::HollowCone, agxCollide::Cone, agxCollide::HollowCylinder, agxCollide::Line, agxCollide::Plane, agxCollide::Cylinder, agxCollide::Capsule, agxCollide::WireShape, agxCollide::Box, and agxCollide::Sphere.

Member Data Documentation

◆ m_entity

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

Definition at line 266 of file Shape.h.

◆ m_geometry

Geometry* agxCollide::Shape::m_geometry
protected

Definition at line 267 of file Shape.h.

◆ m_parent

ShapeGroup* agxCollide::Shape::m_parent
protected

Definition at line 271 of file Shape.h.

◆ m_renderData

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

Definition at line 268 of file Shape.h.

◆ m_shapeIndex

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

Definition at line 269 of file Shape.h.


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