Bullet Collision Detection & Physics Library: btPersistentManifold.cpp Source File

Bullet Collision Detection & Physics Library

btPersistentManifold.cpp
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 #include "btPersistentManifold.h"
17 #include "LinearMath/btTransform.h"
18 #include "LinearMath/btSerializer.h"
19
20 #ifdef BT_USE_DOUBLE_PRECISION
21 #define btCollisionObjectData btCollisionObjectDoubleData
22 #else
23 #define btCollisionObjectData btCollisionObjectFloatData
24 #endif
25
26 btScalar gContactBreakingThreshold = btScalar(0.02);
27 ContactDestroyedCallback gContactDestroyedCallback = 0;
28 ContactProcessedCallback gContactProcessedCallback = 0;
29 ContactStartedCallback gContactStartedCallback = 0;
30 ContactEndedCallback gContactEndedCallback = 0;
33 bool gContactCalcArea3Points = true;
34
35 btPersistentManifold::btPersistentManifold()
36 : btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE),
37 m_body0(0),
38 m_body1(0),
39 m_cachedPoints(0),
40 m_companionIdA(0),
41 m_companionIdB(0),
42 m_index1a(0)
43 {
44 }
45
46 #ifdef DEBUG_PERSISTENCY
47 #include <stdio.h>
48 void btPersistentManifold::DebugPersistency()
49 {
50 int i;
51 printf("DebugPersistency : numPoints %d\n", m_cachedPoints);
52 for (i = 0; i < m_cachedPoints; i++)
53 {
54 printf("m_pointCache[%d].m_userPersistentData = %x\n", i, m_pointCache[i].m_userPersistentData);
55 }
56 }
57 #endif //DEBUG_PERSISTENCY
58
59 void btPersistentManifold::clearUserCache(btManifoldPoint& pt)
60 {
61 void* oldPtr = pt.m_userPersistentData;
62 if (oldPtr)
63 {
64 #ifdef DEBUG_PERSISTENCY
65 int i;
66 int occurance = 0;
67 for (i = 0; i < m_cachedPoints; i++)
68 {
69 if (m_pointCache[i].m_userPersistentData == oldPtr)
70 {
71 occurance++;
72 if (occurance > 1)
73 printf("error in clearUserCache\n");
74 }
75 }
76 btAssert(occurance <= 0);
77 #endif //DEBUG_PERSISTENCY
78
79 if (pt.m_userPersistentData && gContactDestroyedCallback)
80 {
81 (*gContactDestroyedCallback)(pt.m_userPersistentData);
82 pt.m_userPersistentData = 0;
83 }
84
85 #ifdef DEBUG_PERSISTENCY
86 DebugPersistency();
87 #endif
88 }
89 }
90
91 static inline btScalar calcArea4Points(const btVector3& p0, const btVector3& p1, const btVector3& p2, const btVector3& p3)
92 {
93 // It calculates possible 3 area constructed from random 4 points and returns the biggest one.
94
95 btVector3 a[3], b[3];
96 a[0] = p0 - p1;
97 a[1] = p0 - p2;
98 a[2] = p0 - p3;
99 b[0] = p2 - p3;
100 b[1] = p1 - p3;
101 b[2] = p1 - p2;
102
103 //todo: Following 3 cross production can be easily optimized by SIMD.
104 btVector3 tmp0 = a[0].cross(b[0]);
105 btVector3 tmp1 = a[1].cross(b[1]);
106 btVector3 tmp2 = a[2].cross(b[2]);
107
108 return btMax(btMax(tmp0.length2(), tmp1.length2()), tmp2.length2());
109 }
110
111 int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt)
112 {
113 //calculate 4 possible cases areas, and take biggest area
114 //also need to keep 'deepest'
115
116 int maxPenetrationIndex = -1;
117 #define KEEP_DEEPEST_POINT 1
118 #ifdef KEEP_DEEPEST_POINT
119 btScalar maxPenetration = pt.getDistance();
120 for (int i = 0; i < 4; i++)
121 {
122 if (m_pointCache[i].getDistance() < maxPenetration)
123 {
124 maxPenetrationIndex = i;
125 maxPenetration = m_pointCache[i].getDistance();
126 }
127 }
128 #endif //KEEP_DEEPEST_POINT
129
130 btScalar res0(btScalar(0.)), res1(btScalar(0.)), res2(btScalar(0.)), res3(btScalar(0.));
131
132 if (gContactCalcArea3Points)
133 {
134 if (maxPenetrationIndex != 0)
135 {
136 btVector3 a0 = pt.m_localPointA - m_pointCache[1].m_localPointA;
137 btVector3 b0 = m_pointCache[3].m_localPointA - m_pointCache[2].m_localPointA;
138 btVector3 cross = a0.cross(b0);
139 res0 = cross.length2();
140 }
141 if (maxPenetrationIndex != 1)
142 {
143 btVector3 a1 = pt.m_localPointA - m_pointCache[0].m_localPointA;
144 btVector3 b1 = m_pointCache[3].m_localPointA - m_pointCache[2].m_localPointA;
145 btVector3 cross = a1.cross(b1);
146 res1 = cross.length2();
147 }
148
149 if (maxPenetrationIndex != 2)
150 {
151 btVector3 a2 = pt.m_localPointA - m_pointCache[0].m_localPointA;
152 btVector3 b2 = m_pointCache[3].m_localPointA - m_pointCache[1].m_localPointA;
153 btVector3 cross = a2.cross(b2);
154 res2 = cross.length2();
155 }
156
157 if (maxPenetrationIndex != 3)
158 {
159 btVector3 a3 = pt.m_localPointA - m_pointCache[0].m_localPointA;
160 btVector3 b3 = m_pointCache[2].m_localPointA - m_pointCache[1].m_localPointA;
161 btVector3 cross = a3.cross(b3);
162 res3 = cross.length2();
163 }
164 }
165 else
166 {
167 if (maxPenetrationIndex != 0)
168 {
169 res0 = calcArea4Points(pt.m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[2].m_localPointA, m_pointCache[3].m_localPointA);
170 }
171
172 if (maxPenetrationIndex != 1)
173 {
174 res1 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[2].m_localPointA, m_pointCache[3].m_localPointA);
175 }
176
177 if (maxPenetrationIndex != 2)
178 {
179 res2 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[3].m_localPointA);
180 }
181
182 if (maxPenetrationIndex != 3)
183 {
184 res3 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[2].m_localPointA);
185 }
186 }
187 btVector4 maxvec(res0, res1, res2, res3);
188 int biggestarea = maxvec.closestAxis4();
189 return biggestarea;
190 }
191
192 int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const
193 {
194 btScalar shortestDist = getContactBreakingThreshold() * getContactBreakingThreshold();
195 int size = getNumContacts();
196 int nearestPoint = -1;
197 for (int i = 0; i < size; i++)
198 {
199 const btManifoldPoint& mp = m_pointCache[i];
200
201 btVector3 diffA = mp.m_localPointA - newPoint.m_localPointA;
202 const btScalar distToManiPoint = diffA.dot(diffA);
203 if (distToManiPoint < shortestDist)
204 {
205 shortestDist = distToManiPoint;
206 nearestPoint = i;
207 }
208 }
209 return nearestPoint;
210 }
211
212 int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint, bool isPredictive)
213 {
214 if (!isPredictive)
215 {
216 btAssert(validContactDistance(newPoint));
217 }
218
219 int insertIndex = getNumContacts();
220 if (insertIndex == MANIFOLD_CACHE_SIZE)
221 {
222 #if MANIFOLD_CACHE_SIZE >= 4
223 //sort cache so best points come first, based on area
224 insertIndex = sortCachedPoints(newPoint);
225 #else
226 insertIndex = 0;
227 #endif
228 clearUserCache(m_pointCache[insertIndex]);
229 }
230 else
231 {
232 m_cachedPoints++;
233 }
234 if (insertIndex < 0)
235 insertIndex = 0;
236
237 btAssert(m_pointCache[insertIndex].m_userPersistentData == 0);
238 m_pointCache[insertIndex] = newPoint;
239 return insertIndex;
240 }
241
242 btScalar btPersistentManifold::getContactBreakingThreshold() const
243 {
244 return m_contactBreakingThreshold;
245 }
246
247 void btPersistentManifold::refreshContactPoints(const btTransform& trA, const btTransform& trB)
248 {
249 int i;
250 #ifdef DEBUG_PERSISTENCY
251 printf("refreshContactPoints posA = (%f,%f,%f) posB = (%f,%f,%f)\n",
252 trA.getOrigin().getX(),
253 trA.getOrigin().getY(),
254 trA.getOrigin().getZ(),
255 trB.getOrigin().getX(),
256 trB.getOrigin().getY(),
257 trB.getOrigin().getZ());
258 #endif //DEBUG_PERSISTENCY
259 for (i = getNumContacts() - 1; i >= 0; i--)
261 {
262 btManifoldPoint& manifoldPoint = m_pointCache[i];
263 manifoldPoint.m_positionWorldOnA = trA(manifoldPoint.m_localPointA);
264 manifoldPoint.m_positionWorldOnB = trB(manifoldPoint.m_localPointB);
265 manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA - manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB);
266 manifoldPoint.m_lifeTime++;
267 }
268
270 btScalar distance2d;
271 btVector3 projectedDifference, projectedPoint;
272 for (i = getNumContacts() - 1; i >= 0; i--)
273 {
274 btManifoldPoint& manifoldPoint = m_pointCache[i];
275 //contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction)
276 if (!validContactDistance(manifoldPoint))
277 {
278 removeContactPoint(i);
279 }
280 else
281 {
282 //todo: friction anchor may require the contact to be around a bit longer
283 //contact also becomes invalid when relative movement orthogonal to normal exceeds margin
284 projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1;
285 projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint;
286 distance2d = projectedDifference.dot(projectedDifference);
287 if (distance2d > getContactBreakingThreshold() * getContactBreakingThreshold())
288 {
289 removeContactPoint(i);
290 }
291 else
292 {
293 //contact point processed callback
294 if (gContactProcessedCallback)
295 (*gContactProcessedCallback)(manifoldPoint, (void*)m_body0, (void*)m_body1);
296 }
297 }
298 }
299 #ifdef DEBUG_PERSISTENCY
300 DebugPersistency();
301 #endif //
302 }
303
304 int btPersistentManifold::calculateSerializeBufferSize() const
305 {
306 return sizeof(btPersistentManifoldData);
307 }
308
309 const char* btPersistentManifold::serialize(const class btPersistentManifold* manifold, void* dataBuffer, class btSerializer* serializer) const
310 {
311 btPersistentManifoldData* dataOut = (btPersistentManifoldData*)dataBuffer;
312 memset(dataOut, 0, sizeof(btPersistentManifoldData));
313
314 dataOut->m_body0 = (btCollisionObjectData*)serializer->getUniquePointer((void*)manifold->getBody0());
315 dataOut->m_body1 = (btCollisionObjectData*)serializer->getUniquePointer((void*)manifold->getBody1());
316 dataOut->m_contactBreakingThreshold = manifold->getContactBreakingThreshold();
317 dataOut->m_contactProcessingThreshold = manifold->getContactProcessingThreshold();
318 dataOut->m_numCachedPoints = manifold->getNumContacts();
319 dataOut->m_companionIdA = manifold->m_companionIdA;
320 dataOut->m_companionIdB = manifold->m_companionIdB;
321 dataOut->m_index1a = manifold->m_index1a;
322 dataOut->m_objectType = manifold->m_objectType;
323
324 for (int i = 0; i < this->getNumContacts(); i++)
325 {
326 const btManifoldPoint& pt = manifold->getContactPoint(i);
327 dataOut->m_pointCacheAppliedImpulse[i] = pt.m_appliedImpulse;
328 dataOut->m_pointCacheAppliedImpulseLateral1[i] = pt.m_appliedImpulseLateral1;
329 dataOut->m_pointCacheAppliedImpulseLateral2[i] = pt.m_appliedImpulseLateral2;
330 pt.m_localPointA.serialize(dataOut->m_pointCacheLocalPointA[i]);
331 pt.m_localPointB.serialize(dataOut->m_pointCacheLocalPointB[i]);
332 pt.m_normalWorldOnB.serialize(dataOut->m_pointCacheNormalWorldOnB[i]);
333 dataOut->m_pointCacheDistance[i] = pt.m_distance1;
334 dataOut->m_pointCacheCombinedContactDamping1[i] = pt.m_combinedContactDamping1;
335 dataOut->m_pointCacheCombinedContactStiffness1[i] = pt.m_combinedContactStiffness1;
336 dataOut->m_pointCacheLifeTime[i] = pt.m_lifeTime;
337 dataOut->m_pointCacheFrictionCFM[i] = pt.m_frictionCFM;
338 dataOut->m_pointCacheContactERP[i] = pt.m_contactERP;
339 dataOut->m_pointCacheContactCFM[i] = pt.m_contactCFM;
340 dataOut->m_pointCacheContactPointFlags[i] = pt.m_contactPointFlags;
341 dataOut->m_pointCacheIndex0[i] = pt.m_index0;
342 dataOut->m_pointCacheIndex1[i] = pt.m_index1;
343 dataOut->m_pointCachePartId0[i] = pt.m_partId0;
344 dataOut->m_pointCachePartId1[i] = pt.m_partId1;
345 pt.m_positionWorldOnA.serialize(dataOut->m_pointCachePositionWorldOnA[i]);
346 pt.m_positionWorldOnB.serialize(dataOut->m_pointCachePositionWorldOnB[i]);
347 dataOut->m_pointCacheCombinedFriction[i] = pt.m_combinedFriction;
348 pt.m_lateralFrictionDir1.serialize(dataOut->m_pointCacheLateralFrictionDir1[i]);
349 pt.m_lateralFrictionDir2.serialize(dataOut->m_pointCacheLateralFrictionDir2[i]);
350 dataOut->m_pointCacheCombinedRollingFriction[i] = pt.m_combinedRollingFriction;
351 dataOut->m_pointCacheCombinedSpinningFriction[i] = pt.m_combinedSpinningFriction;
352 dataOut->m_pointCacheCombinedRestitution[i] = pt.m_combinedRestitution;
353 dataOut->m_pointCacheContactMotion1[i] = pt.m_contactMotion1;
354 dataOut->m_pointCacheContactMotion2[i] = pt.m_contactMotion2;
355 }
356 return btPersistentManifoldDataName;
357 }
358
359 void btPersistentManifold::deSerialize(const struct btPersistentManifoldDoubleData* manifoldDataPtr)
360 {
361 m_contactBreakingThreshold = manifoldDataPtr->m_contactBreakingThreshold;
362 m_contactProcessingThreshold = manifoldDataPtr->m_contactProcessingThreshold;
363 m_cachedPoints = manifoldDataPtr->m_numCachedPoints;
364 m_companionIdA = manifoldDataPtr->m_companionIdA;
365 m_companionIdB = manifoldDataPtr->m_companionIdB;
366 //m_index1a = manifoldDataPtr->m_index1a;
367 m_objectType = manifoldDataPtr->m_objectType;
368
369 for (int i = 0; i < this->getNumContacts(); i++)
370 {
371 btManifoldPoint& pt = m_pointCache[i];
372
373 pt.m_appliedImpulse = manifoldDataPtr->m_pointCacheAppliedImpulse[i];
374 pt.m_appliedImpulseLateral1 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
375 pt.m_appliedImpulseLateral2 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
376 pt.m_localPointA.deSerializeDouble(manifoldDataPtr->m_pointCacheLocalPointA[i]);
377 pt.m_localPointB.deSerializeDouble(manifoldDataPtr->m_pointCacheLocalPointB[i]);
378 pt.m_normalWorldOnB.deSerializeDouble(manifoldDataPtr->m_pointCacheNormalWorldOnB[i]);
379 pt.m_distance1 = manifoldDataPtr->m_pointCacheDistance[i];
380 pt.m_combinedContactDamping1 = manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
381 pt.m_combinedContactStiffness1 = manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
382 pt.m_lifeTime = manifoldDataPtr->m_pointCacheLifeTime[i];
383 pt.m_frictionCFM = manifoldDataPtr->m_pointCacheFrictionCFM[i];
384 pt.m_contactERP = manifoldDataPtr->m_pointCacheContactERP[i];
385 pt.m_contactCFM = manifoldDataPtr->m_pointCacheContactCFM[i];
386 pt.m_contactPointFlags = manifoldDataPtr->m_pointCacheContactPointFlags[i];
387 pt.m_index0 = manifoldDataPtr->m_pointCacheIndex0[i];
388 pt.m_index1 = manifoldDataPtr->m_pointCacheIndex1[i];
389 pt.m_partId0 = manifoldDataPtr->m_pointCachePartId0[i];
390 pt.m_partId1 = manifoldDataPtr->m_pointCachePartId1[i];
391 pt.m_positionWorldOnA.deSerializeDouble(manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
392 pt.m_positionWorldOnB.deSerializeDouble(manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
393 pt.m_combinedFriction = manifoldDataPtr->m_pointCacheCombinedFriction[i];
394 pt.m_lateralFrictionDir1.deSerializeDouble(manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
395 pt.m_lateralFrictionDir2.deSerializeDouble(manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
396 pt.m_combinedRollingFriction = manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
397 pt.m_combinedSpinningFriction = manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
398 pt.m_combinedRestitution = manifoldDataPtr->m_pointCacheCombinedRestitution[i];
399 pt.m_contactMotion1 = manifoldDataPtr->m_pointCacheContactMotion1[i];
400 pt.m_contactMotion2 = manifoldDataPtr->m_pointCacheContactMotion2[i];
401 }
402 }
403
404 void btPersistentManifold::deSerialize(const struct btPersistentManifoldFloatData* manifoldDataPtr)
405 {
406 m_contactBreakingThreshold = manifoldDataPtr->m_contactBreakingThreshold;
407 m_contactProcessingThreshold = manifoldDataPtr->m_contactProcessingThreshold;
408 m_cachedPoints = manifoldDataPtr->m_numCachedPoints;
409 m_companionIdA = manifoldDataPtr->m_companionIdA;
410 m_companionIdB = manifoldDataPtr->m_companionIdB;
411 //m_index1a = manifoldDataPtr->m_index1a;
412 m_objectType = manifoldDataPtr->m_objectType;
413
414 for (int i = 0; i < this->getNumContacts(); i++)
415 {
416 btManifoldPoint& pt = m_pointCache[i];
417
418 pt.m_appliedImpulse = manifoldDataPtr->m_pointCacheAppliedImpulse[i];
419 pt.m_appliedImpulseLateral1 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
420 pt.m_appliedImpulseLateral2 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
421 pt.m_localPointA.deSerialize(manifoldDataPtr->m_pointCacheLocalPointA[i]);
422 pt.m_localPointB.deSerialize(manifoldDataPtr->m_pointCacheLocalPointB[i]);
423 pt.m_normalWorldOnB.deSerialize(manifoldDataPtr->m_pointCacheNormalWorldOnB[i]);
424 pt.m_distance1 = manifoldDataPtr->m_pointCacheDistance[i];
425 pt.m_combinedContactDamping1 = manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
426 pt.m_combinedContactStiffness1 = manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
427 pt.m_lifeTime = manifoldDataPtr->m_pointCacheLifeTime[i];
428 pt.m_frictionCFM = manifoldDataPtr->m_pointCacheFrictionCFM[i];
429 pt.m_contactERP = manifoldDataPtr->m_pointCacheContactERP[i];
430 pt.m_contactCFM = manifoldDataPtr->m_pointCacheContactCFM[i];
431 pt.m_contactPointFlags = manifoldDataPtr->m_pointCacheContactPointFlags[i];
432 pt.m_index0 = manifoldDataPtr->m_pointCacheIndex0[i];
433 pt.m_index1 = manifoldDataPtr->m_pointCacheIndex1[i];
434 pt.m_partId0 = manifoldDataPtr->m_pointCachePartId0[i];
435 pt.m_partId1 = manifoldDataPtr->m_pointCachePartId1[i];
436 pt.m_positionWorldOnA.deSerialize(manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
437 pt.m_positionWorldOnB.deSerialize(manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
438 pt.m_combinedFriction = manifoldDataPtr->m_pointCacheCombinedFriction[i];
439 pt.m_lateralFrictionDir1.deSerialize(manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
440 pt.m_lateralFrictionDir2.deSerialize(manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
441 pt.m_combinedRollingFriction = manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
442 pt.m_combinedSpinningFriction = manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
443 pt.m_combinedRestitution = manifoldDataPtr->m_pointCacheCombinedRestitution[i];
444 pt.m_contactMotion1 = manifoldDataPtr->m_pointCacheContactMotion1[i];
445 pt.m_contactMotion2 = manifoldDataPtr->m_pointCacheContactMotion2[i];
446 }
447 }
gContactStartedCallback
ContactStartedCallback gContactStartedCallback
Definition: btPersistentManifold.cpp:29
btManifoldPoint::m_contactPointFlags
int m_contactPointFlags
Definition: btManifoldPoint.h:114
btPersistentManifold::m_companionIdA
int m_companionIdA
Definition: btPersistentManifold.h:85
btPersistentManifoldFloatData::m_pointCacheDistance
float m_pointCacheDistance[4]
Definition: btPersistentManifold.h:323
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:63
btPersistentManifold::m_body1
const btCollisionObject * m_body1
Definition: btPersistentManifold.h:70
btPersistentManifold::getContactBreakingThreshold
btScalar getContactBreakingThreshold() const
Definition: btPersistentManifold.cpp:242
btPersistentManifoldDoubleData::m_pointCachePositionWorldOnB
btVector3DoubleData m_pointCachePositionWorldOnB[4]
Definition: btPersistentManifold.h:273
btPersistentManifoldDoubleData::m_pointCacheAppliedImpulseLateral2
double m_pointCacheAppliedImpulseLateral2[4]
Definition: btPersistentManifold.h:289
btVector3::deSerializeDouble
void deSerializeDouble(const struct btVector3DoubleData &dataIn)
Definition: btVector3.h:1311
btPersistentManifoldDoubleData::m_pointCacheContactMotion1
double m_pointCacheContactMotion1[4]
Definition: btPersistentManifold.h:290
btManifoldPoint::m_combinedContactStiffness1
btScalar m_combinedContactStiffness1
Definition: btManifoldPoint.h:124
btManifoldPoint::m_partId1
int m_partId1
Definition: btManifoldPoint.h:108
btManifoldPoint::m_lateralFrictionDir1
btVector3 m_lateralFrictionDir1
Definition: btManifoldPoint.h:136
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
btPersistentManifoldFloatData::m_pointCacheIndex0
int m_pointCacheIndex0[4]
Definition: btPersistentManifold.h:331
BT_PERSISTENT_MANIFOLD_TYPE
Definition: btPersistentManifold.h:49
btPersistentManifoldFloatData::m_pointCachePartId0
int m_pointCachePartId0[4]
Definition: btPersistentManifold.h:329
btPersistentManifoldFloatData::m_pointCacheContactMotion1
float m_pointCacheContactMotion1[4]
Definition: btPersistentManifold.h:336
btManifoldPoint::m_appliedImpulseLateral1
btScalar m_appliedImpulseLateral1
Definition: btManifoldPoint.h:117
btManifoldPoint::m_combinedRestitution
btScalar m_combinedRestitution
Definition: btManifoldPoint.h:104
btPersistentManifoldFloatData::m_pointCacheCombinedFriction
float m_pointCacheCombinedFriction[4]
Definition: btPersistentManifold.h:325
btVector3::length2
btScalar length2() const
Return the length of the vector squared.
Definition: btVector3.h:251
btManifoldPoint::m_contactERP
btScalar m_contactERP
Definition: btManifoldPoint.h:128
btPersistentManifoldDoubleData::m_companionIdA
int m_companionIdA
Definition: btPersistentManifold.h:300
ContactEndedCallback
void(* ContactEndedCallback)(btPersistentManifold *const &manifold)
Definition: btPersistentManifold.h:38
btPersistentManifoldFloatData::m_pointCacheAppliedImpulse
float m_pointCacheAppliedImpulse[4]
Definition: btPersistentManifold.h:324
btPersistentManifold::getNumContacts
int getNumContacts() const
Definition: btPersistentManifold.h:120
btSerializer::getUniquePointer
virtual void * getUniquePointer(void *oldPtr)=0
btPersistentManifoldFloatData::m_pointCacheAppliedImpulseLateral2
float m_pointCacheAppliedImpulseLateral2[4]
Definition: btPersistentManifold.h:335
btPersistentManifoldFloatData::m_contactBreakingThreshold
float m_contactBreakingThreshold
Definition: btPersistentManifold.h:351
btPersistentManifoldDoubleData::m_objectType
int m_objectType
Definition: btPersistentManifold.h:304
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btManifoldPoint::m_appliedImpulse
btScalar m_appliedImpulse
Definition: btManifoldPoint.h:116
btPersistentManifoldFloatData::m_pointCacheLifeTime
int m_pointCacheLifeTime[4]
Definition: btPersistentManifold.h:343
btAssert
#define btAssert(x)
Definition: btScalar.h:133
btPersistentManifoldDoubleData::m_pointCacheCombinedFriction
double m_pointCacheCombinedFriction[4]
Definition: btPersistentManifold.h:279
btPersistentManifoldDoubleData::m_pointCacheLocalPointB
btVector3DoubleData m_pointCacheLocalPointB[4]
Definition: btPersistentManifold.h:271
btPersistentManifoldDoubleData::m_pointCacheCombinedRollingFriction
double m_pointCacheCombinedRollingFriction[4]
Definition: btPersistentManifold.h:280
btPersistentManifold::validContactDistance
bool validContactDistance(const btManifoldPoint &pt) const
Definition: btPersistentManifold.h:238
btVector3::getY
const btScalar & getY() const
Return the y value.
Definition: btVector3.h:563
btPersistentManifold.h
btManifoldPoint::m_frictionCFM
btScalar m_frictionCFM
Definition: btManifoldPoint.h:132
btTransform.h
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:51
btManifoldPoint::m_contactMotion1
btScalar m_contactMotion1
Definition: btManifoldPoint.h:119
MANIFOLD_CACHE_SIZE
#define MANIFOLD_CACHE_SIZE
Definition: btPersistentManifold.h:52
btPersistentManifold::m_cachedPoints
int m_cachedPoints
Definition: btPersistentManifold.h:72
btPersistentManifoldFloatData::m_pointCacheCombinedContactStiffness1
float m_pointCacheCombinedContactStiffness1[4]
Definition: btPersistentManifold.h:339
btPersistentManifold::sortCachedPoints
int sortCachedPoints(const btManifoldPoint &pt)
sort cached points so most isolated points come first
Definition: btPersistentManifold.cpp:111
btPersistentManifoldDoubleData::m_companionIdB
int m_companionIdB
Definition: btPersistentManifold.h:301
btPersistentManifoldDoubleData::m_pointCacheCombinedSpinningFriction
double m_pointCacheCombinedSpinningFriction[4]
Definition: btPersistentManifold.h:281
btSerializer
Definition: btSerializer.h:65
btPersistentManifoldFloatData::m_pointCacheAppliedImpulseLateral1
float m_pointCacheAppliedImpulseLateral1[4]
Definition: btPersistentManifold.h:334
btPersistentManifold::getContactPoint
const btManifoldPoint & getContactPoint(int index) const
Definition: btPersistentManifold.h:130
btPersistentManifoldDoubleData::m_pointCacheLifeTime
int m_pointCacheLifeTime[4]
Definition: btPersistentManifold.h:297
btPersistentManifoldDoubleData::m_pointCacheCombinedContactStiffness1
double m_pointCacheCombinedContactStiffness1[4]
Definition: btPersistentManifold.h:293
btPersistentManifoldDoubleData::m_pointCacheNormalWorldOnB
btVector3DoubleData m_pointCacheNormalWorldOnB[4]
Definition: btPersistentManifold.h:274
btCollisionObjectData
#define btCollisionObjectData
Definition: btPersistentManifold.cpp:23
btPersistentManifoldFloatData::m_pointCacheContactERP
float m_pointCacheContactERP[4]
Definition: btPersistentManifold.h:340
btVector3::getZ
const btScalar & getZ() const
Return the z value.
Definition: btVector3.h:565
btPersistentManifoldDoubleData::m_pointCacheCombinedContactDamping1
double m_pointCacheCombinedContactDamping1[4]
Definition: btPersistentManifold.h:295
btManifoldPoint::m_combinedRollingFriction
btScalar m_combinedRollingFriction
Definition: btManifoldPoint.h:102
btVector4
Definition: btVector3.h:1073
btPersistentManifoldDoubleData::m_pointCachePositionWorldOnA
btVector3DoubleData m_pointCachePositionWorldOnA[4]
Definition: btPersistentManifold.h:272
btPersistentManifoldData
#define btPersistentManifoldData
Definition: btPersistentManifold.h:365
btPersistentManifoldDoubleData::m_pointCacheAppliedImpulse
double m_pointCacheAppliedImpulse[4]
Definition: btPersistentManifold.h:278
btPersistentManifoldFloatData::m_pointCacheContactCFM
float m_pointCacheContactCFM[4]
Definition: btPersistentManifold.h:338
btManifoldPoint::m_normalWorldOnB
btVector3 m_normalWorldOnB
Definition: btManifoldPoint.h:98
btManifoldPoint::m_userPersistentData
void * m_userPersistentData
Definition: btManifoldPoint.h:112
btPersistentManifold::m_companionIdB
int m_companionIdB
Definition: btPersistentManifold.h:86
btManifoldPoint::m_positionWorldOnB
btVector3 m_positionWorldOnB
Definition: btManifoldPoint.h:95
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:113
btPersistentManifoldFloatData::m_pointCacheLocalPointB
btVector3FloatData m_pointCacheLocalPointB[4]
Definition: btPersistentManifold.h:317
btManifoldPoint::m_localPointA
btVector3 m_localPointA
Definition: btManifoldPoint.h:93
btPersistentManifold::getBody0
const btCollisionObject * getBody0() const
Definition: btPersistentManifold.h:105
btManifoldPoint::m_appliedImpulseLateral2
btScalar m_appliedImpulseLateral2
Definition: btManifoldPoint.h:118
btVector3::cross
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
Definition: btVector3.h:380
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:229
ContactStartedCallback
void(* ContactStartedCallback)(btPersistentManifold *const &manifold)
Definition: btPersistentManifold.h:37
btPersistentManifoldDoubleData::m_pointCacheContactMotion2
double m_pointCacheContactMotion2[4]
Definition: btPersistentManifold.h:291
btPersistentManifoldDoubleData::m_pointCacheDistance
double m_pointCacheDistance[4]
Definition: btPersistentManifold.h:277
btPersistentManifold::btPersistentManifold
btPersistentManifold()
Definition: btPersistentManifold.cpp:35
btManifoldPoint::m_lifeTime
int m_lifeTime
Definition: btManifoldPoint.h:134
btPersistentManifoldFloatData::m_companionIdB
int m_companionIdB
Definition: btPersistentManifold.h:347
btPersistentManifoldFloatData
Definition: btPersistentManifold.h:314
calcArea4Points
static btScalar calcArea4Points(const btVector3 &p0, const btVector3 &p1, const btVector3 &p2, const btVector3 &p3)
Definition: btPersistentManifold.cpp:91
btVector3::deSerialize
void deSerialize(const struct btVector3DoubleData &dataIn)
Definition: btVector3.h:1330
btPersistentManifoldFloatData::m_pointCachePositionWorldOnB
btVector3FloatData m_pointCachePositionWorldOnB[4]
Definition: btPersistentManifold.h:319
btPersistentManifoldFloatData::m_contactProcessingThreshold
float m_contactProcessingThreshold
Definition: btPersistentManifold.h:352
btPersistentManifoldDoubleData::m_pointCacheLateralFrictionDir1
btVector3DoubleData m_pointCacheLateralFrictionDir1[4]
Definition: btPersistentManifold.h:275
btPersistentManifoldFloatData::m_pointCacheNormalWorldOnB
btVector3FloatData m_pointCacheNormalWorldOnB[4]
Definition: btPersistentManifold.h:320
btManifoldPoint::m_positionWorldOnA
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity ...
Definition: btManifoldPoint.h:97
btVector4::closestAxis4
int closestAxis4() const
Definition: btVector3.h:1174
btPersistentManifold::getContactProcessingThreshold
btScalar getContactProcessingThreshold() const
Definition: btPersistentManifold.h:145
btPersistentManifold::m_index1a
int m_index1a
Definition: btPersistentManifold.h:88
btPersistentManifoldFloatData::m_pointCacheContactMotion2
float m_pointCacheContactMotion2[4]
Definition: btPersistentManifold.h:337
btPersistentManifold::calculateSerializeBufferSize
int calculateSerializeBufferSize() const
Definition: btPersistentManifold.cpp:304
ContactDestroyedCallback
bool(* ContactDestroyedCallback)(void *userPersistentData)
Definition: btPersistentManifold.h:35
btPersistentManifoldDoubleData::m_pointCacheIndex0
int m_pointCacheIndex0[4]
Definition: btPersistentManifold.h:285
gContactDestroyedCallback
ContactDestroyedCallback gContactDestroyedCallback
Definition: btPersistentManifold.cpp:27
btPersistentManifoldFloatData::m_objectType
int m_objectType
Definition: btPersistentManifold.h:350
btPersistentManifoldDoubleData::m_pointCachePartId1
int m_pointCachePartId1[4]
Definition: btPersistentManifold.h:284
gContactBreakingThreshold
btScalar gContactBreakingThreshold
maximum contact breaking and merging threshold
Definition: btPersistentManifold.cpp:26
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
btPersistentManifoldDoubleData::m_pointCacheContactPointFlags
int m_pointCacheContactPointFlags[4]
Definition: btPersistentManifold.h:287
gContactEndedCallback
ContactEndedCallback gContactEndedCallback
Definition: btPersistentManifold.cpp:30
btPersistentManifoldDoubleData::m_pointCacheIndex1
int m_pointCacheIndex1[4]
Definition: btPersistentManifold.h:286
btPersistentManifold::removeContactPoint
void removeContactPoint(int index)
Definition: btPersistentManifold.h:164
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
btPersistentManifoldFloatData::m_pointCacheIndex1
int m_pointCacheIndex1[4]
Definition: btPersistentManifold.h:332
btVector3::serialize
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1317
btManifoldPoint::m_contactCFM
btScalar m_contactCFM
Definition: btManifoldPoint.h:123
btManifoldPoint::m_index1
int m_index1
Definition: btManifoldPoint.h:110
btPersistentManifoldFloatData::m_pointCacheLocalPointA
btVector3FloatData m_pointCacheLocalPointA[4]
Definition: btPersistentManifold.h:316
btPersistentManifoldFloatData::m_pointCacheCombinedContactDamping1
float m_pointCacheCombinedContactDamping1[4]
Definition: btPersistentManifold.h:341
btManifoldPoint::m_distance1
btScalar m_distance1
Definition: btManifoldPoint.h:100
btPersistentManifoldDoubleData::m_contactProcessingThreshold
double m_contactProcessingThreshold
Definition: btPersistentManifold.h:306
ContactProcessedCallback
bool(* ContactProcessedCallback)(btManifoldPoint &cp, void *body0, void *body1)
Definition: btPersistentManifold.h:36
btManifoldPoint::m_combinedContactDamping1
btScalar m_combinedContactDamping1
Definition: btManifoldPoint.h:129
btPersistentManifoldFloatData::m_pointCacheContactPointFlags
int m_pointCacheContactPointFlags[4]
Definition: btPersistentManifold.h:333
btTypedObject
rudimentary class to provide type info
Definition: btScalar.h:779
btPersistentManifoldDoubleData::m_pointCacheCombinedRestitution
double m_pointCacheCombinedRestitution[4]
Definition: btPersistentManifold.h:282
btPersistentManifoldDoubleData::m_pointCacheContactCFM
double m_pointCacheContactCFM[4]
Definition: btPersistentManifold.h:292
btPersistentManifoldFloatData::m_pointCacheLateralFrictionDir2
btVector3FloatData m_pointCacheLateralFrictionDir2[4]
Definition: btPersistentManifold.h:322
btPersistentManifoldDoubleData::m_contactBreakingThreshold
double m_contactBreakingThreshold
Definition: btPersistentManifold.h:305
btManifoldPoint::m_localPointB
btVector3 m_localPointB
Definition: btManifoldPoint.h:94
btPersistentManifoldDataName
#define btPersistentManifoldDataName
Definition: btPersistentManifold.h:366
btPersistentManifold::getBody1
const btCollisionObject * getBody1() const
Definition: btPersistentManifold.h:106
btPersistentManifoldFloatData::m_companionIdA
int m_companionIdA
Definition: btPersistentManifold.h:346
btPersistentManifoldFloatData::m_pointCacheFrictionCFM
float m_pointCacheFrictionCFM[4]
Definition: btPersistentManifold.h:342
btPersistentManifold::clearUserCache
void clearUserCache(btManifoldPoint &pt)
Definition: btPersistentManifold.cpp:59
btPersistentManifoldDoubleData::m_pointCacheFrictionCFM
double m_pointCacheFrictionCFM[4]
Definition: btPersistentManifold.h:296
gContactCalcArea3Points
bool gContactCalcArea3Points
gContactCalcArea3Points will approximate the convex hull area using 3 points when setting it to false...
Definition: btPersistentManifold.cpp:33
btManifoldPoint::m_contactMotion2
btScalar m_contactMotion2
Definition: btManifoldPoint.h:120
btMax
const T & btMax(const T &a, const T &b)
Definition: btMinMax.h:27
btManifoldPoint::m_combinedFriction
btScalar m_combinedFriction
Definition: btManifoldPoint.h:101
btPersistentManifoldDoubleData::m_pointCacheLateralFrictionDir2
btVector3DoubleData m_pointCacheLateralFrictionDir2[4]
Definition: btPersistentManifold.h:276
btPersistentManifold::serialize
const char * serialize(const class btPersistentManifold *manifold, void *dataBuffer, class btSerializer *serializer) const
Definition: btPersistentManifold.cpp:309
btPersistentManifoldDoubleData::m_pointCacheAppliedImpulseLateral1
double m_pointCacheAppliedImpulseLateral1[4]
Definition: btPersistentManifold.h:288
btPersistentManifold::m_contactProcessingThreshold
btScalar m_contactProcessingThreshold
Definition: btPersistentManifold.h:75
dot
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
Definition: btQuaternion.h:888
btPersistentManifold::m_contactBreakingThreshold
btScalar m_contactBreakingThreshold
Definition: btPersistentManifold.h:74
btPersistentManifold::deSerialize
void deSerialize(const struct btPersistentManifoldDoubleData *manifoldDataPtr)
Definition: btPersistentManifold.cpp:359
btPersistentManifoldDoubleData::m_pointCachePartId0
int m_pointCachePartId0[4]
Definition: btPersistentManifold.h:283
btManifoldPoint::m_lateralFrictionDir2
btVector3 m_lateralFrictionDir2
Definition: btManifoldPoint.h:137
btPersistentManifoldDoubleData::m_pointCacheLocalPointA
btVector3DoubleData m_pointCacheLocalPointA[4]
Definition: btPersistentManifold.h:270
btPersistentManifoldFloatData::m_numCachedPoints
int m_numCachedPoints
Definition: btPersistentManifold.h:345
btPersistentManifoldFloatData::m_pointCacheCombinedSpinningFriction
float m_pointCacheCombinedSpinningFriction[4]
Definition: btPersistentManifold.h:327
btPersistentManifoldDoubleData
Definition: btPersistentManifold.h:268
btPersistentManifold::m_body0
const btCollisionObject * m_body0
this two body pointers can point to the physics rigidbody class.
Definition: btPersistentManifold.h:69
btPersistentManifoldDoubleData::m_pointCacheContactERP
double m_pointCacheContactERP[4]
Definition: btPersistentManifold.h:294
btPersistentManifold::addManifoldPoint
int addManifoldPoint(const btManifoldPoint &newPoint, bool isPredictive=false)
Definition: btPersistentManifold.cpp:212
btManifoldPoint::getDistance
btScalar getDistance() const
Definition: btManifoldPoint.h:139
btVector3::getX
const btScalar & getX() const
Return the x value.
Definition: btVector3.h:561
btManifoldPoint::m_partId0
int m_partId0
Definition: btManifoldPoint.h:107
btPersistentManifoldFloatData::m_pointCacheLateralFrictionDir1
btVector3FloatData m_pointCacheLateralFrictionDir1[4]
Definition: btPersistentManifold.h:321
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btManifoldPoint::m_combinedSpinningFriction
btScalar m_combinedSpinningFriction
Definition: btManifoldPoint.h:103
btPersistentManifoldFloatData::m_pointCachePositionWorldOnA
btVector3FloatData m_pointCachePositionWorldOnA[4]
Definition: btPersistentManifold.h:318
btManifoldPoint::m_index0
int m_index0
Definition: btManifoldPoint.h:109
gContactProcessedCallback
ContactProcessedCallback gContactProcessedCallback
Definition: btPersistentManifold.cpp:28
btPersistentManifold::m_pointCache
btManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE]
Definition: btPersistentManifold.h:66
btPersistentManifoldFloatData::m_pointCacheCombinedRollingFriction
float m_pointCacheCombinedRollingFriction[4]
Definition: btPersistentManifold.h:326
btPersistentManifoldFloatData::m_pointCachePartId1
int m_pointCachePartId1[4]
Definition: btPersistentManifold.h:330
btPersistentManifold::getCacheEntry
int getCacheEntry(const btManifoldPoint &newPoint) const
Definition: btPersistentManifold.cpp:192
btTypedObject::m_objectType
int m_objectType
Definition: btScalar.h:785
btPersistentManifoldDoubleData::m_numCachedPoints
int m_numCachedPoints
Definition: btPersistentManifold.h:299
btSerializer.h
btPersistentManifoldFloatData::m_pointCacheCombinedRestitution
float m_pointCacheCombinedRestitution[4]
Definition: btPersistentManifold.h:328