- 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

@@ -139,11 +139,14 @@ btHingeConstraint::btHingeConstraint(btRigidBody& rbA, const btTransform& rbAFra
m_angularOnly(false),
m_enableAngularMotor(false)
{
///not providing rigidbody B means implicitly using worldspace for body B
// flip axis
m_rbBFrame.getBasis()[0][2] *= btScalar(-1.);
m_rbBFrame.getBasis()[1][2] *= btScalar(-1.);
m_rbBFrame.getBasis()[2][2] *= btScalar(-1.);
m_rbBFrame.getOrigin() = m_rbA.getCenterOfMassTransform()(m_rbAFrame.getOrigin());
//start with free
m_lowerLimit = btScalar(1e30);

View File

@@ -99,7 +99,7 @@ bool MyContactDestroyedCallback(void* userPersistentData)
{
assert (userPersistentData);
btConstraintPersistentData* cpd = (btConstraintPersistentData*)userPersistentData;
delete cpd;
btAlignedFree(cpd);
totalCpd--;
//printf("totalCpd = %i. DELETED Ptr %x\n",totalCpd,userPersistentData);
return true;
@@ -469,7 +469,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
//todo: use stack allocator for this temp memory
int minReservation = numManifolds*2;
tmpSolverBodyPool.reserve(minReservation);
//tmpSolverBodyPool.reserve(minReservation);
//don't convert all bodies, only the one we need so solver the constraints
/*
@@ -489,8 +489,9 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
}
*/
tmpSolverConstraintPool.reserve(minReservation);
tmpSolverFrictionConstraintPool.reserve(minReservation);
//tmpSolverConstraintPool.reserve(minReservation);
//tmpSolverFrictionConstraintPool.reserve(minReservation);
{
int i;
@@ -1024,7 +1025,9 @@ void btSequentialImpulseConstraintSolver::prepareConstraints(btPersistentManifol
} else
{
cpd = new btConstraintPersistentData;
//todo: should this be in a pool?
void* mem = btAlignedAlloc(sizeof(btConstraintPersistentData),16);
cpd = new (mem)btConstraintPersistentData;
assert(cpd);
totalCpd ++;
@@ -1071,7 +1074,6 @@ void btSequentialImpulseConstraintSolver::prepareConstraints(btPersistentManifol
cpd->m_penetration = btScalar(0.);
}
btScalar relaxation = info.m_damping;
if (m_solverMode & SOLVER_USE_WARMSTARTING)