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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btConvexConcaveCollisionAlgorithm.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#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"
24class btDispatcher;
25#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
26#include "btCollisionCreateFunc.h"
27
29 ATTRIBUTE_ALIGNED16(class)
30 btConvexTriangleCallback : public btTriangleCallback
31{
32 btVector3 m_aabbMin;
33 btVector3 m_aabbMax;
34
35 const btCollisionObjectWrapper* m_convexBodyWrap;
36 const btCollisionObjectWrapper* m_triBodyWrap;
37
38 btManifoldResult* m_resultOut;
39 btDispatcher* m_dispatcher;
40 const btDispatcherInfo* m_dispatchInfoPtr;
41 btScalar m_collisionMarginTriangle;
42
43public:
44 BT_DECLARE_ALIGNED_ALLOCATOR();
45
46 int m_triangleCount;
47
48 btPersistentManifold* m_manifoldPtr;
49
50 btConvexTriangleCallback(btDispatcher * dispatcher, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, bool isSwapped);
51
52 void setTimeStepAndCounters(btScalar collisionMarginTriangle, const btDispatcherInfo& dispatchInfo, const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut);
53
54 void clearWrapperData()
55 {
56 m_convexBodyWrap = 0;
57 m_triBodyWrap = 0;
58 }
59 virtual ~btConvexTriangleCallback();
60
61 virtual void processTriangle(btVector3 * triangle, int partId, int triangleIndex);
62
63 void clearCache();
64
65 SIMD_FORCE_INLINE const btVector3& getAabbMin() const
66 {
67 return m_aabbMin;
68 }
69 SIMD_FORCE_INLINE const btVector3& getAabbMax() const
70 {
71 return m_aabbMax;
72 }
73};
74
76 ATTRIBUTE_ALIGNED16(class)
77 btConvexConcaveCollisionAlgorithm : public btActivatingCollisionAlgorithm
78{
79 btConvexTriangleCallback m_btConvexTriangleCallback;
80
81 bool m_isSwapped;
82
83public:
84 BT_DECLARE_ALIGNED_ALLOCATOR();
85
86 btConvexConcaveCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, bool isSwapped);
87
88 virtual ~btConvexConcaveCollisionAlgorithm();
89
90 virtual void processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
91
92 btScalar calculateTimeOfImpact(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
93
94 virtual void getAllContactManifolds(btManifoldArray & manifoldArray);
95
96 void clearCache();
97
98 struct CreateFunc : public btCollisionAlgorithmCreateFunc
99 {
100 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
101 {
102 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm));
103 return new (mem) btConvexConcaveCollisionAlgorithm(ci, body0Wrap, body1Wrap, false);
104 }
105 };
106
107 struct SwappedCreateFunc : 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, true);
113 }
114 };
115};
116
117#endif //BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
btActivatingCollisionAlgorithm.h
btBroadphaseInterface.h
btBroadphaseProxy.h
btCollisionCreateFunc.h
btDispatcher.h
calculateTimeOfImpact
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
getAllContactManifolds
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)
Definition: btEmptyCollisionAlgorithm.h:7
processCollision
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btPersistentManifold.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:98
btTriangleCallback.h
btActivatingCollisionAlgorithm
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
Definition: btActivatingCollisionAlgorithm.h:23
btAlignedObjectArray< btPersistentManifold * >
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
btConvexConcaveCollisionAlgorithm
btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges mes...
Definition: btConvexConcaveCollisionAlgorithm.h:78
btConvexConcaveCollisionAlgorithm::m_isSwapped
bool m_isSwapped
Definition: btConvexConcaveCollisionAlgorithm.h:81
btConvexConcaveCollisionAlgorithm::m_btConvexTriangleCallback
btConvexTriangleCallback m_btConvexTriangleCallback
Definition: btConvexConcaveCollisionAlgorithm.h:79
btConvexConcaveCollisionAlgorithm::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btConvexTriangleCallback
For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy),...
Definition: btConvexConcaveCollisionAlgorithm.h:31
btConvexTriangleCallback::getAabbMax
const btVector3 & getAabbMax() const
Definition: btConvexConcaveCollisionAlgorithm.h:69
btConvexTriangleCallback::m_aabbMin
btVector3 m_aabbMin
Definition: btConvexConcaveCollisionAlgorithm.h:32
btConvexTriangleCallback::m_aabbMax
btVector3 m_aabbMax
Definition: btConvexConcaveCollisionAlgorithm.h:33
btConvexTriangleCallback::m_collisionMarginTriangle
btScalar m_collisionMarginTriangle
Definition: btConvexConcaveCollisionAlgorithm.h:41
btConvexTriangleCallback::getAabbMin
const btVector3 & getAabbMin() const
Definition: btConvexConcaveCollisionAlgorithm.h:65
btConvexTriangleCallback::m_dispatcher
btDispatcher * m_dispatcher
Definition: btConvexConcaveCollisionAlgorithm.h:39
btConvexTriangleCallback::m_resultOut
btManifoldResult * m_resultOut
Definition: btConvexConcaveCollisionAlgorithm.h:38
btConvexTriangleCallback::m_dispatchInfoPtr
const btDispatcherInfo * m_dispatchInfoPtr
Definition: btConvexConcaveCollisionAlgorithm.h:40
btConvexTriangleCallback::m_manifoldPtr
btPersistentManifold * m_manifoldPtr
Definition: btConvexConcaveCollisionAlgorithm.h:48
btConvexTriangleCallback::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btConvexTriangleCallback::m_convexBodyWrap
const btCollisionObjectWrapper * m_convexBodyWrap
Definition: btConvexConcaveCollisionAlgorithm.h:35
btConvexTriangleCallback::m_triBodyWrap
const btCollisionObjectWrapper * m_triBodyWrap
Definition: btConvexConcaveCollisionAlgorithm.h:36
btConvexTriangleCallback::clearWrapperData
void clearWrapperData()
Definition: btConvexConcaveCollisionAlgorithm.h:54
btConvexTriangleCallback::m_triangleCount
int m_triangleCount
Definition: btConvexConcaveCollisionAlgorithm.h:46
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
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition: btTriangleCallback.h:24
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
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
btConvexConcaveCollisionAlgorithm::CreateFunc
Definition: btConvexConcaveCollisionAlgorithm.h:99
btConvexConcaveCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btConvexConcaveCollisionAlgorithm.h:100
btConvexConcaveCollisionAlgorithm::SwappedCreateFunc
Definition: btConvexConcaveCollisionAlgorithm.h:108
btConvexConcaveCollisionAlgorithm::SwappedCreateFunc::CreateCollisionAlgorithm
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btConvexConcaveCollisionAlgorithm.h:109
btDispatcherInfo
Definition: btDispatcher.h:31