Fixes for broadphase/paircache determinism.

Revert definition for ATTRIBUTE_ALIGNED16, and try to force sizeof(btSolverConstraint) by using unions with btScalar, for non-btScalar data types.
Use btAssert and not assert.
Don't access btAlignedObjectArray elements, for zero sets
This commit is contained in:
erwin.coumans
2009-02-10 23:50:21 +00:00
parent be3260280a
commit 7a2a98078a
35 changed files with 323 additions and 205 deletions

View File

@@ -1262,33 +1262,27 @@ void DemoApplication::clientResetScene()
gNumClampedCcdMotions = 0; gNumClampedCcdMotions = 0;
int numObjects = 0; int numObjects = 0;
int i;
if (m_dynamicsWorld) if (m_dynamicsWorld)
{ {
numObjects = m_dynamicsWorld->getNumCollisionObjects(); numObjects = m_dynamicsWorld->getNumCollisionObjects();
} }
#ifdef TEST_DETERMINISM
btCollisionObjectArray copyArray = m_dynamicsWorld->getCollisionObjectArray(); btCollisionObjectArray copyArray = m_dynamicsWorld->getCollisionObjectArray();
for (int i=0;i<copyArray.size();i++) for (i=0;i<copyArray.size();i++)
{ {
btRigidBody* body = btRigidBody::upcast(copyArray[i]); btRigidBody* body = btRigidBody::upcast(copyArray[i]);
if (body) if (body)
m_dynamicsWorld->removeRigidBody(body); m_dynamicsWorld->removeRigidBody(body);
} }
for (int i=0;i<copyArray.size();i++)
{
btRigidBody* body = btRigidBody::upcast(copyArray[i]);
if (body)
m_dynamicsWorld->addRigidBody(btRigidBody::upcast(copyArray[i]));
}
#endif //TEST_DETERMINISM
for (int i=0;i<numObjects;i++) for (i=0;i<numObjects;i++)
{ {
btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i]; btCollisionObject* colObj = copyArray[i];
btRigidBody* body = btRigidBody::upcast(colObj); btRigidBody* body = btRigidBody::upcast(colObj);
if (body) if (body)
{ {
@@ -1304,7 +1298,7 @@ void DemoApplication::clientResetScene()
//colObj->setActivationState(WANTS_DEACTIVATION); //colObj->setActivationState(WANTS_DEACTIVATION);
} }
//removed cached contact points //removed cached contact points
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(colObj->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher()); //m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(colObj->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
btRigidBody* body = btRigidBody::upcast(colObj); btRigidBody* body = btRigidBody::upcast(colObj);
if (body && !body->isStaticObject()) if (body && !body->isStaticObject())
@@ -1318,7 +1312,13 @@ void DemoApplication::clientResetScene()
m_dynamicsWorld->getBroadphase()->resetPool(getDynamicsWorld()->getDispatcher()); m_dynamicsWorld->getBroadphase()->resetPool(getDynamicsWorld()->getDispatcher());
m_dynamicsWorld->getPairCache()->sortOverlappingPairs(getDynamicsWorld()->getDispatcher()); for ( i=0;i<copyArray.size();i++)
{
btRigidBody* body = btRigidBody::upcast(copyArray[i]);
if (body)
m_dynamicsWorld->addRigidBody(btRigidBody::upcast(copyArray[i]));
}
} }

View File

@@ -296,7 +296,7 @@ void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
break; break;
default: default:
{ {
assert(0); btAssert(0);
} }
} }

View File

@@ -193,7 +193,7 @@ bool Raytracer::worldRaytest(const btVector3& rayFrom,const btVector3& rayTo,btV
{ {
//caller already does the filter on the m_closestHitFraction //caller already does the filter on the m_closestHitFraction
assert(rayResult.m_hitFraction <= m_closestHitFraction); btAssert(rayResult.m_hitFraction <= m_closestHitFraction);
m_closestHitFraction = rayResult.m_hitFraction; m_closestHitFraction = rayResult.m_hitFraction;

View File

@@ -19,7 +19,6 @@
// 3. This notice may not be removed or altered from any source distribution. // 3. This notice may not be removed or altered from any source distribution.
#include "btAxisSweep3.h" #include "btAxisSweep3.h"
#include <assert.h>
btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator) btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
:btAxisSweep3Internal<unsigned short int>(worldAabbMin,worldAabbMax,0xfffe,0xffff,maxHandles,pairCache,disableRaycastAccelerator) :btAxisSweep3Internal<unsigned short int>(worldAabbMin,worldAabbMax,0xfffe,0xffff,maxHandles,pairCache,disableRaycastAccelerator)

View File

@@ -221,7 +221,7 @@ void btAxisSweep3<BP_FP_INT_TYPE>::debugPrintAxis(int axis, bool checkCardinalit
} }
if (checkCardinality) if (checkCardinality)
assert(numEdges == m_numHandles*2+1); btAssert(numEdges == m_numHandles*2+1);
} }
#endif //DEBUG_BROADPHASE #endif //DEBUG_BROADPHASE
@@ -347,7 +347,7 @@ m_raycastAccelerator(0)
m_raycastAccelerator->m_deferedcollide = true;//don't add/remove pairs m_raycastAccelerator->m_deferedcollide = true;//don't add/remove pairs
} }
//assert(bounds.HasVolume()); //btAssert(bounds.HasVolume());
// init bounds // init bounds
m_worldAabbMin = worldAabbMin; m_worldAabbMin = worldAabbMin;
@@ -453,7 +453,7 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::quantize(BP_FP_INT_TYPE* out, const b
template <typename BP_FP_INT_TYPE> template <typename BP_FP_INT_TYPE>
BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle() BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
{ {
assert(m_firstFreeHandle); btAssert(m_firstFreeHandle);
BP_FP_INT_TYPE handle = m_firstFreeHandle; BP_FP_INT_TYPE handle = m_firstFreeHandle;
m_firstFreeHandle = getHandle(handle)->GetNextFree(); m_firstFreeHandle = getHandle(handle)->GetNextFree();
@@ -465,7 +465,7 @@ BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
template <typename BP_FP_INT_TYPE> template <typename BP_FP_INT_TYPE>
void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle) void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
{ {
assert(handle > 0 && handle < m_maxHandles); btAssert(handle > 0 && handle < m_maxHandles);
getHandle(handle)->SetNextFree(m_firstFreeHandle); getHandle(handle)->SetNextFree(m_firstFreeHandle);
m_firstFreeHandle = handle; m_firstFreeHandle = handle;
@@ -611,8 +611,83 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatche
if (m_pairCache->hasDeferredRemoval()) if (m_pairCache->hasDeferredRemoval())
{ {
m_pairCache->performDeferredRemoval(dispatcher);
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
m_invalidPair = 0;
int i;
btBroadphasePair previousPair;
previousPair.m_pProxy0 = 0;
previousPair.m_pProxy1 = 0;
previousPair.m_algorithm = 0;
for (i=0;i<overlappingPairArray.size();i++)
{
btBroadphasePair& pair = overlappingPairArray[i];
bool isDuplicate = (pair == previousPair);
previousPair = pair;
bool needsRemoval = false;
if (!isDuplicate)
{
///important to use an AABB test that is consistent with the broadphase
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
if (hasOverlap)
{
needsRemoval = false;//callback->processOverlap(pair);
} else
{
needsRemoval = true;
}
} else
{
//remove duplicate
needsRemoval = true;
//should have no algorithm
btAssert(!pair.m_algorithm);
}
if (needsRemoval)
{
m_pairCache->cleanOverlappingPair(pair,dispatcher);
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
// m_overlappingPairArray.pop_back();
pair.m_pProxy0 = 0;
pair.m_pProxy1 = 0;
m_invalidPair++;
gOverlappingPairs--;
}
}
///if you don't like to skip the invalid pairs in the array, execute following code:
#define CLEAN_INVALID_PAIRS 1
#ifdef CLEAN_INVALID_PAIRS
//perform a sort, to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
m_invalidPair = 0;
#endif//CLEAN_INVALID_PAIRS
//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
} }
} }
@@ -653,8 +728,8 @@ bool btAxisSweep3Internal<BP_FP_INT_TYPE>::testOverlap2D(const Handle* pHandleA,
template <typename BP_FP_INT_TYPE> template <typename BP_FP_INT_TYPE>
void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher) void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher)
{ {
// assert(bounds.IsFinite()); // btAssert(bounds.IsFinite());
//assert(bounds.HasVolume()); //btAssert(bounds.HasVolume());
Handle* pHandle = getHandle(handle); Handle* pHandle = getHandle(handle);

View File

@@ -424,9 +424,14 @@ btDbvt::~btDbvt()
// //
void btDbvt::clear() void btDbvt::clear()
{ {
if(m_root) recursedeletenode(this,m_root); if(m_root)
recursedeletenode(this,m_root);
btAlignedFree(m_free); btAlignedFree(m_free);
m_free=0; m_free=0;
m_lkhd = -1;
m_stkStack.clear();
m_opath = 0;
} }
// //

View File

@@ -133,9 +133,7 @@ btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache* paircache)
m_updates_call = 0; m_updates_call = 0;
m_updates_done = 0; m_updates_done = 0;
m_updates_ratio = 0; m_updates_ratio = 0;
m_paircache = paircache? m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
paircache :
new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
m_gid = 0; m_gid = 0;
m_pid = 0; m_pid = 0;
m_cid = 0; m_cid = 0;
@@ -342,16 +340,102 @@ void btDbvtBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
} }
#endif #endif
performDeferredRemoval(dispatcher);
}
void btDbvtBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
{
if (m_paircache->hasDeferredRemoval()) if (m_paircache->hasDeferredRemoval())
{ {
m_paircache->performDeferredRemoval(dispatcher);
}
btBroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray();
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
int invalidPair = 0;
int i;
btBroadphasePair previousPair;
previousPair.m_pProxy0 = 0;
previousPair.m_pProxy1 = 0;
previousPair.m_algorithm = 0;
for (i=0;i<overlappingPairArray.size();i++)
{
btBroadphasePair& pair = overlappingPairArray[i];
bool isDuplicate = (pair == previousPair);
previousPair = pair;
bool needsRemoval = false;
if (!isDuplicate)
{
//important to perform AABB check that is consistent with the broadphase
btDbvtProxy* pa=(btDbvtProxy*)pair.m_pProxy0;
btDbvtProxy* pb=(btDbvtProxy*)pair.m_pProxy1;
bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume);
if (hasOverlap)
{
needsRemoval = false;
} else
{
needsRemoval = true;
}
} else
{
//remove duplicate
needsRemoval = true;
//should have no algorithm
btAssert(!pair.m_algorithm);
}
if (needsRemoval)
{
m_paircache->cleanOverlappingPair(pair,dispatcher);
pair.m_pProxy0 = 0;
pair.m_pProxy1 = 0;
invalidPair++;
}
}
//perform a sort, to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);
}
} }
// //
void btDbvtBroadphase::collide(btDispatcher* dispatcher) void btDbvtBroadphase::collide(btDispatcher* dispatcher)
{ {
/*printf("---------------------------------------------------------\n");
printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves);
printf("m_sets[1].m_leaves=%d\n",m_sets[1].m_leaves);
printf("numPairs = %d\n",getOverlappingPairCache()->getNumOverlappingPairs());
{
int i;
for (i=0;i<getOverlappingPairCache()->getNumOverlappingPairs();i++)
{
printf("pair[%d]=(%d,%d),",i,getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy0->getUid(),
getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy1->getUid());
}
printf("\n");
}
*/
SPC(m_profiling.m_total); SPC(m_profiling.m_total);
/* optimize */ /* optimize */
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100); m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
@@ -407,11 +491,11 @@ void btDbvtBroadphase::collide(btDispatcher* dispatcher)
btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray(); btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
if(pairs.size()>0) if(pairs.size()>0)
{ {
const int ci=pairs.size();
int ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100)); int ni=btMin(pairs.size(),btMax<int>(m_newpairs,(pairs.size()*m_cupdates)/100));
for(int i=0;i<ni;++i) for(int i=0;i<ni;++i)
{ {
btBroadphasePair& p=pairs[(m_cid+i)%ci]; btBroadphasePair& p=pairs[(m_cid+i)%pairs.size()];
btDbvtProxy* pa=(btDbvtProxy*)p.m_pProxy0; btDbvtProxy* pa=(btDbvtProxy*)p.m_pProxy0;
btDbvtProxy* pb=(btDbvtProxy*)p.m_pProxy1; btDbvtProxy* pb=(btDbvtProxy*)p.m_pProxy1;
if(!Intersect(pa->leaf->volume,pb->leaf->volume)) if(!Intersect(pa->leaf->volume,pb->leaf->volume))
@@ -477,26 +561,35 @@ void btDbvtBroadphase::getBroadphaseAabb(btVector3& aabbMin,btVector3& aab
void btDbvtBroadphase::resetPool(btDispatcher* dispatcher) void btDbvtBroadphase::resetPool(btDispatcher* dispatcher)
{ {
return;
m_sets[0].optimizeBottomUp();
m_sets[1].optimizeBottomUp();
int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves;
btDbvtProxy* current=m_stageRoots[m_stageCurrent]; if (!totalObjects)
if(current)
{ {
btDbvtTreeCollider collider(this); //reset internal dynamic tree data structures
do { m_sets[0].clear();
btDbvtProxy* next=current->links[1]; m_sets[1].clear();
listremove(current,m_stageRoots[current->stage]);
listappend(current,m_stageRoots[m_stageCurrent]); m_deferedcollide = false;
current->stage = m_stageCurrent; m_needcleanup = true;
current = next; m_prediction = 1/(btScalar)2;
} while(current); m_stageCurrent = 0;
m_fixedleft = 0;
m_fupdates = 1;
m_dupdates = 0;
m_cupdates = 10;
m_newpairs = 1;
m_updates_call = 0;
m_updates_done = 0;
m_updates_ratio = 0;
m_gid = 0;
m_pid = 0;
m_cid = 0;
for(int i=0;i<=STAGECOUNT;++i)
{
m_stageRoots[i]=0;
}
} }
} }
// //

View File

@@ -115,6 +115,9 @@ struct btDbvtBroadphase : btBroadphaseInterface
void printStats(); void printStats();
static void benchmark(btBroadphaseInterface*); static void benchmark(btBroadphaseInterface*);
void performDeferredRemoval(btDispatcher* dispatcher);
///reset broadphase internal structures, to ensure determinism/reproducability ///reset broadphase internal structures, to ensure determinism/reproducability
virtual void resetPool(btDispatcher* dispatcher); virtual void resetPool(btDispatcher* dispatcher);

View File

@@ -462,7 +462,7 @@ void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{ {
//don't add overlap with own //don't add overlap with own
assert(proxy0 != proxy1); btAssert(proxy0 != proxy1);
if (!needsBroadphaseCollision(proxy0,proxy1)) if (!needsBroadphaseCollision(proxy0,proxy1))
return 0; return 0;
@@ -493,7 +493,7 @@ btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseP
if (findIndex < m_overlappingPairArray.size()) if (findIndex < m_overlappingPairArray.size())
{ {
//assert(it != m_overlappingPairSet.end()); //btAssert(it != m_overlappingPairSet.end());
btBroadphasePair* pair = &m_overlappingPairArray[findIndex]; btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
return pair; return pair;
} }
@@ -631,70 +631,3 @@ void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher
//should already be sorted //should already be sorted
} }
void btSortedOverlappingPairCache::performDeferredRemoval(btDispatcher* dispatcher)
{
btBroadphasePairArray& overlappingPairArray = getOverlappingPairArray();
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
int invalidPair = 0;
int i;
btBroadphasePair previousPair;
previousPair.m_pProxy0 = 0;
previousPair.m_pProxy1 = 0;
previousPair.m_algorithm = 0;
for (i=0;i<overlappingPairArray.size();i++)
{
btBroadphasePair& pair = overlappingPairArray[i];
bool isDuplicate = (pair == previousPair);
previousPair = pair;
bool needsRemoval = false;
if (!isDuplicate)
{
bool hasOverlap = TestAabbAgainstAabb2(pair.m_pProxy0->m_aabbMin,pair.m_pProxy0->m_aabbMax,pair.m_pProxy1->m_aabbMin,pair.m_pProxy1->m_aabbMax);
if (hasOverlap)
{
needsRemoval = false;
} else
{
needsRemoval = true;
}
} else
{
//remove duplicate
needsRemoval = true;
//should have no algorithm
btAssert(!pair.m_algorithm);
}
if (needsRemoval)
{
cleanOverlappingPair(pair,dispatcher);
pair.m_pProxy0 = 0;
pair.m_pProxy1 = 0;
invalidPair++;
}
}
//perform a sort, to sort 'invalid' pairs to the end
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);
}

View File

@@ -86,7 +86,6 @@ public:
virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0; virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0;
virtual void performDeferredRemoval(btDispatcher* dispatcher) = 0;
}; };
@@ -265,10 +264,6 @@ private:
virtual void sortOverlappingPairs(btDispatcher* dispatcher); virtual void sortOverlappingPairs(btDispatcher* dispatcher);
virtual void performDeferredRemoval(btDispatcher* dispatcher)
{
}
protected: protected:
@@ -382,8 +377,6 @@ class btSortedOverlappingPairCache : public btOverlappingPairCache
virtual void sortOverlappingPairs(btDispatcher* dispatcher); virtual void sortOverlappingPairs(btDispatcher* dispatcher);
void performDeferredRemoval(btDispatcher* dispatcher);
}; };
@@ -466,9 +459,6 @@ public:
{ {
} }
virtual void performDeferredRemoval(btDispatcher* dispatcher)
{
}
}; };

View File

@@ -52,7 +52,7 @@ btCollisionDispatcher::btCollisionDispatcher (btCollisionConfiguration* collisio
for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++) for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++)
{ {
m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j); m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j);
assert(m_doubleDispatch[i][j]); btAssert(m_doubleDispatch[i][j]);
} }
} }
@@ -160,8 +160,8 @@ bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionOb
bool btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1) bool btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
{ {
assert(body0); btAssert(body0);
assert(body1); btAssert(body1);
bool needsCollision = true; bool needsCollision = true;

View File

@@ -29,7 +29,7 @@ m_sharedManifold(ci.m_manifold)
m_ownsManifold = false; m_ownsManifold = false;
btCollisionObject* colObj = m_isSwapped? body1 : body0; btCollisionObject* colObj = m_isSwapped? body1 : body0;
assert (colObj->getCollisionShape()->isCompound()); btAssert (colObj->getCollisionShape()->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
m_compoundShapeRevision = compoundShape->getUpdateRevision(); m_compoundShapeRevision = compoundShape->getUpdateRevision();
@@ -41,7 +41,7 @@ void btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject*
{ {
btCollisionObject* colObj = m_isSwapped? body1 : body0; btCollisionObject* colObj = m_isSwapped? body1 : body0;
btCollisionObject* otherObj = m_isSwapped? body0 : body1; btCollisionObject* otherObj = m_isSwapped? body0 : body1;
assert (colObj->getCollisionShape()->isCompound()); btAssert (colObj->getCollisionShape()->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
@@ -186,7 +186,7 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
assert (colObj->getCollisionShape()->isCompound()); btAssert (colObj->getCollisionShape()->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
///btCompoundShape might have changed: ///btCompoundShape might have changed:
@@ -296,7 +296,7 @@ btScalar btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject*
btCollisionObject* colObj = m_isSwapped? body1 : body0; btCollisionObject* colObj = m_isSwapped? body1 : body0;
btCollisionObject* otherObj = m_isSwapped? body0 : body1; btCollisionObject* otherObj = m_isSwapped? body0 : body1;
assert (colObj->getCollisionShape()->isCompound()); btAssert (colObj->getCollisionShape()->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());

View File

@@ -55,7 +55,7 @@ btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* b
void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
{ {
assert(m_manifoldPtr); btAssert(m_manifoldPtr);
//order in manifold needs to match //order in manifold needs to match
if (depth > m_manifoldPtr->getContactBreakingThreshold()) if (depth > m_manifoldPtr->getContactBreakingThreshold())

View File

@@ -43,10 +43,10 @@ void btSimulationIslandManager::findUnions(btDispatcher* /* dispatcher */,btColl
{ {
{ {
btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++) for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++)
{ {
btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
const btBroadphasePair& collisionPair = pairPtr[i]; const btBroadphasePair& collisionPair = pairPtr[i];
btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject; btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
@@ -185,7 +185,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisio
// printf("error in island management\n"); // printf("error in island management\n");
} }
assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId) if (colObj0->getIslandTag() == islandId)
{ {
if (colObj0->getActivationState()== ACTIVE_TAG) if (colObj0->getActivationState()== ACTIVE_TAG)
@@ -212,7 +212,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisio
// printf("error in island management\n"); // printf("error in island management\n");
} }
assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId) if (colObj0->getIslandTag() == islandId)
{ {
@@ -233,7 +233,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisio
// printf("error in island management\n"); // printf("error in island management\n");
} }
assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId) if (colObj0->getIslandTag() == islandId)
{ {

View File

@@ -14,8 +14,6 @@ subject to the following restrictions:
*/ */
#include "btUnionFind.h" #include "btUnionFind.h"
#include <assert.h>

View File

@@ -98,8 +98,8 @@ class btUnionFind
int find(int x) int find(int x)
{ {
//assert(x < m_N); //btAssert(x < m_N);
//assert(x >= 0); //btAssert(x >= 0);
while (x != m_elements[x].m_id) while (x != m_elements[x].m_id)
{ {
@@ -110,8 +110,8 @@ class btUnionFind
m_elements[x].m_id = m_elements[m_elements[x].m_id].m_id; m_elements[x].m_id = m_elements[m_elements[x].m_id].m_id;
#endif // #endif //
x = m_elements[x].m_id; x = m_elements[x].m_id;
//assert(x < m_N); //btAssert(x < m_N);
//assert(x >= 0); //btAssert(x >= 0);
} }
return x; return x;

View File

@@ -179,7 +179,7 @@ public:
plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z()); plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
break; break;
default: default:
assert(0); btAssert(0);
} }
} }
@@ -306,7 +306,7 @@ public:
penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.)); penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
break; break;
default: default:
assert(0); btAssert(0);
} }
} }

View File

@@ -60,7 +60,7 @@ void btConeShape::setConeUpIndex(int upIndex)
m_coneIndices[2] = 1; m_coneIndices[2] = 1;
break; break;
default: default:
assert(0); btAssert(0);
}; };
} }

View File

@@ -181,7 +181,7 @@ void btConvexHullShape::getPlane(btVector3& ,btVector3& ,int ) const
//not yet //not yet
bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
{ {
assert(0); btAssert(0);
return false; return false;
} }

View File

@@ -150,7 +150,7 @@ void btConvexPointCloudShape::getPlane(btVector3& ,btVector3& ,int ) const
//not yet //not yet
bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
{ {
assert(0); btAssert(0);
return false; return false;
} }

View File

@@ -35,13 +35,13 @@ m_weldingThreshold(0.0)
if (m_use32bitIndices) if (m_use32bitIndices)
{ {
m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3; m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0]; m_indexedMeshes[0].m_triangleIndexBase = 0;
m_indexedMeshes[0].m_indexType = PHY_INTEGER; m_indexedMeshes[0].m_indexType = PHY_INTEGER;
m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int); m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
} else } else
{ {
m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3; m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0]; m_indexedMeshes[0].m_triangleIndexBase = 0;
m_indexedMeshes[0].m_indexType = PHY_SHORT; m_indexedMeshes[0].m_indexType = PHY_SHORT;
m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int); m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
} }
@@ -49,12 +49,12 @@ m_weldingThreshold(0.0)
if (m_use4componentVertices) if (m_use4componentVertices)
{ {
m_indexedMeshes[0].m_numVertices = m_4componentVertices.size(); m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0]; m_indexedMeshes[0].m_vertexBase = 0;
m_indexedMeshes[0].m_vertexStride = sizeof(btVector3); m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
} else } else
{ {
m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3; m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; m_indexedMeshes[0].m_vertexBase = 0;
m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar); m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
} }

View File

@@ -40,7 +40,7 @@ public:
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const
{ {
assert(0); btAssert(0);
return localGetSupportingVertex(vec); return localGetSupportingVertex(vec);
} }

View File

@@ -25,8 +25,6 @@ subject to the following restrictions:
#include "btVoronoiSimplexSolver.h" #include "btVoronoiSimplexSolver.h"
#include <assert.h>
//#include <stdio.h>
#define VERTA 0 #define VERTA 0
#define VERTB 1 #define VERTB 1
@@ -37,7 +35,7 @@ subject to the following restrictions:
void btVoronoiSimplexSolver::removeVertex(int index) void btVoronoiSimplexSolver::removeVertex(int index)
{ {
assert(m_numVertices>0); btAssert(m_numVertices>0);
m_numVertices--; m_numVertices--;
m_simplexVectorW[index] = m_simplexVectorW[m_numVertices]; m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
m_simplexPointsP[index] = m_simplexPointsP[m_numVertices]; m_simplexPointsP[index] = m_simplexPointsP[m_numVertices];

View File

@@ -22,7 +22,7 @@ subject to the following restrictions:
#include "LinearMath/btMinMax.h" #include "LinearMath/btMinMax.h"
#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
#define ASSERT2 assert #define ASSERT2 btAssert
#define USE_INTERNAL_APPLY_IMPULSE 1 #define USE_INTERNAL_APPLY_IMPULSE 1
@@ -114,7 +114,7 @@ btScalar resolveSingleCollision(
btScalar Kcor = Kerp *Kfps; btScalar Kcor = Kerp *Kfps;
btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
assert(cpd); btAssert(cpd);
btScalar distance = cpd->m_penetration; btScalar distance = cpd->m_penetration;
btScalar positionalError = Kcor *-distance; btScalar positionalError = Kcor *-distance;
btScalar velocityError = cpd->m_restitution - rel_vel;// * damping; btScalar velocityError = cpd->m_restitution - rel_vel;// * damping;
@@ -166,7 +166,7 @@ btScalar resolveSingleFriction(
btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
assert(cpd); btAssert(cpd);
btScalar combinedFriction = cpd->m_friction; btScalar combinedFriction = cpd->m_friction;
@@ -255,7 +255,7 @@ btScalar resolveSingleFrictionOriginal(
btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition();
btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
assert(cpd); btAssert(cpd);
btScalar combinedFriction = cpd->m_friction; btScalar combinedFriction = cpd->m_friction;
@@ -337,7 +337,7 @@ btScalar resolveSingleCollisionCombined(
btScalar Kcor = Kerp *Kfps; btScalar Kcor = Kerp *Kfps;
btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData; btConstraintPersistentData* cpd = (btConstraintPersistentData*) contactPoint.m_userPersistentData;
assert(cpd); btAssert(cpd);
btScalar distance = cpd->m_penetration; btScalar distance = cpd->m_penetration;
btScalar positionalError = Kcor *-distance; btScalar positionalError = Kcor *-distance;
btScalar velocityError = cpd->m_restitution - rel_vel;// * damping; btScalar velocityError = cpd->m_restitution - rel_vel;// * damping;

View File

@@ -262,7 +262,6 @@ btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(c
solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdA = solverBodyIdA;
solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_solverBodyIdB = solverBodyIdB;
solverConstraint.m_constraintType = btSolverConstraint::BT_SOLVER_FRICTION_1D;
solverConstraint.m_frictionIndex = frictionIndex; solverConstraint.m_frictionIndex = frictionIndex;
solverConstraint.m_friction = cp.m_combinedFriction; solverConstraint.m_friction = cp.m_combinedFriction;
@@ -465,6 +464,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
info2.m_J2linearAxis = 0; info2.m_J2linearAxis = 0;
info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal;
info2.rowskip = sizeof(btSolverConstraint)/sizeof(btScalar);//check this info2.rowskip = sizeof(btSolverConstraint)/sizeof(btScalar);//check this
///the size of btSolverConstraint needs be a multiple of btScalar
btAssert(info2.rowskip*sizeof(btScalar)== sizeof(btSolverConstraint));
info2.m_constraintError = &currentConstraintRow->m_rhs; info2.m_constraintError = &currentConstraintRow->m_rhs;
info2.cfm = &currentConstraintRow->m_cfm; info2.cfm = &currentConstraintRow->m_cfm;
info2.m_lowerLimit = &currentConstraintRow->m_lowerLimit; info2.m_lowerLimit = &currentConstraintRow->m_lowerLimit;
@@ -581,7 +582,6 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdA = solverBodyIdA;
solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_solverBodyIdB = solverBodyIdB;
solverConstraint.m_constraintType = btSolverConstraint::BT_SOLVER_CONTACT_1D;
solverConstraint.m_originalContactPoint = &cp; solverConstraint.m_originalContactPoint = &cp;
@@ -945,6 +945,9 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(
/// btSequentialImpulseConstraintSolver Sequentially applies impulses /// btSequentialImpulseConstraintSolver Sequentially applies impulses
btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/) btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/)
{ {
BT_PROFILE("solveGroup"); BT_PROFILE("solveGroup");
//we only implement SOLVER_CACHE_FRIENDLY now //we only implement SOLVER_CACHE_FRIENDLY now
//you need to provide at least some bodies //you need to provide at least some bodies

View File

@@ -49,9 +49,10 @@ struct btSimdScalar
} }
union union
{ {
__m128 m_vec128; __m128 m_vec128;
float m_floats[4]; float m_floats[4];
int m_ints[4]; int m_ints[4];
btScalar m_unusedPadding;
}; };
SIMD_FORCE_INLINE __m128 get128() SIMD_FORCE_INLINE __m128 get128()
{ {

View File

@@ -37,22 +37,40 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint
//btVector3 m_contactNormal2;//usually m_contactNormal2 == -m_contactNormal //btVector3 m_contactNormal2;//usually m_contactNormal2 == -m_contactNormal
btVector3 m_angularComponentA; btVector3 m_angularComponentA;
btVector3 m_angularComponentB; btVector3 m_angularComponentB;
mutable btSimdScalar m_appliedPushImpulse; mutable btSimdScalar m_appliedPushImpulse;
mutable btSimdScalar m_appliedImpulse; mutable btSimdScalar m_appliedImpulse;
int m_solverBodyIdA;
int m_solverBodyIdB;
btScalar m_friction; btScalar m_friction;
btScalar m_restitution; btScalar m_restitution;
btScalar m_jacDiagABInv; btScalar m_jacDiagABInv;
btScalar m_penetration; btScalar m_penetration;
int m_constraintType;
int m_frictionIndex; union
void* m_originalContactPoint; {
int m_frictionIndex;
btScalar m_unusedPadding1;
};
union
{
int m_solverBodyIdA;
btScalar m_unusedPadding2;
};
union
{
int m_solverBodyIdB;
btScalar m_unusedPadding3;
};
union
{
void* m_originalContactPoint;
btScalar m_unusedPadding4;
};
btScalar m_rhs; btScalar m_rhs;
btScalar m_cfm; btScalar m_cfm;
btScalar m_lowerLimit; btScalar m_lowerLimit;

View File

@@ -67,7 +67,7 @@ public:
int m_numConstraintRows,nub; int m_numConstraintRows,nub;
}; };
ATTRIBUTE_ALIGNED16(struct) btConstraintInfo2 { struct btConstraintInfo2 {
// integrator parameters: frames per second (1/stepsize), default error // integrator parameters: frames per second (1/stepsize), default error
// reduction parameter (0..1). // reduction parameter (0..1).
btScalar fps,erp; btScalar fps,erp;

View File

@@ -110,16 +110,16 @@ void plDeleteDynamicsWorld(plDynamicsWorldHandle world)
void plStepSimulation(plDynamicsWorldHandle world, plReal timeStep) void plStepSimulation(plDynamicsWorldHandle world, plReal timeStep)
{ {
btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
assert(dynamicsWorld); btAssert(dynamicsWorld);
dynamicsWorld->stepSimulation(timeStep); dynamicsWorld->stepSimulation(timeStep);
} }
void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object) void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object)
{ {
btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
assert(dynamicsWorld); btAssert(dynamicsWorld);
btRigidBody* body = reinterpret_cast< btRigidBody* >(object); btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
assert(body); btAssert(body);
dynamicsWorld->addRigidBody(body); dynamicsWorld->addRigidBody(body);
} }
@@ -127,9 +127,9 @@ void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object)
void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object) void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object)
{ {
btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world);
assert(dynamicsWorld); btAssert(dynamicsWorld);
btRigidBody* body = reinterpret_cast< btRigidBody* >(object); btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
assert(body); btAssert(body);
dynamicsWorld->removeRigidBody(body); dynamicsWorld->removeRigidBody(body);
} }
@@ -142,7 +142,7 @@ plRigidBodyHandle plCreateRigidBody( void* user_data, float mass, plCollisionSh
trans.setIdentity(); trans.setIdentity();
btVector3 localInertia(0,0,0); btVector3 localInertia(0,0,0);
btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape); btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
assert(shape); btAssert(shape);
if (mass) if (mass)
{ {
shape->calculateLocalInertia(mass,localInertia); shape->calculateLocalInertia(mass,localInertia);
@@ -158,7 +158,7 @@ plRigidBodyHandle plCreateRigidBody( void* user_data, float mass, plCollisionSh
void plDeleteRigidBody(plRigidBodyHandle cbody) void plDeleteRigidBody(plRigidBodyHandle cbody)
{ {
btRigidBody* body = reinterpret_cast< btRigidBody* >(cbody); btRigidBody* body = reinterpret_cast< btRigidBody* >(cbody);
assert(body); btAssert(body);
btAlignedFree( body); btAlignedFree( body);
} }
@@ -262,13 +262,13 @@ void plAddVertex(plCollisionShapeHandle cshape, plReal x,plReal y,plReal z)
void plDeleteShape(plCollisionShapeHandle cshape) void plDeleteShape(plCollisionShapeHandle cshape)
{ {
btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape); btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
assert(shape); btAssert(shape);
btAlignedFree(shape); btAlignedFree(shape);
} }
void plSetScaling(plCollisionShapeHandle cshape, plVector3 cscaling) void plSetScaling(plCollisionShapeHandle cshape, plVector3 cscaling)
{ {
btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape); btCollisionShape* shape = reinterpret_cast<btCollisionShape*>( cshape);
assert(shape); btAssert(shape);
btVector3 scaling(cscaling[0],cscaling[1],cscaling[2]); btVector3 scaling(cscaling[0],cscaling[1],cscaling[2]);
shape->setLocalScaling(scaling); shape->setLocalScaling(scaling);
} }

View File

@@ -712,7 +712,7 @@ void btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
sortedConstraints[i] = m_constraints[i]; sortedConstraints[i] = m_constraints[i];
} }
// assert(0); // btAssert(0);

View File

@@ -87,7 +87,7 @@ btWheelInfo& btRaycastVehicle::addWheel( const btVector3& connectionPointCS, con
const btTransform& btRaycastVehicle::getWheelTransformWS( int wheelIndex ) const const btTransform& btRaycastVehicle::getWheelTransformWS( int wheelIndex ) const
{ {
assert(wheelIndex < getNumWheels()); btAssert(wheelIndex < getNumWheels());
const btWheelInfo& wheel = m_wheelInfo[wheelIndex]; const btWheelInfo& wheel = m_wheelInfo[wheelIndex];
return wheel.m_worldTransform; return wheel.m_worldTransform;
@@ -175,7 +175,7 @@ btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel)
btVehicleRaycaster::btVehicleRaycasterResult rayResults; btVehicleRaycaster::btVehicleRaycasterResult rayResults;
assert(m_vehicleRaycaster); btAssert(m_vehicleRaycaster);
void* object = m_vehicleRaycaster->castRay(source,target,rayResults); void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
@@ -359,7 +359,7 @@ void btRaycastVehicle::updateVehicle( btScalar step )
void btRaycastVehicle::setSteeringValue(btScalar steering,int wheel) void btRaycastVehicle::setSteeringValue(btScalar steering,int wheel)
{ {
assert(wheel>=0 && wheel < getNumWheels()); btAssert(wheel>=0 && wheel < getNumWheels());
btWheelInfo& wheelInfo = getWheelInfo(wheel); btWheelInfo& wheelInfo = getWheelInfo(wheel);
wheelInfo.m_steering = steering; wheelInfo.m_steering = steering;
@@ -375,7 +375,7 @@ btScalar btRaycastVehicle::getSteeringValue(int wheel) const
void btRaycastVehicle::applyEngineForce(btScalar force, int wheel) void btRaycastVehicle::applyEngineForce(btScalar force, int wheel)
{ {
assert(wheel>=0 && wheel < getNumWheels()); btAssert(wheel>=0 && wheel < getNumWheels());
btWheelInfo& wheelInfo = getWheelInfo(wheel); btWheelInfo& wheelInfo = getWheelInfo(wheel);
wheelInfo.m_engineForce = force; wheelInfo.m_engineForce = force;
} }

View File

@@ -95,7 +95,7 @@ void SpuCollisionTaskProcess::initialize2(bool useEpa)
#ifdef DEBUG_SpuCollisionTaskProcess #ifdef DEBUG_SpuCollisionTaskProcess
m_initialized = true; m_initialized = true;
assert(MIDPHASE_NUM_WORKUNITS_PER_TASK*sizeof(SpuGatherAndProcessWorkUnitInput) <= MIDPHASE_WORKUNIT_TASK_SIZE); btAssert(MIDPHASE_NUM_WORKUNITS_PER_TASK*sizeof(SpuGatherAndProcessWorkUnitInput) <= MIDPHASE_WORKUNIT_TASK_SIZE);
#endif #endif
} }
@@ -173,8 +173,8 @@ void SpuCollisionTaskProcess::addWorkToTask(void* pairArrayPtr,int startIndex,in
#endif //DEBUG_SPU_TASK_SCHEDULING #endif //DEBUG_SPU_TASK_SCHEDULING
#ifdef DEBUG_SpuCollisionTaskProcess #ifdef DEBUG_SpuCollisionTaskProcess
assert(m_initialized); btAssert(m_initialized);
assert(m_workUnitTaskBuffers); btAssert(m_workUnitTaskBuffers);
#endif #endif

View File

@@ -25,7 +25,6 @@ subject to the following restrictions:
#include "SpuVoronoiSimplexSolver.h" #include "SpuVoronoiSimplexSolver.h"
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#define VERTA 0 #define VERTA 0
@@ -37,7 +36,7 @@ subject to the following restrictions:
void SpuVoronoiSimplexSolver::removeVertex(int index) void SpuVoronoiSimplexSolver::removeVertex(int index)
{ {
assert(m_numVertices>0); btAssert(m_numVertices>0);
m_numVertices--; m_numVertices--;
m_simplexVectorW[index] = m_simplexVectorW[m_numVertices]; m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
m_simplexPointsP[index] = m_simplexPointsP[m_numVertices]; m_simplexPointsP[index] = m_simplexPointsP[m_numVertices];

View File

@@ -58,7 +58,7 @@ public:
void setRotation(const btVector3& axis, const btScalar& angle) void setRotation(const btVector3& axis, const btScalar& angle)
{ {
btScalar d = axis.length(); btScalar d = axis.length();
assert(d != btScalar(0.0)); btAssert(d != btScalar(0.0));
btScalar s = btSin(angle * btScalar(0.5)) / d; btScalar s = btSin(angle * btScalar(0.5)) / d;
setValue(axis.x() * s, axis.y() * s, axis.z() * s, setValue(axis.x() * s, axis.y() * s, axis.z() * s,
btCos(angle * btScalar(0.5))); btCos(angle * btScalar(0.5)));
@@ -177,7 +177,7 @@ public:
* @param s The inverse scale factor */ * @param s The inverse scale factor */
btQuaternion operator/(const btScalar& s) const btQuaternion operator/(const btScalar& s) const
{ {
assert(s != btScalar(0.0)); btAssert(s != btScalar(0.0));
return *this * (btScalar(1.0) / s); return *this * (btScalar(1.0) / s);
} }
@@ -185,7 +185,7 @@ public:
* @param s The scale factor */ * @param s The scale factor */
btQuaternion& operator/=(const btScalar& s) btQuaternion& operator/=(const btScalar& s)
{ {
assert(s != btScalar(0.0)); btAssert(s != btScalar(0.0));
return *this *= btScalar(1.0) / s; return *this *= btScalar(1.0) / s;
} }
@@ -199,7 +199,7 @@ public:
btScalar angle(const btQuaternion& q) const btScalar angle(const btQuaternion& q) const
{ {
btScalar s = btSqrt(length2() * q.length2()); btScalar s = btSqrt(length2() * q.length2());
assert(s != btScalar(0.0)); btAssert(s != btScalar(0.0));
return btAcos(dot(q) / s); return btAcos(dot(q) / s);
} }
/**@brief Return the angle of rotation represented by this quaternion */ /**@brief Return the angle of rotation represented by this quaternion */

View File

@@ -130,8 +130,11 @@ inline int btGetVersion()
//non-windows systems //non-windows systems
#define SIMD_FORCE_INLINE inline #define SIMD_FORCE_INLINE inline
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) ///@todo: check out alignment methods for other platforms/compilers
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) ///#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
///#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
#define ATTRIBUTE_ALIGNED16(a) a
#define ATTRIBUTE_ALIGNED128(a) a
#ifndef assert #ifndef assert
#include <assert.h> #include <assert.h>
#endif #endif