Blender  V3.3
btManifoldResult.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_MANIFOLD_RESULT_H
17 #define BT_MANIFOLD_RESULT_H
18 
19 class btCollisionObject;
21 
23 class btManifoldPoint;
24 
26 
27 #include "LinearMath/btTransform.h"
30 
31 typedef bool (*ContactAddedCallback)(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1);
33 
34 //#define DEBUG_PART_INDEX 1
35 
38 
45 
48 {
49 protected:
51 
54  int m_partId0;
55  int m_partId1;
56  int m_index0;
57  int m_index1;
58 
59 public:
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
70  {
71  }
72 
73  btManifoldResult(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
74 
75  virtual ~btManifoldResult(){};
76 
78  {
80  }
81 
83  {
84  return m_manifoldPtr;
85  }
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 
106  {
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 
124  {
125  return m_body0Wrap;
126  }
128  {
129  return m_body1Wrap;
130  }
131 
133  {
134  m_body0Wrap = obj0Wrap;
135  }
136 
138  {
139  m_body1Wrap = obj1Wrap;
140  }
141 
143  {
145  }
146 
148  {
150  }
151 
153 
156  static btScalar calculateCombinedFriction(const btCollisionObject* body0, const btCollisionObject* body1);
161 };
162 
163 #endif //BT_MANIFOLD_RESULT_H
btCollisionObject
CalculateCombinedCallback gCalculateCombinedContactStiffnessCallback
CalculateCombinedCallback gCalculateCombinedContactDampingCallback
ContactAddedCallback gContactAddedCallback
This is to allow MaterialCombiner/Custom Friction/Restitution values.
CalculateCombinedCallback gCalculateCombinedSpinningFrictionCallback
CalculateCombinedCallback gCalculateCombinedFrictionCallback
CalculateCombinedCallback gCalculateCombinedRollingFrictionCallback
bool(* ContactAddedCallback)(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)
btScalar(* CalculateCombinedCallback)(const btCollisionObject *body0, const btCollisionObject *body1)
These callbacks are used to customize the algorith that combine restitution, friction,...
CalculateCombinedCallback gCalculateCombinedRestitutionCallback
btPersistentManifold()
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define SIMD_FORCE_INLINE
Definition: btScalar.h:280
#define btAssert(x)
Definition: btScalar.h:295
btSequentialImpulseConstraintSolverMt int btPersistentManifold ** manifoldPtr
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
btManifoldResult is a helper class to manage contact results.
virtual void setShapeIdentifiersA(int partId0, int index0)
setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material comb...
void setBody0Wrap(const btCollisionObjectWrapper *obj0Wrap)
const btCollisionObject * getBody0Internal() const
const btCollisionObjectWrapper * m_body0Wrap
const btCollisionObjectWrapper * getBody1Wrap() const
static btScalar calculateCombinedFriction(const btCollisionObject *body0, const btCollisionObject *body1)
User can override this material combiner by implementing gContactAddedCallback and setting body0->m_c...
const btPersistentManifold * getPersistentManifold() const
static btScalar calculateCombinedContactDamping(const btCollisionObject *body0, const btCollisionObject *body1)
const btCollisionObjectWrapper * m_body1Wrap
static btScalar calculateCombinedContactStiffness(const btCollisionObject *body0, const btCollisionObject *body1)
const btCollisionObjectWrapper * getBody0Wrap() const
btPersistentManifold * getPersistentManifold()
static btScalar calculateCombinedSpinningFriction(const btCollisionObject *body0, const btCollisionObject *body1)
void setBody1Wrap(const btCollisionObjectWrapper *obj1Wrap)
static btScalar calculateCombinedRollingFriction(const btCollisionObject *body0, const btCollisionObject *body1)
void setPersistentManifold(btPersistentManifold *manifoldPtr)
virtual void setShapeIdentifiersB(int partId1, int index1)
virtual ~btManifoldResult()
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
btScalar m_closestPointDistanceThreshold
SIMD_FORCE_INLINE void refreshContactPoints()
btPersistentManifold * m_manifoldPtr
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
const btCollisionObject * getBody1Internal() const
SIMD_FORCE_INLINE const btCollisionObject * getCollisionObject() const