Added preliminary cmake support for PE branch, Win32 only for now.

This commit is contained in:
erwin.coumans 2011-01-07 01:48:50 +00:00
parent 22ff43e388
commit f10846ed7a
12 changed files with 143 additions and 80 deletions

View File

@ -42,8 +42,11 @@ typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispa
///Time of Impact, Closest Points and Penetration Depth.
class btCollisionDispatcher : public btDispatcher
{
protected:
int m_dispatcherFlags;
btAlignedObjectArray<btPersistentManifold*> m_manifoldsPtr;
btManifoldResult m_defaultManifoldResult;

View File

@ -277,13 +277,13 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
nodeSubPart);
unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT||indicestype==PHY_UCHAR);
const btVector3& meshScaling = m_meshInterface->getScaling();
for (int j=2;j>=0;j--)
{
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:indicestype==PHY_INTEGER?gfxbase[j]:((unsigned char*)gfxbase)[j];
#ifdef DEBUG_TRIANGLE_MESH

View File

@ -88,6 +88,21 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
}
break;
}
case PHY_UCHAR:
{
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
{
unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
}
break;
}
default:
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
}
@ -130,6 +145,21 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
}
break;
}
case PHY_UCHAR:
{
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
{
unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
}
break;
}
default:
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
}
@ -266,6 +296,24 @@ const char* btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* s
}
break;
}
case PHY_UCHAR:
{
if (numtriangles)
{
btChunk* chunk = serializer->allocate(sizeof(btCharIndexTripletData),numtriangles);
btCharIndexTripletData* tmpIndices = (btCharIndexTripletData*)chunk->m_oldPtr;
memPtr->m_3indices8 = (btCharIndexTripletData*) serializer->getUniquePointer(tmpIndices);
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
{
unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
tmpIndices[gfxindex].m_values[0] = tri_indices[0];
tmpIndices[gfxindex].m_values[1] = tri_indices[1];
tmpIndices[gfxindex].m_values[2] = tri_indices[2];
}
serializer->finalizeChunk(chunk,"btCharIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
}
break;
}
default:
{
btAssert(0);

View File

@ -116,6 +116,13 @@ struct btShortIntIndexTripletData
char m_pad[2];
};
struct btCharIndexTripletData
{
unsigned char m_values[3];
char m_pad;
};
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btMeshPartData
{
@ -124,6 +131,7 @@ struct btMeshPartData
btIntIndexData *m_indices32;
btShortIntIndexTripletData *m_3indices16;
btCharIndexTripletData *m_3indices8;
btShortIntIndexData *m_indices16;//backwards compatibility

View File

@ -19,16 +19,21 @@ subject to the following restrictions:
#include "LinearMath/btVector3.h"
#include "LinearMath/btTransformUtil.h"
// Don't change following order of parameters
ATTRIBUTE_ALIGNED16(struct) PfxConstraintRow {
btScalar mNormal[3];
btScalar mRhs;
btScalar mJacDiagInv;
btScalar mLowerLimit;
btScalar mUpperLimit;
btScalar mAccumImpulse;
};
#if 1 //#ifdef PFX_USE_FREE_VECTORMATH
#include "physics_effects\base_level\solver\pfx_constraint_row.h"
typedef sce::PhysicsEffects::PfxConstraintRow btConstraintRow;
#else
// Don't change following order of parameters
ATTRIBUTE_ALIGNED16(struct) btConstraintRow {
btScalar m_normal[3];
btScalar m_rhs;
btScalar m_jacDiagInv;
btScalar m_lowerLimit;
btScalar m_upperLimit;
btScalar m_accumImpulse;
};
typedef btConstraintRow PfxConstraintRow;
#endif //PFX_USE_FREE_VECTORMATH
@ -71,9 +76,9 @@ class btManifoldPoint
m_contactCFM2(0.f),
m_lifeTime(0)
{
mConstraintRow[0].mAccumImpulse = 0.f;
mConstraintRow[1].mAccumImpulse = 0.f;
mConstraintRow[2].mAccumImpulse = 0.f;
mConstraintRow[0].m_accumImpulse = 0.f;
mConstraintRow[1].m_accumImpulse = 0.f;
mConstraintRow[2].m_accumImpulse = 0.f;
}
@ -113,7 +118,7 @@ class btManifoldPoint
PfxConstraintRow mConstraintRow[3];
btConstraintRow mConstraintRow[3];
btScalar getDistance() const

View File

@ -146,9 +146,9 @@ public:
m_pointCache[index] = m_pointCache[lastUsedIndex];
//get rid of duplicated userPersistentData pointer
m_pointCache[lastUsedIndex].m_userPersistentData = 0;
m_pointCache[lastUsedIndex].mConstraintRow[0].mAccumImpulse = 0.f;
m_pointCache[lastUsedIndex].mConstraintRow[1].mAccumImpulse = 0.f;
m_pointCache[lastUsedIndex].mConstraintRow[2].mAccumImpulse = 0.f;
m_pointCache[lastUsedIndex].mConstraintRow[0].m_accumImpulse = 0.f;
m_pointCache[lastUsedIndex].mConstraintRow[1].m_accumImpulse = 0.f;
m_pointCache[lastUsedIndex].mConstraintRow[2].m_accumImpulse = 0.f;
m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f;
m_pointCache[lastUsedIndex].m_lateralFrictionInitialized = false;
@ -167,9 +167,9 @@ public:
#define MAINTAIN_PERSISTENCY 1
#ifdef MAINTAIN_PERSISTENCY
int lifeTime = m_pointCache[insertIndex].getLifeTime();
btScalar appliedImpulse = m_pointCache[insertIndex].mConstraintRow[0].mAccumImpulse;
btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].mConstraintRow[1].mAccumImpulse;
btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].mConstraintRow[2].mAccumImpulse;
btScalar appliedImpulse = m_pointCache[insertIndex].mConstraintRow[0].m_accumImpulse;
btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].mConstraintRow[1].m_accumImpulse;
btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].mConstraintRow[2].m_accumImpulse;
// bool isLateralFrictionInitialized = m_pointCache[insertIndex].m_lateralFrictionInitialized;
@ -184,9 +184,9 @@ public:
m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1;
m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2;
m_pointCache[insertIndex].mConstraintRow[0].mAccumImpulse = appliedImpulse;
m_pointCache[insertIndex].mConstraintRow[1].mAccumImpulse = appliedLateralImpulse1;
m_pointCache[insertIndex].mConstraintRow[2].mAccumImpulse = appliedLateralImpulse2;
m_pointCache[insertIndex].mConstraintRow[0].m_accumImpulse = appliedImpulse;
m_pointCache[insertIndex].mConstraintRow[1].m_accumImpulse = appliedLateralImpulse1;
m_pointCache[insertIndex].mConstraintRow[2].m_accumImpulse = appliedLateralImpulse2;
m_pointCache[insertIndex].m_lifeTime = lifeTime;

View File

@ -89,7 +89,7 @@ class btRigidBody : public btCollisionObject
int m_rigidbodyFlags;
int m_debugBodyId;
protected:
@ -617,6 +617,7 @@ public:
void internalWritebackVelocity(btScalar timeStep);
///////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
#include "LinearMath/btScalar.h"
#include "LinearMath/btMinMax.h"
#include "vectormath/vmInclude.h"
#include "vecmath/vmInclude.h"
@ -27,11 +27,9 @@ typedef union
typedef unsigned char uint8_t;
#ifndef __PHYSICS_COMMON_H__
#ifndef __PFX_COMMON_H__
#ifndef __BT_SKIP_UINT64_H
typedef unsigned long int uint64_t;
#endif //__BT_SKIP_UINT64_H
#endif //__PFX_COMMON_H__
typedef unsigned int uint32_t;
#endif //__PHYSICS_COMMON_H__
typedef unsigned short uint16_t;

View File

@ -24,7 +24,7 @@ subject to the following restrictions:
#include <math.h>
#include "vectormath/vmInclude.h"
#include "vecmath/vmInclude.h"
#include "../PlatformDefinitions.h"

View File

@ -18,7 +18,7 @@ subject to the following restrictions:
#define __TRBSTATEVEC_H__
#include <stdlib.h>
#include "vectormath/vmInclude.h"
#include "vecmath/vmInclude.h"
#include "PlatformDefinitions.h"

View File

@ -21,7 +21,7 @@ subject to the following restrictions:
#include "LinearMath/btQuickprof.h"
#include "BulletMultiThreaded/btThreadSupportInterface.h"
#include "vectormath/vmInclude.h"
#include "vecmath/vmInclude.h"
#include "HeapManager.h"
@ -92,20 +92,20 @@ unsigned char ATTRIBUTE_ALIGNED128(tmp_buff[TMP_BUFF_BYTES]);
static SIMD_FORCE_INLINE
void pfxSolveLinearConstraintRow(PfxConstraintRow &constraint,
void pfxSolveLinearConstraintRow(btConstraintRow &constraint,
vmVector3 &deltaLinearVelocityA,vmVector3 &deltaAngularVelocityA,
float massInvA,const vmMatrix3 &inertiaInvA,const vmVector3 &rA,
vmVector3 &deltaLinearVelocityB,vmVector3 &deltaAngularVelocityB,
float massInvB,const vmMatrix3 &inertiaInvB,const vmVector3 &rB)
{
const vmVector3 normal(btReadVector3(constraint.mNormal));
btScalar deltaImpulse = constraint.mRhs;
const vmVector3 normal(btReadVector3(constraint.m_normal));
btScalar deltaImpulse = constraint.m_rhs;
vmVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA);
vmVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB);
deltaImpulse -= constraint.mJacDiagInv * dot(normal,dVA-dVB);
btScalar oldImpulse = constraint.mAccumImpulse;
constraint.mAccumImpulse = btClamped(oldImpulse + deltaImpulse,constraint.mLowerLimit,constraint.mUpperLimit);
deltaImpulse = constraint.mAccumImpulse - oldImpulse;
deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB);
btScalar oldImpulse = constraint.m_accumImpulse;
constraint.m_accumImpulse = btClamped(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit);
deltaImpulse = constraint.m_accumImpulse - oldImpulse;
deltaLinearVelocityA += deltaImpulse * massInvA * normal;
deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal);
deltaLinearVelocityB -= deltaImpulse * massInvB * normal;
@ -114,9 +114,9 @@ void pfxSolveLinearConstraintRow(PfxConstraintRow &constraint,
}
void btSolveContactConstraint(
PfxConstraintRow &constraintResponse,
PfxConstraintRow &constraintFriction1,
PfxConstraintRow &constraintFriction2,
btConstraintRow &constraintResponse,
btConstraintRow &constraintFriction1,
btConstraintRow &constraintFriction2,
const vmVector3 &contactPointA,
const vmVector3 &contactPointB,
PfxSolverBody &solverBodyA,
@ -131,11 +131,11 @@ void btSolveContactConstraint(
solverBodyA.mDeltaLinearVelocity,solverBodyA.mDeltaAngularVelocity,solverBodyA.mMassInv,solverBodyA.mInertiaInv,rA,
solverBodyB.mDeltaLinearVelocity,solverBodyB.mDeltaAngularVelocity,solverBodyB.mMassInv,solverBodyB.mInertiaInv,rB);
float mf = friction*fabsf(constraintResponse.mAccumImpulse);
constraintFriction1.mLowerLimit = -mf;
constraintFriction1.mUpperLimit = mf;
constraintFriction2.mLowerLimit = -mf;
constraintFriction2.mUpperLimit = mf;
float mf = friction*fabsf(constraintResponse.m_accumImpulse);
constraintFriction1.m_lowerLimit = -mf;
constraintFriction1.m_upperLimit = mf;
constraintFriction2.m_lowerLimit = -mf;
constraintFriction2.m_upperLimit = mf;
pfxSolveLinearConstraintRow(constraintFriction1,
solverBodyA.mDeltaLinearVelocity,solverBodyA.mDeltaAngularVelocity,solverBodyA.mMassInv,solverBodyA.mInertiaInv,rA,
@ -226,8 +226,8 @@ void CustomSolveConstraintsTaskParallel(
vmVector3 rB = rotate(solverBodyB.mOrientation,btReadVector3(cp.m_localPointB));
for(int k=0;k<3;k++) {
vmVector3 normal = btReadVector3(cp.mConstraintRow[k].mNormal);
float deltaImpulse = cp.mConstraintRow[k].mAccumImpulse;
vmVector3 normal = btReadVector3(cp.mConstraintRow[k].m_normal);
float deltaImpulse = cp.mConstraintRow[k].m_accumImpulse;
solverBodyA.mDeltaLinearVelocity += deltaImpulse * solverBodyA.mMassInv * normal;
solverBodyA.mDeltaAngularVelocity += deltaImpulse * solverBodyA.mInertiaInv * cross(rA,normal);
solverBodyB.mDeltaLinearVelocity -= deltaImpulse * solverBodyB.mMassInv * normal;
@ -311,9 +311,9 @@ void pfxGetPlaneSpace(const vmVector3& n, vmVector3& p, vmVector3& q)
#define PFX_CONTACT_SLOP 0.001f
void btSetupContactConstraint(
PfxConstraintRow &constraintResponse,
PfxConstraintRow &constraintFriction1,
PfxConstraintRow &constraintFriction2,
btConstraintRow &constraintResponse,
btConstraintRow &constraintFriction1,
btConstraintRow &constraintFriction2,
float penetrationDepth,
float restitution,
float friction,
@ -342,9 +342,9 @@ void btSetupContactConstraint(
vmVector3 tangent1,tangent2;
btPlaneSpace1(contactNormal,tangent1,tangent2);
// constraintResponse.mAccumImpulse = 0.f;
// constraintFriction1.mAccumImpulse = 0.f;
// constraintFriction2.mAccumImpulse = 0.f;
// constraintResponse.m_accumImpulse = 0.f;
// constraintFriction1.m_accumImpulse = 0.f;
// constraintFriction2.m_accumImpulse = 0.f;
// Contact Constraint
{
@ -352,13 +352,13 @@ void btSetupContactConstraint(
float denom = dot(K*normal,normal);
constraintResponse.mRhs = -(1.0f+restitution)*dot(vAB,normal); // velocity error
constraintResponse.mRhs -= (separateBias * btMin(0.0f,penetrationDepth+PFX_CONTACT_SLOP)) / timeStep; // position error
constraintResponse.mRhs /= denom;
constraintResponse.mJacDiagInv = 1.0f/denom;
constraintResponse.mLowerLimit = 0.0f;
constraintResponse.mUpperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintResponse.mNormal);
constraintResponse.m_rhs = -(1.0f+restitution)*dot(vAB,normal); // velocity error
constraintResponse.m_rhs -= (separateBias * btMin(0.0f,penetrationDepth+PFX_CONTACT_SLOP)) / timeStep; // position error
constraintResponse.m_rhs /= denom;
constraintResponse.m_jacDiagInv = 1.0f/denom;
constraintResponse.m_lowerLimit = 0.0f;
constraintResponse.m_upperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintResponse.m_normal);
}
// Friction Constraint 1
@ -367,12 +367,12 @@ void btSetupContactConstraint(
float denom = dot(K*normal,normal);
constraintFriction1.mJacDiagInv = 1.0f/denom;
constraintFriction1.mRhs = -dot(vAB,normal);
constraintFriction1.mRhs *= constraintFriction1.mJacDiagInv;
constraintFriction1.mLowerLimit = 0.0f;
constraintFriction1.mUpperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintFriction1.mNormal);
constraintFriction1.m_jacDiagInv = 1.0f/denom;
constraintFriction1.m_rhs = -dot(vAB,normal);
constraintFriction1.m_rhs *= constraintFriction1.m_jacDiagInv;
constraintFriction1.m_lowerLimit = 0.0f;
constraintFriction1.m_upperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintFriction1.m_normal);
}
// Friction Constraint 2
@ -381,12 +381,12 @@ void btSetupContactConstraint(
float denom = dot(K*normal,normal);
constraintFriction2.mJacDiagInv = 1.0f/denom;
constraintFriction2.mRhs = -dot(vAB,normal);
constraintFriction2.mRhs *= constraintFriction2.mJacDiagInv;
constraintFriction2.mLowerLimit = 0.0f;
constraintFriction2.mUpperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintFriction2.mNormal);
constraintFriction2.m_jacDiagInv = 1.0f/denom;
constraintFriction2.m_rhs = -dot(vAB,normal);
constraintFriction2.m_rhs *= constraintFriction2.m_jacDiagInv;
constraintFriction2.m_lowerLimit = 0.0f;
constraintFriction2.m_upperLimit = SIMD_INFINITY;
btStoreVector3(normal,constraintFriction2.m_normal);
}
}
@ -435,7 +435,7 @@ void CustomSetupContactConstraintsTask(
cp.getDistance(),
restitution,
friction,
btReadVector3(cp.m_normalWorldOnB),//.mConstraintRow[0].mNormal),
btReadVector3(cp.m_normalWorldOnB),//.mConstraintRow[0].m_normal),
btReadVector3(cp.m_localPointA),
btReadVector3(cp.m_localPointB),
stateA,
@ -994,7 +994,7 @@ btScalar btParallelConstraintSolver::solveGroup(btCollisionObject** bodies1,int
int sz2 = sizeof(vmVector3);
int sz3 = sizeof(vmMatrix3);
int sz4 = sizeof(vmQuat);
int sz5 = sizeof(PfxConstraintRow);
int sz5 = sizeof(btConstraintRow);
int sz6 = sizeof(btSolverConstraint);
int sz7 = sizeof(TrbState);
*/
@ -1119,7 +1119,7 @@ btScalar btParallelConstraintSolver::solveGroup(btCollisionObject** bodies1,int
pfxSetActive(pair,numPosPoints>0);
pfxSetBroadphaseFlag(pair,0);
pfxSetContactId(pair,(uint64_t)m);//contactId);
pfxSetContactId(pair,(uint32_t)m);//contactId);
pfxSetNumConstraints(pair,numPosPoints);//manifoldPtr[i]->getNumContacts());
actualNumManifolds++;
}
@ -1279,7 +1279,7 @@ btScalar btParallelConstraintSolver::solveGroup(btCollisionObject** bodies1,int
pfxSetMotionMaskB(pair,m_memoryCache->m_mystates[idB].getMotionMask());
pfxSetActive(pair,true);
pfxSetContactId(pair,(uint64_t)currentConstraintRow);//contactId);
pfxSetContactId(pair,(uint32_t)currentConstraintRow);//contactId);
actualNumJoints++;

View File

@ -31,7 +31,7 @@
#define AOS_VECTORMATH_BULLET_CONVERT_H
#include "vectormath/vmInclude.h"
#include "vecmath/vmInclude.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btQuaternion.h"
#include "LinearMath/btMatrix3x3.h"