Bullet Collision Detection & Physics Library
Public Member Functions | Protected Attributes | List of all members
btCompoundShape Class Reference

The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave collision objects. More...

#include <btCompoundShape.h>

Inheritance diagram for btCompoundShape:
Inheritance graph
[legend]
Collaboration diagram for btCompoundShape:
Collaboration graph
[legend]

Public Member Functions

 BT_DECLARE_ALIGNED_ALLOCATOR ()
 
 btCompoundShape (bool enableDynamicAabbTree=true, const int initialChildCapacity=0)
 
virtual ~btCompoundShape ()
 
void addChildShape (const btTransform &localTransform, btCollisionShape *shape)
 
virtual void removeChildShape (btCollisionShape *shape)
 Remove all children shapes that contain the specified shape. More...
 
void removeChildShapeByIndex (int childShapeindex)
 
int getNumChildShapes () const
 
btCollisionShapegetChildShape (int index)
 
const btCollisionShapegetChildShape (int index) const
 
btTransformgetChildTransform (int index)
 
const btTransformgetChildTransform (int index) const
 
void updateChildTransform (int childIndex, const btTransform &newChildTransform, bool shouldRecalculateLocalAabb=true)
 set a new transform for a child, and update internal data structures (local aabb and dynamic tree) More...
 
btCompoundShapeChildgetChildList ()
 
virtual void getAabb (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
 getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version More...
 
virtual void recalculateLocalAabb ()
 Re-calculate the local Aabb. More...
 
virtual void setLocalScaling (const btVector3 &scaling)
 
virtual const btVector3getLocalScaling () const
 
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const
 
virtual void setMargin (btScalar margin)
 
virtual btScalar getMargin () const
 
virtual const char * getName () const
 
const btDbvtgetDynamicAabbTree () const
 
btDbvtgetDynamicAabbTree ()
 
void createAabbTreeFromChildren ()
 
void calculatePrincipalAxisTransform (const btScalar *masses, btTransform &principal, btVector3 &inertia) const
 computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia and the center of mass to the current coordinate system. More...
 
int getUpdateRevision () const
 
virtual int calculateSerializeBufferSize () const
 
virtual const char * serialize (void *dataBuffer, btSerializer *serializer) const
 fills the dataBuffer and returns the struct name (and 0 on failure) More...
 
- Public Member Functions inherited from btCollisionShape
 BT_DECLARE_ALIGNED_ALLOCATOR ()
 
 btCollisionShape ()
 
virtual ~btCollisionShape ()
 
virtual void getAabb (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
 getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t. More...
 
virtual void getBoundingSphere (btVector3 &center, btScalar &radius) const
 
virtual btScalar getAngularMotionDisc () const
 getAngularMotionDisc returns the maximum radius needed for Conservative Advancement to handle time-of-impact with rotations. More...
 
virtual btScalar getContactBreakingThreshold (btScalar defaultContactThresholdFactor) const
 
void calculateTemporalAabb (const btTransform &curTrans, const btVector3 &linvel, const btVector3 &angvel, btScalar timeStep, btVector3 &temporalAabbMin, btVector3 &temporalAabbMax) const
 calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep) result is conservative More...
 
bool isPolyhedral () const
 
bool isConvex2d () const
 
bool isConvex () const
 
bool isNonMoving () const
 
bool isConcave () const
 
bool isCompound () const
 
bool isSoftBody () const
 
bool isInfinite () const
 isInfinite is used to catch simulation error (aabb check) More...
 
virtual void setLocalScaling (const btVector3 &scaling)=0
 
virtual const btVector3getLocalScaling () const =0
 
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const =0
 
virtual const char * getName () const =0
 
int getShapeType () const
 
virtual btVector3 getAnisotropicRollingFrictionDirection () const
 the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See Bullet/Demos/RollingFrictionDemo for an example More...
 
virtual void setMargin (btScalar margin)=0
 
virtual btScalar getMargin () const =0
 
void setUserPointer (void *userPtr)
 optional user data pointer More...
 
void * getUserPointer () const
 
void setUserIndex (int index)
 
int getUserIndex () const
 
void setUserIndex2 (int index)
 
int getUserIndex2 () const
 
virtual int calculateSerializeBufferSize () const
 
virtual const char * serialize (void *dataBuffer, btSerializer *serializer) const
 fills the dataBuffer and returns the struct name (and 0 on failure) More...
 
virtual void serializeSingleShape (btSerializer *serializer) const
 

Protected Attributes

btAlignedObjectArray< btCompoundShapeChildm_children
 
btVector3 m_localAabbMin
 
btVector3 m_localAabbMax
 
btDbvtm_dynamicAabbTree
 
int m_updateRevision
 increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated More...
 
btScalar m_collisionMargin
 
btVector3 m_localScaling
 
- Protected Attributes inherited from btCollisionShape
int m_shapeType
 
void * m_userPointer
 
int m_userIndex
 
int m_userIndex2
 

Detailed Description

The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave collision objects.

This is more general then the static concave btBvhTriangleMeshShape. It has an (optional) dynamic aabb tree to accelerate early rejection tests.

Definition at line 55 of file btCompoundShape.h.

Constructor & Destructor Documentation

◆ btCompoundShape()

btCompoundShape::btCompoundShape ( bool  enableDynamicAabbTree = true,
const int  initialChildCapacity = 0 
)
explicit

Definition at line 21 of file btCompoundShape.cpp.

◆ ~btCompoundShape()

btCompoundShape::~btCompoundShape ( )
virtual

Definition at line 41 of file btCompoundShape.cpp.

Member Function Documentation

◆ addChildShape()

void btCompoundShape::addChildShape ( const btTransform localTransform,
btCollisionShape shape 
)

Definition at line 50 of file btCompoundShape.cpp.

◆ BT_DECLARE_ALIGNED_ALLOCATOR()

btCompoundShape::BT_DECLARE_ALIGNED_ALLOCATOR ( )

◆ calculateLocalInertia()

void btCompoundShape::calculateLocalInertia ( btScalar  mass,
btVector3 inertia 
) const
virtual

Implements btCollisionShape.

Definition at line 183 of file btCompoundShape.cpp.

◆ calculatePrincipalAxisTransform()

void btCompoundShape::calculatePrincipalAxisTransform ( const btScalar masses,
btTransform principal,
btVector3 inertia 
) const

computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia and the center of mass to the current coordinate system.

"masses" points to an array of masses of the children. The resulting transform "principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform of the collision object by the principal transform.

Definition at line 202 of file btCompoundShape.cpp.

◆ calculateSerializeBufferSize()

int btCompoundShape::calculateSerializeBufferSize ( ) const
inlinevirtual

Reimplemented from btCollisionShape.

Definition at line 202 of file btCompoundShape.h.

◆ createAabbTreeFromChildren()

void btCompoundShape::createAabbTreeFromChildren ( )

Definition at line 279 of file btCompoundShape.cpp.

◆ getAabb()

void btCompoundShape::getAabb ( const btTransform t,
btVector3 aabbMin,
btVector3 aabbMax 
) const
virtual

getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version

Implements btCollisionShape.

Definition at line 161 of file btCompoundShape.cpp.

◆ getChildList()

btCompoundShapeChild * btCompoundShape::getChildList ( )
inline

Definition at line 112 of file btCompoundShape.h.

◆ getChildShape() [1/2]

btCollisionShape * btCompoundShape::getChildShape ( int  index)
inline

Definition at line 91 of file btCompoundShape.h.

◆ getChildShape() [2/2]

const btCollisionShape * btCompoundShape::getChildShape ( int  index) const
inline

Definition at line 95 of file btCompoundShape.h.

◆ getChildTransform() [1/2]

btTransform & btCompoundShape::getChildTransform ( int  index)
inline

Definition at line 100 of file btCompoundShape.h.

◆ getChildTransform() [2/2]

const btTransform & btCompoundShape::getChildTransform ( int  index) const
inline

Definition at line 104 of file btCompoundShape.h.

◆ getDynamicAabbTree() [1/2]

btDbvt * btCompoundShape::getDynamicAabbTree ( )
inline

Definition at line 151 of file btCompoundShape.h.

◆ getDynamicAabbTree() [2/2]

const btDbvt * btCompoundShape::getDynamicAabbTree ( ) const
inline

Definition at line 146 of file btCompoundShape.h.

◆ getLocalScaling()

virtual const btVector3 & btCompoundShape::getLocalScaling ( ) const
inlinevirtual

Implements btCollisionShape.

Definition at line 126 of file btCompoundShape.h.

◆ getMargin()

virtual btScalar btCompoundShape::getMargin ( ) const
inlinevirtual

Implements btCollisionShape.

Definition at line 137 of file btCompoundShape.h.

◆ getName()

virtual const char * btCompoundShape::getName ( ) const
inlinevirtual

Implements btCollisionShape.

Definition at line 141 of file btCompoundShape.h.

◆ getNumChildShapes()

int btCompoundShape::getNumChildShapes ( ) const
inline

Definition at line 86 of file btCompoundShape.h.

◆ getUpdateRevision()

int btCompoundShape::getUpdateRevision ( ) const
inline

Definition at line 165 of file btCompoundShape.h.

◆ recalculateLocalAabb()

void btCompoundShape::recalculateLocalAabb ( )
virtual

Re-calculate the local Aabb.

Is called at the end of removeChildShapes. Use this yourself if you modify the children or their transforms.

Definition at line 137 of file btCompoundShape.cpp.

◆ removeChildShape()

void btCompoundShape::removeChildShape ( btCollisionShape shape)
virtual

Remove all children shapes that contain the specified shape.

Definition at line 121 of file btCompoundShape.cpp.

◆ removeChildShapeByIndex()

void btCompoundShape::removeChildShapeByIndex ( int  childShapeindex)

Definition at line 107 of file btCompoundShape.cpp.

◆ serialize()

const char * btCompoundShape::serialize ( void *  dataBuffer,
btSerializer serializer 
) const
virtual

fills the dataBuffer and returns the struct name (and 0 on failure)

Reimplemented from btCollisionShape.

Definition at line 303 of file btCompoundShape.cpp.

◆ setLocalScaling()

void btCompoundShape::setLocalScaling ( const btVector3 scaling)
virtual

Implements btCollisionShape.

Definition at line 262 of file btCompoundShape.cpp.

◆ setMargin()

virtual void btCompoundShape::setMargin ( btScalar  margin)
inlinevirtual

Implements btCollisionShape.

Definition at line 133 of file btCompoundShape.h.

◆ updateChildTransform()

void btCompoundShape::updateChildTransform ( int  childIndex,
const btTransform newChildTransform,
bool  shouldRecalculateLocalAabb = true 
)

set a new transform for a child, and update internal data structures (local aabb and dynamic tree)

update the dynamic aabb tree

Definition at line 86 of file btCompoundShape.cpp.

Member Data Documentation

◆ m_children

btAlignedObjectArray<btCompoundShapeChild> btCompoundShape::m_children
protected

Definition at line 59 of file btCompoundShape.h.

◆ m_collisionMargin

btScalar btCompoundShape::m_collisionMargin
protected

Definition at line 68 of file btCompoundShape.h.

◆ m_dynamicAabbTree

btDbvt* btCompoundShape::m_dynamicAabbTree
protected

Definition at line 63 of file btCompoundShape.h.

◆ m_localAabbMax

btVector3 btCompoundShape::m_localAabbMax
protected

Definition at line 61 of file btCompoundShape.h.

◆ m_localAabbMin

btVector3 btCompoundShape::m_localAabbMin
protected

Definition at line 60 of file btCompoundShape.h.

◆ m_localScaling

btVector3 btCompoundShape::m_localScaling
protected

Definition at line 70 of file btCompoundShape.h.

◆ m_updateRevision

int btCompoundShape::m_updateRevision
protected

increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated

Definition at line 66 of file btCompoundShape.h.


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