improved performance, and allowed custom friction and contact solver models. See CcdPhysicsDemo #define USER_DEFINED_FRICTION_MODEL
This commit is contained in:
@@ -47,17 +47,14 @@ void AxisSweep3::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const
|
||||
|
||||
|
||||
|
||||
AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles, int maxOverlaps)
|
||||
:OverlappingPairCache(maxOverlaps)
|
||||
AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles)
|
||||
:OverlappingPairCache()
|
||||
{
|
||||
//assert(bounds.HasVolume());
|
||||
|
||||
// 1 handle is reserved as sentinel
|
||||
assert(maxHandles > 1 && maxHandles < 32767);
|
||||
|
||||
// doesn't need this limit right now, but I may want to use unsigned short indexes into overlaps array
|
||||
assert(maxOverlaps > 0 && maxOverlaps < 65536);
|
||||
|
||||
// init bounds
|
||||
m_worldAabbMin = worldAabbMin;
|
||||
m_worldAabbMax = worldAabbMax;
|
||||
|
||||
@@ -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 = 20000, int maxOverlaps = 60000);
|
||||
AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles = 16384);
|
||||
virtual ~AxisSweep3();
|
||||
|
||||
virtual void RefreshOverlappingPairs()
|
||||
|
||||
@@ -21,11 +21,11 @@ subject to the following restrictions:
|
||||
#include "Dispatcher.h"
|
||||
#include "CollisionAlgorithm.h"
|
||||
|
||||
int gOverlappingPairs = 0;
|
||||
|
||||
OverlappingPairCache::OverlappingPairCache(int maxOverlap):
|
||||
m_blockedForChanges(false),
|
||||
//m_NumOverlapBroadphasePair(0),
|
||||
m_maxOverlap(maxOverlap)
|
||||
OverlappingPairCache::OverlappingPairCache():
|
||||
m_blockedForChanges(false)
|
||||
//m_NumOverlapBroadphasePair(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,14 +36,17 @@ OverlappingPairCache::~OverlappingPairCache()
|
||||
}
|
||||
|
||||
|
||||
void OverlappingPairCache::RemoveOverlappingPair(BroadphasePair& pair)
|
||||
void OverlappingPairCache::RemoveOverlappingPair(BroadphasePair& findPair)
|
||||
{
|
||||
CleanOverlappingPair(pair);
|
||||
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(pair);
|
||||
|
||||
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(findPair);
|
||||
// assert(it != m_overlappingPairSet.end());
|
||||
|
||||
if (it != m_overlappingPairSet.end())
|
||||
{
|
||||
gOverlappingPairs--;
|
||||
BroadphasePair* pair = (BroadphasePair*)(&(*it));
|
||||
CleanOverlappingPair(*pair);
|
||||
m_overlappingPairSet.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -79,6 +82,7 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
|
||||
BroadphasePair pair(*proxy0,*proxy1);
|
||||
|
||||
m_overlappingPairSet.insert(pair);
|
||||
gOverlappingPairs++;
|
||||
|
||||
}
|
||||
|
||||
@@ -179,10 +183,17 @@ void OverlappingPairCache::ProcessAllOverlappingPairs(OverlapCallback* callback)
|
||||
CleanOverlappingPair(*pair);
|
||||
|
||||
std::set<BroadphasePair>::iterator it2 = it;
|
||||
it++;
|
||||
//why does next line not compile under OS X??
|
||||
//it = m_overlappingPairSet.erase(it2);
|
||||
#ifdef MAC_OSX_FIXED_STL_SET
|
||||
it2++;
|
||||
it = m_overlappingPairSet.erase(it);
|
||||
assert(it == it2);
|
||||
#else
|
||||
it++;
|
||||
m_overlappingPairSet.erase(it2);
|
||||
#endif //MAC_OSX_FIXED_STL_SET
|
||||
|
||||
gOverlappingPairs--;
|
||||
} else
|
||||
{
|
||||
it++;
|
||||
|
||||
@@ -37,14 +37,12 @@ class OverlappingPairCache : public BroadphaseInterface
|
||||
//avoid brute-force finding all the time
|
||||
std::set<BroadphasePair> m_overlappingPairSet;
|
||||
|
||||
int m_maxOverlap;
|
||||
|
||||
//during the dispatch, check that user doesn't destroy/create proxy
|
||||
bool m_blockedForChanges;
|
||||
|
||||
public:
|
||||
|
||||
OverlappingPairCache(int maxOverlap);
|
||||
OverlappingPairCache();
|
||||
virtual ~OverlappingPairCache();
|
||||
|
||||
void ProcessAllOverlappingPairs(OverlapCallback*);
|
||||
|
||||
@@ -35,8 +35,8 @@ void SimpleBroadphase::validate()
|
||||
|
||||
}
|
||||
|
||||
SimpleBroadphase::SimpleBroadphase(int maxProxies,int maxOverlap)
|
||||
:OverlappingPairCache(maxOverlap),
|
||||
SimpleBroadphase::SimpleBroadphase(int maxProxies)
|
||||
:OverlappingPairCache(),
|
||||
m_firstFreeProxy(0),
|
||||
m_numProxies(0),
|
||||
m_maxProxies(maxProxies)
|
||||
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
|
||||
virtual void RefreshOverlappingPairs();
|
||||
public:
|
||||
SimpleBroadphase(int maxProxies=4096,int maxOverlap=8192);
|
||||
SimpleBroadphase(int maxProxies=16384);
|
||||
virtual ~SimpleBroadphase();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user