make parallel solver compile on MSVC 6

This commit is contained in:
ejcoumans
2007-10-12 06:59:59 +00:00
parent 0af676a2c5
commit 9e530a005c
3 changed files with 43 additions and 33 deletions

View File

@@ -1116,9 +1116,11 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
//cellDmaWaitTagStatusAll(DMA_MASK(2)); //cellDmaWaitTagStatusAll(DMA_MASK(2));
cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2));
int i;
// DMA all the subshapes // DMA all the subshapes
for (int i = 0; i < childShapeCount0; ++i) for ( i = 0; i < childShapeCount0; ++i)
{ {
btCompoundShapeChild& childShape = lsMem.gSubshapes[i]; btCompoundShapeChild& childShape = lsMem.gSubshapes[i];
@@ -1133,7 +1135,7 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
} }
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
for (int i = 0; i < childShapeCount1; ++i) for ( i = 0; i < childShapeCount1; ++i)
{ {
btCompoundShapeChild& childShape = lsMem.gSubshapes[MAX_SPU_COMPOUND_SUBSHAPES+i]; btCompoundShapeChild& childShape = lsMem.gSubshapes[MAX_SPU_COMPOUND_SUBSHAPES+i];
@@ -1149,7 +1151,7 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
// Start the N^2 // Start the N^2
for (int i = 0; i < childShapeCount0; ++i) for ( i = 0; i < childShapeCount0; ++i)
{ {
btCompoundShapeChild& childShape0 = lsMem.gSubshapes[i]; btCompoundShapeChild& childShape0 = lsMem.gSubshapes[i];

View File

@@ -53,15 +53,16 @@ static void clearHash (SpuSolverHash* hash)
{ {
size_t hashSize = sizeof(SpuSolverHash); size_t hashSize = sizeof(SpuSolverHash);
memset(hash, 0, hashSize); memset(hash, 0, hashSize);
int i;
// Setup basic dependency // Setup basic dependency
for (int i = 0; i < SPU_HASH_NUMCELLS; ++i) for ( i = 0; i < SPU_HASH_NUMCELLS; ++i)
{ {
hash->m_dependencyMatrix[i][i >> 5] |= (1 << (i & 31)); hash->m_dependencyMatrix[i][i >> 5] |= (1 << (i & 31));
} }
// Set some ones to "unused cells" // Set some ones to "unused cells"
for (int i = SPU_HASH_WORDWIDTH-SPU_HASH_NUMUNUSEDBITS; i < SPU_HASH_WORDWIDTH; ++i) for ( i = SPU_HASH_WORDWIDTH-SPU_HASH_NUMUNUSEDBITS; i < SPU_HASH_WORDWIDTH; ++i)
{ {
hash->m_currentMask[0][SPU_HASH_NUMCELLDWORDS-1] |= (1 << i); hash->m_currentMask[0][SPU_HASH_NUMCELLDWORDS-1] |= (1 << i);
} }
@@ -109,9 +110,11 @@ btScalar btParallelSequentialImpulseSolver::solveGroup(btCollisionObject** bodie
{ {
if (!numManifolds && !numConstraints) if (!numManifolds && !numConstraints)
return 0; return 0;
int i;
///refresh contact points is not needed anymore, it has been moved into the processCollision detection part. ///refresh contact points is not needed anymore, it has been moved into the processCollision detection part.
#ifdef FORCE_REFESH_CONTACT_MANIFOLDS #ifdef FORCE_REFESH_CONTACT_MANIFOLDS
for (int i = 0; i < numManifolds; ++i) for ( i = 0; i < numManifolds; ++i)
{ {
btPersistentManifold* currManifold = manifold[i]; btPersistentManifold* currManifold = manifold[i];
btRigidBody* rb0 = (btRigidBody*)currManifold->getBody0(); btRigidBody* rb0 = (btRigidBody*)currManifold->getBody0();
@@ -122,7 +125,7 @@ btScalar btParallelSequentialImpulseSolver::solveGroup(btCollisionObject** bodie
#endif //FORCE_REFESH_CONTACT_MANIFOLDS #endif //FORCE_REFESH_CONTACT_MANIFOLDS
// Record and mark the manifolds to the cells // Record and mark the manifolds to the cells
for (int i = 0; i < numManifolds; ++i) for ( i = 0; i < numManifolds; ++i)
{ {
// Compute a hash cell for this manifold // Compute a hash cell for this manifold
btPersistentManifold* currManifold = manifold[i]; btPersistentManifold* currManifold = manifold[i];
@@ -163,7 +166,7 @@ btScalar btParallelSequentialImpulseSolver::solveGroup(btCollisionObject** bodie
} }
// Record and mark constraints to the cells // Record and mark constraints to the cells
for (int i = 0; i < numConstraints; ++i) for ( i = 0; i < numConstraints; ++i)
{ {
// Compute a hash cell for this manifold // Compute a hash cell for this manifold
btTypedConstraint* currConstraint = constraints[i]; btTypedConstraint* currConstraint = constraints[i];
@@ -202,7 +205,7 @@ btScalar btParallelSequentialImpulseSolver::solveGroup(btCollisionObject** bodie
} }
// Save all RBs // Save all RBs
for (int i = 0; i < numBodies; ++i) for ( i = 0; i < numBodies; ++i)
{ {
btCollisionObject* obj = bodies[i]; btCollisionObject* obj = bodies[i];
//unsigned int cellIdx = getObjectIndex(obj); //unsigned int cellIdx = getObjectIndex(obj);

View File

@@ -509,8 +509,8 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
{ {
btVector3 normal (0,0,0); btVector3 normal (0,0,0);
const btVector3& bias (constraint.m_linearBias); const btVector3& bias =constraint.m_linearBias;
const btVector3& jacInv (constraint.m_jacdiagABInv); const btVector3& jacInv =constraint.m_jacdiagABInv;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
@@ -557,12 +557,12 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
case HINGE_CONSTRAINT_TYPE: case HINGE_CONSTRAINT_TYPE:
{ {
// Angular solving for the two first axes // Angular solving for the two first axes
const btVector3& bias (constraint.hinge.m_angularBias); const btVector3& bias =constraint.hinge.m_angularBias;
const btVector3& jacInv (constraint.hinge.m_angJacdiagABInv); const btVector3& jacInv =constraint.hinge.m_angJacdiagABInv;
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
const btVector3& axis (constraint.hinge.m_frameAinW[i]); const btVector3& axis =constraint.hinge.m_frameAinW[i];
// Compute relative velocity // Compute relative velocity
btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity; btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity;
@@ -587,7 +587,7 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
// Limit // Limit
if (constraint.m_flags.m_limit1) if (constraint.m_flags.m_limit1)
{ {
const btVector3& axis (constraint.hinge.m_frameAinW[2]); const btVector3& axis =constraint.hinge.m_frameAinW[2];
// Compute relative velocity // Compute relative velocity
btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity; btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity;
@@ -617,7 +617,7 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
// Motor // Motor
if (constraint.m_flags.m_motor1) if (constraint.m_flags.m_motor1)
{ {
const btVector3& axis (constraint.hinge.m_frameAinW[2]); const btVector3& axis =constraint.hinge.m_frameAinW[2];
// Compute relative velocity // Compute relative velocity
btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity; btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity;
@@ -650,7 +650,7 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
// Swing // Swing
if (constraint.m_flags.m_limit1) if (constraint.m_flags.m_limit1)
{ {
const btVector3& axis (constraint.conetwist.m_swingAxis); const btVector3& axis =constraint.conetwist.m_swingAxis;
// Compute relative velocity // Compute relative velocity
btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity; btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity;
@@ -680,7 +680,7 @@ static void solveConstraint (SpuSolverConstraint& constraint, SpuSolverBody& bod
// Twist // Twist
if (constraint.m_flags.m_limit2) if (constraint.m_flags.m_limit2)
{ {
const btVector3& axis (constraint.conetwist.m_twistAxis); const btVector3& axis =constraint.conetwist.m_twistAxis;
// Compute relative velocity // Compute relative velocity
btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity; btVector3 relVel = bodyA.m_angularVelocity - bodyB.m_angularVelocity;
@@ -845,8 +845,9 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
} }
int b;
// DMA the rigid bodies // DMA the rigid bodies
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* body = bodyPtrList[b]; btRigidBody* body = bodyPtrList[b];
int dmaSize = sizeof(btRigidBody); int dmaSize = sizeof(btRigidBody);
@@ -855,7 +856,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* localBody = bodyList+b; btRigidBody* localBody = bodyList+b;
SpuSolverBody* spuBody = spuBodyList + b; SpuSolverBody* spuBody = spuBodyList + b;
@@ -867,7 +868,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
// DMA the rigid bodies back // DMA the rigid bodies back
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* body = bodyPtrList[b]; btRigidBody* body = bodyPtrList[b];
int dmaSize = sizeof(btRigidBody); int dmaSize = sizeof(btRigidBody);
@@ -936,8 +937,9 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
} }
int m;
// DMA the manifold list // DMA the manifold list
for (int m = 0; m < packageSize; ++m) for ( m = 0; m < packageSize; ++m)
{ {
int dmaSize = sizeof(btPersistentManifold); int dmaSize = sizeof(btPersistentManifold);
uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (manifoldHolderList[m].m_manifold); uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (manifoldHolderList[m].m_manifold);
@@ -945,7 +947,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
for (int m = 0; m < packageSize; ++m) for ( m = 0; m < packageSize; ++m)
{ {
btPersistentManifold* currManifold = manifoldList + m; btPersistentManifold* currManifold = manifoldList + m;
@@ -1182,8 +1184,9 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
} }
int c;
// DMA the constraint list // DMA the constraint list
for (int c = 0; c < packageSize; ++c) for ( c = 0; c < packageSize; ++c)
{ {
//int dmaSize = CONSTRAINT_MAX_SIZE; //int dmaSize = CONSTRAINT_MAX_SIZE;
int dmaSize = getConstraintSize((btTypedConstraintType)constraintHolderList[c].m_constraintType); int dmaSize = getConstraintSize((btTypedConstraintType)constraintHolderList[c].m_constraintType);
@@ -1192,7 +1195,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
for (int c = 0; c < packageSize; ++c) for ( c = 0; c < packageSize; ++c)
{ {
btTypedConstraint* currConstraint = (btTypedConstraint*)(constraintList + CONSTRAINT_MAX_SIZE*c); btTypedConstraint* currConstraint = (btTypedConstraint*)(constraintList + CONSTRAINT_MAX_SIZE*c);
btTypedConstraintType type = currConstraint->getConstraintType(); btTypedConstraintType type = currConstraint->getConstraintType();
@@ -1563,7 +1566,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
// Get the body list // Get the body list
uint32_t* indexList = (uint32_t*)allocTemporaryStorage(localMemory, sizeof(uint32_t)*hashCell.m_numLocalBodies); uint32_t* indexList = (uint32_t*)allocTemporaryStorage(localMemory, sizeof(uint32_t)*hashCell.m_numLocalBodies);
SpuSolverBody* bodyList = allocBodyStorage(localMemory, hashCell.m_numLocalBodies); SpuSolverBody* bodyList = allocBodyStorage(localMemory, hashCell.m_numLocalBodies);
int b;
{ {
int dmaSize = sizeof(uint32_t)*hashCell.m_numLocalBodies; int dmaSize = sizeof(uint32_t)*hashCell.m_numLocalBodies;
uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyOffsetList + hashCell.m_solverBodyOffsetListOffset); uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyOffsetList + hashCell.m_solverBodyOffsetListOffset);
@@ -1572,7 +1575,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
// DMA the bodies // DMA the bodies
for (int b = 0; b < hashCell.m_numLocalBodies; ++b) for ( b = 0; b < hashCell.m_numLocalBodies; ++b)
{ {
int dmaSize = sizeof(SpuSolverBody); int dmaSize = sizeof(SpuSolverBody);
uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyList + indexList[b]); uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyList + indexList[b]);
@@ -1649,8 +1652,9 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
int j;
// Solve // Solve
for (int j = 0; j < packetSize*3; j += 3) for ( j = 0; j < packetSize*3; j += 3)
{ {
SpuSolverInternalConstraint& contact = internalConstraints[j]; SpuSolverInternalConstraint& contact = internalConstraints[j];
SpuSolverBody& bodyA = bodyList[contact.m_localOffsetBodyA]; SpuSolverBody& bodyA = bodyList[contact.m_localOffsetBodyA];
@@ -1659,7 +1663,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
solveContact(contact, bodyA, bodyB); solveContact(contact, bodyA, bodyB);
} }
for (int j = 0; j < packetSize*3; j += 3) for ( j = 0; j < packetSize*3; j += 3)
{ {
SpuSolverInternalConstraint& contact = internalConstraints[j]; SpuSolverInternalConstraint& contact = internalConstraints[j];
SpuSolverBody& bodyA = bodyList[contact.m_localOffsetBodyA]; SpuSolverBody& bodyA = bodyList[contact.m_localOffsetBodyA];
@@ -1690,7 +1694,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
// DMA the bodies back to main memory // DMA the bodies back to main memory
for (int b = 0; b < hashCell.m_numLocalBodies; ++b) for ( b = 0; b < hashCell.m_numLocalBodies; ++b)
{ {
int dmaSize = sizeof(SpuSolverBody); int dmaSize = sizeof(SpuSolverBody);
uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyList + indexList[b]); uint64_t dmaPpuAddress2 = reinterpret_cast<uint64_t> (taskDesc.m_solverData.m_solverBodyList + indexList[b]);
@@ -1726,8 +1730,9 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaWaitTagStatusAll(DMA_MASK(1));
} }
int b;
// DMA the rigid bodies // DMA the rigid bodies
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* body = bodyPtrList[b]; btRigidBody* body = bodyPtrList[b];
int dmaSize = sizeof(btRigidBody); int dmaSize = sizeof(btRigidBody);
@@ -1744,7 +1749,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2));
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* localBody = bodyList + b; btRigidBody* localBody = bodyList + b;
SpuSolverBody* solverBody = spuBodyList + b; SpuSolverBody* solverBody = spuBodyList + b;
@@ -1758,7 +1763,7 @@ void processSolverTask(void* userPtr, void* lsMemory)
} }
// DMA the rigid bodies // DMA the rigid bodies
for (int b = 0; b < packageSize; ++b) for ( b = 0; b < packageSize; ++b)
{ {
btRigidBody* body = bodyPtrList[b]; btRigidBody* body = bodyPtrList[b];
int dmaSize = sizeof(btRigidBody); int dmaSize = sizeof(btRigidBody);