20#ifdef BT_USE_DOUBLE_PRECISION
21#define btCollisionObjectData btCollisionObjectDoubleData
23#define btCollisionObjectData btCollisionObjectFloatData
35btPersistentManifold::btPersistentManifold()
46#ifdef DEBUG_PERSISTENCY
48void btPersistentManifold::DebugPersistency()
54 printf(
"m_pointCache[%d].m_userPersistentData = %x\n", i, m_pointCache[i].m_userPersistentData);
64#ifdef DEBUG_PERSISTENCY
69 if (m_pointCache[i].m_userPersistentData == oldPtr)
73 printf(
"error in clearUserCache\n");
85#ifdef DEBUG_PERSISTENCY
104 btVector3 tmp0 = a[0].cross(
b[0]);
105 btVector3 tmp1 = a[1].cross(
b[1]);
106 btVector3 tmp2 = a[2].cross(
b[2]);
108 return btMax(
btMax(tmp0.length2(), tmp1.length2()), tmp2.length2());
116 int maxPenetrationIndex = -1;
117#define KEEP_DEEPEST_POINT 1
118#ifdef KEEP_DEEPEST_POINT
120 for (
int i = 0; i < 4; i++)
122 if (m_pointCache[i].getDistance() < maxPenetration)
124 maxPenetrationIndex = i;
125 maxPenetration = m_pointCache[i].getDistance();
134 if (maxPenetrationIndex != 0)
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();
141 if (maxPenetrationIndex != 1)
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();
149 if (maxPenetrationIndex != 2)
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();
157 if (maxPenetrationIndex != 3)
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();
167 if (maxPenetrationIndex != 0)
172 if (maxPenetrationIndex != 1)
177 if (maxPenetrationIndex != 2)
182 if (maxPenetrationIndex != 3)
187 btVector4 maxvec(res0, res1, res2, res3);
196 int nearestPoint = -1;
197 for (
int i = 0; i <
size; i++)
202 const btScalar distToManiPoint = diffA.dot(diffA);
203 if (distToManiPoint < shortestDist)
205 shortestDist = distToManiPoint;
212int btPersistentManifold::addManifoldPoint(
const btManifoldPoint& newPoint,
bool isPredictive)
222#if MANIFOLD_CACHE_SIZE >= 4
237 btAssert(m_pointCache[insertIndex].m_userPersistentData == 0);
238 m_pointCache[insertIndex] = newPoint;
242btScalar btPersistentManifold::getContactBreakingThreshold()
const
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--)
271 btVector3 projectedDifference, projectedPoint;
286 distance2d = projectedDifference.dot(projectedDifference);
295 (*gContactProcessedCallback)(manifoldPoint, (
void*)
m_body0, (
void*)
m_body1);
299#ifdef DEBUG_PERSISTENCY
304int btPersistentManifold::calculateSerializeBufferSize()
const
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;
328 dataOut->m_pointCachePrevRHS[i] = pt.
m_prevRHS;
331 pt.
m_localPointA.serialize(dataOut->m_pointCacheLocalPointA[i]);
332 pt.
m_localPointB.serialize(dataOut->m_pointCacheLocalPointB[i]);
337 dataOut->m_pointCacheLifeTime[i] = pt.
m_lifeTime;
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;
btScalar m_contactProcessingThreshold
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const T & btMax(const T &a, const T &b)
bool gContactCalcArea3Points
#define btCollisionObjectData
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
bool validContactDistance(const btManifoldPoint &pt) const
const btCollisionObject * m_body0
this two body pointers can point to the physics rigidbody class.
void(* ContactEndedCallback)(btPersistentManifold *const &manifold)
const btCollisionObject * m_body1
btScalar m_contactBreakingThreshold
int sortCachedPoints(const btManifoldPoint &pt)
sort cached points so most isolated points come first
void removeContactPoint(int index)
void(* ContactStartedCallback)(btPersistentManifold *const &manifold)
bool(* ContactDestroyedCallback)(void *userPersistentData)
void clearUserCache(btManifoldPoint &pt)
btScalar getContactBreakingThreshold() const
#define btPersistentManifoldDataName
#define btPersistentManifoldData
@ BT_PERSISTENT_MANIFOLD_TYPE
#define MANIFOLD_CACHE_SIZE
bool(* ContactProcessedCallback)(btManifoldPoint &cp, void *body0, void *body1)
SIMD_FORCE_INLINE int getNumContacts() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar m_combinedSpinningFriction
btScalar m_combinedRollingFriction
btScalar getDistance() const
btScalar m_combinedContactStiffness1
btScalar m_combinedRestitution
btVector3 m_lateralFrictionDir2
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity
btScalar m_combinedContactDamping1
btScalar m_appliedImpulseLateral2
btScalar m_appliedImpulse
void * m_userPersistentData
btScalar m_appliedImpulseLateral1
btVector3 m_normalWorldOnB
btScalar m_combinedFriction
btVector3 m_positionWorldOnB
btScalar m_contactMotion2
btVector3 m_lateralFrictionDir1
btScalar m_contactMotion1
virtual void * getUniquePointer(void *oldPtr)=0
SIMD_FORCE_INLINE int closestAxis4() const
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
ccl_device_inline float cross(const float2 a, const float2 b)
double m_pointCachePrevRHS[4]
int m_pointCachePartId0[4]
btVector3DoubleData m_pointCacheLateralFrictionDir1[4]
btVector3DoubleData m_pointCachePositionWorldOnB[4]
double m_contactProcessingThreshold
double m_pointCacheCombinedRollingFriction[4]
double m_contactBreakingThreshold
int m_pointCacheContactPointFlags[4]
double m_pointCacheDistance[4]
int m_pointCacheLifeTime[4]
btVector3DoubleData m_pointCacheLocalPointB[4]
double m_pointCacheAppliedImpulseLateral2[4]
double m_pointCacheCombinedContactDamping1[4]
btVector3DoubleData m_pointCachePositionWorldOnA[4]
double m_pointCacheAppliedImpulseLateral1[4]
double m_pointCacheContactMotion2[4]
double m_pointCacheCombinedContactStiffness1[4]
int m_pointCacheIndex0[4]
double m_pointCacheContactERP[4]
double m_pointCacheContactMotion1[4]
btVector3DoubleData m_pointCacheNormalWorldOnB[4]
double m_pointCacheContactCFM[4]
btVector3DoubleData m_pointCacheLateralFrictionDir2[4]
double m_pointCacheAppliedImpulse[4]
int m_pointCachePartId1[4]
double m_pointCacheCombinedRestitution[4]
double m_pointCacheFrictionCFM[4]
double m_pointCacheCombinedSpinningFriction[4]
int m_pointCacheIndex1[4]
double m_pointCacheCombinedFriction[4]
btVector3DoubleData m_pointCacheLocalPointA[4]
int m_pointCachePartId0[4]
float m_pointCacheDistance[4]
float m_pointCacheAppliedImpulse[4]
float m_pointCacheAppliedImpulseLateral1[4]
btVector3FloatData m_pointCacheNormalWorldOnB[4]
float m_pointCacheContactERP[4]
int m_pointCacheIndex0[4]
int m_pointCacheLifeTime[4]
float m_pointCacheCombinedContactDamping1[4]
float m_pointCacheContactMotion2[4]
float m_pointCacheCombinedFriction[4]
btVector3FloatData m_pointCacheLocalPointB[4]
float m_contactBreakingThreshold
float m_pointCacheCombinedContactStiffness1[4]
float m_pointCacheFrictionCFM[4]
int m_pointCacheIndex1[4]
float m_pointCacheContactMotion1[4]
int m_pointCacheContactPointFlags[4]
float m_pointCacheCombinedRollingFriction[4]
float m_pointCacheAppliedImpulseLateral2[4]
btVector3FloatData m_pointCachePositionWorldOnB[4]
float m_pointCachePrevRHS[4]
float m_pointCacheCombinedRestitution[4]
float m_pointCacheContactCFM[4]
btVector3FloatData m_pointCacheLocalPointA[4]
float m_pointCacheCombinedSpinningFriction[4]
btVector3FloatData m_pointCachePositionWorldOnA[4]
btVector3FloatData m_pointCacheLateralFrictionDir1[4]
float m_contactProcessingThreshold
int m_pointCachePartId1[4]
btVector3FloatData m_pointCacheLateralFrictionDir2[4]
rudimentary class to provide type info