diff --git a/Bullet/BroadphaseCollision/AxisSweep3.h b/Bullet/BroadphaseCollision/AxisSweep3.h index 0a4a75d52..8bbe31643 100644 --- a/Bullet/BroadphaseCollision/AxisSweep3.h +++ b/Bullet/BroadphaseCollision/AxisSweep3.h @@ -91,7 +91,7 @@ private: void SortMaxUp(int axis, unsigned short edge, bool updateOverlaps = true); public: - AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles = 1024, int maxOverlaps = 8192); + AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles = 20000, int maxOverlaps = 60000); virtual ~AxisSweep3(); virtual void RefreshOverlappingPairs() diff --git a/Bullet/BroadphaseCollision/OverlappingPairCache.cpp b/Bullet/BroadphaseCollision/OverlappingPairCache.cpp index 3f0b5cd3a..86ddb41c6 100644 --- a/Bullet/BroadphaseCollision/OverlappingPairCache.cpp +++ b/Bullet/BroadphaseCollision/OverlappingPairCache.cpp @@ -98,7 +98,9 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase } - +///this FindPair becomes really slow. Either sort the list to speedup the query, or +///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed. +///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address) BroadphasePair* OverlappingPairCache::FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) { BroadphasePair* foundPair = 0; diff --git a/Bullet/NarrowPhaseCollision/PersistentManifold.cpp b/Bullet/NarrowPhaseCollision/PersistentManifold.cpp index 457662aa5..39227e3ea 100644 --- a/Bullet/NarrowPhaseCollision/PersistentManifold.cpp +++ b/Bullet/NarrowPhaseCollision/PersistentManifold.cpp @@ -91,33 +91,51 @@ void PersistentManifold::ClearUserCache(ManifoldPoint& pt) } - - int PersistentManifold::SortCachedPoints(const ManifoldPoint& pt) { //calculate 4 possible cases areas, and take biggest area - - SimdScalar res0,res1,res2,res3; - + //also need to keep 'deepest' + + int maxPenetrationIndex = -1; +#define KEEP_DEEPEST_POINT 1 +#ifdef KEEP_DEEPEST_POINT + float maxPenetration = pt.GetDistance(); + for (int i=0;i<4;i++) + { + if (m_pointCache[i].GetDistance() < maxPenetration) + { + maxPenetrationIndex = i; + maxPenetration = m_pointCache[i].GetDistance(); + } + } +#endif //KEEP_DEEPEST_POINT + + SimdScalar res0(0.f),res1(0.f),res2(0.f),res3(0.f); + if (maxPenetrationIndex != 0) { SimdVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA; SimdVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; SimdVector3 cross = a0.cross(b0); res0 = cross.length2(); } + if (maxPenetrationIndex != 1) { SimdVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA; SimdVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; SimdVector3 cross = a1.cross(b1); res1 = cross.length2(); } + + if (maxPenetrationIndex != 2) { SimdVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA; SimdVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA; SimdVector3 cross = a2.cross(b2); res2 = cross.length2(); } + + if (maxPenetrationIndex != 3) { SimdVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA; SimdVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA; @@ -127,14 +145,10 @@ int PersistentManifold::SortCachedPoints(const ManifoldPoint& pt) SimdVector4 maxvec(res0,res1,res2,res3); int biggestarea = maxvec.closestAxis4(); - return biggestarea; - - } - int PersistentManifold::GetCacheEntry(const ManifoldPoint& newPoint) const { SimdScalar shortestDist = GetContactBreakingTreshold() * GetContactBreakingTreshold();