started working on some serious performance improvements. now the union find is optimized, the broadphase add/remove overlapping pair was too slow. added a stl::set to keep track of overlapping pairs. this speeds up the set find/remove. work in progress.the SimpleBroadphase is broken. will be fixed tomorrow.
Did some tests with 3000 rigidbodies, works much smoother now :)
This commit is contained in:
@@ -215,7 +215,7 @@ void AxisSweep3::RemoveHandle(unsigned short handle)
|
||||
{
|
||||
Handle* pHandle = GetHandle(handle);
|
||||
|
||||
RemoveOverlappingPairsContainingProxy(pHandle);
|
||||
//RemoveOverlappingPairsContainingProxy(pHandle);
|
||||
|
||||
|
||||
// compute current limit of edge arrays
|
||||
|
||||
@@ -42,6 +42,9 @@ IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
|
||||
TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
///used for demo integration FAST/Swift collision library and Bullet
|
||||
FAST_CONCAVE_MESH_PROXYTYPE,
|
||||
|
||||
EMPTY_SHAPE_PROXYTYPE,
|
||||
STATIC_PLANE_PROXYTYPE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
@@ -124,17 +127,26 @@ struct BroadphasePair
|
||||
}
|
||||
}
|
||||
BroadphasePair(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1)
|
||||
:
|
||||
m_pProxy0(&proxy0),
|
||||
m_pProxy1(&proxy1)
|
||||
{
|
||||
|
||||
//keep them sorted, so the std::set operations work
|
||||
if (&proxy0 < &proxy1)
|
||||
{
|
||||
m_pProxy0 = &proxy0;
|
||||
m_pProxy1 = &proxy1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pProxy0 = &proxy1;
|
||||
m_pProxy1 = &proxy0;
|
||||
}
|
||||
|
||||
for (int i=0;i<SIMPLE_MAX_ALGORITHMS;i++)
|
||||
{
|
||||
{
|
||||
m_algorithms[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
BroadphaseProxy* m_pProxy0;
|
||||
BroadphaseProxy* m_pProxy1;
|
||||
@@ -142,5 +154,14 @@ struct BroadphasePair
|
||||
mutable CollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS];
|
||||
};
|
||||
|
||||
|
||||
//comparison for set operation, see Solid DT_Encounter
|
||||
inline bool operator<(const BroadphasePair& a, const BroadphasePair& b)
|
||||
{
|
||||
return a.m_pProxy0 < b.m_pProxy0 ||
|
||||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1);
|
||||
}
|
||||
|
||||
|
||||
#endif //BROADPHASE_PROXY_H
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
virtual void ReleaseManifoldResult(ManifoldResult*)=0;
|
||||
|
||||
virtual void DispatchAllCollisionPairs(struct BroadphasePair* pairs,int numPairs,DispatcherInfo& dispatchInfo)=0;
|
||||
virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo)=0;
|
||||
|
||||
virtual int GetNumManifolds() const = 0;
|
||||
|
||||
|
||||
@@ -24,26 +24,24 @@ subject to the following restrictions:
|
||||
|
||||
OverlappingPairCache::OverlappingPairCache(int maxOverlap):
|
||||
m_blockedForChanges(false),
|
||||
m_NumOverlapBroadphasePair(0),
|
||||
//m_NumOverlapBroadphasePair(0),
|
||||
m_maxOverlap(maxOverlap)
|
||||
{
|
||||
m_OverlappingPairs = new BroadphasePair[maxOverlap];
|
||||
}
|
||||
|
||||
|
||||
OverlappingPairCache::~OverlappingPairCache()
|
||||
{
|
||||
delete [] m_OverlappingPairs;
|
||||
//todo/test: show we erase/delete data, or is it automatic
|
||||
}
|
||||
|
||||
|
||||
void OverlappingPairCache::RemoveOverlappingPair(BroadphasePair& pair)
|
||||
{
|
||||
CleanOverlappingPair(pair);
|
||||
int index = &pair - &m_OverlappingPairs[0];
|
||||
//remove efficiently, swap with the last
|
||||
m_OverlappingPairs[index] = m_OverlappingPairs[m_NumOverlapBroadphasePair-1];
|
||||
m_NumOverlapBroadphasePair--;
|
||||
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(pair);
|
||||
assert(it != m_overlappingPairSet.end());
|
||||
m_overlappingPairSet.erase(pair);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,25 +73,22 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
|
||||
|
||||
|
||||
BroadphasePair pair(*proxy0,*proxy1);
|
||||
m_OverlappingPairs[m_NumOverlapBroadphasePair] = pair;
|
||||
|
||||
|
||||
m_overlappingPairSet.insert(pair);
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
/*
|
||||
BroadphasePair& pr = (*newElem);
|
||||
int i;
|
||||
for (i=0;i<SIMPLE_MAX_ALGORITHMS;i++)
|
||||
{
|
||||
assert(!m_OverlappingPairs[m_NumOverlapBroadphasePair].m_algorithms[i]);
|
||||
m_OverlappingPairs[m_NumOverlapBroadphasePair].m_algorithms[i] = 0;
|
||||
//m_OverlappingPairs[m_NumOverlapBroadphasePair].m_algorithms[i] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (m_NumOverlapBroadphasePair >= m_maxOverlap)
|
||||
{
|
||||
//printf("Error: too many overlapping objects: m_NumOverlapBroadphasePair: %d\n",m_NumOverlapBroadphasePair);
|
||||
#ifdef DEBUG
|
||||
assert(0);
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
m_NumOverlapBroadphasePair++;
|
||||
}
|
||||
#endif _DEBUG
|
||||
|
||||
|
||||
}
|
||||
@@ -104,27 +99,25 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
|
||||
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
|
||||
BroadphasePair* OverlappingPairCache::FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
|
||||
{
|
||||
BroadphasePair* foundPair = 0;
|
||||
if (!NeedsCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
int i;
|
||||
for (i=m_NumOverlapBroadphasePair-1;i>=0;i--)
|
||||
{
|
||||
BroadphasePair& pair = m_OverlappingPairs[i];
|
||||
if (((pair.m_pProxy0 == proxy0) && (pair.m_pProxy1 == proxy1)) ||
|
||||
((pair.m_pProxy0 == proxy1) && (pair.m_pProxy1 == proxy0)))
|
||||
{
|
||||
foundPair = &pair;
|
||||
return foundPair;
|
||||
}
|
||||
}
|
||||
BroadphasePair tmpPair(*proxy0,*proxy1);
|
||||
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(tmpPair);
|
||||
if ((it == m_overlappingPairSet.end()))
|
||||
return 0;
|
||||
|
||||
return foundPair;
|
||||
//assert(it != m_overlappingPairSet.end());
|
||||
BroadphasePair* pair = &(*it);
|
||||
return pair;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy)
|
||||
{
|
||||
assert(0);
|
||||
/*
|
||||
for (int i=0;i<m_NumOverlapBroadphasePair;i++)
|
||||
{
|
||||
BroadphasePair& pair = m_OverlappingPairs[i];
|
||||
@@ -134,11 +127,17 @@ void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy)
|
||||
CleanOverlappingPair(pair);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy* proxy)
|
||||
{
|
||||
|
||||
assert(0);
|
||||
/*
|
||||
int i;
|
||||
|
||||
for ( i=m_NumOverlapBroadphasePair-1;i>=0;i--)
|
||||
{
|
||||
BroadphasePair& pair = m_OverlappingPairs[i];
|
||||
@@ -148,7 +147,23 @@ void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy
|
||||
RemoveOverlappingPair(pair);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OverlappingPairCache::ProcessAllOverlappingPairs(OverlapCallback* callback)
|
||||
{
|
||||
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.begin();
|
||||
for (; !(it==m_overlappingPairSet.end());it++)
|
||||
{
|
||||
BroadphasePair& pair = (*it);
|
||||
if (callback->ProcessOverlap(pair))
|
||||
{
|
||||
assert(0);
|
||||
m_overlappingPairSet.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,35 +21,33 @@ subject to the following restrictions:
|
||||
#include "BroadphaseInterface.h"
|
||||
#include "BroadphaseProxy.h"
|
||||
#include "SimdPoint3.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
struct OverlapCallback
|
||||
{
|
||||
//return true for deletion of the pair
|
||||
virtual bool ProcessOverlap(BroadphasePair& pair) = 0;
|
||||
};
|
||||
|
||||
///OverlappingPairCache maintains the objects with overlapping AABB
|
||||
///Typically managed by the Broadphase, Axis3Sweep or SimpleBroadphase
|
||||
class OverlappingPairCache : public BroadphaseInterface
|
||||
{
|
||||
|
||||
BroadphasePair* m_OverlappingPairs;
|
||||
int m_NumOverlapBroadphasePair;
|
||||
//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);
|
||||
virtual ~OverlappingPairCache();
|
||||
|
||||
int GetNumOverlappingPairs() const
|
||||
{
|
||||
return m_NumOverlapBroadphasePair;
|
||||
}
|
||||
|
||||
BroadphasePair& GetOverlappingPair(int index)
|
||||
{
|
||||
return m_OverlappingPairs[index];
|
||||
}
|
||||
void ProcessAllOverlappingPairs(OverlapCallback*);
|
||||
|
||||
void RemoveOverlappingPair(BroadphasePair& pair);
|
||||
|
||||
@@ -58,8 +56,7 @@ class OverlappingPairCache : public BroadphaseInterface
|
||||
void AddOverlappingPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1);
|
||||
|
||||
BroadphasePair* FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
|
||||
|
||||
void CleanProxyFromPairs(BroadphaseProxy* proxy);
|
||||
|
||||
|
||||
@@ -95,7 +95,27 @@ BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const
|
||||
return proxy;
|
||||
}
|
||||
|
||||
class RemovingOverlapCallback : public OverlapCallback
|
||||
{
|
||||
virtual bool ProcessOverlap(BroadphasePair& pair)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
};
|
||||
|
||||
class RemovePairContainingProxy
|
||||
{
|
||||
|
||||
BroadphaseProxy* m_targetProxy;
|
||||
|
||||
virtual bool ProcessOverlap(BroadphasePair& pair)
|
||||
{
|
||||
SimpleBroadphaseProxy* proxy0 = static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy0);
|
||||
SimpleBroadphaseProxy* proxy1 = static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy1);
|
||||
|
||||
return ((m_targetProxy == proxy0 || m_targetProxy == proxy1));
|
||||
};
|
||||
};
|
||||
|
||||
void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg)
|
||||
{
|
||||
@@ -109,7 +129,24 @@ void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg)
|
||||
assert (index < m_maxProxies);
|
||||
m_freeProxies[--m_firstFreeProxy] = index;
|
||||
|
||||
RemoveOverlappingPairsContainingProxy(proxyOrg);
|
||||
//RemoveOverlappingPairsContainingProxy(proxyOrg);
|
||||
|
||||
assert(0);
|
||||
//then remove non-overlapping ones
|
||||
/*for (i=0;i<GetNumOverlappingPairs();i++)
|
||||
{
|
||||
BroadphasePair& pair = GetOverlappingPair(i);
|
||||
|
||||
SimpleBroadphaseProxy* proxy0 = GetSimpleProxyFromProxy(pair.m_pProxy0);
|
||||
SimpleBroadphaseProxy* proxy1 = GetSimpleProxyFromProxy(pair.m_pProxy1);
|
||||
if ((proxy0==proxyOrg) || (proxy1==proxyOrg))
|
||||
{
|
||||
RemoveOverlappingPair(pair);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
for (i=0;i<m_numProxies;i++)
|
||||
@@ -172,6 +209,8 @@ void SimpleBroadphase::RefreshOverlappingPairs()
|
||||
}
|
||||
}
|
||||
|
||||
assert(0);
|
||||
/*
|
||||
//then remove non-overlapping ones
|
||||
for (i=0;i<GetNumOverlappingPairs();i++)
|
||||
{
|
||||
@@ -185,7 +224,8 @@ void SimpleBroadphase::RefreshOverlappingPairs()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,72 @@ void CollisionDispatcher::ReleaseManifoldResult(ManifoldResult*)
|
||||
}
|
||||
|
||||
|
||||
void CollisionDispatcher::DispatchAllCollisionPairs(BroadphasePair* pairs,int numPairs,DispatcherInfo& dispatchInfo)
|
||||
class CollisionPairCallback : public OverlapCallback
|
||||
{
|
||||
DispatcherInfo& m_dispatchInfo;
|
||||
CollisionDispatcher* m_dispatcher;
|
||||
int m_dispatcherId;
|
||||
public:
|
||||
|
||||
CollisionPairCallback(DispatcherInfo& dispatchInfo,CollisionDispatcher* dispatcher,int dispatcherId)
|
||||
:m_dispatchInfo(dispatchInfo),
|
||||
m_dispatcher(dispatcher),
|
||||
m_dispatcherId(dispatcherId)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool ProcessOverlap(BroadphasePair& pair)
|
||||
{
|
||||
if (m_dispatcherId>= 0)
|
||||
{
|
||||
//dispatcher will keep algorithms persistent in the collision pair
|
||||
if (!pair.m_algorithms[m_dispatcherId])
|
||||
{
|
||||
pair.m_algorithms[m_dispatcherId] = m_dispatcher->FindAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
}
|
||||
|
||||
if (pair.m_algorithms[m_dispatcherId])
|
||||
{
|
||||
if (m_dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
pair.m_algorithms[m_dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
} else
|
||||
{
|
||||
float toi = pair.m_algorithms[m_dispatcherId]->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
if (m_dispatchInfo.m_timeOfImpact > toi)
|
||||
m_dispatchInfo.m_timeOfImpact = toi;
|
||||
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
//non-persistent algorithm dispatcher
|
||||
CollisionAlgorithm* algo = m_dispatcher->FindAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
|
||||
if (algo)
|
||||
{
|
||||
if (m_dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
} else
|
||||
{
|
||||
float toi = algo->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
if (m_dispatchInfo.m_timeOfImpact > toi)
|
||||
m_dispatchInfo.m_timeOfImpact = toi;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void CollisionDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo)
|
||||
{
|
||||
//m_blockedForChanges = true;
|
||||
|
||||
@@ -273,58 +338,9 @@ void CollisionDispatcher::DispatchAllCollisionPairs(BroadphasePair* pairs,int nu
|
||||
|
||||
int dispatcherId = GetUniqueId();
|
||||
|
||||
|
||||
CollisionPairCallback collisionCallback(dispatchInfo,this,dispatcherId);
|
||||
|
||||
for (i=0;i<numPairs;i++)
|
||||
{
|
||||
|
||||
BroadphasePair& pair = pairs[i];
|
||||
|
||||
if (dispatcherId>= 0)
|
||||
{
|
||||
//dispatcher will keep algorithms persistent in the collision pair
|
||||
if (!pair.m_algorithms[dispatcherId])
|
||||
{
|
||||
pair.m_algorithms[dispatcherId] = FindAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
}
|
||||
|
||||
if (pair.m_algorithms[dispatcherId])
|
||||
{
|
||||
if (dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
pair.m_algorithms[dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
|
||||
} else
|
||||
{
|
||||
float toi = pair.m_algorithms[dispatcherId]->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
|
||||
if (dispatchInfo.m_timeOfImpact > toi)
|
||||
dispatchInfo.m_timeOfImpact = toi;
|
||||
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
//non-persistent algorithm dispatcher
|
||||
CollisionAlgorithm* algo = FindAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
|
||||
if (algo)
|
||||
{
|
||||
if (dispatchInfo.m_dispatchFunc == DispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
|
||||
} else
|
||||
{
|
||||
float toi = algo->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
|
||||
if (dispatchInfo.m_timeOfImpact > toi)
|
||||
dispatchInfo.m_timeOfImpact = toi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
pairCache->ProcessAllOverlappingPairs(&collisionCallback);
|
||||
|
||||
//m_blockedForChanges = false;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;}
|
||||
|
||||
virtual void DispatchAllCollisionPairs(BroadphasePair* pairs,int numPairs,DispatcherInfo& dispatchInfo);
|
||||
virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ void CollisionWorld::PerformDiscreteCollisionDetection()
|
||||
|
||||
Dispatcher* dispatcher = GetDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->DispatchAllCollisionPairs(&m_pairCache->GetOverlappingPair(0),m_pairCache->GetNumOverlappingPairs(),dispatchInfo);
|
||||
dispatcher->DispatchAllCollisionPairs(m_pairCache,dispatchInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ subject to the following restrictions:
|
||||
#include "IDebugDraw.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
|
||||
#include "CollisionDispatch/SphereSphereCollisionAlgorithm.h"
|
||||
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ const int maxProxies = 32766;
|
||||
const int maxOverlap = 65535;
|
||||
|
||||
bool createConstraint = true;//false;
|
||||
bool useCompound = true;//false;
|
||||
bool useCompound = false;//true;//false;
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
const int numObjects = 50;
|
||||
const int numObjects = 250;
|
||||
#else
|
||||
const int numObjects = 120;
|
||||
const int numObjects = 3250;
|
||||
#endif
|
||||
|
||||
const int maxNumObjects = 32760;
|
||||
@@ -255,6 +255,8 @@ void CcdPhysicsDemo::initPhysics()
|
||||
SimdVector3 worldAabbMax(30000,30000,30000);
|
||||
|
||||
OverlappingPairCache* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax,maxProxies,maxOverlap);
|
||||
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new SphereSphereCollisionAlgorithm::CreateFunc);
|
||||
|
||||
//OverlappingPairCache* broadphase = new SimpleBroadphase(maxProxies,maxOverlap);
|
||||
|
||||
#ifdef USE_PARALLEL_DISPATCHER
|
||||
|
||||
@@ -27,7 +27,7 @@ subject to the following restrictions:
|
||||
#include "BMF_Api.h"
|
||||
|
||||
int numObjects = 0;
|
||||
const int maxNumObjects = 450;
|
||||
const int maxNumObjects = 4096;
|
||||
DefaultMotionState ms[maxNumObjects];
|
||||
CcdPhysicsController* physObjects[maxNumObjects];
|
||||
SimdTransform startTransforms[maxNumObjects];
|
||||
@@ -335,6 +335,9 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y)
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_physicsEnvironmentPtr)
|
||||
m_physicsEnvironmentPtr->setDebugMode(m_debugMode);
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ subject to the following restrictions:
|
||||
#include "ConstraintSolver/SequentialImpulseConstraintSolver.h"
|
||||
#include "CollisionDispatch/CollisionDispatcher.h"
|
||||
#include "BroadphaseCollision/SimpleBroadphase.h"
|
||||
#include "BroadphaseCollision/AxisSweep3.h"
|
||||
|
||||
#include "CollisionShapes/TriangleMeshShape.h"
|
||||
#include "CollisionShapes/TriangleIndexVertexArray.h"
|
||||
#include "CollisionShapes/BvhTriangleMeshShape.h"
|
||||
@@ -39,7 +41,7 @@ subject to the following restrictions:
|
||||
#include "GlutStuff.h"
|
||||
|
||||
//The user defined collision algorithm
|
||||
#include "SphereSphereCollisionAlgorithm.h"
|
||||
#include "CollisionDispatch/SphereSphereCollisionAlgorithm.h"
|
||||
|
||||
GLDebugDrawer debugDrawer;
|
||||
|
||||
@@ -139,7 +141,8 @@ void UserCollisionAlgorithm::initPhysics()
|
||||
|
||||
CollisionDispatcher* dispatcher = new CollisionDispatcher();
|
||||
|
||||
OverlappingPairCache* broadphase = new SimpleBroadphase();
|
||||
SimdVector3 maxAabb(10000,10000,10000);
|
||||
OverlappingPairCache* broadphase = new AxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
|
||||
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new SphereSphereCollisionAlgorithm::CreateFunc);
|
||||
|
||||
|
||||
|
||||
2
Doxyfile
2
Doxyfile
@@ -267,7 +267,7 @@ WARN_LOGFILE =
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = Bullet BulletDynamics LinearMath Extras/PhysicsInterface
|
||||
INPUT = Bullet BulletDynamics LinearMath Extras/PhysicsInterface Demos
|
||||
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
|
||||
@@ -687,7 +687,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
dispatchInfo.m_debugDraw = this->m_debugDrawer;
|
||||
|
||||
scene->RefreshOverlappingPairs();
|
||||
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(&scene->GetOverlappingPair(0),scene->GetNumOverlappingPairs(),dispatchInfo);
|
||||
|
||||
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo);
|
||||
|
||||
|
||||
#ifdef USE_QUICKPROF
|
||||
@@ -856,7 +857,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
dispatchInfo.m_dispatchFunc = DispatcherInfo::DISPATCH_CONTINUOUS;
|
||||
|
||||
//pairCache->RefreshOverlappingPairs();//??
|
||||
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(&scene->GetOverlappingPair(0),scene->GetNumOverlappingPairs(),dispatchInfo);
|
||||
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo);
|
||||
|
||||
toi = dispatchInfo.m_timeOfImpact;
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ void ParallelIslandDispatcher::ReleaseManifoldResult(ManifoldResult*)
|
||||
}
|
||||
|
||||
|
||||
void ParallelIslandDispatcher::DispatchAllCollisionPairs(BroadphasePair* pairs,int numPairs,DispatcherInfo& dispatchInfo)
|
||||
void ParallelIslandDispatcher::DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo)
|
||||
{
|
||||
//m_blockedForChanges = true;
|
||||
|
||||
@@ -290,8 +290,9 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(BroadphasePair* pairs,i
|
||||
|
||||
int dispatcherId = GetUniqueId();
|
||||
|
||||
assert(0);
|
||||
|
||||
|
||||
/*
|
||||
for (i=0;i<numPairs;i++)
|
||||
{
|
||||
|
||||
@@ -342,7 +343,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(BroadphasePair* pairs,i
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
//m_blockedForChanges = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
|
||||
virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;}
|
||||
|
||||
virtual void DispatchAllCollisionPairs(BroadphasePair* pairs,int numPairs,DispatcherInfo& dispatchInfo);
|
||||
virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -110,8 +110,13 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
|
||||
//this is a brute force approach, will rethink later about more subtle ways
|
||||
int i;
|
||||
|
||||
assert(0);
|
||||
/*
|
||||
for (i=0;i< scene->GetNumOverlappingPairs();i++)
|
||||
{
|
||||
|
||||
|
||||
BroadphasePair* pair = &scene->GetOverlappingPair(i);
|
||||
|
||||
CollisionObject* col0 = static_cast<CollisionObject*>(pair->m_pProxy0->m_clientObject);
|
||||
@@ -124,7 +129,9 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
{
|
||||
simulationIslands[col1->m_islandTag1].m_overlappingPairIndices.push_back(i);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
//store constraint indices for each island
|
||||
for (i=0;i<m_constraints.size();i++)
|
||||
@@ -176,14 +183,19 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
|
||||
|
||||
|
||||
|
||||
assert(0);
|
||||
/*
|
||||
//Each simulation island can be processed in parallel (will be put on a job queue)
|
||||
for (k=0;k<simulationIslands.size();k++)
|
||||
{
|
||||
if (simulationIslands[k].m_controllers.size())
|
||||
{
|
||||
assert(0);//seems to be wrong, passing ALL overlapping pairs
|
||||
simulationIslands[k].Simulate(m_debugDrawer,m_numIterations, constraintBase ,&scene->GetOverlappingPair(0),dispatcher,GetBroadphase(),m_solver,timeStep);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef USE_QUICKPROF
|
||||
Profiler::endBlock("SimulateIsland");
|
||||
|
||||
@@ -102,7 +102,8 @@ bool SimulationIsland::Simulate(IDebugDraw* debugDrawer,int numSolverIterations,
|
||||
//pairCache->RefreshOverlappingPairs();
|
||||
if (overlappingPairs.size())
|
||||
{
|
||||
dispatcher->DispatchAllCollisionPairs(&overlappingPairs[0],overlappingPairs.size(),dispatchInfo);///numsubstep,g);
|
||||
assert(0);
|
||||
//dispatcher->DispatchAllCollisionPairs(&overlappingPairs[0],overlappingPairs.size(),dispatchInfo);///numsubstep,g);
|
||||
}
|
||||
|
||||
//scatter overlapping pair info, mainly the created algorithms/contact caches
|
||||
|
||||
@@ -23,6 +23,10 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
class SimdTransform {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum {
|
||||
TRANSLATION = 0x01,
|
||||
ROTATION = 0x02,
|
||||
@@ -32,12 +36,8 @@ class SimdTransform {
|
||||
AFFINE = TRANSLATION | LINEAR
|
||||
};
|
||||
|
||||
public:
|
||||
SimdTransform() {}
|
||||
|
||||
// template <typename Scalar2>
|
||||
// explicit Transform(const Scalar2 *m) { setValue(m); }
|
||||
|
||||
explicit SIMD_FORCE_INLINE SimdTransform(const SimdQuaternion& q,
|
||||
const SimdVector3& c = SimdVector3(SimdScalar(0), SimdScalar(0), SimdScalar(0)))
|
||||
: m_basis(q),
|
||||
|
||||
Reference in New Issue
Block a user