- keep track of all memory allocations (gNumAllignedAllocs/gNumAllignedFree)

All memory allocations in Bullet go through btAlignedAlloc/btAlignedFree
Fix in hinge constraint constructors, thanks Marcus Hennix!
This commit is contained in:
ejcoumans
2007-10-22 22:23:10 +00:00
parent 1b70c4e5c9
commit ec76f2e0a3
18 changed files with 210 additions and 113 deletions

View File

@@ -35,7 +35,8 @@ m_ownsBvh(false)
if (buildBvh)
{
m_bvh = new btOptimizedBvh();
void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
m_bvh = new (mem) btOptimizedBvh();
m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
m_ownsBvh = true;
}
@@ -55,7 +56,9 @@ m_ownsBvh(false)
if (buildBvh)
{
m_bvh = new btOptimizedBvh();
void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
m_bvh = new (mem) btOptimizedBvh();
m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
m_ownsBvh = true;
}
@@ -83,7 +86,9 @@ void btBvhTriangleMeshShape::refitTree()
btBvhTriangleMeshShape::~btBvhTriangleMeshShape()
{
if (m_ownsBvh)
delete m_bvh;
{
btAlignedFree(m_bvh);
}
}
//perform bvh tree traversal and report overlapping triangles to 'callback'
@@ -180,9 +185,12 @@ void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
{
btTriangleMeshShape::setLocalScaling(scaling);
if (m_ownsBvh)
delete m_bvh;
{
btAlignedFree(m_bvh);
}
///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
m_bvh = new btOptimizedBvh();
void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
m_bvh = new(mem) btOptimizedBvh();
//rebuild the bvh...
m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);