Bullet Collision Detection & Physics Library: btCompoundCollisionAlgorithm.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btCompoundCollisionAlgorithm.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14
15*/
16
17#ifndef BT_COMPOUND_COLLISION_ALGORITHM_H
18#define BT_COMPOUND_COLLISION_ALGORITHM_H
19
20#include "btActivatingCollisionAlgorithm.h"
21#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
22#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
23
24#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
25class btDispatcher;
26#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
27#include "btCollisionCreateFunc.h"
28#include "LinearMath/btAlignedObjectArray.h"
29#include "BulletCollision/BroadphaseCollision/btDbvt.h"
30class btDispatcher;
31class btCollisionObject;
32
33class btCollisionShape;
34 typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1);
35extern btShapePairCallback gCompoundChildShapePairCallback;
36
38 class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm
39{
40 btNodeStack stack2;
41 btManifoldArray manifoldArray;
42
43protected:
44 btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
45 bool m_isSwapped;
46
47 class btPersistentManifold* m_sharedManifold;
48 bool m_ownsManifold;
49
50 int m_compoundShapeRevision; //to keep track of changes, so that childAlgorithm array can be updated
51
52 void removeChildAlgorithms();
53
54 void preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
55
56public:
57 btCompoundCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, bool isSwapped);
58
59 virtual ~btCompoundCollisionAlgorithm();
60
61 btCollisionAlgorithm* getChildAlgorithm(int n) const
62 {
63 return m_childCollisionAlgorithms[n];
64 }
65
66 virtual void processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
67
68 btScalar calculateTimeOfImpact(btCollisionObject* body0, btCollisionObject* body1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
69
70 virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
71 {
72 int i;
73 for (i = 0; i < m_childCollisionAlgorithms.size(); i++)
74 {
75 if (m_childCollisionAlgorithms[i])
76 m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
77 }
78 }
79
80 struct CreateFunc : public btCollisionAlgorithmCreateFunc
81 {
82 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
83 {
84 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
85 return new (mem) btCompoundCollisionAlgorithm(ci, body0Wrap, body1Wrap, false);
86 }
87 };
88
89 struct SwappedCreateFunc : public btCollisionAlgorithmCreateFunc
90 {
91 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
92 {
93 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm));
94 return new (mem) btCompoundCollisionAlgorithm(ci, body0Wrap, body1Wrap, true);
95 }
96 };
97};
98
99#endif //BT_COMPOUND_COLLISION_ALGORITHM_H
btActivatingCollisionAlgorithm.h
btAlignedObjectArray.h
btBroadphaseInterface.h
btBroadphaseProxy.h
btCollisionCreateFunc.h
gCompoundChildShapePairCallback
btShapePairCallback gCompoundChildShapePairCallback
Definition btCompoundCollisionAlgorithm.cpp:26
btShapePairCallback
bool(* btShapePairCallback)(const btCollisionShape *pShape0, const btCollisionShape *pShape1)
Definition btCompoundCollisionAlgorithm.h:34
btDbvt.h
btDispatcher.h
btPersistentManifold.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btActivatingCollisionAlgorithm
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
Definition btActivatingCollisionAlgorithm.h:23
btAlignedObjectArray< const btDbvtNode * >
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition btAlignedObjectArray.h:142
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition btCollisionAlgorithm.h:54
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition btCollisionObject.h:51
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition btCollisionShape.h:28
btCompoundCollisionAlgorithm
btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision s...
Definition btCompoundCollisionAlgorithm.h:39
btCompoundCollisionAlgorithm::processCollision
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
Definition btCompoundCollisionAlgorithm.cpp:230
btCompoundCollisionAlgorithm::getAllContactManifolds
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)
Definition btCompoundCollisionAlgorithm.h:70
btCompoundCollisionAlgorithm::m_sharedManifold
class btPersistentManifold * m_sharedManifold
Definition btCompoundCollisionAlgorithm.h:47
btCompoundCollisionAlgorithm::m_childCollisionAlgorithms
btAlignedObjectArray< btCollisionAlgorithm * > m_childCollisionAlgorithms
Definition btCompoundCollisionAlgorithm.h:44
btCompoundCollisionAlgorithm::stack2
btNodeStack stack2
Definition btCompoundCollisionAlgorithm.h:40
btCompoundCollisionAlgorithm::getChildAlgorithm
btCollisionAlgorithm * getChildAlgorithm(int n) const
Definition btCompoundCollisionAlgorithm.h:61
btCompoundCollisionAlgorithm::m_ownsManifold
bool m_ownsManifold
Definition btCompoundCollisionAlgorithm.h:48
btCompoundCollisionAlgorithm::removeChildAlgorithms
void removeChildAlgorithms()
Definition btCompoundCollisionAlgorithm.cpp:75
btCompoundCollisionAlgorithm::m_isSwapped
bool m_isSwapped
Definition btCompoundCollisionAlgorithm.h:45
btCompoundCollisionAlgorithm::calculateTimeOfImpact
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
Definition btCompoundCollisionAlgorithm.cpp:343
btCompoundCollisionAlgorithm::preallocateChildAlgorithms
void preallocateChildAlgorithms(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition btCompoundCollisionAlgorithm.cpp:44
btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm
btCompoundCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
Definition btCompoundCollisionAlgorithm.cpp:28
btCompoundCollisionAlgorithm::m_compoundShapeRevision
int m_compoundShapeRevision
Definition btCompoundCollisionAlgorithm.h:50
btCompoundCollisionAlgorithm::manifoldArray
btManifoldArray manifoldArray
Definition btCompoundCollisionAlgorithm.h:41
btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm
virtual ~btCompoundCollisionAlgorithm()
Definition btCompoundCollisionAlgorithm.cpp:89
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition btDispatcher.h:77
btDispatcher::allocateCollisionAlgorithm
virtual void * allocateCollisionAlgorithm(int size)=0
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition btManifoldResult.h:48
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition btPersistentManifold.h:65
btCollisionAlgorithmConstructionInfo
Definition btCollisionAlgorithm.h:33
btCollisionAlgorithmConstructionInfo::m_dispatcher1
btDispatcher * m_dispatcher1
Definition btCollisionAlgorithm.h:45
btCollisionAlgorithmCreateFunc
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
Definition btCollisionCreateFunc.h:27
btCollisionObjectWrapper
Definition btCollisionObjectWrapper.h:18
btCompoundCollisionAlgorithm::CreateFunc
Definition btCompoundCollisionAlgorithm.h:81
btCompoundCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition btCompoundCollisionAlgorithm.h:82
btCompoundCollisionAlgorithm::SwappedCreateFunc
Definition btCompoundCollisionAlgorithm.h:90
btCompoundCollisionAlgorithm::SwappedCreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition btCompoundCollisionAlgorithm.h:91
btDispatcherInfo
Definition btDispatcher.h:31