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

Bullet Collision Detection & Physics Library

btConvexConcaveCollisionAlgorithm.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
17 #define BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
18
19 #include "btActivatingCollisionAlgorithm.h"
20 #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
21 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
22 #include "BulletCollision/CollisionShapes/btTriangleCallback.h"
23 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
24 class btDispatcher;
25 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
26 #include "btCollisionCreateFunc.h"
27
29 ATTRIBUTE_ALIGNED16(class) btConvexTriangleCallback : public btTriangleCallback
30 {
31
32 btVector3 m_aabbMin;
33 btVector3 m_aabbMax ;
34
35 const btCollisionObjectWrapper* m_convexBodyWrap;
36 const btCollisionObjectWrapper* m_triBodyWrap;
37
38
39
40 btManifoldResult* m_resultOut;
41 btDispatcher* m_dispatcher;
42 const btDispatcherInfo* m_dispatchInfoPtr;
43 btScalar m_collisionMarginTriangle;
44
45 public:
46 BT_DECLARE_ALIGNED_ALLOCATOR();
47
48 int m_triangleCount;
49
50 btPersistentManifold* m_manifoldPtr;
51
52 btConvexTriangleCallback(btDispatcher* dispatcher,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
53
54 void setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut);
55
56 void clearWrapperData()
57 {
58 m_convexBodyWrap = 0;
59 m_triBodyWrap = 0;
60 }
61 virtual ~btConvexTriangleCallback();
62
63 virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
64
65 void clearCache();
66
67 SIMD_FORCE_INLINE const btVector3& getAabbMin() const
68 {
69 return m_aabbMin;
70 }
71 SIMD_FORCE_INLINE const btVector3& getAabbMax() const
72 {
73 return m_aabbMax;
74 }
75
76 };
77
78
79
80
82 ATTRIBUTE_ALIGNED16(class) btConvexConcaveCollisionAlgorithm : public btActivatingCollisionAlgorithm
83 {
84
85 btConvexTriangleCallback m_btConvexTriangleCallback;
86
87 bool m_isSwapped;
88
89
90
91 public:
92
93 BT_DECLARE_ALIGNED_ALLOCATOR();
94
95 btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped);
96
97 virtual ~btConvexConcaveCollisionAlgorithm();
98
99 virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
100
101 btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
102
103 virtual void getAllContactManifolds(btManifoldArray& manifoldArray);
104
105 void clearCache();
106
107 struct CreateFunc :public btCollisionAlgorithmCreateFunc
108 {
109 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
110 {
111 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
112 return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0Wrap,body1Wrap,false);
113 }
114 };
115
116 struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc
117 {
118 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
119 {
120 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
121 return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0Wrap,body1Wrap,true);
122 }
123 };
124
125 };
126
127 #endif //BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:63
btConvexTriangleCallback::m_dispatchInfoPtr
const btDispatcherInfo * m_dispatchInfoPtr
Definition: btConvexConcaveCollisionAlgorithm.h:42
btConvexConcaveCollisionAlgorithm::SwappedCreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btConvexConcaveCollisionAlgorithm.h:118
btConvexTriangleCallback::m_dispatcher
btDispatcher * m_dispatcher
Definition: btConvexConcaveCollisionAlgorithm.h:41
btConvexConcaveCollisionAlgorithm::m_btConvexTriangleCallback
btConvexTriangleCallback m_btConvexTriangleCallback
Definition: btConvexConcaveCollisionAlgorithm.h:85
btConvexConcaveCollisionAlgorithm::CreateFunc
Definition: btConvexConcaveCollisionAlgorithm.h:107
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:53
btConvexTriangleCallback::m_collisionMarginTriangle
btScalar m_collisionMarginTriangle
Definition: btConvexConcaveCollisionAlgorithm.h:43
btActivatingCollisionAlgorithm
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
Definition: btActivatingCollisionAlgorithm.h:22
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
btPersistentManifold.h
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition: btManifoldResult.h:39
btCollisionCreateFunc.h
btBroadphaseInterface.h
btConvexTriangleCallback::m_triangleCount
int m_triangleCount
Definition: btConvexConcaveCollisionAlgorithm.h:48
btConvexTriangleCallback::m_convexBodyWrap
const btCollisionObjectWrapper * m_convexBodyWrap
Definition: btConvexConcaveCollisionAlgorithm.h:35
btDispatcher::allocateCollisionAlgorithm
virtual void * allocateCollisionAlgorithm(int size)=0
btTriangleCallback.h
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition: btTriangleCallback.h:24
btCollisionAlgorithmCreateFunc
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
Definition: btCollisionCreateFunc.h:26
btConvexConcaveCollisionAlgorithm::m_isSwapped
bool m_isSwapped
Definition: btConvexConcaveCollisionAlgorithm.h:87
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
processCollision
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btBroadphaseProxy.h
calculateTimeOfImpact
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btConvexTriangleCallback::m_aabbMax
btVector3 m_aabbMax
Definition: btConvexConcaveCollisionAlgorithm.h:33
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
btConvexConcaveCollisionAlgorithm
btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges mes...
Definition: btConvexConcaveCollisionAlgorithm.h:82
btConvexTriangleCallback::getAabbMin
const btVector3 & getAabbMin() const
Definition: btConvexConcaveCollisionAlgorithm.h:67
btConvexTriangleCallback::getAabbMax
const btVector3 & getAabbMax() const
Definition: btConvexConcaveCollisionAlgorithm.h:71
btConvexTriangleCallback::clearWrapperData
void clearWrapperData()
Definition: btConvexConcaveCollisionAlgorithm.h:56
btConvexConcaveCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btConvexConcaveCollisionAlgorithm.h:109
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btConvexTriangleCallback::m_triBodyWrap
const btCollisionObjectWrapper * m_triBodyWrap
Definition: btConvexConcaveCollisionAlgorithm.h:36
btConvexTriangleCallback::m_aabbMin
btVector3 m_aabbMin
Definition: btConvexConcaveCollisionAlgorithm.h:32
btActivatingCollisionAlgorithm.h
btConvexTriangleCallback
For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
Definition: btConvexConcaveCollisionAlgorithm.h:29
btDispatcherInfo
Definition: btDispatcher.h:30
btCollisionAlgorithmConstructionInfo::m_dispatcher1
btDispatcher * m_dispatcher1
Definition: btCollisionAlgorithm.h:45
btConvexTriangleCallback::m_manifoldPtr
btPersistentManifold * m_manifoldPtr
Definition: btConvexConcaveCollisionAlgorithm.h:50
btCollisionAlgorithmConstructionInfo
Definition: btCollisionAlgorithm.h:32
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition: btCollisionAlgorithm.h:55
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:17
btConvexConcaveCollisionAlgorithm::SwappedCreateFunc
Definition: btConvexConcaveCollisionAlgorithm.h:116
btDispatcher.h
getAllContactManifolds
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)
Definition: btEmptyCollisionAlgorithm.h:39
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btConvexTriangleCallback::m_resultOut
btManifoldResult * m_resultOut
Definition: btConvexConcaveCollisionAlgorithm.h:40