btPersistentManifold.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #include "btPersistentManifold.h"
  14. #include "LinearMath/btTransform.h"
  15. #include "LinearMath/btSerializer.h"
  16. #ifdef BT_USE_DOUBLE_PRECISION
  17. #define btCollisionObjectData btCollisionObjectDoubleData
  18. #else
  19. #define btCollisionObjectData btCollisionObjectFloatData
  20. #endif
  21. btScalar gContactBreakingThreshold = btScalar(0.02);
  22. ContactDestroyedCallback gContactDestroyedCallback = 0;
  23. ContactProcessedCallback gContactProcessedCallback = 0;
  24. ContactStartedCallback gContactStartedCallback = 0;
  25. ContactEndedCallback gContactEndedCallback = 0;
  26. ///gContactCalcArea3Points will approximate the convex hull area using 3 points
  27. ///when setting it to false, it will use 4 points to compute the area: it is more accurate but slower
  28. bool gContactCalcArea3Points = true;
  29. btPersistentManifold::btPersistentManifold()
  30. : btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE),
  31. m_body0(0),
  32. m_body1(0),
  33. m_cachedPoints(0),
  34. m_companionIdA(0),
  35. m_companionIdB(0),
  36. m_index1a(0)
  37. {
  38. }
  39. #ifdef DEBUG_PERSISTENCY
  40. #include <stdio.h>
  41. void btPersistentManifold::DebugPersistency()
  42. {
  43. int i;
  44. printf("DebugPersistency : numPoints %d\n", m_cachedPoints);
  45. for (i = 0; i < m_cachedPoints; i++)
  46. {
  47. printf("m_pointCache[%d].m_userPersistentData = %x\n", i, m_pointCache[i].m_userPersistentData);
  48. }
  49. }
  50. #endif //DEBUG_PERSISTENCY
  51. void btPersistentManifold::clearUserCache(btManifoldPoint& pt)
  52. {
  53. void* oldPtr = pt.m_userPersistentData;
  54. if (oldPtr)
  55. {
  56. #ifdef DEBUG_PERSISTENCY
  57. int i;
  58. int occurance = 0;
  59. for (i = 0; i < m_cachedPoints; i++)
  60. {
  61. if (m_pointCache[i].m_userPersistentData == oldPtr)
  62. {
  63. occurance++;
  64. if (occurance > 1)
  65. printf("error in clearUserCache\n");
  66. }
  67. }
  68. btAssert(occurance <= 0);
  69. #endif //DEBUG_PERSISTENCY
  70. if (pt.m_userPersistentData && gContactDestroyedCallback)
  71. {
  72. (*gContactDestroyedCallback)(pt.m_userPersistentData);
  73. pt.m_userPersistentData = 0;
  74. }
  75. #ifdef DEBUG_PERSISTENCY
  76. DebugPersistency();
  77. #endif
  78. }
  79. }
  80. static inline btScalar calcArea4Points(const btVector3& p0, const btVector3& p1, const btVector3& p2, const btVector3& p3)
  81. {
  82. // It calculates possible 3 area constructed from random 4 points and returns the biggest one.
  83. btVector3 a[3], b[3];
  84. a[0] = p0 - p1;
  85. a[1] = p0 - p2;
  86. a[2] = p0 - p3;
  87. b[0] = p2 - p3;
  88. b[1] = p1 - p3;
  89. b[2] = p1 - p2;
  90. //todo: Following 3 cross production can be easily optimized by SIMD.
  91. btVector3 tmp0 = a[0].cross(b[0]);
  92. btVector3 tmp1 = a[1].cross(b[1]);
  93. btVector3 tmp2 = a[2].cross(b[2]);
  94. return btMax(btMax(tmp0.length2(), tmp1.length2()), tmp2.length2());
  95. }
  96. int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt)
  97. {
  98. //calculate 4 possible cases areas, and take biggest area
  99. //also need to keep 'deepest'
  100. int maxPenetrationIndex = -1;
  101. #define KEEP_DEEPEST_POINT 1
  102. #ifdef KEEP_DEEPEST_POINT
  103. btScalar maxPenetration = pt.getDistance();
  104. for (int i = 0; i < 4; i++)
  105. {
  106. if (m_pointCache[i].getDistance() < maxPenetration)
  107. {
  108. maxPenetrationIndex = i;
  109. maxPenetration = m_pointCache[i].getDistance();
  110. }
  111. }
  112. #endif //KEEP_DEEPEST_POINT
  113. btScalar res0(btScalar(0.)), res1(btScalar(0.)), res2(btScalar(0.)), res3(btScalar(0.));
  114. if (gContactCalcArea3Points)
  115. {
  116. if (maxPenetrationIndex != 0)
  117. {
  118. btVector3 a0 = pt.m_localPointA - m_pointCache[1].m_localPointA;
  119. btVector3 b0 = m_pointCache[3].m_localPointA - m_pointCache[2].m_localPointA;
  120. btVector3 cross = a0.cross(b0);
  121. res0 = cross.length2();
  122. }
  123. if (maxPenetrationIndex != 1)
  124. {
  125. btVector3 a1 = pt.m_localPointA - m_pointCache[0].m_localPointA;
  126. btVector3 b1 = m_pointCache[3].m_localPointA - m_pointCache[2].m_localPointA;
  127. btVector3 cross = a1.cross(b1);
  128. res1 = cross.length2();
  129. }
  130. if (maxPenetrationIndex != 2)
  131. {
  132. btVector3 a2 = pt.m_localPointA - m_pointCache[0].m_localPointA;
  133. btVector3 b2 = m_pointCache[3].m_localPointA - m_pointCache[1].m_localPointA;
  134. btVector3 cross = a2.cross(b2);
  135. res2 = cross.length2();
  136. }
  137. if (maxPenetrationIndex != 3)
  138. {
  139. btVector3 a3 = pt.m_localPointA - m_pointCache[0].m_localPointA;
  140. btVector3 b3 = m_pointCache[2].m_localPointA - m_pointCache[1].m_localPointA;
  141. btVector3 cross = a3.cross(b3);
  142. res3 = cross.length2();
  143. }
  144. }
  145. else
  146. {
  147. if (maxPenetrationIndex != 0)
  148. {
  149. res0 = calcArea4Points(pt.m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[2].m_localPointA, m_pointCache[3].m_localPointA);
  150. }
  151. if (maxPenetrationIndex != 1)
  152. {
  153. res1 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[2].m_localPointA, m_pointCache[3].m_localPointA);
  154. }
  155. if (maxPenetrationIndex != 2)
  156. {
  157. res2 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[3].m_localPointA);
  158. }
  159. if (maxPenetrationIndex != 3)
  160. {
  161. res3 = calcArea4Points(pt.m_localPointA, m_pointCache[0].m_localPointA, m_pointCache[1].m_localPointA, m_pointCache[2].m_localPointA);
  162. }
  163. }
  164. btVector4 maxvec(res0, res1, res2, res3);
  165. int biggestarea = maxvec.closestAxis4();
  166. return biggestarea;
  167. }
  168. int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const
  169. {
  170. btScalar shortestDist = getContactBreakingThreshold() * getContactBreakingThreshold();
  171. int size = getNumContacts();
  172. int nearestPoint = -1;
  173. for (int i = 0; i < size; i++)
  174. {
  175. const btManifoldPoint& mp = m_pointCache[i];
  176. btVector3 diffA = mp.m_localPointA - newPoint.m_localPointA;
  177. const btScalar distToManiPoint = diffA.dot(diffA);
  178. if (distToManiPoint < shortestDist)
  179. {
  180. shortestDist = distToManiPoint;
  181. nearestPoint = i;
  182. }
  183. }
  184. return nearestPoint;
  185. }
  186. int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint, bool isPredictive)
  187. {
  188. if (!isPredictive)
  189. {
  190. btAssert(validContactDistance(newPoint));
  191. }
  192. int insertIndex = getNumContacts();
  193. if (insertIndex == MANIFOLD_CACHE_SIZE)
  194. {
  195. #if MANIFOLD_CACHE_SIZE >= 4
  196. //sort cache so best points come first, based on area
  197. insertIndex = sortCachedPoints(newPoint);
  198. #else
  199. insertIndex = 0;
  200. #endif
  201. clearUserCache(m_pointCache[insertIndex]);
  202. }
  203. else
  204. {
  205. m_cachedPoints++;
  206. }
  207. if (insertIndex < 0)
  208. insertIndex = 0;
  209. btAssert(m_pointCache[insertIndex].m_userPersistentData == 0);
  210. m_pointCache[insertIndex] = newPoint;
  211. return insertIndex;
  212. }
  213. btScalar btPersistentManifold::getContactBreakingThreshold() const
  214. {
  215. return m_contactBreakingThreshold;
  216. }
  217. void btPersistentManifold::refreshContactPoints(const btTransform& trA, const btTransform& trB)
  218. {
  219. int i;
  220. #ifdef DEBUG_PERSISTENCY
  221. printf("refreshContactPoints posA = (%f,%f,%f) posB = (%f,%f,%f)\n",
  222. trA.getOrigin().getX(),
  223. trA.getOrigin().getY(),
  224. trA.getOrigin().getZ(),
  225. trB.getOrigin().getX(),
  226. trB.getOrigin().getY(),
  227. trB.getOrigin().getZ());
  228. #endif //DEBUG_PERSISTENCY
  229. /// first refresh worldspace positions and distance
  230. for (i = getNumContacts() - 1; i >= 0; i--)
  231. {
  232. btManifoldPoint& manifoldPoint = m_pointCache[i];
  233. manifoldPoint.m_positionWorldOnA = trA(manifoldPoint.m_localPointA);
  234. manifoldPoint.m_positionWorldOnB = trB(manifoldPoint.m_localPointB);
  235. manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA - manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB);
  236. manifoldPoint.m_lifeTime++;
  237. }
  238. /// then
  239. btScalar distance2d;
  240. btVector3 projectedDifference, projectedPoint;
  241. for (i = getNumContacts() - 1; i >= 0; i--)
  242. {
  243. btManifoldPoint& manifoldPoint = m_pointCache[i];
  244. //contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction)
  245. if (!validContactDistance(manifoldPoint))
  246. {
  247. removeContactPoint(i);
  248. }
  249. else
  250. {
  251. //todo: friction anchor may require the contact to be around a bit longer
  252. //contact also becomes invalid when relative movement orthogonal to normal exceeds margin
  253. projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1;
  254. projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint;
  255. distance2d = projectedDifference.dot(projectedDifference);
  256. if (distance2d > getContactBreakingThreshold() * getContactBreakingThreshold())
  257. {
  258. removeContactPoint(i);
  259. }
  260. else
  261. {
  262. //contact point processed callback
  263. if (gContactProcessedCallback)
  264. (*gContactProcessedCallback)(manifoldPoint, (void*)m_body0, (void*)m_body1);
  265. }
  266. }
  267. }
  268. #ifdef DEBUG_PERSISTENCY
  269. DebugPersistency();
  270. #endif //
  271. }
  272. int btPersistentManifold::calculateSerializeBufferSize() const
  273. {
  274. return sizeof(btPersistentManifoldData);
  275. }
  276. const char* btPersistentManifold::serialize(const class btPersistentManifold* manifold, void* dataBuffer, class btSerializer* serializer) const
  277. {
  278. btPersistentManifoldData* dataOut = (btPersistentManifoldData*)dataBuffer;
  279. memset(dataOut, 0, sizeof(btPersistentManifoldData));
  280. dataOut->m_body0 = (btCollisionObjectData*)serializer->getUniquePointer((void*)manifold->getBody0());
  281. dataOut->m_body1 = (btCollisionObjectData*)serializer->getUniquePointer((void*)manifold->getBody1());
  282. dataOut->m_contactBreakingThreshold = manifold->getContactBreakingThreshold();
  283. dataOut->m_contactProcessingThreshold = manifold->getContactProcessingThreshold();
  284. dataOut->m_numCachedPoints = manifold->getNumContacts();
  285. dataOut->m_companionIdA = manifold->m_companionIdA;
  286. dataOut->m_companionIdB = manifold->m_companionIdB;
  287. dataOut->m_index1a = manifold->m_index1a;
  288. dataOut->m_objectType = manifold->m_objectType;
  289. for (int i = 0; i < this->getNumContacts(); i++)
  290. {
  291. const btManifoldPoint& pt = manifold->getContactPoint(i);
  292. dataOut->m_pointCacheAppliedImpulse[i] = pt.m_appliedImpulse;
  293. dataOut->m_pointCachePrevRHS[i] = pt.m_prevRHS;
  294. dataOut->m_pointCacheAppliedImpulseLateral1[i] = pt.m_appliedImpulseLateral1;
  295. dataOut->m_pointCacheAppliedImpulseLateral2[i] = pt.m_appliedImpulseLateral2;
  296. pt.m_localPointA.serialize(dataOut->m_pointCacheLocalPointA[i]);
  297. pt.m_localPointB.serialize(dataOut->m_pointCacheLocalPointB[i]);
  298. pt.m_normalWorldOnB.serialize(dataOut->m_pointCacheNormalWorldOnB[i]);
  299. dataOut->m_pointCacheDistance[i] = pt.m_distance1;
  300. dataOut->m_pointCacheCombinedContactDamping1[i] = pt.m_combinedContactDamping1;
  301. dataOut->m_pointCacheCombinedContactStiffness1[i] = pt.m_combinedContactStiffness1;
  302. dataOut->m_pointCacheLifeTime[i] = pt.m_lifeTime;
  303. dataOut->m_pointCacheFrictionCFM[i] = pt.m_frictionCFM;
  304. dataOut->m_pointCacheContactERP[i] = pt.m_contactERP;
  305. dataOut->m_pointCacheContactCFM[i] = pt.m_contactCFM;
  306. dataOut->m_pointCacheContactPointFlags[i] = pt.m_contactPointFlags;
  307. dataOut->m_pointCacheIndex0[i] = pt.m_index0;
  308. dataOut->m_pointCacheIndex1[i] = pt.m_index1;
  309. dataOut->m_pointCachePartId0[i] = pt.m_partId0;
  310. dataOut->m_pointCachePartId1[i] = pt.m_partId1;
  311. pt.m_positionWorldOnA.serialize(dataOut->m_pointCachePositionWorldOnA[i]);
  312. pt.m_positionWorldOnB.serialize(dataOut->m_pointCachePositionWorldOnB[i]);
  313. dataOut->m_pointCacheCombinedFriction[i] = pt.m_combinedFriction;
  314. pt.m_lateralFrictionDir1.serialize(dataOut->m_pointCacheLateralFrictionDir1[i]);
  315. pt.m_lateralFrictionDir2.serialize(dataOut->m_pointCacheLateralFrictionDir2[i]);
  316. dataOut->m_pointCacheCombinedRollingFriction[i] = pt.m_combinedRollingFriction;
  317. dataOut->m_pointCacheCombinedSpinningFriction[i] = pt.m_combinedSpinningFriction;
  318. dataOut->m_pointCacheCombinedRestitution[i] = pt.m_combinedRestitution;
  319. dataOut->m_pointCacheContactMotion1[i] = pt.m_contactMotion1;
  320. dataOut->m_pointCacheContactMotion2[i] = pt.m_contactMotion2;
  321. }
  322. return btPersistentManifoldDataName;
  323. }
  324. void btPersistentManifold::deSerialize(const struct btPersistentManifoldDoubleData* manifoldDataPtr)
  325. {
  326. m_contactBreakingThreshold = manifoldDataPtr->m_contactBreakingThreshold;
  327. m_contactProcessingThreshold = manifoldDataPtr->m_contactProcessingThreshold;
  328. m_cachedPoints = manifoldDataPtr->m_numCachedPoints;
  329. m_companionIdA = manifoldDataPtr->m_companionIdA;
  330. m_companionIdB = manifoldDataPtr->m_companionIdB;
  331. //m_index1a = manifoldDataPtr->m_index1a;
  332. m_objectType = manifoldDataPtr->m_objectType;
  333. for (int i = 0; i < this->getNumContacts(); i++)
  334. {
  335. btManifoldPoint& pt = m_pointCache[i];
  336. pt.m_appliedImpulse = manifoldDataPtr->m_pointCacheAppliedImpulse[i];
  337. pt.m_prevRHS = manifoldDataPtr->m_pointCachePrevRHS[i];
  338. pt.m_appliedImpulseLateral1 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
  339. pt.m_appliedImpulseLateral2 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
  340. pt.m_localPointA.deSerializeDouble(manifoldDataPtr->m_pointCacheLocalPointA[i]);
  341. pt.m_localPointB.deSerializeDouble(manifoldDataPtr->m_pointCacheLocalPointB[i]);
  342. pt.m_normalWorldOnB.deSerializeDouble(manifoldDataPtr->m_pointCacheNormalWorldOnB[i]);
  343. pt.m_distance1 = manifoldDataPtr->m_pointCacheDistance[i];
  344. pt.m_combinedContactDamping1 = manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
  345. pt.m_combinedContactStiffness1 = manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
  346. pt.m_lifeTime = manifoldDataPtr->m_pointCacheLifeTime[i];
  347. pt.m_frictionCFM = manifoldDataPtr->m_pointCacheFrictionCFM[i];
  348. pt.m_contactERP = manifoldDataPtr->m_pointCacheContactERP[i];
  349. pt.m_contactCFM = manifoldDataPtr->m_pointCacheContactCFM[i];
  350. pt.m_contactPointFlags = manifoldDataPtr->m_pointCacheContactPointFlags[i];
  351. pt.m_index0 = manifoldDataPtr->m_pointCacheIndex0[i];
  352. pt.m_index1 = manifoldDataPtr->m_pointCacheIndex1[i];
  353. pt.m_partId0 = manifoldDataPtr->m_pointCachePartId0[i];
  354. pt.m_partId1 = manifoldDataPtr->m_pointCachePartId1[i];
  355. pt.m_positionWorldOnA.deSerializeDouble(manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
  356. pt.m_positionWorldOnB.deSerializeDouble(manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
  357. pt.m_combinedFriction = manifoldDataPtr->m_pointCacheCombinedFriction[i];
  358. pt.m_lateralFrictionDir1.deSerializeDouble(manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
  359. pt.m_lateralFrictionDir2.deSerializeDouble(manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
  360. pt.m_combinedRollingFriction = manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
  361. pt.m_combinedSpinningFriction = manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
  362. pt.m_combinedRestitution = manifoldDataPtr->m_pointCacheCombinedRestitution[i];
  363. pt.m_contactMotion1 = manifoldDataPtr->m_pointCacheContactMotion1[i];
  364. pt.m_contactMotion2 = manifoldDataPtr->m_pointCacheContactMotion2[i];
  365. }
  366. }
  367. void btPersistentManifold::deSerialize(const struct btPersistentManifoldFloatData* manifoldDataPtr)
  368. {
  369. m_contactBreakingThreshold = manifoldDataPtr->m_contactBreakingThreshold;
  370. m_contactProcessingThreshold = manifoldDataPtr->m_contactProcessingThreshold;
  371. m_cachedPoints = manifoldDataPtr->m_numCachedPoints;
  372. m_companionIdA = manifoldDataPtr->m_companionIdA;
  373. m_companionIdB = manifoldDataPtr->m_companionIdB;
  374. //m_index1a = manifoldDataPtr->m_index1a;
  375. m_objectType = manifoldDataPtr->m_objectType;
  376. for (int i = 0; i < this->getNumContacts(); i++)
  377. {
  378. btManifoldPoint& pt = m_pointCache[i];
  379. pt.m_appliedImpulse = manifoldDataPtr->m_pointCacheAppliedImpulse[i];
  380. pt.m_prevRHS = manifoldDataPtr->m_pointCachePrevRHS[i];
  381. pt.m_appliedImpulseLateral1 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral1[i];
  382. pt.m_appliedImpulseLateral2 = manifoldDataPtr->m_pointCacheAppliedImpulseLateral2[i];
  383. pt.m_localPointA.deSerialize(manifoldDataPtr->m_pointCacheLocalPointA[i]);
  384. pt.m_localPointB.deSerialize(manifoldDataPtr->m_pointCacheLocalPointB[i]);
  385. pt.m_normalWorldOnB.deSerialize(manifoldDataPtr->m_pointCacheNormalWorldOnB[i]);
  386. pt.m_distance1 = manifoldDataPtr->m_pointCacheDistance[i];
  387. pt.m_combinedContactDamping1 = manifoldDataPtr->m_pointCacheCombinedContactDamping1[i];
  388. pt.m_combinedContactStiffness1 = manifoldDataPtr->m_pointCacheCombinedContactStiffness1[i];
  389. pt.m_lifeTime = manifoldDataPtr->m_pointCacheLifeTime[i];
  390. pt.m_frictionCFM = manifoldDataPtr->m_pointCacheFrictionCFM[i];
  391. pt.m_contactERP = manifoldDataPtr->m_pointCacheContactERP[i];
  392. pt.m_contactCFM = manifoldDataPtr->m_pointCacheContactCFM[i];
  393. pt.m_contactPointFlags = manifoldDataPtr->m_pointCacheContactPointFlags[i];
  394. pt.m_index0 = manifoldDataPtr->m_pointCacheIndex0[i];
  395. pt.m_index1 = manifoldDataPtr->m_pointCacheIndex1[i];
  396. pt.m_partId0 = manifoldDataPtr->m_pointCachePartId0[i];
  397. pt.m_partId1 = manifoldDataPtr->m_pointCachePartId1[i];
  398. pt.m_positionWorldOnA.deSerialize(manifoldDataPtr->m_pointCachePositionWorldOnA[i]);
  399. pt.m_positionWorldOnB.deSerialize(manifoldDataPtr->m_pointCachePositionWorldOnB[i]);
  400. pt.m_combinedFriction = manifoldDataPtr->m_pointCacheCombinedFriction[i];
  401. pt.m_lateralFrictionDir1.deSerialize(manifoldDataPtr->m_pointCacheLateralFrictionDir1[i]);
  402. pt.m_lateralFrictionDir2.deSerialize(manifoldDataPtr->m_pointCacheLateralFrictionDir2[i]);
  403. pt.m_combinedRollingFriction = manifoldDataPtr->m_pointCacheCombinedRollingFriction[i];
  404. pt.m_combinedSpinningFriction = manifoldDataPtr->m_pointCacheCombinedSpinningFriction[i];
  405. pt.m_combinedRestitution = manifoldDataPtr->m_pointCacheCombinedRestitution[i];
  406. pt.m_contactMotion1 = manifoldDataPtr->m_pointCacheContactMotion1[i];
  407. pt.m_contactMotion2 = manifoldDataPtr->m_pointCacheContactMotion2[i];
  408. }
  409. }