Refactoring: another huge number of changes, renamed methods to start with lower-case.
This commit is contained in:
@@ -52,7 +52,7 @@ btCollisionDispatcher::btCollisionDispatcher ():
|
||||
{
|
||||
for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++)
|
||||
{
|
||||
m_doubleDispatch[i][j] = InternalFindCreateFunc(i,j);
|
||||
m_doubleDispatch[i][j] = internalFindCreateFunc(i,j);
|
||||
assert(m_doubleDispatch[i][j]);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ btCollisionDispatcher::btCollisionDispatcher ():
|
||||
|
||||
};
|
||||
|
||||
void btCollisionDispatcher::RegisterCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
|
||||
void btCollisionDispatcher::registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
|
||||
{
|
||||
m_doubleDispatch[proxyType0][proxyType1] = createFunc;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ btCollisionDispatcher::~btCollisionDispatcher()
|
||||
delete m_emptyCreateFunc;
|
||||
}
|
||||
|
||||
btPersistentManifold* btCollisionDispatcher::GetNewManifold(void* b0,void* b1)
|
||||
btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
|
||||
{
|
||||
gNumManifold++;
|
||||
|
||||
@@ -91,20 +91,20 @@ btPersistentManifold* btCollisionDispatcher::GetNewManifold(void* b0,void* b1)
|
||||
return manifold;
|
||||
}
|
||||
|
||||
void btCollisionDispatcher::ClearManifold(btPersistentManifold* manifold)
|
||||
void btCollisionDispatcher::clearManifold(btPersistentManifold* manifold)
|
||||
{
|
||||
manifold->ClearManifold();
|
||||
manifold->clearManifold();
|
||||
}
|
||||
|
||||
|
||||
void btCollisionDispatcher::ReleaseManifold(btPersistentManifold* manifold)
|
||||
void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
|
||||
{
|
||||
|
||||
gNumManifold--;
|
||||
|
||||
//printf("ReleaseManifold: gNumManifold %d\n",gNumManifold);
|
||||
//printf("releaseManifold: gNumManifold %d\n",gNumManifold);
|
||||
|
||||
ClearManifold(manifold);
|
||||
clearManifold(manifold);
|
||||
|
||||
std::vector<btPersistentManifold*>::iterator i =
|
||||
std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold);
|
||||
@@ -121,7 +121,7 @@ void btCollisionDispatcher::ReleaseManifold(btPersistentManifold* manifold)
|
||||
|
||||
|
||||
|
||||
btCollisionAlgorithm* btCollisionDispatcher::FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
{
|
||||
#define USE_DISPATCH_REGISTRY_ARRAY 1
|
||||
#ifdef USE_DISPATCH_REGISTRY_ARRAY
|
||||
@@ -129,39 +129,39 @@ btCollisionAlgorithm* btCollisionDispatcher::FindAlgorithm(btBroadphaseProxy& pr
|
||||
btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject;
|
||||
btCollisionAlgorithmConstructionInfo ci;
|
||||
ci.m_dispatcher = this;
|
||||
btCollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->GetShapeType()][body1->m_collisionShape->GetShapeType()]
|
||||
btCollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->getShapeType()][body1->m_collisionShape->getShapeType()]
|
||||
->CreateCollisionAlgorithm(ci,&proxy0,&proxy1);
|
||||
#else
|
||||
btCollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1);
|
||||
btCollisionAlgorithm* algo = internalFindAlgorithm(proxy0,proxy1);
|
||||
#endif //USE_DISPATCH_REGISTRY_ARRAY
|
||||
return algo;
|
||||
}
|
||||
|
||||
|
||||
btCollisionAlgorithmCreateFunc* btCollisionDispatcher::InternalFindCreateFunc(int proxyType0,int proxyType1)
|
||||
btCollisionAlgorithmCreateFunc* btCollisionDispatcher::internalFindCreateFunc(int proxyType0,int proxyType1)
|
||||
{
|
||||
|
||||
if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConvex(proxyType1))
|
||||
if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
|
||||
{
|
||||
return m_convexConvexCreateFunc;
|
||||
}
|
||||
|
||||
if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConcave(proxyType1))
|
||||
if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
|
||||
{
|
||||
return m_convexConcaveCreateFunc;
|
||||
}
|
||||
|
||||
if (btBroadphaseProxy::IsConvex(proxyType1) && btBroadphaseProxy::IsConcave(proxyType0))
|
||||
if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
|
||||
{
|
||||
return m_swappedConvexConcaveCreateFunc;
|
||||
}
|
||||
|
||||
if (btBroadphaseProxy::IsCompound(proxyType0))
|
||||
if (btBroadphaseProxy::isCompound(proxyType0))
|
||||
{
|
||||
return m_compoundCreateFunc;
|
||||
} else
|
||||
{
|
||||
if (btBroadphaseProxy::IsCompound(proxyType1))
|
||||
if (btBroadphaseProxy::isCompound(proxyType1))
|
||||
{
|
||||
return m_swappedCompoundCreateFunc;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ btCollisionAlgorithmCreateFunc* btCollisionDispatcher::InternalFindCreateFunc(in
|
||||
|
||||
|
||||
|
||||
btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
{
|
||||
m_count++;
|
||||
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
|
||||
@@ -182,27 +182,27 @@ btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseP
|
||||
btCollisionAlgorithmConstructionInfo ci;
|
||||
ci.m_dispatcher = this;
|
||||
|
||||
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConvex() )
|
||||
if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConvex() )
|
||||
{
|
||||
return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1);
|
||||
}
|
||||
|
||||
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConcave())
|
||||
if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConcave())
|
||||
{
|
||||
return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1);
|
||||
}
|
||||
|
||||
if (body1->m_collisionShape->IsConvex() && body0->m_collisionShape->IsConcave())
|
||||
if (body1->m_collisionShape->isConvex() && body0->m_collisionShape->isConcave())
|
||||
{
|
||||
return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0);
|
||||
}
|
||||
|
||||
if (body0->m_collisionShape->IsCompound())
|
||||
if (body0->m_collisionShape->isCompound())
|
||||
{
|
||||
return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1);
|
||||
} else
|
||||
{
|
||||
if (body1->m_collisionShape->IsCompound())
|
||||
if (body1->m_collisionShape->isCompound())
|
||||
{
|
||||
return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseP
|
||||
|
||||
}
|
||||
|
||||
bool btCollisionDispatcher::NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)
|
||||
bool btCollisionDispatcher::needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)
|
||||
{
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ bool btCollisionDispatcher::NeedsResponse(const btCollisionObject& colObj0,cons
|
||||
return hasResponse;
|
||||
}
|
||||
|
||||
bool btCollisionDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
bool btCollisionDispatcher::needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
{
|
||||
|
||||
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
|
||||
@@ -249,7 +249,7 @@ bool btCollisionDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphas
|
||||
}
|
||||
|
||||
///allows the user to get contact point callbacks
|
||||
btManifoldResult* btCollisionDispatcher::GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold)
|
||||
btManifoldResult* btCollisionDispatcher::getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold)
|
||||
{
|
||||
|
||||
|
||||
@@ -259,34 +259,34 @@ btManifoldResult* btCollisionDispatcher::GetNewManifoldResult(btCollisionObject*
|
||||
}
|
||||
|
||||
///allows the user to get contact point callbacks
|
||||
void btCollisionDispatcher::ReleaseManifoldResult(btManifoldResult*)
|
||||
void btCollisionDispatcher::releaseManifoldResult(btManifoldResult*)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CollisionPairCallback : public btOverlapCallback
|
||||
class btCollisionPairCallback : public btOverlapCallback
|
||||
{
|
||||
btDispatcherInfo& m_dispatchInfo;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
int m_dispatcherId;
|
||||
public:
|
||||
|
||||
CollisionPairCallback(btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher,int dispatcherId)
|
||||
btCollisionPairCallback(btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher,int dispatcherId)
|
||||
:m_dispatchInfo(dispatchInfo),
|
||||
m_dispatcher(dispatcher),
|
||||
m_dispatcherId(dispatcherId)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool ProcessOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& 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_algorithms[m_dispatcherId] = m_dispatcher->findAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
}
|
||||
@@ -295,10 +295,10 @@ public:
|
||||
{
|
||||
if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
pair.m_algorithms[m_dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
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);
|
||||
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;
|
||||
|
||||
@@ -307,7 +307,7 @@ public:
|
||||
} else
|
||||
{
|
||||
//non-persistent algorithm dispatcher
|
||||
btCollisionAlgorithm* algo = m_dispatcher->FindAlgorithm(
|
||||
btCollisionAlgorithm* algo = m_dispatcher->findAlgorithm(
|
||||
*pair.m_pProxy0,
|
||||
*pair.m_pProxy1);
|
||||
|
||||
@@ -315,10 +315,10 @@ public:
|
||||
{
|
||||
if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
|
||||
{
|
||||
algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
algo->processCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
} else
|
||||
{
|
||||
float toi = algo->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
float toi = algo->calculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
|
||||
if (m_dispatchInfo.m_timeOfImpact > toi)
|
||||
m_dispatchInfo.m_timeOfImpact = toi;
|
||||
}
|
||||
@@ -330,15 +330,15 @@ public:
|
||||
};
|
||||
|
||||
|
||||
void btCollisionDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)
|
||||
void btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
//m_blockedForChanges = true;
|
||||
|
||||
int dispatcherId = GetUniqueId();
|
||||
int dispatcherId = getUniqueId();
|
||||
|
||||
CollisionPairCallback collisionCallback(dispatchInfo,this,dispatcherId);
|
||||
btCollisionPairCallback collisionCallback(dispatchInfo,this,dispatcherId);
|
||||
|
||||
pairCache->ProcessAllOverlappingPairs(&collisionCallback);
|
||||
pairCache->processAllOverlappingPairs(&collisionCallback);
|
||||
|
||||
//m_blockedForChanges = false;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class btCollisionDispatcher : public btDispatcher
|
||||
|
||||
btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
|
||||
|
||||
btCollisionAlgorithmCreateFunc* InternalFindCreateFunc(int proxyType0,int proxyType1);
|
||||
btCollisionAlgorithmCreateFunc* internalFindCreateFunc(int proxyType0,int proxyType1);
|
||||
|
||||
//default CreationFunctions, filling the m_doubleDispatch table
|
||||
btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc;
|
||||
@@ -58,10 +58,10 @@ class btCollisionDispatcher : public btDispatcher
|
||||
|
||||
public:
|
||||
|
||||
///RegisterCollisionCreateFunc allows registration of custom/alternative collision create functions
|
||||
void RegisterCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
|
||||
///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
|
||||
void registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
|
||||
|
||||
int GetNumManifolds() const
|
||||
int getNumManifolds() const
|
||||
{
|
||||
return m_manifoldsPtr.size();
|
||||
}
|
||||
@@ -71,12 +71,12 @@ public:
|
||||
return &m_manifoldsPtr[0];
|
||||
}
|
||||
|
||||
btPersistentManifold* GetManifoldByIndexInternal(int index)
|
||||
btPersistentManifold* getManifoldByIndexInternal(int index)
|
||||
{
|
||||
return m_manifoldsPtr[index];
|
||||
}
|
||||
|
||||
const btPersistentManifold* GetManifoldByIndexInternal(int index) const
|
||||
const btPersistentManifold* getManifoldByIndexInternal(int index) const
|
||||
{
|
||||
return m_manifoldsPtr[index];
|
||||
}
|
||||
@@ -86,31 +86,31 @@ public:
|
||||
btCollisionDispatcher ();
|
||||
virtual ~btCollisionDispatcher();
|
||||
|
||||
virtual btPersistentManifold* GetNewManifold(void* b0,void* b1);
|
||||
virtual btPersistentManifold* getNewManifold(void* b0,void* b1);
|
||||
|
||||
virtual void ReleaseManifold(btPersistentManifold* manifold);
|
||||
virtual void releaseManifold(btPersistentManifold* manifold);
|
||||
|
||||
|
||||
///allows the user to get contact point callbacks
|
||||
virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold);
|
||||
virtual btManifoldResult* getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold);
|
||||
|
||||
///allows the user to get contact point callbacks
|
||||
virtual void ReleaseManifoldResult(btManifoldResult*);
|
||||
virtual void releaseManifoldResult(btManifoldResult*);
|
||||
|
||||
virtual void ClearManifold(btPersistentManifold* manifold);
|
||||
virtual void clearManifold(btPersistentManifold* manifold);
|
||||
|
||||
|
||||
btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
btCollisionAlgorithm* findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
|
||||
btCollisionAlgorithm* InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
btCollisionAlgorithm* internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
|
||||
virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
virtual bool needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
|
||||
|
||||
virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1);
|
||||
virtual bool needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1);
|
||||
|
||||
virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;}
|
||||
virtual int getUniqueId() { return RIGIDBODY_DISPATCHER;}
|
||||
|
||||
virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo);
|
||||
virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ btCollisionWorld::~btCollisionWorld()
|
||||
//
|
||||
// only clear the cached algorithms
|
||||
//
|
||||
GetBroadphase()->CleanProxyFromPairs(bp);
|
||||
GetBroadphase()->DestroyProxy(bp);
|
||||
getBroadphase()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->destroyProxy(bp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ btCollisionWorld::~btCollisionWorld()
|
||||
|
||||
|
||||
|
||||
void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
{
|
||||
m_collisionObjects.push_back(collisionObject);
|
||||
|
||||
@@ -70,10 +70,10 @@ void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,sho
|
||||
|
||||
btVector3 minAabb;
|
||||
btVector3 maxAabb;
|
||||
collisionObject->m_collisionShape->GetAabb(trans,minAabb,maxAabb);
|
||||
collisionObject->m_collisionShape->getAabb(trans,minAabb,maxAabb);
|
||||
|
||||
int type = collisionObject->m_collisionShape->GetShapeType();
|
||||
collisionObject->m_broadphaseHandle = GetBroadphase()->CreateProxy(
|
||||
int type = collisionObject->m_collisionShape->getShapeType();
|
||||
collisionObject->m_broadphaseHandle = getBroadphase()->createProxy(
|
||||
minAabb,
|
||||
maxAabb,
|
||||
type,
|
||||
@@ -87,7 +87,7 @@ void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,sho
|
||||
|
||||
}
|
||||
|
||||
void btCollisionWorld::PerformDiscreteCollisionDetection()
|
||||
void btCollisionWorld::performDiscreteCollisionDetection()
|
||||
{
|
||||
btDispatcherInfo dispatchInfo;
|
||||
dispatchInfo.m_timeStep = 0.f;
|
||||
@@ -99,20 +99,20 @@ void btCollisionWorld::PerformDiscreteCollisionDetection()
|
||||
for (size_t i=0;i<m_collisionObjects.size();i++)
|
||||
{
|
||||
m_collisionObjects[i]->m_cachedInvertedWorldTransform = m_collisionObjects[i]->m_worldTransform.inverse();
|
||||
m_collisionObjects[i]->m_collisionShape->GetAabb(m_collisionObjects[i]->m_worldTransform,aabbMin,aabbMax);
|
||||
m_pairCache->SetAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax);
|
||||
m_collisionObjects[i]->m_collisionShape->getAabb(m_collisionObjects[i]->m_worldTransform,aabbMin,aabbMax);
|
||||
m_pairCache->setAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax);
|
||||
}
|
||||
|
||||
m_pairCache->RefreshOverlappingPairs();
|
||||
m_pairCache->refreshOverlappingPairs();
|
||||
|
||||
btDispatcher* dispatcher = GetDispatcher();
|
||||
btDispatcher* dispatcher = getDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->DispatchAllCollisionPairs(m_pairCache,dispatchInfo);
|
||||
dispatcher->dispatchAllCollisionPairs(m_pairCache,dispatchInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject)
|
||||
void btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
|
||||
{
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject)
|
||||
//
|
||||
// only clear the cached algorithms
|
||||
//
|
||||
GetBroadphase()->CleanProxyFromPairs(bp);
|
||||
GetBroadphase()->DestroyProxy(bp);
|
||||
getBroadphase()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->destroyProxy(bp);
|
||||
collisionObject->m_broadphaseHandle = 0;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject)
|
||||
}
|
||||
}
|
||||
|
||||
void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
|
||||
void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
|
||||
btCollisionObject* collisionObject,
|
||||
const btCollisionShape* collisionShape,
|
||||
const btTransform& colObjWorldTransform,
|
||||
@@ -151,7 +151,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
|
||||
|
||||
btSphereShape pointShape(0.0f);
|
||||
|
||||
if (collisionShape->IsConvex())
|
||||
if (collisionShape->isConvex())
|
||||
{
|
||||
btConvexCast::CastResult castResult;
|
||||
castResult.m_fraction = 1.f;//??
|
||||
@@ -189,7 +189,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
|
||||
else
|
||||
{
|
||||
|
||||
if (collisionShape->IsConcave())
|
||||
if (collisionShape->isConcave())
|
||||
{
|
||||
|
||||
btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape;
|
||||
@@ -217,7 +217,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
|
||||
}
|
||||
|
||||
|
||||
virtual float ReportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
virtual float reportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
{
|
||||
btCollisionWorld::LocalShapeInfo shapeInfo;
|
||||
shapeInfo.m_shapePart = partId;
|
||||
@@ -245,21 +245,21 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
|
||||
btVector3 rayAabbMaxLocal = rayFromLocal;
|
||||
rayAabbMaxLocal.setMax(rayToLocal);
|
||||
|
||||
triangleMesh->ProcessAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
|
||||
triangleMesh->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
|
||||
|
||||
} else
|
||||
{
|
||||
//todo: use AABB tree or other BVH acceleration structure!
|
||||
if (collisionShape->IsCompound())
|
||||
if (collisionShape->isCompound())
|
||||
{
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
|
||||
int i=0;
|
||||
for (i=0;i<compoundShape->GetNumChildShapes();i++)
|
||||
for (i=0;i<compoundShape->getNumChildShapes();i++)
|
||||
{
|
||||
btTransform childTrans = compoundShape->GetChildTransform(i);
|
||||
const btCollisionShape* childCollisionShape = compoundShape->GetChildShape(i);
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
|
||||
btTransform childWorldTrans = colObjWorldTransform * childTrans;
|
||||
RayTestSingle(rayFromTrans,rayToTrans,
|
||||
rayTestSingle(rayFromTrans,rayToTrans,
|
||||
collisionObject,
|
||||
childCollisionShape,
|
||||
childWorldTrans,
|
||||
@@ -273,7 +273,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
|
||||
}
|
||||
}
|
||||
|
||||
void btCollisionWorld::RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback)
|
||||
void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback)
|
||||
{
|
||||
|
||||
|
||||
@@ -304,13 +304,13 @@ void btCollisionWorld::RayTest(const btVector3& rayFromWorld, const btVector3& r
|
||||
|
||||
//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
|
||||
btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
|
||||
collisionObject->m_collisionShape->GetAabb(collisionObject->m_worldTransform,collisionObjectAabbMin,collisionObjectAabbMax);
|
||||
collisionObject->m_collisionShape->getAabb(collisionObject->m_worldTransform,collisionObjectAabbMin,collisionObjectAabbMax);
|
||||
|
||||
//check aabb overlap
|
||||
|
||||
if (TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,collisionObjectAabbMin,collisionObjectAabbMax))
|
||||
{
|
||||
RayTestSingle(rayFromTrans,rayToTrans,
|
||||
rayTestSingle(rayFromTrans,rayToTrans,
|
||||
collisionObject,
|
||||
collisionObject->m_collisionShape,
|
||||
collisionObject->m_worldTransform,
|
||||
|
||||
@@ -44,7 +44,8 @@ subject to the following restrictions:
|
||||
* The Dependencies can be seen in this documentation under Directories
|
||||
*
|
||||
* @subsection step4 Step 4: Integrating in your application, Full Rigid Body Simulation
|
||||
* Check out CcdPhysicsDemo how to create a CcdPhysicsEnvironment , btCollisionShape and btRigidBody, Stepping the simulation and synchronizing your derived version of the PHY_IMotionState class.
|
||||
* Check out CcdPhysicsDemo how to create a btDynamicsWorld, btRigidBody and btCollisionShape, Stepping the simulation and synchronizing your graphics object transform.
|
||||
* PLEASE NOTE THE CcdPhysicsEnvironment and CcdPhysicsController is obsolete and will be removed. It has been replaced by classes derived frmo btDynamicsWorld and btRididBody
|
||||
* @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras)
|
||||
* Bullet Collision Detection can also be used without the Dynamics/Extras.
|
||||
* Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo. Also in Extras/test_BulletOde.cpp there is a sample Collision Detection integration with Open Dynamics Engine, ODE, http://www.ode.org
|
||||
@@ -101,18 +102,18 @@ public:
|
||||
virtual ~btCollisionWorld();
|
||||
|
||||
|
||||
btBroadphaseInterface* GetBroadphase()
|
||||
btBroadphaseInterface* getBroadphase()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
btOverlappingPairCache* GetPairCache()
|
||||
btOverlappingPairCache* getPairCache()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
|
||||
btDispatcher* GetDispatcher()
|
||||
btDispatcher* getDispatcher()
|
||||
{
|
||||
return m_dispatcher1;
|
||||
}
|
||||
@@ -200,40 +201,40 @@ public:
|
||||
|
||||
|
||||
|
||||
int GetNumCollisionObjects() const
|
||||
int getNumCollisionObjects() const
|
||||
{
|
||||
return m_collisionObjects.size();
|
||||
}
|
||||
|
||||
/// RayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
|
||||
/// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
|
||||
/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
|
||||
void RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback);
|
||||
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback);
|
||||
|
||||
/// RayTestSingle performs a raycast call and calls the resultCallback. It is used internally by RayTest.
|
||||
/// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
|
||||
/// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
|
||||
/// This allows more customization.
|
||||
void RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
|
||||
void rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
|
||||
btCollisionObject* collisionObject,
|
||||
const btCollisionShape* collisionShape,
|
||||
const btTransform& colObjWorldTransform,
|
||||
RayResultCallback& resultCallback);
|
||||
|
||||
void AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);
|
||||
void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);
|
||||
|
||||
btCollisionObjectArray& GetCollisionObjectArray()
|
||||
btCollisionObjectArray& getCollisionObjectArray()
|
||||
{
|
||||
return m_collisionObjects;
|
||||
}
|
||||
|
||||
const btCollisionObjectArray& GetCollisionObjectArray() const
|
||||
const btCollisionObjectArray& getCollisionObjectArray() const
|
||||
{
|
||||
return m_collisionObjects;
|
||||
}
|
||||
|
||||
|
||||
void RemoveCollisionObject(btCollisionObject* collisionObject);
|
||||
void removeCollisionObject(btCollisionObject* collisionObject);
|
||||
|
||||
virtual void PerformDiscreteCollisionDetection();
|
||||
virtual void performDiscreteCollisionDetection();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ m_compoundProxy(*proxy0),
|
||||
m_otherProxy(*proxy1)
|
||||
{
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
|
||||
assert (colObj->m_collisionShape->IsCompound());
|
||||
assert (colObj->m_collisionShape->isCompound());
|
||||
|
||||
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
|
||||
int numChildren = compoundShape->GetNumChildShapes();
|
||||
int numChildren = compoundShape->getNumChildShapes();
|
||||
m_childProxies.resize( numChildren );
|
||||
int i;
|
||||
for (i=0;i<numChildren;i++)
|
||||
@@ -38,11 +38,11 @@ m_otherProxy(*proxy1)
|
||||
m_childCollisionAlgorithms.resize(numChildren);
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
btCollisionShape* childShape = compoundShape->GetChildShape(i);
|
||||
btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
|
||||
btCollisionShape* orgShape = colObj->m_collisionShape;
|
||||
colObj->m_collisionShape = childShape;
|
||||
m_childCollisionAlgorithms[i] = m_dispatcher->FindAlgorithm(m_childProxies[i],m_otherProxy);
|
||||
m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(m_childProxies[i],m_otherProxy);
|
||||
colObj->m_collisionShape =orgShape;
|
||||
}
|
||||
}
|
||||
@@ -58,10 +58,10 @@ btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
|
||||
}
|
||||
}
|
||||
|
||||
void btCompoundCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
void btCompoundCollisionAlgorithm::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
|
||||
assert (colObj->m_collisionShape->IsCompound());
|
||||
assert (colObj->m_collisionShape->isCompound());
|
||||
|
||||
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
|
||||
|
||||
@@ -78,29 +78,29 @@ void btCompoundCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroad
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
//temporarily exchange parent btCollisionShape with childShape, and recurse
|
||||
btCollisionShape* childShape = compoundShape->GetChildShape(i);
|
||||
btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
|
||||
|
||||
//backup
|
||||
btTransform orgTrans = colObj->m_worldTransform;
|
||||
btCollisionShape* orgShape = colObj->m_collisionShape;
|
||||
|
||||
btTransform childTrans = compoundShape->GetChildTransform(i);
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->m_worldTransform = newChildWorldTrans;
|
||||
|
||||
colObj->m_collisionShape = childShape;
|
||||
m_childCollisionAlgorithms[i]->ProcessCollision(&m_childProxies[i],&m_otherProxy,dispatchInfo);
|
||||
m_childCollisionAlgorithms[i]->processCollision(&m_childProxies[i],&m_otherProxy,dispatchInfo);
|
||||
//revert back
|
||||
colObj->m_collisionShape =orgShape;
|
||||
colObj->m_worldTransform = orgTrans;
|
||||
}
|
||||
}
|
||||
|
||||
float btCompoundCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
float btCompoundCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
|
||||
assert (colObj->m_collisionShape->IsCompound());
|
||||
assert (colObj->m_collisionShape->isCompound());
|
||||
|
||||
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
|
||||
|
||||
@@ -118,19 +118,19 @@ float btCompoundCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* pro
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
//temporarily exchange parent btCollisionShape with childShape, and recurse
|
||||
btCollisionShape* childShape = compoundShape->GetChildShape(i);
|
||||
btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
|
||||
|
||||
//backup
|
||||
btTransform orgTrans = colObj->m_worldTransform;
|
||||
btCollisionShape* orgShape = colObj->m_collisionShape;
|
||||
|
||||
btTransform childTrans = compoundShape->GetChildTransform(i);
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->m_worldTransform = newChildWorldTrans;
|
||||
|
||||
colObj->m_collisionShape = childShape;
|
||||
float frac = m_childCollisionAlgorithms[i]->CalculateTimeOfImpact(&m_childProxies[i],&m_otherProxy,dispatchInfo);
|
||||
float frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(&m_childProxies[i],&m_otherProxy,dispatchInfo);
|
||||
if (frac<hitFraction)
|
||||
{
|
||||
hitFraction = frac;
|
||||
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
|
||||
virtual ~btCompoundCollisionAlgorithm();
|
||||
|
||||
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||
{
|
||||
|
||||
@@ -48,27 +48,27 @@ btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher* dispatcher,btB
|
||||
//
|
||||
// create the manifold from the dispatcher 'manifold pool'
|
||||
//
|
||||
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
|
||||
ClearCache();
|
||||
clearCache();
|
||||
}
|
||||
|
||||
btConvexTriangleCallback::~btConvexTriangleCallback()
|
||||
{
|
||||
ClearCache();
|
||||
m_dispatcher->ReleaseManifold( m_manifoldPtr );
|
||||
clearCache();
|
||||
m_dispatcher->releaseManifold( m_manifoldPtr );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btConvexTriangleCallback::ClearCache()
|
||||
void btConvexTriangleCallback::clearCache()
|
||||
{
|
||||
m_dispatcher->ClearManifold(m_manifoldPtr);
|
||||
m_dispatcher->clearManifold(m_manifoldPtr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
{
|
||||
|
||||
//just for debugging purposes
|
||||
@@ -85,29 +85,29 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
|
||||
|
||||
|
||||
///debug drawing of the overlapping triangles
|
||||
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->GetDebugMode() > 0)
|
||||
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
|
||||
{
|
||||
btVector3 color(255,255,0);
|
||||
btTransform& tr = ob->m_worldTransform;
|
||||
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(triangle[1]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(triangle[2]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[2]),tr(triangle[0]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
|
||||
|
||||
//btVector3 center = triangle[0] + triangle[1]+triangle[2];
|
||||
//center *= 0.333333f;
|
||||
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[2]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
|
||||
|
||||
if (colObj->m_collisionShape->IsConvex())
|
||||
if (colObj->m_collisionShape->isConvex())
|
||||
{
|
||||
btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
|
||||
tm.SetMargin(m_collisionMarginTriangle);
|
||||
tm.setMargin(m_collisionMarginTriangle);
|
||||
|
||||
|
||||
btCollisionShape* tmpShape = ob->m_collisionShape;
|
||||
@@ -115,8 +115,8 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
|
||||
|
||||
///this should use the btDispatcher, so the actual registered algorithm is used
|
||||
btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexProxy,&m_triangleProxy);
|
||||
cvxcvxalgo.SetShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||
cvxcvxalgo.ProcessCollision(m_convexProxy,&m_triangleProxy,*m_dispatchInfoPtr);
|
||||
cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||
cvxcvxalgo.processCollision(m_convexProxy,&m_triangleProxy,*m_dispatchInfoPtr);
|
||||
ob->m_collisionShape = tmpShape;
|
||||
|
||||
}
|
||||
@@ -127,7 +127,7 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
|
||||
|
||||
|
||||
|
||||
void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo)
|
||||
void btConvexTriangleCallback::setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
m_dispatchInfoPtr = &dispatchInfo;
|
||||
m_collisionMarginTriangle = collisionMarginTriangle;
|
||||
@@ -142,7 +142,7 @@ void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTrian
|
||||
btCollisionShape* convexShape = static_cast<btCollisionShape*>(convexBody->m_collisionShape);
|
||||
//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
|
||||
|
||||
convexShape->GetAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
|
||||
convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
|
||||
|
||||
float extraMargin = collisionMarginTriangle;//CONVEX_DISTANCE_MARGIN;//+0.1f;
|
||||
|
||||
@@ -153,22 +153,22 @@ void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTrian
|
||||
|
||||
}
|
||||
|
||||
void btConvexConcaveCollisionAlgorithm::ClearCache()
|
||||
void btConvexConcaveCollisionAlgorithm::clearCache()
|
||||
{
|
||||
m_btConvexTriangleCallback.ClearCache();
|
||||
m_btConvexTriangleCallback.clearCache();
|
||||
|
||||
}
|
||||
|
||||
void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
void btConvexConcaveCollisionAlgorithm::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
|
||||
btCollisionObject* convexBody = static_cast<btCollisionObject* >(m_convex.m_clientObject);
|
||||
btCollisionObject* triBody = static_cast<btCollisionObject* >(m_concave.m_clientObject);
|
||||
|
||||
if (triBody->m_collisionShape->IsConcave())
|
||||
if (triBody->m_collisionShape->isConcave())
|
||||
{
|
||||
|
||||
if (!m_dispatcher->NeedsCollision(m_convex,m_concave))
|
||||
if (!m_dispatcher->needsCollision(m_convex,m_concave))
|
||||
return;
|
||||
|
||||
|
||||
@@ -176,19 +176,19 @@ void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,bt
|
||||
btCollisionObject* triOb = static_cast<btCollisionObject*>(m_concave.m_clientObject);
|
||||
ConcaveShape* concaveShape = static_cast<ConcaveShape*>( triOb->m_collisionShape);
|
||||
|
||||
if (convexBody->m_collisionShape->IsConvex())
|
||||
if (convexBody->m_collisionShape->isConvex())
|
||||
{
|
||||
float collisionMarginTriangle = concaveShape->GetMargin();
|
||||
float collisionMarginTriangle = concaveShape->getMargin();
|
||||
|
||||
m_btConvexTriangleCallback.SetTimeStepAndCounters(collisionMarginTriangle,dispatchInfo);
|
||||
m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo);
|
||||
|
||||
//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
|
||||
//m_dispatcher->ClearManifold(m_btConvexTriangleCallback.m_manifoldPtr);
|
||||
//m_dispatcher->clearManifold(m_btConvexTriangleCallback.m_manifoldPtr);
|
||||
|
||||
|
||||
m_btConvexTriangleCallback.m_manifoldPtr->SetBodies(m_convex.m_clientObject,m_concave.m_clientObject);
|
||||
m_btConvexTriangleCallback.m_manifoldPtr->setBodies(m_convex.m_clientObject,m_concave.m_clientObject);
|
||||
|
||||
concaveShape->ProcessAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.GetAabbMin(),m_btConvexTriangleCallback.GetAabbMax());
|
||||
concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax());
|
||||
|
||||
|
||||
}
|
||||
@@ -198,7 +198,7 @@ void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,bt
|
||||
}
|
||||
|
||||
|
||||
float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
|
||||
//quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast)
|
||||
@@ -239,7 +239,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
|
||||
}
|
||||
|
||||
|
||||
virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex)
|
||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
|
||||
{
|
||||
//do a swept sphere for now
|
||||
btTransform ident;
|
||||
@@ -269,7 +269,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
|
||||
|
||||
|
||||
|
||||
if (triBody->m_collisionShape->IsConcave())
|
||||
if (triBody->m_collisionShape->isConcave())
|
||||
{
|
||||
btVector3 rayAabbMin = convexFromLocal.getOrigin();
|
||||
rayAabbMin.setMin(convexToLocal.getOrigin());
|
||||
@@ -290,7 +290,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
|
||||
|
||||
if (triangleMesh)
|
||||
{
|
||||
triangleMesh->ProcessAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
|
||||
triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class btDispatcher;
|
||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||
#include "btCollisionCreateFunc.h"
|
||||
|
||||
///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), ProcessTriangle is called.
|
||||
///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
|
||||
class btConvexTriangleCallback : public btTriangleCallback
|
||||
{
|
||||
btBroadphaseProxy* m_convexProxy;
|
||||
@@ -45,19 +45,19 @@ int m_triangleCount;
|
||||
|
||||
btConvexTriangleCallback(btDispatcher* dispatcher,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
void SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo);
|
||||
void setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
virtual ~btConvexTriangleCallback();
|
||||
|
||||
virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex);
|
||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
||||
|
||||
void ClearCache();
|
||||
void clearCache();
|
||||
|
||||
inline const btVector3& GetAabbMin() const
|
||||
inline const btVector3& getAabbMin() const
|
||||
{
|
||||
return m_aabbMin;
|
||||
}
|
||||
inline const btVector3& GetAabbMax() const
|
||||
inline const btVector3& getAabbMax() const
|
||||
{
|
||||
return m_aabbMax;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public:
|
||||
|
||||
virtual ~btConvexConcaveCollisionAlgorithm();
|
||||
|
||||
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
void ClearCache();
|
||||
void clearCache();
|
||||
|
||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||
{
|
||||
|
||||
@@ -91,12 +91,12 @@ m_ownManifold (false),
|
||||
m_manifoldPtr(mf),
|
||||
m_lowLevelOfDetail(false)
|
||||
{
|
||||
CheckPenetrationDepthSolver();
|
||||
checkPenetrationDepthSolver();
|
||||
|
||||
{
|
||||
if (!m_manifoldPtr && m_dispatcher->NeedsCollision(m_box0,m_box1))
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(m_box0,m_box1))
|
||||
{
|
||||
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
m_ownManifold = true;
|
||||
}
|
||||
}
|
||||
@@ -110,11 +110,11 @@ btConvexConvexAlgorithm::~btConvexConvexAlgorithm()
|
||||
if (m_ownManifold)
|
||||
{
|
||||
if (m_manifoldPtr)
|
||||
m_dispatcher->ReleaseManifold(m_manifoldPtr);
|
||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||
}
|
||||
}
|
||||
|
||||
void btConvexConvexAlgorithm ::SetLowLevelOfDetail(bool useLowLevel)
|
||||
void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
|
||||
{
|
||||
m_lowLevelOfDetail = useLowLevel;
|
||||
}
|
||||
@@ -133,11 +133,11 @@ public:
|
||||
|
||||
}
|
||||
|
||||
virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
||||
{
|
||||
btVector3 flippedNormal = -normalOnBInWorld;
|
||||
|
||||
m_org->AddContactPoint(flippedNormal,pointInWorld,depth);
|
||||
m_org->addContactPoint(flippedNormal,pointInWorld,depth);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -150,7 +150,7 @@ static btMinkowskiPenetrationDepthSolver gPenetrationDepthSolver;
|
||||
Solid3EpaPenetrationDepth gSolidEpaPenetrationSolver;
|
||||
#endif //USE_EPA
|
||||
|
||||
void btConvexConvexAlgorithm::CheckPenetrationDepthSolver()
|
||||
void btConvexConvexAlgorithm::checkPenetrationDepthSolver()
|
||||
{
|
||||
if (m_useEpa != gUseEpa)
|
||||
{
|
||||
@@ -158,12 +158,12 @@ void btConvexConvexAlgorithm::CheckPenetrationDepthSolver()
|
||||
if (m_useEpa)
|
||||
{
|
||||
|
||||
// m_gjkPairDetector.SetPenetrationDepthSolver(&gEpaPenetrationDepthSolver);
|
||||
// m_gjkPairDetector.setPenetrationDepthSolver(&gEpaPenetrationDepthSolver);
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
m_gjkPairDetector.SetPenetrationDepthSolver(&gPenetrationDepthSolver);
|
||||
m_gjkPairDetector.setPenetrationDepthSolver(&gPenetrationDepthSolver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
//normalOnBInWorld.normalize();
|
||||
btVector3 pointInWorld(positionsWorld[i].GetX(),positionsWorld[i].GetY(),positionsWorld[i].GetZ());
|
||||
float depth = -depths[i];
|
||||
m_manifoldResult.AddContactPoint(normalOnBInWorld,pointInWorld,depth);
|
||||
m_manifoldResult.addContactPoint(normalOnBInWorld,pointInWorld,depth);
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -237,17 +237,17 @@ public:
|
||||
//
|
||||
// Convex-Convex collision algorithm
|
||||
//
|
||||
void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
void btConvexConvexAlgorithm ::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
|
||||
if (!m_manifoldPtr)
|
||||
return;
|
||||
|
||||
CheckPenetrationDepthSolver();
|
||||
checkPenetrationDepthSolver();
|
||||
|
||||
// printf("btConvexConvexAlgorithm::ProcessCollision\n");
|
||||
// printf("btConvexConvexAlgorithm::processCollision\n");
|
||||
|
||||
bool needsCollision = m_dispatcher->NeedsCollision(m_box0,m_box1);
|
||||
bool needsCollision = m_dispatcher->needsCollision(m_box0,m_box1);
|
||||
if (!needsCollision)
|
||||
return;
|
||||
|
||||
@@ -259,8 +259,8 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
|
||||
|
||||
if (dispatchInfo.m_enableSatConvex)
|
||||
{
|
||||
if ((col0->m_collisionShape->IsPolyhedral()) &&
|
||||
(col1->m_collisionShape->IsPolyhedral()))
|
||||
if ((col0->m_collisionShape->isPolyhedral()) &&
|
||||
(col1->m_collisionShape->isPolyhedral()))
|
||||
{
|
||||
|
||||
|
||||
@@ -283,8 +283,8 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
|
||||
Transform trB = GetTransformFrombtTransform(col1->m_worldTransform);
|
||||
|
||||
//either use persistent manifold or clear it every time
|
||||
m_dispatcher->ClearManifold(m_manifoldPtr);
|
||||
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
m_dispatcher->clearManifold(m_manifoldPtr);
|
||||
btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
|
||||
btManifoldResultCollector hullContactCollector(*resultOut);
|
||||
|
||||
@@ -301,7 +301,7 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
|
||||
#endif //USE_HULL
|
||||
|
||||
|
||||
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
|
||||
btConvexShape* min0 = static_cast<btConvexShape*>(col0->m_collisionShape);
|
||||
btConvexShape* min1 = static_cast<btConvexShape*>(col1->m_collisionShape);
|
||||
@@ -310,9 +310,9 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
|
||||
|
||||
|
||||
//TODO: if (dispatchInfo.m_useContinuous)
|
||||
m_gjkPairDetector.SetMinkowskiA(min0);
|
||||
m_gjkPairDetector.SetMinkowskiB(min1);
|
||||
input.m_maximumDistanceSquared = min0->GetMargin() + min1->GetMargin() + m_manifoldPtr->GetContactBreakingTreshold();
|
||||
m_gjkPairDetector.setMinkowskiA(min0);
|
||||
m_gjkPairDetector.setMinkowskiB(min1);
|
||||
input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingTreshold();
|
||||
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
||||
|
||||
// input.m_maximumDistanceSquared = 1e30f;
|
||||
@@ -320,15 +320,15 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
|
||||
input.m_transformA = col0->m_worldTransform;
|
||||
input.m_transformB = col1->m_worldTransform;
|
||||
|
||||
m_gjkPairDetector.GetClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
|
||||
m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
|
||||
|
||||
m_dispatcher->ReleaseManifoldResult(resultOut);
|
||||
m_dispatcher->releaseManifoldResult(resultOut);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool disableCcd = false;
|
||||
float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
float btConvexConvexAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
///Rather then checking ALL pairs, only calculate TOI when motion exceeds treshold
|
||||
|
||||
@@ -350,7 +350,7 @@ float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,b
|
||||
if (disableCcd)
|
||||
return 1.f;
|
||||
|
||||
CheckPenetrationDepthSolver();
|
||||
checkPenetrationDepthSolver();
|
||||
|
||||
//An adhoc way of testing the Continuous Collision Detection algorithms
|
||||
//One object is approximated as a sphere, to simplify things
|
||||
@@ -358,7 +358,7 @@ float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,b
|
||||
//For proper CCD, better accuracy and handling of 'allowed' penetration should be added
|
||||
//also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies)
|
||||
|
||||
bool needsCollision = m_dispatcher->NeedsCollision(m_box0,m_box1);
|
||||
bool needsCollision = m_dispatcher->needsCollision(m_box0,m_box1);
|
||||
|
||||
if (!needsCollision)
|
||||
return 1.f;
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
btPersistentManifold* m_manifoldPtr;
|
||||
bool m_lowLevelOfDetail;
|
||||
|
||||
void CheckPenetrationDepthSolver();
|
||||
void checkPenetrationDepthSolver();
|
||||
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ public:
|
||||
|
||||
virtual ~btConvexConvexAlgorithm();
|
||||
|
||||
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
void SetLowLevelOfDetail(bool useLowLevel);
|
||||
void setLowLevelOfDetail(bool useLowLevel);
|
||||
|
||||
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
{
|
||||
m_gjkPairDetector.m_partId0=partId0;
|
||||
m_gjkPairDetector.m_partId1=partId1;
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
m_gjkPairDetector.m_index1=index1;
|
||||
}
|
||||
|
||||
const btPersistentManifold* GetManifold()
|
||||
const btPersistentManifold* getManifold()
|
||||
{
|
||||
return m_manifoldPtr;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ btEmptyAlgorithm::btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& c
|
||||
{
|
||||
}
|
||||
|
||||
void btEmptyAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
void btEmptyAlgorithm::processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float btEmptyAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
float btEmptyAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ public:
|
||||
|
||||
btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
|
||||
|
||||
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||
{
|
||||
|
||||
@@ -51,9 +51,9 @@ btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* b
|
||||
}
|
||||
|
||||
|
||||
void btManifoldResult::AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
||||
void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
||||
{
|
||||
if (depth > m_manifoldPtr->GetContactBreakingTreshold())
|
||||
if (depth > m_manifoldPtr->getContactBreakingTreshold())
|
||||
return;
|
||||
|
||||
|
||||
@@ -69,14 +69,14 @@ void btManifoldResult::AddContactPoint(const btVector3& normalOnBInWorld,const b
|
||||
|
||||
|
||||
|
||||
int insertIndex = m_manifoldPtr->GetCacheEntry(newPt);
|
||||
int insertIndex = m_manifoldPtr->getCacheEntry(newPt);
|
||||
if (insertIndex >= 0)
|
||||
{
|
||||
|
||||
// This is not needed, just use the old info!
|
||||
// const btManifoldPoint& oldPoint = m_manifoldPtr->GetContactPoint(insertIndex);
|
||||
// const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex);
|
||||
// newPt.CopyPersistentInformation(oldPoint);
|
||||
// m_manifoldPtr->ReplaceContactPoint(newPt,insertIndex);
|
||||
// m_manifoldPtr->replaceContactPoint(newPt,insertIndex);
|
||||
|
||||
|
||||
} else
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
virtual ~btManifoldResult() {};
|
||||
|
||||
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
{
|
||||
m_partId0=partId0;
|
||||
m_partId1=partId1;
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
m_index1=index1;
|
||||
}
|
||||
|
||||
virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);
|
||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,23 +18,23 @@ btSimulationIslandManager::~btSimulationIslandManager()
|
||||
}
|
||||
|
||||
|
||||
void btSimulationIslandManager::InitUnionFind(int n)
|
||||
void btSimulationIslandManager::initUnionFind(int n)
|
||||
{
|
||||
m_unionFind.reset(n);
|
||||
}
|
||||
|
||||
|
||||
void btSimulationIslandManager::FindUnions(btDispatcher* dispatcher)
|
||||
void btSimulationIslandManager::findUnions(btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
{
|
||||
for (int i=0;i<dispatcher->GetNumManifolds();i++)
|
||||
for (int i=0;i<dispatcher->getNumManifolds();i++)
|
||||
{
|
||||
const btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i);
|
||||
const btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
|
||||
//static objects (invmass 0.f) don't merge !
|
||||
|
||||
const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->GetBody0());
|
||||
const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->GetBody1());
|
||||
const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->getBody0());
|
||||
const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->getBody1());
|
||||
|
||||
if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
|
||||
((colObj1) && ((colObj1)->mergesSimulationIslands())))
|
||||
@@ -48,18 +48,18 @@ void btSimulationIslandManager::FindUnions(btDispatcher* dispatcher)
|
||||
}
|
||||
|
||||
|
||||
void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher)
|
||||
void btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
InitUnionFind(colWorld->GetCollisionObjectArray().size());
|
||||
initUnionFind(colWorld->getCollisionObjectArray().size());
|
||||
|
||||
// put the index into m_controllers into m_tag
|
||||
{
|
||||
std::vector<btCollisionObject*>::iterator i;
|
||||
|
||||
int index = 0;
|
||||
for (i=colWorld->GetCollisionObjectArray().begin();
|
||||
!(i==colWorld->GetCollisionObjectArray().end()); i++)
|
||||
for (i=colWorld->getCollisionObjectArray().begin();
|
||||
!(i==colWorld->getCollisionObjectArray().end()); i++)
|
||||
{
|
||||
|
||||
btCollisionObject* collisionObject= (*i);
|
||||
@@ -71,7 +71,7 @@ void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld
|
||||
}
|
||||
// do the union find
|
||||
|
||||
FindUnions(dispatcher);
|
||||
findUnions(dispatcher);
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld
|
||||
|
||||
|
||||
|
||||
void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* colWorld)
|
||||
void btSimulationIslandManager::storeIslandActivationState(btCollisionWorld* colWorld)
|
||||
{
|
||||
// put the islandId ('find' value) into m_tag
|
||||
{
|
||||
@@ -89,8 +89,8 @@ void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* col
|
||||
std::vector<btCollisionObject*>::iterator i;
|
||||
|
||||
int index = 0;
|
||||
for (i=colWorld->GetCollisionObjectArray().begin();
|
||||
!(i==colWorld->GetCollisionObjectArray().end()); i++)
|
||||
for (i=colWorld->getCollisionObjectArray().begin();
|
||||
!(i==colWorld->getCollisionObjectArray().end()); i++)
|
||||
{
|
||||
btCollisionObject* collisionObject= (*i);
|
||||
|
||||
@@ -109,8 +109,8 @@ void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* col
|
||||
inline int getIslandId(const btPersistentManifold* lhs)
|
||||
{
|
||||
int islandId;
|
||||
const btCollisionObject* rcolObj0 = static_cast<const btCollisionObject*>(lhs->GetBody0());
|
||||
const btCollisionObject* rcolObj1 = static_cast<const btCollisionObject*>(lhs->GetBody1());
|
||||
const btCollisionObject* rcolObj0 = static_cast<const btCollisionObject*>(lhs->getBody0());
|
||||
const btCollisionObject* rcolObj1 = static_cast<const btCollisionObject*>(lhs->getBody1());
|
||||
islandId= rcolObj0->m_islandTag1>=0?rcolObj0->m_islandTag1:rcolObj1->m_islandTag1;
|
||||
return islandId;
|
||||
|
||||
@@ -128,21 +128,21 @@ bool btPersistentManifoldSortPredicate(const btPersistentManifold* lhs, const bt
|
||||
//
|
||||
// todo: this is random access, it can be walked 'cache friendly'!
|
||||
//
|
||||
void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
|
||||
void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
|
||||
{
|
||||
//we are going to sort the unionfind array, and store the element id in the size
|
||||
//afterwards, we clean unionfind, to make sure no-one uses it anymore
|
||||
|
||||
GetUnionFind().sortIslands();
|
||||
int numElem = GetUnionFind().getNumElements();
|
||||
getUnionFind().sortIslands();
|
||||
int numElem = getUnionFind().getNumElements();
|
||||
|
||||
int endIslandIndex=1;
|
||||
|
||||
//update the sleeping state for bodies, if all are sleeping
|
||||
for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
|
||||
{
|
||||
int islandId = GetUnionFind().getElement(startIslandIndex).m_id;
|
||||
for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (GetUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
|
||||
int islandId = getUnionFind().getElement(startIslandIndex).m_id;
|
||||
for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
|
||||
int idx;
|
||||
for (idx=startIslandIndex;idx<endIslandIndex;idx++)
|
||||
{
|
||||
int i = GetUnionFind().getElement(idx).m_sz;
|
||||
int i = getUnionFind().getElement(idx).m_sz;
|
||||
|
||||
btCollisionObject* colObj0 = collisionObjects[i];
|
||||
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
|
||||
@@ -180,7 +180,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
|
||||
int idx;
|
||||
for (idx=startIslandIndex;idx<endIslandIndex;idx++)
|
||||
{
|
||||
int i = GetUnionFind().getElement(idx).m_sz;
|
||||
int i = getUnionFind().getElement(idx).m_sz;
|
||||
btCollisionObject* colObj0 = collisionObjects[i];
|
||||
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
|
||||
{
|
||||
@@ -200,7 +200,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
|
||||
int idx;
|
||||
for (idx=startIslandIndex;idx<endIslandIndex;idx++)
|
||||
{
|
||||
int i = GetUnionFind().getElement(idx).m_sz;
|
||||
int i = getUnionFind().getElement(idx).m_sz;
|
||||
|
||||
btCollisionObject* colObj0 = collisionObjects[i];
|
||||
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
|
||||
@@ -223,22 +223,22 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
|
||||
|
||||
std::vector<btPersistentManifold*> islandmanifold;
|
||||
int i;
|
||||
int maxNumManifolds = dispatcher->GetNumManifolds();
|
||||
int maxNumManifolds = dispatcher->getNumManifolds();
|
||||
islandmanifold.reserve(maxNumManifolds);
|
||||
|
||||
for (i=0;i<maxNumManifolds ;i++)
|
||||
{
|
||||
btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i);
|
||||
btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
|
||||
|
||||
btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->GetBody0());
|
||||
btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->GetBody1());
|
||||
btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->getBody0());
|
||||
btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
|
||||
|
||||
//todo: check sleeping conditions!
|
||||
if (((colObj0) && colObj0->GetActivationState() != ISLAND_SLEEPING) ||
|
||||
((colObj1) && colObj1->GetActivationState() != ISLAND_SLEEPING))
|
||||
{
|
||||
//filtering for response
|
||||
if (dispatcher->NeedsResponse(*colObj0,*colObj1))
|
||||
if (dispatcher->needsResponse(*colObj0,*colObj1))
|
||||
islandmanifold.push_back(manifold);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,16 @@ public:
|
||||
virtual ~btSimulationIslandManager();
|
||||
|
||||
|
||||
void InitUnionFind(int n);
|
||||
void initUnionFind(int n);
|
||||
|
||||
|
||||
btUnionFind& GetUnionFind() { return m_unionFind;}
|
||||
btUnionFind& getUnionFind() { return m_unionFind;}
|
||||
|
||||
virtual void UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
|
||||
virtual void StoreIslandActivationState(btCollisionWorld* world);
|
||||
virtual void updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
|
||||
virtual void storeIslandActivationState(btCollisionWorld* world);
|
||||
|
||||
|
||||
void FindUnions(btDispatcher* dispatcher);
|
||||
void findUnions(btDispatcher* dispatcher);
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
virtual void ProcessIsland(class btPersistentManifold** manifolds,int numManifolds) = 0;
|
||||
};
|
||||
|
||||
void BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
||||
void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentM
|
||||
m_ownManifold(false),
|
||||
m_manifoldPtr(mf)
|
||||
{
|
||||
if (!m_manifoldPtr && m_dispatcher->NeedsCollision(*proxy0,*proxy1))
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(*proxy0,*proxy1))
|
||||
{
|
||||
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
|
||||
m_ownManifold = true;
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,11 @@ btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm()
|
||||
if (m_ownManifold)
|
||||
{
|
||||
if (m_manifoldPtr)
|
||||
m_dispatcher->ReleaseManifold(m_manifoldPtr);
|
||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||
}
|
||||
}
|
||||
|
||||
void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
void btSphereSphereCollisionAlgorithm::processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
if (!m_manifoldPtr)
|
||||
return;
|
||||
@@ -51,8 +51,8 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
|
||||
|
||||
btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin();
|
||||
float len = diff.length();
|
||||
btScalar radius0 = sphere0->GetRadius();
|
||||
btScalar radius1 = sphere1->GetRadius();
|
||||
btScalar radius0 = sphere0->getRadius();
|
||||
btScalar radius1 = sphere1->getRadius();
|
||||
|
||||
///iff distance positive, don't generate a new contact
|
||||
if ( len > (radius0+radius1))
|
||||
@@ -68,13 +68,13 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
|
||||
btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB;
|
||||
|
||||
/// report a contact. internally this will be kept persistent, and contact reduction is done
|
||||
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
resultOut->AddContactPoint(normalOnSurfaceB,pos1,dist);
|
||||
m_dispatcher->ReleaseManifoldResult(resultOut);
|
||||
btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
|
||||
resultOut->addContactPoint(normalOnSurfaceB,pos1,dist);
|
||||
m_dispatcher->releaseManifoldResult(resultOut);
|
||||
|
||||
}
|
||||
|
||||
float btSphereSphereCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
float btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
//not yet
|
||||
return 1.f;
|
||||
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||
: btCollisionAlgorithm(ci) {}
|
||||
|
||||
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
|
||||
|
||||
btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ btUnionFind::btUnionFind()
|
||||
|
||||
}
|
||||
|
||||
void btUnionFind::Allocate(int N)
|
||||
void btUnionFind::allocate(int N)
|
||||
{
|
||||
m_elements.resize(N);
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void btUnionFind::Free()
|
||||
|
||||
void btUnionFind::reset(int N)
|
||||
{
|
||||
Allocate(N);
|
||||
allocate(N);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ class btUnionFind
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
void Allocate(int N);
|
||||
void allocate(int N);
|
||||
void Free();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user