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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btManifoldResult.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_MANIFOLD_RESULT_H
17#define BT_MANIFOLD_RESULT_H
18
19class btCollisionObject;
20struct btCollisionObjectWrapper;
21
22#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
23class btManifoldPoint;
24
25#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
26
27#include "LinearMath/btTransform.h"
28#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
29#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
30
31 typedef bool (*ContactAddedCallback)(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1);
32extern ContactAddedCallback gContactAddedCallback;
33
34//#define DEBUG_PART_INDEX 1
35
37 typedef btScalar (*CalculateCombinedCallback)(const btCollisionObject* body0, const btCollisionObject* body1);
38
39extern CalculateCombinedCallback gCalculateCombinedRestitutionCallback;
40extern CalculateCombinedCallback gCalculateCombinedFrictionCallback;
41extern CalculateCombinedCallback gCalculateCombinedRollingFrictionCallback;
42extern CalculateCombinedCallback gCalculateCombinedSpinningFrictionCallback;
43extern CalculateCombinedCallback gCalculateCombinedContactDampingCallback;
44extern CalculateCombinedCallback gCalculateCombinedContactStiffnessCallback;
45
47 class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result
48{
49protected:
50 btPersistentManifold* m_manifoldPtr;
51
52 const btCollisionObjectWrapper* m_body0Wrap;
53 const btCollisionObjectWrapper* m_body1Wrap;
54 int m_partId0;
55 int m_partId1;
56 int m_index0;
57 int m_index1;
58
59public:
60 btManifoldResult()
61 :
62#ifdef DEBUG_PART_INDEX
63
64 m_partId0(-1),
65 m_partId1(-1),
66 m_index0(-1),
67 m_index1(-1)
68#endif //DEBUG_PART_INDEX
69 m_closestPointDistanceThreshold(0)
70 {
71 }
72
73 btManifoldResult(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
74
75 virtual ~btManifoldResult(){};
76
77 void setPersistentManifold(btPersistentManifold* manifoldPtr)
78 {
79 m_manifoldPtr = manifoldPtr;
80 }
81
82 const btPersistentManifold* getPersistentManifold() const
83 {
84 return m_manifoldPtr;
85 }
86 btPersistentManifold* getPersistentManifold()
87 {
88 return m_manifoldPtr;
89 }
90
91 virtual void setShapeIdentifiersA(int partId0, int index0)
92 {
93 m_partId0 = partId0;
94 m_index0 = index0;
95 }
96
97 virtual void setShapeIdentifiersB(int partId1, int index1)
98 {
99 m_partId1 = partId1;
100 m_index1 = index1;
101 }
102
103 virtual void addContactPoint(const btVector3& normalOnBInWorld, const btVector3& pointInWorld, btScalar depth);
104
105 SIMD_FORCE_INLINE void refreshContactPoints()
106 {
107 btAssert(m_manifoldPtr);
108 if (!m_manifoldPtr->getNumContacts())
109 return;
110
111 bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject();
112
113 if (isSwapped)
114 {
115 m_manifoldPtr->refreshContactPoints(m_body1Wrap->getCollisionObject()->getWorldTransform(), m_body0Wrap->getCollisionObject()->getWorldTransform());
116 }
117 else
118 {
119 m_manifoldPtr->refreshContactPoints(m_body0Wrap->getCollisionObject()->getWorldTransform(), m_body1Wrap->getCollisionObject()->getWorldTransform());
120 }
121 }
122
123 const btCollisionObjectWrapper* getBody0Wrap() const
124 {
125 return m_body0Wrap;
126 }
127 const btCollisionObjectWrapper* getBody1Wrap() const
128 {
129 return m_body1Wrap;
130 }
131
132 void setBody0Wrap(const btCollisionObjectWrapper* obj0Wrap)
133 {
134 m_body0Wrap = obj0Wrap;
135 }
136
137 void setBody1Wrap(const btCollisionObjectWrapper* obj1Wrap)
138 {
139 m_body1Wrap = obj1Wrap;
140 }
141
142 const btCollisionObject* getBody0Internal() const
143 {
144 return m_body0Wrap->getCollisionObject();
145 }
146
147 const btCollisionObject* getBody1Internal() const
148 {
149 return m_body1Wrap->getCollisionObject();
150 }
151
152 btScalar m_closestPointDistanceThreshold;
153
155 static btScalar calculateCombinedRestitution(const btCollisionObject* body0, const btCollisionObject* body1);
156 static btScalar calculateCombinedFriction(const btCollisionObject* body0, const btCollisionObject* body1);
157 static btScalar calculateCombinedRollingFriction(const btCollisionObject* body0, const btCollisionObject* body1);
158 static btScalar calculateCombinedSpinningFriction(const btCollisionObject* body0, const btCollisionObject* body1);
159 static btScalar calculateCombinedContactDamping(const btCollisionObject* body0, const btCollisionObject* body1);
160 static btScalar calculateCombinedContactStiffness(const btCollisionObject* body0, const btCollisionObject* body1);
161};
162
163#endif //BT_MANIFOLD_RESULT_H
btCollisionObjectWrapper.h
btCollisionObject.h
btDiscreteCollisionDetectorInterface.h
gCalculateCombinedContactStiffnessCallback
CalculateCombinedCallback gCalculateCombinedContactStiffnessCallback
Definition btManifoldResult.cpp:29
gCalculateCombinedContactDampingCallback
CalculateCombinedCallback gCalculateCombinedContactDampingCallback
Definition btManifoldResult.cpp:28
gContactAddedCallback
ContactAddedCallback gContactAddedCallback
This is to allow MaterialCombiner/Custom Friction/Restitution values.
Definition btManifoldResult.cpp:22
gCalculateCombinedSpinningFrictionCallback
CalculateCombinedCallback gCalculateCombinedSpinningFrictionCallback
Definition btManifoldResult.cpp:27
gCalculateCombinedFrictionCallback
CalculateCombinedCallback gCalculateCombinedFrictionCallback
Definition btManifoldResult.cpp:25
gCalculateCombinedRollingFrictionCallback
CalculateCombinedCallback gCalculateCombinedRollingFrictionCallback
Definition btManifoldResult.cpp:26
ContactAddedCallback
bool(* ContactAddedCallback)(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)
Definition btManifoldResult.h:31
CalculateCombinedCallback
btScalar(* CalculateCombinedCallback)(const btCollisionObject *body0, const btCollisionObject *body1)
These callbacks are used to customize the algorith that combine restitution, friction,...
Definition btManifoldResult.h:37
gCalculateCombinedRestitutionCallback
CalculateCombinedCallback gCalculateCombinedRestitutionCallback
Definition btManifoldResult.cpp:24
btPersistentManifold.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btAssert
#define btAssert(x)
Definition btScalar.h:153
btTransform.h
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition btCollisionObject.h:51
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition btCollisionObject.h:379
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition btManifoldPoint.h:52
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition btManifoldResult.h:48
btManifoldResult::setShapeIdentifiersA
virtual void setShapeIdentifiersA(int partId0, int index0)
setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material comb...
Definition btManifoldResult.h:91
btManifoldResult::setBody0Wrap
void setBody0Wrap(const btCollisionObjectWrapper *obj0Wrap)
Definition btManifoldResult.h:132
btManifoldResult::m_body0Wrap
const btCollisionObjectWrapper * m_body0Wrap
Definition btManifoldResult.h:52
btManifoldResult::m_partId0
int m_partId0
Definition btManifoldResult.h:54
btManifoldResult::calculateCombinedFriction
static btScalar calculateCombinedFriction(const btCollisionObject *body0, const btCollisionObject *body1)
User can override this material combiner by implementing gContactAddedCallback and setting body0->m_c...
Definition btManifoldResult.cpp:56
btManifoldResult::btManifoldResult
btManifoldResult()
Definition btManifoldResult.h:60
btManifoldResult::calculateCombinedContactDamping
static btScalar calculateCombinedContactDamping(const btCollisionObject *body0, const btCollisionObject *body1)
Definition btManifoldResult.cpp:73
btManifoldResult::m_body1Wrap
const btCollisionObjectWrapper * m_body1Wrap
Definition btManifoldResult.h:53
btManifoldResult::getPersistentManifold
const btPersistentManifold * getPersistentManifold() const
Definition btManifoldResult.h:82
btManifoldResult::calculateCombinedContactStiffness
static btScalar calculateCombinedContactStiffness(const btCollisionObject *body0, const btCollisionObject *body1)
Definition btManifoldResult.cpp:78
btManifoldResult::getBody1Wrap
const btCollisionObjectWrapper * getBody1Wrap() const
Definition btManifoldResult.h:127
btManifoldResult::getBody1Internal
const btCollisionObject * getBody1Internal() const
Definition btManifoldResult.h:147
btManifoldResult::m_partId1
int m_partId1
Definition btManifoldResult.h:55
btManifoldResult::calculateCombinedSpinningFriction
static btScalar calculateCombinedSpinningFriction(const btCollisionObject *body0, const btCollisionObject *body1)
Definition btManifoldResult.cpp:43
btManifoldResult::setBody1Wrap
void setBody1Wrap(const btCollisionObjectWrapper *obj1Wrap)
Definition btManifoldResult.h:137
btManifoldResult::calculateCombinedRollingFriction
static btScalar calculateCombinedRollingFriction(const btCollisionObject *body0, const btCollisionObject *body1)
Definition btManifoldResult.cpp:31
btManifoldResult::setPersistentManifold
void setPersistentManifold(btPersistentManifold *manifoldPtr)
Definition btManifoldResult.h:77
btManifoldResult::getBody0Internal
const btCollisionObject * getBody0Internal() const
Definition btManifoldResult.h:142
btManifoldResult::m_index0
int m_index0
Definition btManifoldResult.h:56
btManifoldResult::setShapeIdentifiersB
virtual void setShapeIdentifiersB(int partId1, int index1)
Definition btManifoldResult.h:97
btManifoldResult::~btManifoldResult
virtual ~btManifoldResult()
Definition btManifoldResult.h:75
btManifoldResult::calculateCombinedRestitution
static btScalar calculateCombinedRestitution(const btCollisionObject *body0, const btCollisionObject *body1)
in the future we can let the user override the methods to combine restitution and friction
Definition btManifoldResult.cpp:68
btManifoldResult::m_closestPointDistanceThreshold
btScalar m_closestPointDistanceThreshold
Definition btManifoldResult.h:152
btManifoldResult::refreshContactPoints
void refreshContactPoints()
Definition btManifoldResult.h:105
btManifoldResult::getBody0Wrap
const btCollisionObjectWrapper * getBody0Wrap() const
Definition btManifoldResult.h:123
btManifoldResult::getPersistentManifold
btPersistentManifold * getPersistentManifold()
Definition btManifoldResult.h:86
btManifoldResult::m_manifoldPtr
btPersistentManifold * m_manifoldPtr
Definition btManifoldResult.h:50
btManifoldResult::addContactPoint
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
Definition btManifoldResult.cpp:103
btManifoldResult::m_index1
int m_index1
Definition btManifoldResult.h:57
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition btPersistentManifold.h:65
btPersistentManifold::getBody0
const btCollisionObject * getBody0() const
Definition btPersistentManifold.h:105
btPersistentManifold::refreshContactPoints
void refreshContactPoints(const btTransform &trA, const btTransform &trB)
calculated new worldspace coordinates and depth, and reject points that exceed the collision margin
Definition btPersistentManifold.cpp:247
btPersistentManifold::getNumContacts
int getNumContacts() const
Definition btPersistentManifold.h:120
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btCollisionObjectWrapper
Definition btCollisionObjectWrapper.h:18
btCollisionObjectWrapper::getCollisionObject
const btCollisionObject * getCollisionObject() const
Definition btCollisionObjectWrapper.h:45
btDiscreteCollisionDetectorInterface::Result
Definition btDiscreteCollisionDetectorInterface.h:30