Bullet Collision Detection & Physics Library: btCollisionWorld Class Reference

Bullet Collision Detection & Physics Library

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
btCollisionWorld Class Reference

CollisionWorld is interface and container for the collision detection. More...

`#include <btCollisionWorld.h>`

Inheritance diagram for btCollisionWorld:
[legend]
Collaboration diagram for btCollisionWorld:
[legend]

## Classes
struct | LocalShapeInfo
| LocalShapeInfo gives extra information for complex shapes Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart. More...
struct | LocalRayResult
struct | RayResultCallback
| RayResultCallback is used to report new raycast results. More...
struct | ClosestRayResultCallback
struct | AllHitsRayResultCallback
struct | LocalConvexResult
struct | ConvexResultCallback
| RayResultCallback is used to report new raycast results. More...
struct | ClosestConvexResultCallback
struct | ContactResultCallback
| ContactResultCallback is used to report contact points. More...

## Public Member Functions
| btCollisionWorld (btDispatcher *dispatcher, btBroadphaseInterface *broadphasePairCache, btCollisionConfiguration *collisionConfiguration)
| for debug drawing
virtual | ~btCollisionWorld ()
void | setBroadphase (btBroadphaseInterface *pairCache)
const btBroadphaseInterface * | getBroadphase () const
btBroadphaseInterface * | getBroadphase ()
btOverlappingPairCache * | getPairCache ()
btDispatcher * | getDispatcher ()
const btDispatcher * | getDispatcher () const
void | updateSingleAabb (btCollisionObject *colObj)
virtual void | updateAabbs ()
virtual void | computeOverlappingPairs ()
| the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSimulation) it can be useful to use if you perform ray tests without collision detection/simulation
virtual void | setDebugDrawer (btIDebugDraw *debugDrawer)
virtual btIDebugDraw * | getDebugDrawer ()
virtual void | debugDrawWorld ()
virtual void | debugDrawObject (const btTransform &worldTransform, const btCollisionShape *shape, const btVector3 &color)
int | getNumCollisionObjects () const
virtual void | rayTest (const btVector3 &rayFromWorld, const btVector3 &rayToWorld, RayResultCallback &resultCallback) const
| rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
void | convexSweepTest (const btConvexShape *castShape, const btTransform &from, const btTransform &to, ConvexResultCallback &resultCallback, btScalar allowedCcdPenetration=btScalar(0.)) const
| convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
void | contactTest (btCollisionObject *colObj, ContactResultCallback &resultCallback)
| contactTest performs a discrete collision test between colObj against all objects in the btCollisionWorld, and calls the resultCallback.
void | contactPairTest (btCollisionObject *colObjA, btCollisionObject *colObjB, ContactResultCallback &resultCallback)
| contactTest performs a discrete collision test between two collision objects and calls the resultCallback if overlap if detected.
virtual void | addCollisionObject (btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
virtual void | refreshBroadphaseProxy (btCollisionObject *collisionObject)
btCollisionObjectArray & | getCollisionObjectArray ()
const btCollisionObjectArray & | getCollisionObjectArray () const
virtual void | removeCollisionObject (btCollisionObject *collisionObject)
virtual void | performDiscreteCollisionDetection ()
btDispatcherInfo & | getDispatchInfo ()
const btDispatcherInfo & | getDispatchInfo () const
bool | getForceUpdateAllAabbs () const
void | setForceUpdateAllAabbs (bool forceUpdateAllAabbs)
virtual void | serialize (btSerializer *serializer)
| Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo).

## Static Public Member Functions
static void | rayTestSingle (const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
| rayTestSingle performs a raycast call and calls the resultCallback.
static void | rayTestSingleInternal (const btTransform &rayFromTrans, const btTransform &rayToTrans, const btCollisionObjectWrapper *collisionObjectWrap, RayResultCallback &resultCallback)
static void | objectQuerySingle (const btConvexShape *castShape, const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, ConvexResultCallback &resultCallback, btScalar allowedPenetration)
| objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.
static void | objectQuerySingleInternal (const btConvexShape *castShape, const btTransform &convexFromTrans, const btTransform &convexToTrans, const btCollisionObjectWrapper *colObjWrap, ConvexResultCallback &resultCallback, btScalar allowedPenetration)

## Protected Member Functions
void | serializeCollisionObjects (btSerializer *serializer)
void | serializeContactManifolds (btSerializer *serializer)

## Protected Attributes
btAlignedObjectArray< btCollisionObject * > | m_collisionObjects
btDispatcher * | m_dispatcher1
btDispatcherInfo | m_dispatchInfo
btBroadphaseInterface * | m_broadphasePairCache
btIDebugDraw * | m_debugDrawer
bool | m_forceUpdateAllAabbs
| m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB)

## Detailed Description

CollisionWorld is interface and container for the collision detection.

Definition at line 85 of file btCollisionWorld.h.

## Constructor & Destructor Documentation

## ◆ btCollisionWorld()

btCollisionWorld::btCollisionWorld | ( | btDispatcher * | dispatcher,
|  | btBroadphaseInterface * | broadphasePairCache,
|  | btCollisionConfiguration * | collisionConfiguration )

for debug drawing

Definition at line 67 of file btCollisionWorld.cpp.

## ◆ ~btCollisionWorld()

btCollisionWorld::~btCollisionWorld | ( |  | ) |
| virtual

Definition at line 75 of file btCollisionWorld.cpp.

## Member Function Documentation

## ◆ addCollisionObject()

void btCollisionWorld::addCollisionObject | ( | btCollisionObject * | collisionObject,
|  | int | collisionFilterGroup = btBroadphaseProxy::DefaultFilter,
|  | int | collisionFilterMask = btBroadphaseProxy::AllFilter )
| virtual

Reimplemented in btDiscreteDynamicsWorld.

Definition at line 124 of file btCollisionWorld.cpp.

## ◆ computeOverlappingPairs()

void btCollisionWorld::computeOverlappingPairs | ( |  | ) |
| virtual

the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSimulation) it can be useful to use if you perform ray tests without collision detection/simulation

Definition at line 214 of file btCollisionWorld.cpp.

## ◆ contactPairTest()

void btCollisionWorld::contactPairTest | ( | btCollisionObject * | colObjA,
|  | btCollisionObject * | colObjB,
|  | ContactResultCallback & | resultCallback )

contactTest performs a discrete collision test between two collision objects and calls the resultCallback if overlap if detected.

it reports one or more contact points (including the one with deepest penetration)

Definition at line 1242 of file btCollisionWorld.cpp.

## ◆ contactTest()

void btCollisionWorld::contactTest | ( | btCollisionObject * | colObj,
|  | ContactResultCallback & | resultCallback )

contactTest performs a discrete collision test between colObj against all objects in the btCollisionWorld, and calls the resultCallback.

contactTest performs a discrete collision test against all objects in the btCollisionWorld, and calls the resultCallback.

it reports one or more contact points for every overlapping object (including the one with deepest penetration)

Definition at line 1231 of file btCollisionWorld.cpp.

## ◆ convexSweepTest()

void btCollisionWorld::convexSweepTest | ( | const btConvexShape * | castShape,
|  | const btTransform & | from,
|  | const btTransform & | to,
|  | ConvexResultCallback & | resultCallback,
|  | btScalar | allowedCcdPenetration = btScalar(0.) ) const

convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.

use the broadphase to accelerate the search for objects, based on their aabb and for each object with ray-aabb overlap, perform an exact ray test unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical

Definition at line 1075 of file btCollisionWorld.cpp.

## ◆ debugDrawObject()

void btCollisionWorld::debugDrawObject | ( | const btTransform & | worldTransform,
|  | const btCollisionShape * | shape,
|  | const btVector3 & | color )
| virtual

for polyhedral shapes

Definition at line 1300 of file btCollisionWorld.cpp.

## ◆ debugDrawWorld()

void btCollisionWorld::debugDrawWorld | ( |  | ) |
| virtual

Reimplemented in btDeformableMultiBodyDynamicsWorld, btDiscreteDynamicsWorld, btDynamicsWorld, btMultiBodyDynamicsWorld, btSimpleDynamicsWorld, btSoftMultiBodyDynamicsWorld, and btSoftRigidDynamicsWorld.

Definition at line 1467 of file btCollisionWorld.cpp.

## ◆ getBroadphase() [1/2]

btBroadphaseInterface * btCollisionWorld::getBroadphase | ( |  | ) |
| inline

Definition at line 122 of file btCollisionWorld.h.

## ◆ getBroadphase() [2/2]

const btBroadphaseInterface * btCollisionWorld::getBroadphase | ( |  | ) | const
| inline

Definition at line 117 of file btCollisionWorld.h.

## ◆ getCollisionObjectArray() [1/2]

btCollisionObjectArray & btCollisionWorld::getCollisionObjectArray | ( |  | ) |
| inline

Definition at line 476 of file btCollisionWorld.h.

## ◆ getCollisionObjectArray() [2/2]

const btCollisionObjectArray & btCollisionWorld::getCollisionObjectArray | ( |  | ) | const
| inline

Definition at line 481 of file btCollisionWorld.h.

## ◆ getDebugDrawer()

virtual btIDebugDraw * btCollisionWorld::getDebugDrawer | ( |  | ) |
| inlinevirtual

Definition at line 155 of file btCollisionWorld.h.

## ◆ getDispatcher() [1/2]

btDispatcher * btCollisionWorld::getDispatcher | ( |  | ) |
| inline

Definition at line 132 of file btCollisionWorld.h.

## ◆ getDispatcher() [2/2]

const btDispatcher * btCollisionWorld::getDispatcher | ( |  | ) | const
| inline

Definition at line 137 of file btCollisionWorld.h.

## ◆ getDispatchInfo() [1/2]

btDispatcherInfo & btCollisionWorld::getDispatchInfo | ( |  | ) |
| inline

Definition at line 490 of file btCollisionWorld.h.

## ◆ getDispatchInfo() [2/2]

const btDispatcherInfo & btCollisionWorld::getDispatchInfo | ( |  | ) | const
| inline

Definition at line 495 of file btCollisionWorld.h.

## ◆ getForceUpdateAllAabbs()

bool btCollisionWorld::getForceUpdateAllAabbs | ( |  | ) | const
| inline

Definition at line 500 of file btCollisionWorld.h.

## ◆ getNumCollisionObjects()

int btCollisionWorld::getNumCollisionObjects | ( |  | ) | const
| inline

Definition at line 427 of file btCollisionWorld.h.

## ◆ getPairCache()

btOverlappingPairCache * btCollisionWorld::getPairCache | ( |  | ) |
| inline

Definition at line 127 of file btCollisionWorld.h.

## ◆ objectQuerySingle()

void btCollisionWorld::objectQuerySingle | ( | const btConvexShape * | castShape,
|  | const btTransform & | rayFromTrans,
|  | const btTransform & | rayToTrans,
|  | btCollisionObject * | collisionObject,
|  | const btCollisionShape * | collisionShape,
|  | const btTransform & | colObjWorldTransform,
|  | ConvexResultCallback & | resultCallback,
|  | btScalar | allowedPenetration )
| static

objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.

Definition at line 601 of file btCollisionWorld.cpp.

## ◆ objectQuerySingleInternal()

void btCollisionWorld::objectQuerySingleInternal | ( | const btConvexShape * | castShape,
|  | const btTransform & | convexFromTrans,
|  | const btTransform & | convexToTrans,
|  | const btCollisionObjectWrapper * | colObjWrap,
|  | ConvexResultCallback & | resultCallback,
|  | btScalar | allowedPenetration )
| static

Definition at line 611 of file btCollisionWorld.cpp.

## ◆ performDiscreteCollisionDetection()

void btCollisionWorld::performDiscreteCollisionDetection | ( |  | ) |
| virtual

Definition at line 220 of file btCollisionWorld.cpp.

## ◆ rayTest()

void btCollisionWorld::rayTest | ( | const btVector3 & | rayFromWorld,
|  | const btVector3 & | rayToWorld,
|  | RayResultCallback & | resultCallback ) const
| virtual

rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.

use the broadphase to accelerate the search for objects, based on their aabb and for each object with ray-aabb overlap, perform an exact ray test

Reimplemented in btDeformableMultiBodyDynamicsWorld, btSoftMultiBodyDynamicsWorld, and btSoftRigidDynamicsWorld.

Definition at line 1003 of file btCollisionWorld.cpp.

## ◆ rayTestSingle()

void btCollisionWorld::rayTestSingle | ( | const btTransform & | rayFromTrans,
|  | const btTransform & | rayToTrans,
|  | btCollisionObject * | collisionObject,
|  | const btCollisionShape * | collisionShape,
|  | const btTransform & | colObjWorldTransform,
|  | RayResultCallback & | resultCallback )
| static

rayTestSingle performs a raycast call and calls the resultCallback.

It is used internally by rayTest. In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape. This allows more customization.

Definition at line 276 of file btCollisionWorld.cpp.

## ◆ rayTestSingleInternal()

void btCollisionWorld::rayTestSingleInternal | ( | const btTransform & | rayFromTrans,
|  | const btTransform & | rayToTrans,
|  | const btCollisionObjectWrapper * | collisionObjectWrap,
|  | RayResultCallback & | resultCallback )
| static

optimized version for btBvhTriangleMeshShape

optimized version for btScaledBvhTriangleMeshShape

optimized version for btHeightfieldTerrainShape

Definition at line 286 of file btCollisionWorld.cpp.

## ◆ refreshBroadphaseProxy()

void btCollisionWorld::refreshBroadphaseProxy | ( | btCollisionObject * | collisionObject | ) |
| virtual

Definition at line 96 of file btCollisionWorld.cpp.

## ◆ removeCollisionObject()

void btCollisionWorld::removeCollisionObject | ( | btCollisionObject * | collisionObject | ) |
| virtual

Reimplemented in btDeformableMultiBodyDynamicsWorld, btDiscreteDynamicsWorld, btSimpleDynamicsWorld, btSoftMultiBodyDynamicsWorld, and btSoftRigidDynamicsWorld.

Definition at line 238 of file btCollisionWorld.cpp.

## ◆ serialize()

void btCollisionWorld::serialize | ( | btSerializer * | serializer | ) |
| virtual

Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo).

Reimplemented in btDiscreteDynamicsWorld, btMultiBodyDynamicsWorld, btSoftMultiBodyDynamicsWorld, and btSoftRigidDynamicsWorld.

Definition at line 1615 of file btCollisionWorld.cpp.

## ◆ serializeCollisionObjects()

void btCollisionWorld::serializeCollisionObjects | ( | btSerializer * | serializer | ) |
| protected

keep track of shapes already serialized

Definition at line 1565 of file btCollisionWorld.cpp.

## ◆ serializeContactManifolds()

void btCollisionWorld::serializeContactManifolds | ( | btSerializer * | serializer | ) |
| protected

Definition at line 1595 of file btCollisionWorld.cpp.

## ◆ setBroadphase()

void btCollisionWorld::setBroadphase | ( | btBroadphaseInterface * | pairCache | ) |
| inline

Definition at line 112 of file btCollisionWorld.h.

## ◆ setDebugDrawer()

virtual void btCollisionWorld::setDebugDrawer | ( | btIDebugDraw * | debugDrawer | ) |
| inlinevirtual

Definition at line 150 of file btCollisionWorld.h.

## ◆ setForceUpdateAllAabbs()

void btCollisionWorld::setForceUpdateAllAabbs | ( | bool | forceUpdateAllAabbs | ) |
| inline

Definition at line 504 of file btCollisionWorld.h.

## ◆ updateAabbs()

void btCollisionWorld::updateAabbs | ( |  | ) |
| virtual

Reimplemented in btSimpleDynamicsWorld.

Definition at line 197 of file btCollisionWorld.cpp.

## ◆ updateSingleAabb()

void btCollisionWorld::updateSingleAabb | ( | btCollisionObject * | colObj | ) |

Definition at line 153 of file btCollisionWorld.cpp.

## Member Data Documentation

## ◆ m_broadphasePairCache

btBroadphaseInterface* btCollisionWorld::m_broadphasePairCache
| protected

Definition at line 94 of file btCollisionWorld.h.

## ◆ m_collisionObjects

btAlignedObjectArray<btCollisionObject*> btCollisionWorld::m_collisionObjects
| protected

Definition at line 88 of file btCollisionWorld.h.

## ◆ m_debugDrawer

btIDebugDraw* btCollisionWorld::m_debugDrawer
| protected

Definition at line 96 of file btCollisionWorld.h.

## ◆ m_dispatcher1

btDispatcher* btCollisionWorld::m_dispatcher1
| protected

Definition at line 90 of file btCollisionWorld.h.

## ◆ m_dispatchInfo

btDispatcherInfo btCollisionWorld::m_dispatchInfo
| protected

Definition at line 92 of file btCollisionWorld.h.

## ◆ m_forceUpdateAllAabbs

bool btCollisionWorld::m_forceUpdateAllAabbs
| protected

m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB)

Definition at line 100 of file btCollisionWorld.h.

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

- btCollisionWorld.h
- btCollisionWorld.cpp