remove some debug globals from third_party/bullet
There are some debug global variables that prevent using bullet safely on multi-threaded environments (tsan failures). PATCH from marioprats@
This commit is contained in:
@@ -291,10 +291,6 @@ void SoftDemo::createStack( btCollisionShape* boxShape, float halfCubeSize, int
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
||||||
extern int gNumManifold;
|
|
||||||
extern int gOverlappingPairs;
|
|
||||||
|
|
||||||
///for mouse picking
|
///for mouse picking
|
||||||
void pickingPreTickCallback (btDynamicsWorld *world, btScalar timeStep)
|
void pickingPreTickCallback (btDynamicsWorld *world, btScalar timeStep)
|
||||||
{
|
{
|
||||||
@@ -1727,13 +1723,6 @@ void SoftDemo::clientMoveAndDisplay()
|
|||||||
btProfiler::endBlock("render");
|
btProfiler::endBlock("render");
|
||||||
#endif
|
#endif
|
||||||
glFlush();
|
glFlush();
|
||||||
//some additional debugging info
|
|
||||||
#ifdef PRINT_CONTACT_STATISTICS
|
|
||||||
printf("num manifolds: %i\n",gNumManifold);
|
|
||||||
printf("num gOverlappingPairs: %i\n",gOverlappingPairs);
|
|
||||||
|
|
||||||
#endif //PRINT_CONTACT_STATISTICS
|
|
||||||
|
|
||||||
|
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
|
|||||||
@@ -628,7 +628,6 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* /*dispatcher*
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern int gOverlappingPairs;
|
|
||||||
//#include <stdio.h>
|
//#include <stdio.h>
|
||||||
|
|
||||||
template <typename BP_FP_INT_TYPE>
|
template <typename BP_FP_INT_TYPE>
|
||||||
@@ -695,10 +694,9 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatche
|
|||||||
pair.m_pProxy0 = 0;
|
pair.m_pProxy0 = 0;
|
||||||
pair.m_pProxy1 = 0;
|
pair.m_pProxy1 = 0;
|
||||||
m_invalidPair++;
|
m_invalidPair++;
|
||||||
gOverlappingPairs--;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||||
#define CLEAN_INVALID_PAIRS 1
|
#define CLEAN_INVALID_PAIRS 1
|
||||||
|
|||||||
@@ -23,11 +23,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int gOverlappingPairs = 0;
|
|
||||||
|
|
||||||
int gRemovePairs =0;
|
|
||||||
int gAddedPairs =0;
|
|
||||||
int gFindPairs =0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -134,7 +129,6 @@ void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroad
|
|||||||
|
|
||||||
btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||||
{
|
{
|
||||||
gFindPairs++;
|
|
||||||
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
||||||
btSwap(proxy0,proxy1);
|
btSwap(proxy0,proxy1);
|
||||||
int proxyId1 = proxy0->getUid();
|
int proxyId1 = proxy0->getUid();
|
||||||
@@ -271,7 +265,6 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProx
|
|||||||
|
|
||||||
void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1,btDispatcher* dispatcher)
|
void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1,btDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
gRemovePairs++;
|
|
||||||
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
||||||
btSwap(proxy0,proxy1);
|
btSwap(proxy0,proxy1);
|
||||||
int proxyId1 = proxy0->getUid();
|
int proxyId1 = proxy0->getUid();
|
||||||
@@ -386,8 +379,6 @@ void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
|||||||
if (callback->processOverlap(*pair))
|
if (callback->processOverlap(*pair))
|
||||||
{
|
{
|
||||||
removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher);
|
removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher);
|
||||||
|
|
||||||
gOverlappingPairs--;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@@ -499,7 +490,6 @@ void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
|||||||
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
||||||
if (findIndex < m_overlappingPairArray.size())
|
if (findIndex < m_overlappingPairArray.size())
|
||||||
{
|
{
|
||||||
gOverlappingPairs--;
|
|
||||||
btBroadphasePair& pair = m_overlappingPairArray[findIndex];
|
btBroadphasePair& pair = m_overlappingPairArray[findIndex];
|
||||||
void* userData = pair.m_internalInfo1;
|
void* userData = pair.m_internalInfo1;
|
||||||
cleanOverlappingPair(pair,dispatcher);
|
cleanOverlappingPair(pair,dispatcher);
|
||||||
@@ -533,10 +523,7 @@ btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseP
|
|||||||
void* mem = &m_overlappingPairArray.expandNonInitializing();
|
void* mem = &m_overlappingPairArray.expandNonInitializing();
|
||||||
btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
|
btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
|
||||||
|
|
||||||
gOverlappingPairs++;
|
if (m_ghostPairCallback)
|
||||||
gAddedPairs++;
|
|
||||||
|
|
||||||
if (m_ghostPairCallback)
|
|
||||||
m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
||||||
return pair;
|
return pair;
|
||||||
|
|
||||||
@@ -590,7 +577,6 @@ void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
|||||||
pair->m_pProxy1 = 0;
|
pair->m_pProxy1 = 0;
|
||||||
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||||
m_overlappingPairArray.pop_back();
|
m_overlappingPairArray.pop_back();
|
||||||
gOverlappingPairs--;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@@ -623,7 +609,6 @@ void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,b
|
|||||||
pair.m_algorithm->~btCollisionAlgorithm();
|
pair.m_algorithm->~btCollisionAlgorithm();
|
||||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||||
pair.m_algorithm=0;
|
pair.m_algorithm=0;
|
||||||
gRemovePairs--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ struct btOverlapFilterCallback
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int gRemovePairs;
|
|
||||||
extern int gAddedPairs;
|
|
||||||
extern int gFindPairs;
|
|
||||||
|
|
||||||
const int BT_NULL_PAIR=0xffffffff;
|
const int BT_NULL_PAIR=0xffffffff;
|
||||||
|
|
||||||
///The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
|
///The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
|
||||||
@@ -133,8 +129,6 @@ public:
|
|||||||
// no new pair is created and the old one is returned.
|
// no new pair is created and the old one is returned.
|
||||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||||
{
|
{
|
||||||
gAddedPairs++;
|
|
||||||
|
|
||||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
extern int gOverlappingPairs;
|
|
||||||
|
|
||||||
void btSimpleBroadphase::validate()
|
void btSimpleBroadphase::validate()
|
||||||
{
|
{
|
||||||
for (int i=0;i<m_numHandles;i++)
|
for (int i=0;i<m_numHandles;i++)
|
||||||
@@ -315,7 +313,6 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
|||||||
pair.m_pProxy0 = 0;
|
pair.m_pProxy0 = 0;
|
||||||
pair.m_pProxy1 = 0;
|
pair.m_pProxy1 = 0;
|
||||||
m_invalidPair++;
|
m_invalidPair++;
|
||||||
gOverlappingPairs--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
|
||||||
|
|
||||||
int gNumManifold = 0;
|
|
||||||
|
|
||||||
#ifdef BT_DEBUG
|
#ifdef BT_DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -77,8 +75,6 @@ btCollisionDispatcher::~btCollisionDispatcher()
|
|||||||
|
|
||||||
btPersistentManifold* btCollisionDispatcher::getNewManifold(const btCollisionObject* body0,const btCollisionObject* body1)
|
btPersistentManifold* btCollisionDispatcher::getNewManifold(const btCollisionObject* body0,const btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
gNumManifold++;
|
|
||||||
|
|
||||||
//btAssert(gNumManifold < 65535);
|
//btAssert(gNumManifold < 65535);
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +117,6 @@ void btCollisionDispatcher::clearManifold(btPersistentManifold* manifold)
|
|||||||
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);
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btAlignedAllocator.h"
|
#include "btAlignedAllocator.h"
|
||||||
|
|
||||||
int gNumAlignedAllocs = 0;
|
|
||||||
int gNumAlignedFree = 0;
|
|
||||||
int gTotalBytesAlignedAllocs = 0;//detect memory leaks
|
|
||||||
|
|
||||||
static void *btAllocDefault(size_t size)
|
static void *btAllocDefault(size_t size)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
@@ -163,9 +159,6 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
|||||||
// printf("big alloc!%d\n", size);
|
// printf("big alloc!%d\n", size);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
gTotalBytesAlignedAllocs += size;
|
|
||||||
gNumAlignedAllocs++;
|
|
||||||
|
|
||||||
|
|
||||||
int sz4prt = 4*sizeof(void *);
|
int sz4prt = 4*sizeof(void *);
|
||||||
|
|
||||||
@@ -190,7 +183,6 @@ int sz4prt = 4*sizeof(void *);
|
|||||||
ret = (void *)(real);//??
|
ret = (void *)(real);//??
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("allocation %d at address %x, from %s,line %d, size %d (total allocated = %d)\n",allocId,real, filename,line,size,gTotalBytesAlignedAllocs);
|
|
||||||
allocId++;
|
allocId++;
|
||||||
|
|
||||||
int* ptr = (int*)ret;
|
int* ptr = (int*)ret;
|
||||||
@@ -204,7 +196,6 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
void* real;
|
void* real;
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
gNumAlignedFree++;
|
|
||||||
|
|
||||||
btDebugPtrMagic p;
|
btDebugPtrMagic p;
|
||||||
p.vptr = ptr;
|
p.vptr = ptr;
|
||||||
@@ -230,11 +221,6 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gTotalBytesAlignedAllocs -= size;
|
|
||||||
|
|
||||||
int diff = gNumAlignedAllocs-gNumAlignedFree;
|
|
||||||
printf("free %d at address %x, from %s,line %d, size %d (total remain = %d in %d non-freed allocations)\n",allocId,real, filename,line,size, gTotalBytesAlignedAllocs, diff);
|
|
||||||
|
|
||||||
sFreeFunc(real);
|
sFreeFunc(real);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -246,7 +232,6 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
|
|
||||||
void* btAlignedAllocInternal (size_t size, int alignment)
|
void* btAlignedAllocInternal (size_t size, int alignment)
|
||||||
{
|
{
|
||||||
gNumAlignedAllocs++;
|
|
||||||
void* ptr;
|
void* ptr;
|
||||||
ptr = sAlignedAllocFunc(size, alignment);
|
ptr = sAlignedAllocFunc(size, alignment);
|
||||||
// printf("btAlignedAllocInternal %d, %x\n",size,ptr);
|
// printf("btAlignedAllocInternal %d, %x\n",size,ptr);
|
||||||
@@ -260,7 +245,6 @@ void btAlignedFreeInternal (void* ptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gNumAlignedFree++;
|
|
||||||
// printf("btAlignedFreeInternal %x\n",ptr);
|
// printf("btAlignedFreeInternal %x\n",ptr);
|
||||||
sAlignedFreeFunc(ptr);
|
sAlignedFreeFunc(ptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user