20#ifdef BT_USE_DOUBLE_PRECISION
21#define btCollisionObjectData btCollisionObjectDoubleData
23#define btCollisionObjectData btCollisionObjectFloatData
46#ifdef DEBUG_PERSISTENCY
48void btPersistentManifold::DebugPersistency()
54 printf(
"m_pointCache[%d].m_userPersistentData = %x\n", i,
m_pointCache[i].m_userPersistentData);
61 void* oldPtr =
pt.m_userPersistentData;
64#ifdef DEBUG_PERSISTENCY
73 printf(
"error in clearUserCache\n");
81 (*gContactDestroyedCallback)(
pt.m_userPersistentData);
82 pt.m_userPersistentData = 0;
85#ifdef DEBUG_PERSISTENCY
117#define KEEP_DEEPEST_POINT 1
118#ifdef KEEP_DEEPEST_POINT
120 for (
int i = 0; i < 4; i++)
197 for (
int i = 0; i <
size; i++)
222#if MANIFOLD_CACHE_SIZE >= 4
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());
260 for (i = getNumContacts() - 1; i >= 0; i--)
299#ifdef DEBUG_PERSISTENCY
316 dataOut->m_contactBreakingThreshold =
manifold->getContactBreakingThreshold();
317 dataOut->m_contactProcessingThreshold =
manifold->getContactProcessingThreshold();
328 dataOut->m_pointCachePrevRHS[i] =
pt.m_prevRHS;
329 dataOut->m_pointCacheAppliedImpulseLateral1[i] =
pt.m_appliedImpulseLateral1;
330 dataOut->m_pointCacheAppliedImpulseLateral2[i] =
pt.m_appliedImpulseLateral2;
331 pt.m_localPointA.serialize(
dataOut->m_pointCacheLocalPointA[i]);
332 pt.m_localPointB.serialize(
dataOut->m_pointCacheLocalPointB[i]);
333 pt.m_normalWorldOnB.serialize(
dataOut->m_pointCacheNormalWorldOnB[i]);
334 dataOut->m_pointCacheDistance[i] =
pt.m_distance1;
335 dataOut->m_pointCacheCombinedContactDamping1[i] =
pt.m_combinedContactDamping1;
336 dataOut->m_pointCacheCombinedContactStiffness1[i] =
pt.m_combinedContactStiffness1;
337 dataOut->m_pointCacheLifeTime[i] =
pt.m_lifeTime;
338 dataOut->m_pointCacheFrictionCFM[i] =
pt.m_frictionCFM;
339 dataOut->m_pointCacheContactERP[i] =
pt.m_contactERP;
340 dataOut->m_pointCacheContactCFM[i] =
pt.m_contactCFM;
341 dataOut->m_pointCacheContactPointFlags[i] =
pt.m_contactPointFlags;
342 dataOut->m_pointCacheIndex0[i] =
pt.m_index0;
343 dataOut->m_pointCacheIndex1[i] =
pt.m_index1;
344 dataOut->m_pointCachePartId0[i] =
pt.m_partId0;
345 dataOut->m_pointCachePartId1[i] =
pt.m_partId1;
346 pt.m_positionWorldOnA.serialize(
dataOut->m_pointCachePositionWorldOnA[i]);
347 pt.m_positionWorldOnB.serialize(
dataOut->m_pointCachePositionWorldOnB[i]);
348 dataOut->m_pointCacheCombinedFriction[i] =
pt.m_combinedFriction;
349 pt.m_lateralFrictionDir1.serialize(
dataOut->m_pointCacheLateralFrictionDir1[i]);
350 pt.m_lateralFrictionDir2.serialize(
dataOut->m_pointCacheLateralFrictionDir2[i]);
351 dataOut->m_pointCacheCombinedRollingFriction[i] =
pt.m_combinedRollingFriction;
352 dataOut->m_pointCacheCombinedSpinningFriction[i] =
pt.m_combinedSpinningFriction;
353 dataOut->m_pointCacheCombinedRestitution[i] =
pt.m_combinedRestitution;
354 dataOut->m_pointCacheContactMotion1[i] =
pt.m_contactMotion1;
355 dataOut->m_pointCacheContactMotion2[i] =
pt.m_contactMotion2;
376 pt.m_appliedImpulseLateral1 =
manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
377 pt.m_appliedImpulseLateral2 =
manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
380 pt.m_normalWorldOnB.deSerializeDouble(
manifoldDataPtr->m_pointCacheNormalWorldOnB[i]);
382 pt.m_combinedContactDamping1 =
manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
383 pt.m_combinedContactStiffness1 =
manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
393 pt.m_positionWorldOnA.deSerializeDouble(
manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
394 pt.m_positionWorldOnB.deSerializeDouble(
manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
396 pt.m_lateralFrictionDir1.deSerializeDouble(
manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
397 pt.m_lateralFrictionDir2.deSerializeDouble(
manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
398 pt.m_combinedRollingFriction =
manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
399 pt.m_combinedSpinningFriction =
manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
422 pt.m_appliedImpulseLateral1 =
manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
423 pt.m_appliedImpulseLateral2 =
manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
428 pt.m_combinedContactDamping1 =
manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
429 pt.m_combinedContactStiffness1 =
manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
439 pt.m_positionWorldOnA.deSerialize(
manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
440 pt.m_positionWorldOnB.deSerialize(
manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
442 pt.m_lateralFrictionDir1.deSerialize(
manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
443 pt.m_lateralFrictionDir2.deSerialize(
manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
444 pt.m_combinedRollingFriction =
manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
445 pt.m_combinedSpinningFriction =
manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
#define btCollisionObjectData
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const T & btMax(const T &a, const T &b)
bool gContactCalcArea3Points
gContactCalcArea3Points will approximate the convex hull area using 3 points when setting it to false...
ContactEndedCallback gContactEndedCallback
static btScalar calcArea4Points(const btVector3 &p0, const btVector3 &p1, const btVector3 &p2, const btVector3 &p3)
ContactStartedCallback gContactStartedCallback
ContactProcessedCallback gContactProcessedCallback
ContactDestroyedCallback gContactDestroyedCallback
btScalar gContactBreakingThreshold
maximum contact breaking and merging threshold
void(* ContactEndedCallback)(btPersistentManifold *const &manifold)
void(* ContactStartedCallback)(btPersistentManifold *const &manifold)
ContactProcessedCallback gContactProcessedCallback
bool(* ContactDestroyedCallback)(void *userPersistentData)
#define btPersistentManifoldDataName
#define btPersistentManifoldData
@ BT_PERSISTENT_MANIFOLD_TYPE
ContactDestroyedCallback gContactDestroyedCallback
#define MANIFOLD_CACHE_SIZE
bool(* ContactProcessedCallback)(btManifoldPoint &cp, void *body0, void *body1)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
ManifoldContactPoint collects and maintains persistent contactpoints.
btScalar getDistance() const
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
btScalar m_appliedImpulse
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
const btCollisionObject * m_body1
btScalar m_contactBreakingThreshold
bool validContactDistance(const btManifoldPoint &pt) const
const char * serialize(const class btPersistentManifold *manifold, void *dataBuffer, class btSerializer *serializer) const
int getCacheEntry(const btManifoldPoint &newPoint) const
void refreshContactPoints(const btTransform &trA, const btTransform &trB)
calculated new worldspace coordinates and depth, and reject points that exceed the collision margin
int calculateSerializeBufferSize() const
int sortCachedPoints(const btManifoldPoint &pt)
sort cached points so most isolated points come first
btScalar m_contactProcessingThreshold
void clearUserCache(btManifoldPoint &pt)
void removeContactPoint(int index)
void deSerialize(const struct btPersistentManifoldDoubleData *manifoldDataPtr)
int getNumContacts() const
int addManifoldPoint(const btManifoldPoint &newPoint, bool isPredictive=false)
btScalar getContactBreakingThreshold() const
const btCollisionObject * m_body0
this two body pointers can point to the physics rigidbody class.
btManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE]
btVector3 can be used to represent 3D points and vectors.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
btScalar length2() const
Return the length of the vector squared.
rudimentary class to provide type info