fix many warnings
remove btMultiSapBroadphase.* make collisionFilterGroup/collisionFilterMark int (instead of short int)
This commit is contained in:
@@ -1021,9 +1021,10 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
||||
unsigned int signs[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0};
|
||||
|
||||
b3Scalar lambda_max = rayDir.dot(rayTo-rayFrom);
|
||||
|
||||
#ifdef COMPARE_BTRAY_AABB2
|
||||
b3Vector3 resultNormal;
|
||||
|
||||
#endif//COMPARE_BTRAY_AABB2
|
||||
|
||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||
|
||||
int depth=1;
|
||||
|
||||
@@ -164,8 +164,8 @@ b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb
|
||||
const b3Vector3& aabbMax,
|
||||
int objectId,
|
||||
void* userPtr,
|
||||
short int collisionFilterGroup,
|
||||
short int collisionFilterMask)
|
||||
int collisionFilterGroup,
|
||||
int collisionFilterMask)
|
||||
{
|
||||
b3DbvtProxy* mem = &m_proxies[objectId];
|
||||
b3DbvtProxy* proxy=new(mem) b3DbvtProxy( aabbMin,aabbMax,userPtr,
|
||||
|
||||
@@ -61,9 +61,8 @@ B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//Usually the client b3CollisionObject or Rigidbody class
|
||||
void* m_clientObject;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
void* m_multiSapParentProxy;
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
|
||||
|
||||
b3Vector3 m_aabbMin;
|
||||
@@ -75,18 +74,17 @@ B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
}
|
||||
|
||||
//used for memory pools
|
||||
b3BroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
|
||||
b3BroadphaseProxy() :m_clientObject(0)
|
||||
{
|
||||
}
|
||||
|
||||
b3BroadphaseProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
|
||||
b3BroadphaseProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
:m_clientObject(userPtr),
|
||||
m_collisionFilterGroup(collisionFilterGroup),
|
||||
m_collisionFilterMask(collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax)
|
||||
{
|
||||
m_multiSapParentProxy = multiSapParentProxy;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -107,7 +105,7 @@ struct b3DbvtProxy : b3BroadphaseProxy
|
||||
/* ctor */
|
||||
|
||||
explicit b3DbvtProxy() {}
|
||||
b3DbvtProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||
b3DbvtProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr, int collisionFilterGroup, int collisionFilterMask) :
|
||||
b3BroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
{
|
||||
links[0]=links[1]=0;
|
||||
@@ -165,7 +163,7 @@ struct b3DynamicBvhBroadphase
|
||||
void optimize();
|
||||
|
||||
/* b3BroadphaseInterface Implementation */
|
||||
b3BroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int objectIndex,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
b3BroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int objectIndex,void* userPtr, int collisionFilterGroup, int collisionFilterMask);
|
||||
virtual void destroyProxy(b3BroadphaseProxy* proxy,b3Dispatcher* dispatcher);
|
||||
virtual void setAabb(int objectId,const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3Dispatcher* dispatcher);
|
||||
virtual void rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, b3BroadphaseRayCallback& rayCallback, const b3Vector3& aabbMin=b3MakeVector3(0,0,0), const b3Vector3& aabbMax = b3MakeVector3(0,0,0));
|
||||
|
||||
@@ -32,8 +32,8 @@ int b3g_findPairs =0;
|
||||
|
||||
|
||||
b3HashedOverlappingPairCache::b3HashedOverlappingPairCache():
|
||||
m_overlapFilterCallback(0),
|
||||
m_blockedForChanges(false)
|
||||
m_overlapFilterCallback(0)
|
||||
//, m_blockedForChanges(false)
|
||||
{
|
||||
int initialAllocatedSize= 2;
|
||||
m_overlappingPairArray.reserve(initialAllocatedSize);
|
||||
|
||||
@@ -98,7 +98,7 @@ class b3HashedOverlappingPairCache : public b3OverlappingPairCache
|
||||
{
|
||||
b3BroadphasePairArray m_overlappingPairArray;
|
||||
b3OverlapFilterCallback* m_overlapFilterCallback;
|
||||
bool m_blockedForChanges;
|
||||
// bool m_blockedForChanges;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -108,7 +108,7 @@ __kernel void clipFacesAndFindContactsKernel( __global const b3Float4* sepa
|
||||
|
||||
|
||||
int closestFaceA = clippingFaces[pairIndex].x;
|
||||
int closestFaceB = clippingFaces[pairIndex].y;
|
||||
// int closestFaceB = clippingFaces[pairIndex].y;
|
||||
int numVertsInA = clippingFaces[pairIndex].z;
|
||||
int numVertsInB = clippingFaces[pairIndex].w;
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ inline int b3ClipFaceAgainstHull(const b3Float4& separatingNormal, const b3Conve
|
||||
b3GpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];
|
||||
|
||||
// clip polygon to back of planes of all faces of hull A that are adjacent to witness face
|
||||
int numContacts = numWorldVertsB1;
|
||||
//int numContacts = numWorldVertsB1;
|
||||
int numVerticesA = polyA.m_numIndices;
|
||||
for(int e0=0;e0<numVerticesA;e0++)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ inline int b3ClipHullAgainstHull(const b3Float4& separatingNormal,
|
||||
|
||||
B3_PROFILE("clipHullAgainstHull");
|
||||
|
||||
float curMaxDist=maxDist;
|
||||
//float curMaxDist=maxDist;
|
||||
int closestFaceB=-1;
|
||||
float dmax = -FLT_MAX;
|
||||
|
||||
@@ -399,7 +399,7 @@ inline int b3ClipHullHullSingle(
|
||||
contact.m_frictionCoeffCmp = 45874;
|
||||
contact.m_restituitionCoeffCmp = 0;
|
||||
|
||||
float distance = 0.f;
|
||||
// float distance = 0.f;
|
||||
for (int p=0;p<numPoints;p++)
|
||||
{
|
||||
contact.m_worldPosB[p] = contactsOut[contactIdx.s[p]];//check if it is actually on B
|
||||
@@ -461,9 +461,6 @@ inline int b3ContactConvexConvexSAT(
|
||||
//printf("numvertsB = %d\n",hullB.m_numVertices);
|
||||
|
||||
|
||||
// b3Float4 contactsOut[B3_MAX_VERTS];
|
||||
int contactCapacity = B3_MAX_VERTS;
|
||||
int numContactsOut=0;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -323,7 +323,7 @@ bool b3FindSeparatingAxisEdgeEdge( const b3ConvexPolyhedronData* hullA, __global
|
||||
b3Float4 posB = posB1;
|
||||
posB.w = 0.f;
|
||||
|
||||
int curPlaneTests=0;
|
||||
// int curPlaneTests=0;
|
||||
|
||||
int curEdgeEdge = 0;
|
||||
// Test edges
|
||||
@@ -577,7 +577,7 @@ __kernel void b3FindConcaveSeparatingAxisKernel( __global b3Int4* concavePairs
|
||||
|
||||
hasSeparatingNormals[i] = 0;
|
||||
|
||||
int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
// int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
int numActualConcaveConvexTests = 0;
|
||||
|
||||
int f = concavePairs[i].z;
|
||||
@@ -620,7 +620,7 @@ __kernel void b3FindConcaveSeparatingAxisKernel( __global b3Int4* concavePairs
|
||||
int hasSeparatingAxis=5;
|
||||
b3Float4 sepAxis=b3MakeFloat4(1,2,3,4);
|
||||
|
||||
int localCC=0;
|
||||
// int localCC=0;
|
||||
numActualConcaveConvexTests++;
|
||||
|
||||
//a triangle has 3 unique edges
|
||||
@@ -665,7 +665,7 @@ __kernel void b3FindConcaveSeparatingAxisKernel( __global b3Int4* concavePairs
|
||||
indicesA[5]=0;
|
||||
curUsedIndices+=3;
|
||||
float c = b3Dot(normal,verticesA[0]);
|
||||
float c1 = -face.m_plane.w;
|
||||
// float c1 = -face.m_plane.w;
|
||||
facesA[fidx].m_plane.x = -normal.x;
|
||||
facesA[fidx].m_plane.y = -normal.y;
|
||||
facesA[fidx].m_plane.z = -normal.z;
|
||||
|
||||
@@ -16,7 +16,7 @@ inline void b3ProjectAxis(const b3ConvexPolyhedronData& hull, const b3Float4& p
|
||||
{
|
||||
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
|
||||
//b3Scalar dp = pt.dot(dir);
|
||||
b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
//b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
b3Scalar dp = b3Dot3F4((b3Float4&)vertices[hull.m_vertexOffset+i],localDir);
|
||||
//b3Assert(dp==dpL);
|
||||
if(dp < min) min = dp;
|
||||
|
||||
@@ -180,7 +180,7 @@ B3_STATIC void b3MprConvexSupport(int pairIndex,int bodyIndex, b3ConstArray(b3R
|
||||
{
|
||||
|
||||
|
||||
b3Float4 supVec = b3MakeFloat4(0,0,0,0);
|
||||
// b3Float4 supVec = b3MakeFloat4(0,0,0,0);
|
||||
float maxDot = -B3_LARGE_FLOAT;
|
||||
|
||||
if( 0 < hull->m_numVertices )
|
||||
|
||||
@@ -142,8 +142,9 @@ int getNumContacts(b3Contact4* contact)
|
||||
}
|
||||
|
||||
b3PgsJacobiSolver::b3PgsJacobiSolver(bool usePgs)
|
||||
:m_btSeed2(0),m_usePgs(usePgs),
|
||||
m_numSplitImpulseRecoveries(0)
|
||||
:m_usePgs(usePgs),
|
||||
m_numSplitImpulseRecoveries(0),
|
||||
m_btSeed2(0)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1084,7 +1085,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyData* bodies
|
||||
m_deltaAngularVelocities.resize(0);
|
||||
m_deltaAngularVelocities.resize(numBodies,b3MakeVector3(0,0,0));
|
||||
|
||||
int totalBodies = 0;
|
||||
//int totalBodies = 0;
|
||||
|
||||
for (int i=0;i<numConstraints;i++)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ void b3Point2PointConstraint::getInfo2NonVirtual (b3ConstraintInfo2* info, const
|
||||
info->m_J1linearAxis[2*info->rowskip+2] = 1;
|
||||
|
||||
b3Vector3 a1 = body0_trans.getBasis()*getPivotInA();
|
||||
b3Vector3 a1a = b3QuatRotate(body0_trans.getRotation(),getPivotInA());
|
||||
//b3Vector3 a1a = b3QuatRotate(body0_trans.getRotation(),getPivotInA());
|
||||
|
||||
{
|
||||
b3Vector3* angular0 = (b3Vector3*)(info->m_J1angularAxis);
|
||||
|
||||
@@ -254,9 +254,12 @@ struct b3SolveTask// : public ThreadPool::Task
|
||||
int maxNumBatches,
|
||||
b3AlignedObjectArray<int>* wgUsedBodies, int curWgidx
|
||||
)
|
||||
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ),m_maxNumBatches(maxNumBatches),
|
||||
m_wgUsedBodies(wgUsedBodies),m_curWgidx(curWgidx)
|
||||
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ),
|
||||
m_wgUsedBodies(wgUsedBodies),m_curWgidx(curWgidx),
|
||||
m_start( start ),
|
||||
m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ),
|
||||
m_maxNumBatches(maxNumBatches)
|
||||
{}
|
||||
|
||||
unsigned short int getType(){ return 0; }
|
||||
@@ -281,10 +284,11 @@ struct b3SolveTask// : public ThreadPool::Task
|
||||
float frictionCoeff = b3GetFrictionCoeff(&m_constraints[i]);
|
||||
int aIdx = (int)m_constraints[i].m_bodyA;
|
||||
int bIdx = (int)m_constraints[i].m_bodyB;
|
||||
int localBatch = m_constraints[i].m_batchIdx;
|
||||
//int localBatch = m_constraints[i].m_batchIdx;
|
||||
b3RigidBodyData& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = m_bodies[bIdx];
|
||||
|
||||
#if 0
|
||||
if ((bodyA.m_invMass) && (bodyB.m_invMass))
|
||||
{
|
||||
// printf("aIdx=%d, bIdx=%d\n", aIdx,bIdx);
|
||||
@@ -293,7 +297,7 @@ struct b3SolveTask// : public ThreadPool::Task
|
||||
{
|
||||
//printf("ic(b)=%d, localBatch=%d\n",ic,localBatch);
|
||||
}
|
||||
|
||||
#endif
|
||||
if (aIdx==10)
|
||||
{
|
||||
//printf("ic(a)=%d, localBatch=%d\n",ic,localBatch);
|
||||
@@ -393,7 +397,7 @@ void b3CpuRigidBodyPipeline::solveContactConstraints()
|
||||
int m_nIterations = 4;
|
||||
|
||||
b3AlignedObjectArray<b3ContactConstraint4> contactConstraints;
|
||||
const b3AlignedObjectArray<b3Contact4Data>& contacts = m_data->m_np->getContacts();
|
||||
// const b3AlignedObjectArray<b3Contact4Data>& contacts = m_data->m_np->getContacts();
|
||||
int n = contactConstraints.size();
|
||||
//convert contacts...
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)=0;
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)=0;
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)=0;
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)=0;
|
||||
|
||||
virtual void calculateOverlappingPairs(int maxPairs)=0;
|
||||
virtual void calculateOverlappingPairsHost(int maxPairs)=0;
|
||||
|
||||
@@ -38,8 +38,9 @@ m_largeAabbsMappingGPU(ctx,q),
|
||||
m_gpuPairs(ctx,q),
|
||||
|
||||
m_hashGpu(ctx,q),
|
||||
m_paramsGPU(ctx,q),
|
||||
m_cellStartGpu(ctx,q)
|
||||
|
||||
m_cellStartGpu(ctx,q),
|
||||
m_paramsGPU(ctx,q)
|
||||
{
|
||||
|
||||
|
||||
@@ -110,7 +111,7 @@ b3GpuGridBroadphase::~b3GpuGridBroadphase()
|
||||
|
||||
|
||||
|
||||
void b3GpuGridBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void b3GpuGridBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
b3SapAabb aabb;
|
||||
aabb.m_minVec = aabbMin;
|
||||
@@ -122,7 +123,7 @@ void b3GpuGridBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3
|
||||
m_allAabbsCPU1.push_back(aabb);
|
||||
|
||||
}
|
||||
void b3GpuGridBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void b3GpuGridBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
b3SapAabb aabb;
|
||||
aabb.m_minVec = aabbMin;
|
||||
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
|
||||
|
||||
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask);
|
||||
|
||||
virtual void calculateOverlappingPairs(int maxPairs);
|
||||
virtual void calculateOverlappingPairsHost(int maxPairs);
|
||||
|
||||
@@ -24,7 +24,7 @@ b3GpuParallelLinearBvhBroadphase::b3GpuParallelLinearBvhBroadphase(cl_context co
|
||||
{
|
||||
}
|
||||
|
||||
void b3GpuParallelLinearBvhBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, short int collisionFilterGroup, short int collisionFilterMask)
|
||||
void b3GpuParallelLinearBvhBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
int newAabbIndex = m_aabbsCpu.size();
|
||||
|
||||
@@ -39,7 +39,7 @@ void b3GpuParallelLinearBvhBroadphase::createProxy(const b3Vector3& aabbMin, con
|
||||
|
||||
m_aabbsCpu.push_back(aabb);
|
||||
}
|
||||
void b3GpuParallelLinearBvhBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, short int collisionFilterGroup, short int collisionFilterMask)
|
||||
void b3GpuParallelLinearBvhBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
int newAabbIndex = m_aabbsCpu.size();
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
b3GpuParallelLinearBvhBroadphase(cl_context context, cl_device_id device, cl_command_queue queue);
|
||||
virtual ~b3GpuParallelLinearBvhBroadphase() {}
|
||||
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, short int collisionFilterGroup, short int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, short int collisionFilterGroup, short int collisionFilterMask);
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask);
|
||||
|
||||
virtual void calculateOverlappingPairs(int maxPairs);
|
||||
virtual void calculateOverlappingPairsHost(int maxPairs);
|
||||
|
||||
@@ -14,22 +14,53 @@ bool searchIncremental3dSapOnGpu = true;
|
||||
|
||||
#define B3_BROADPHASE_SAP_PATH "src/Bullet3OpenCL/BroadphaseCollision/kernels/sap.cl"
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
b3OpenCLArray<int> m_pairCount;
|
||||
|
||||
|
||||
b3OpenCLArray<b3SapAabb> m_allAabbsGPU;
|
||||
b3AlignedObjectArray<b3SapAabb> m_allAabbsCPU;
|
||||
|
||||
virtual b3OpenCLArray<b3SapAabb>& getAllAabbsGPU()
|
||||
{
|
||||
return m_allAabbsGPU;
|
||||
}
|
||||
virtual b3AlignedObjectArray<b3SapAabb>& getAllAabbsCPU()
|
||||
{
|
||||
return m_allAabbsCPU;
|
||||
}
|
||||
|
||||
b3OpenCLArray<b3Vector3> m_sum;
|
||||
b3OpenCLArray<b3Vector3> m_sum2;
|
||||
b3OpenCLArray<b3Vector3> m_dst;
|
||||
|
||||
b3OpenCLArray<int> m_smallAabbsMappingGPU;
|
||||
b3AlignedObjectArray<int> m_smallAabbsMappingCPU;
|
||||
|
||||
b3OpenCLArray<int> m_largeAabbsMappingGPU;
|
||||
b3AlignedObjectArray<int> m_largeAabbsMappingCPU;
|
||||
|
||||
|
||||
b3OpenCLArray<b3Int4> m_overlappingPairs;
|
||||
|
||||
//temporary gpu work memory
|
||||
b3OpenCLArray<b3SortData> m_gpuSmallSortData;
|
||||
b3OpenCLArray<b3SapAabb> m_gpuSmallSortedAabbs;
|
||||
|
||||
class b3PrefixScanFloat4CL* m_prefixScanFloat4;
|
||||
*/
|
||||
|
||||
b3GpuSapBroadphase::b3GpuSapBroadphase(cl_context ctx,cl_device_id device, cl_command_queue q , b3GpuSapKernelType kernelType)
|
||||
:m_context(ctx),
|
||||
m_device(device),
|
||||
m_queue(q),
|
||||
m_allAabbsGPU(ctx,q),
|
||||
m_smallAabbsMappingGPU(ctx,q),
|
||||
m_largeAabbsMappingGPU(ctx,q),
|
||||
m_pairCount(ctx,q),
|
||||
m_overlappingPairs(ctx,q),
|
||||
m_gpuSmallSortData(ctx,q),
|
||||
m_gpuSmallSortedAabbs(ctx,q),
|
||||
m_sum(ctx,q),
|
||||
m_sum2(ctx,q),
|
||||
m_dst(ctx,q),
|
||||
m_currentBuffer(-1),
|
||||
|
||||
m_objectMinMaxIndexGPUaxis0(ctx,q),
|
||||
m_objectMinMaxIndexGPUaxis1(ctx,q),
|
||||
m_objectMinMaxIndexGPUaxis2(ctx,q),
|
||||
@@ -45,7 +76,18 @@ m_sortedAxisGPU2prev(ctx,q),
|
||||
m_addedHostPairsGPU(ctx,q),
|
||||
m_removedHostPairsGPU(ctx,q),
|
||||
m_addedCountGPU(ctx,q),
|
||||
m_removedCountGPU(ctx,q)
|
||||
m_removedCountGPU(ctx,q),
|
||||
m_currentBuffer(-1),
|
||||
m_pairCount(ctx,q),
|
||||
m_allAabbsGPU(ctx,q),
|
||||
m_sum(ctx,q),
|
||||
m_sum2(ctx,q),
|
||||
m_dst(ctx,q),
|
||||
m_smallAabbsMappingGPU(ctx,q),
|
||||
m_largeAabbsMappingGPU(ctx,q),
|
||||
m_overlappingPairs(ctx,q),
|
||||
m_gpuSmallSortData(ctx,q),
|
||||
m_gpuSmallSortedAabbs(ctx,q)
|
||||
{
|
||||
const char* sapSrc = sapCL;
|
||||
|
||||
@@ -191,7 +233,7 @@ void b3GpuSapBroadphase::init3dSap()
|
||||
|
||||
for (int axis=0;axis<3;axis++)
|
||||
{
|
||||
int totalNumAabbs = m_allAabbsCPU.size();
|
||||
//int totalNumAabbs = m_allAabbsCPU.size();
|
||||
int numEndPoints = m_sortedAxisCPU[axis][m_currentBuffer].size();
|
||||
m_objectMinMaxIndexCPU[axis][m_currentBuffer].resize(numEndPoints);
|
||||
for (int i=0;i<numEndPoints;i++)
|
||||
@@ -240,7 +282,7 @@ b3AlignedObjectArray<b3SapAabb> preAabbs;
|
||||
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
{
|
||||
static int framepje = 0;
|
||||
//static int framepje = 0;
|
||||
//printf("framepje=%d\n",framepje++);
|
||||
|
||||
|
||||
@@ -371,6 +413,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
m_sorter->executeHost(m_sortedAxisCPU[axis][m_currentBuffer]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (0)
|
||||
{
|
||||
for (int axis=0;axis<3;axis++)
|
||||
@@ -378,14 +421,14 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
//printf("axis %d\n",axis);
|
||||
for (int i=0;i<m_sortedAxisCPU[axis][m_currentBuffer].size();i++)
|
||||
{
|
||||
int key = m_sortedAxisCPU[axis][m_currentBuffer][i].m_key;
|
||||
int value = m_sortedAxisCPU[axis][m_currentBuffer][i].m_value;
|
||||
//int key = m_sortedAxisCPU[axis][m_currentBuffer][i].m_key;
|
||||
//int value = m_sortedAxisCPU[axis][m_currentBuffer][i].m_value;
|
||||
//printf("[%d]=%d\n",i,value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
B3_PROFILE("assign m_objectMinMaxIndexCPU");
|
||||
@@ -409,7 +452,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
if (0)
|
||||
{
|
||||
printf("==========================\n");
|
||||
@@ -440,6 +483,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int a = m_objectMinMaxIndexCPU[0][m_currentBuffer].size();
|
||||
@@ -654,7 +698,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
int otherIndex = otherIndex2/2;
|
||||
if (otherIndex!=i)
|
||||
{
|
||||
bool otherIsMin = ((otherIndex2&1)==0);
|
||||
//bool otherIsMin = ((otherIndex2&1)==0);
|
||||
//if (otherIsMin)
|
||||
{
|
||||
//bool overlap = TestAabbAgainstAabb2((const b3Vector3&)m_allAabbsCPU[i].m_min, (const b3Vector3&)m_allAabbsCPU[i].m_max,(const b3Vector3&)m_allAabbsCPU[otherIndex].m_min,(const b3Vector3&)m_allAabbsCPU[otherIndex].m_max);
|
||||
@@ -906,7 +950,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost(int maxPairs)
|
||||
for (int i=0;i<numSmallAabbs;i++)
|
||||
{
|
||||
b3SapAabb smallAabbi = m_allAabbsCPU[m_smallAabbsMappingCPU[i]];
|
||||
float reference = smallAabbi.m_max[axis];
|
||||
//float reference = smallAabbi.m_max[axis];
|
||||
|
||||
for (int j=i+1;j<numSmallAabbs;j++)
|
||||
{
|
||||
@@ -941,7 +985,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost(int maxPairs)
|
||||
{
|
||||
b3SapAabb smallAabbi = m_allAabbsCPU[m_smallAabbsMappingCPU[i]];
|
||||
|
||||
float reference = smallAabbi.m_max[axis];
|
||||
//float reference = smallAabbi.m_max[axis];
|
||||
int numLargeAabbs = m_largeAabbsMappingCPU.size();
|
||||
|
||||
for (int j=0;j<numLargeAabbs;j++)
|
||||
@@ -1022,7 +1066,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
|
||||
{
|
||||
|
||||
bool syncOnHost = false;
|
||||
//bool syncOnHost = false;
|
||||
|
||||
int numSmallAabbs = m_smallAabbsMappingCPU.size();
|
||||
if (m_prefixScanFloat4 && numSmallAabbs)
|
||||
@@ -1261,7 +1305,7 @@ void b3GpuSapBroadphase::writeAabbsToGpu()
|
||||
|
||||
}
|
||||
|
||||
void b3GpuSapBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void b3GpuSapBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
int index = userPtr;
|
||||
b3SapAabb aabb;
|
||||
@@ -1277,7 +1321,7 @@ void b3GpuSapBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vec
|
||||
m_allAabbsCPU.push_back(aabb);
|
||||
}
|
||||
|
||||
void b3GpuSapBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void b3GpuSapBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
int index = userPtr;
|
||||
b3SapAabb aabb;
|
||||
|
||||
@@ -133,8 +133,8 @@ public:
|
||||
void init3dSap();
|
||||
virtual void calculateOverlappingPairsHostIncremental3Sap();
|
||||
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask);
|
||||
virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask);
|
||||
|
||||
//call writeAabbsToGpu after done making all changes (createProxy etc)
|
||||
virtual void writeAabbsToGpu();
|
||||
|
||||
@@ -172,7 +172,7 @@ cl_platform_id b3OpenCLUtils_getPlatform(int platformIndex0, cl_int* pErrNum)
|
||||
cl_uint numPlatforms;
|
||||
cl_int ciErrNum = clGetPlatformIDs(0, NULL, &numPlatforms);
|
||||
|
||||
if (platformIndex>=0 && platformIndex<numPlatforms)
|
||||
if (platformIndex<numPlatforms)
|
||||
{
|
||||
cl_platform_id* platforms = (cl_platform_id*) malloc (sizeof(cl_platform_id)*numPlatforms);
|
||||
ciErrNum = clGetPlatformIDs(numPlatforms, platforms, NULL);
|
||||
@@ -583,7 +583,7 @@ static const char* strip2(const char* name, const char* pattern)
|
||||
const char * oriptr;
|
||||
const char * patloc;
|
||||
// find how many times the pattern occurs in the original string
|
||||
for (oriptr = name; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen)
|
||||
for (oriptr = name; (patloc = strstr(oriptr, pattern)); oriptr = patloc + patlen)
|
||||
{
|
||||
patcnt++;
|
||||
}
|
||||
@@ -608,8 +608,9 @@ cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
char driverVersion[256];
|
||||
const char* strippedName;
|
||||
int fileUpToDate = 0;
|
||||
#ifdef _WIN32
|
||||
int binaryFileValid=0;
|
||||
|
||||
#endif
|
||||
if (!disableBinaryCaching && clFileNameForCaching)
|
||||
{
|
||||
clGetDeviceInfo(device, CL_DEVICE_NAME, 256, &deviceName, NULL);
|
||||
@@ -862,7 +863,8 @@ cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
int kernelSize = ftell( file );
|
||||
rewind( file );
|
||||
kernelSrc = (char*)malloc(kernelSize+1);
|
||||
int readBytes = fread((void*)kernelSrc,1,kernelSize, file);
|
||||
int readBytes;
|
||||
readBytes = fread((void*)kernelSrc,1,kernelSize, file);
|
||||
kernelSrc[kernelSize] = 0;
|
||||
fclose(file);
|
||||
kernelSource = kernelSrc;
|
||||
|
||||
@@ -105,21 +105,29 @@ GpuSatCollision::GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_
|
||||
:m_context(ctx),
|
||||
m_device(device),
|
||||
m_queue(q),
|
||||
|
||||
m_findSeparatingAxisKernel(0),
|
||||
m_findSeparatingAxisVertexFaceKernel(0),
|
||||
m_findSeparatingAxisEdgeEdgeKernel(0),
|
||||
m_unitSphereDirections(m_context,m_queue),
|
||||
|
||||
m_totalContactsOut(m_context, m_queue),
|
||||
m_sepNormals(m_context, m_queue),
|
||||
m_dmins(m_context,m_queue),
|
||||
|
||||
m_hasSeparatingNormals(m_context, m_queue),
|
||||
m_concaveSepNormals(m_context, m_queue),
|
||||
m_concaveHasSeparatingNormals(m_context,m_queue),
|
||||
m_numConcavePairsOut(m_context, m_queue),
|
||||
|
||||
|
||||
m_gpuCompoundPairs(m_context, m_queue),
|
||||
|
||||
|
||||
m_gpuCompoundSepNormals(m_context, m_queue),
|
||||
m_gpuHasCompoundSepNormals(m_context, m_queue),
|
||||
m_numCompoundPairsOut(m_context, m_queue),
|
||||
m_dmins(m_context,m_queue),
|
||||
m_unitSphereDirections(m_context,m_queue)
|
||||
|
||||
m_numCompoundPairsOut(m_context, m_queue)
|
||||
{
|
||||
m_totalContactsOut.push_back(0);
|
||||
|
||||
@@ -553,7 +561,7 @@ inline void project(const b3ConvexPolyhedronData& hull, const float4& pos, cons
|
||||
{
|
||||
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
|
||||
//b3Scalar dp = pt.dot(dir);
|
||||
b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
//b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
b3Scalar dp = dot3F4((float4&)vertices[hull.m_vertexOffset+i],localDir);
|
||||
//b3Assert(dp==dpL);
|
||||
if(dp < min) min = dp;
|
||||
@@ -764,7 +772,7 @@ bool findSeparatingAxisEdgeEdge( __global const b3ConvexPolyhedronData* hullA, _
|
||||
float4 posB = posB1;
|
||||
posB.w = 0.f;
|
||||
|
||||
int curPlaneTests=0;
|
||||
//int curPlaneTests=0;
|
||||
|
||||
int curEdgeEdge = 0;
|
||||
// Test edges
|
||||
@@ -927,7 +935,7 @@ int clipFaceAgainstHull(const float4& separatingNormal, const b3ConvexPolyhedron
|
||||
b3GpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];
|
||||
|
||||
// clip polygon to back of planes of all faces of hull A that are adjacent to witness face
|
||||
int numContacts = numWorldVertsB1;
|
||||
// int numContacts = numWorldVertsB1;
|
||||
int numVerticesA = polyA.m_numIndices;
|
||||
for(int e0=0;e0<numVerticesA;e0++)
|
||||
{
|
||||
@@ -1008,7 +1016,7 @@ static int clipHullAgainstHull(const float4& separatingNormal,
|
||||
|
||||
B3_PROFILE("clipHullAgainstHull");
|
||||
|
||||
float curMaxDist=maxDist;
|
||||
// float curMaxDist=maxDist;
|
||||
int closestFaceB=-1;
|
||||
float dmax = -FLT_MAX;
|
||||
|
||||
@@ -1318,7 +1326,7 @@ int clipHullHullSingle(
|
||||
contact.m_frictionCoeffCmp = 45874;
|
||||
contact.m_restituitionCoeffCmp = 0;
|
||||
|
||||
float distance = 0.f;
|
||||
// float distance = 0.f;
|
||||
for (int p=0;p<numPoints;p++)
|
||||
{
|
||||
contact.m_worldPosB[p] = contactsOut[contactIdx.s[p]];//check if it is actually on B
|
||||
@@ -1362,8 +1370,8 @@ void computeContactPlaneConvex(int pairIndex,
|
||||
b3Vector3 posA = rigidBodies[bodyIndexA].m_pos;
|
||||
b3Quaternion ornA = rigidBodies[bodyIndexA].m_quat;
|
||||
|
||||
int numContactsOut = 0;
|
||||
int numWorldVertsB1= 0;
|
||||
// int numContactsOut = 0;
|
||||
// int numWorldVertsB1= 0;
|
||||
|
||||
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
||||
b3Vector3 planeNormal=b3MakeVector3(planeEq.x,planeEq.y,planeEq.z);
|
||||
@@ -1518,7 +1526,7 @@ __kernel void findCompoundPairsKernel(
|
||||
{
|
||||
numAabbChecks=0;
|
||||
maxNumAabbChecks=0;
|
||||
int i = pairIndex;
|
||||
// int i = pairIndex;
|
||||
{
|
||||
|
||||
|
||||
@@ -1590,10 +1598,10 @@ __kernel void findCompoundPairsKernel(
|
||||
{
|
||||
|
||||
int startNodeIndexA = subtreeA.m_rootNodeIndex+bvhInfoCPU[bvhA].m_nodeOffset;
|
||||
int endNodeIndexA = startNodeIndexA+subtreeA.m_subtreeSize;
|
||||
// int endNodeIndexA = startNodeIndexA+subtreeA.m_subtreeSize;
|
||||
|
||||
int startNodeIndexB = subtreeB.m_rootNodeIndex+bvhInfoCPU[bvhB].m_nodeOffset;
|
||||
int endNodeIndexB = startNodeIndexB+subtreeB.m_subtreeSize;
|
||||
// int endNodeIndexB = startNodeIndexB+subtreeB.m_subtreeSize;
|
||||
|
||||
b3AlignedObjectArray<b3Int2> nodeStack;
|
||||
b3Int2 node0;
|
||||
@@ -1790,19 +1798,21 @@ __kernel void findCompoundPairsKernel(
|
||||
{
|
||||
if (1)
|
||||
{
|
||||
int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
float dmin = FLT_MAX;
|
||||
// int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
// float dmin = FLT_MAX;
|
||||
float4 posA = newPosA;
|
||||
posA.w = 0.f;
|
||||
float4 posB = rigidBodies[bodyIndexB].m_pos;
|
||||
posB.w = 0.f;
|
||||
float4 c0local = convexShapes[shapeIndexA].m_localCenter;
|
||||
b3Quat ornA = newOrnA;
|
||||
float4 c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c0;
|
||||
c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c1local = convexShapes[shapeIndexB].m_localCenter;
|
||||
b3Quat ornB = rigidBodies[bodyIndexB].m_quat;
|
||||
float4 c1 = transform(&c1local,&posB,&ornB);
|
||||
const float4 DeltaC2 = c0 - c1;
|
||||
float4 c1;
|
||||
c1 = transform(&c1local,&posB,&ornB);
|
||||
// const float4 DeltaC2 = c0 - c1;
|
||||
|
||||
{
|
||||
int compoundPairIdx = b3AtomicInc(numCompoundPairsOut);
|
||||
@@ -1838,19 +1848,21 @@ __kernel void findCompoundPairsKernel(
|
||||
|
||||
if (1)
|
||||
{
|
||||
int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
float dmin = FLT_MAX;
|
||||
// int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
// float dmin = FLT_MAX;
|
||||
float4 posA = rigidBodies[bodyIndexA].m_pos;
|
||||
posA.w = 0.f;
|
||||
float4 posB = newPosB;
|
||||
posB.w = 0.f;
|
||||
float4 c0local = convexShapes[shapeIndexA].m_localCenter;
|
||||
b3Quat ornA = rigidBodies[bodyIndexA].m_quat;
|
||||
float4 c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c0;
|
||||
c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c1local = convexShapes[shapeIndexB].m_localCenter;
|
||||
b3Quat ornB =newOrnB;
|
||||
float4 c1 = transform(&c1local,&posB,&ornB);
|
||||
const float4 DeltaC2 = c0 - c1;
|
||||
float4 c1;
|
||||
c1 = transform(&c1local,&posB,&ornB);
|
||||
// const float4 DeltaC2 = c0 - c1;
|
||||
{//
|
||||
int compoundPairIdx = b3AtomicInc(numCompoundPairsOut);
|
||||
if (compoundPairIdx<maxNumCompoundPairsCapacity)
|
||||
@@ -1948,7 +1960,7 @@ __kernel void processCompoundPairsKernel( __global const b3Int4* gpuCompoundPa
|
||||
|
||||
int hasSeparatingAxis = 5;
|
||||
|
||||
int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
// int numFacesA = convexShapes[shapeIndexA].m_numFaces;
|
||||
float dmin = FLT_MAX;
|
||||
posA.w = 0.f;
|
||||
posB.w = 0.f;
|
||||
@@ -2326,8 +2338,8 @@ void computeContactPlaneCompound(int pairIndex,
|
||||
b3Vector3 posA = rigidBodies[bodyIndexA].m_pos;
|
||||
b3Quaternion ornA = rigidBodies[bodyIndexA].m_quat;
|
||||
|
||||
int numContactsOut = 0;
|
||||
int numWorldVertsB1= 0;
|
||||
// int numContactsOut = 0;
|
||||
// int numWorldVertsB1= 0;
|
||||
|
||||
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
|
||||
b3Vector3 planeNormal=b3MakeVector3(planeEq.x,planeEq.y,planeEq.z);
|
||||
@@ -2475,7 +2487,7 @@ void computeContactSphereConvex(int pairIndex,
|
||||
int shapeIndex = collidables[collidableIndex].m_shapeIndex;
|
||||
int numFaces = convexShapes[shapeIndex].m_numFaces;
|
||||
float4 closestPnt = b3MakeVector3(0, 0, 0, 0);
|
||||
float4 hitNormalWorld = b3MakeVector3(0, 0, 0, 0);
|
||||
// float4 hitNormalWorld = b3MakeVector3(0, 0, 0, 0);
|
||||
float minDist = -1000000.f; // TODO: What is the largest/smallest float?
|
||||
bool bCollide = true;
|
||||
int region = -1;
|
||||
@@ -2641,7 +2653,7 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
int shapeIndexA = collidables[collidableIndexA].m_shapeIndex;
|
||||
int shapeIndexB = collidables[collidableIndexB].m_shapeIndex;
|
||||
|
||||
int sz = sizeof(b3Contact4);
|
||||
//int sz = sizeof(b3Contact4);
|
||||
|
||||
bool result2 = getClosestPoints(&gjkDetector, transA, transB,
|
||||
convexShapes[shapeIndexA], convexShapes[shapeIndexB],
|
||||
@@ -2709,8 +2721,8 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
{
|
||||
resultPointOnBWorld.w = distance2;
|
||||
newContact.m_worldPosB[p] = resultPointOnBWorld;
|
||||
b3Vector3 resultPointOnAWorld = resultPointOnBWorld+distance2*sepAxis2;
|
||||
#ifdef PERSISTENT_CONTACTS_HOST
|
||||
b3Vector3 resultPointOnAWorld = resultPointOnBWorld+distance2*sepAxis2;
|
||||
newContact.m_localPosA[p] = transA.inverse()*resultPointOnAWorld;
|
||||
newContact.m_localPosB[p] = transB.inverse()*resultPointOnBWorld;
|
||||
#endif
|
||||
@@ -2774,8 +2786,8 @@ int computeContactConvexConvex2(
|
||||
hullB = convexShapes[colB.m_shapeIndex];
|
||||
//printf("numvertsB = %d\n",hullB.m_numVertices);
|
||||
|
||||
int contactCapacity = MAX_VERTS;
|
||||
int numContactsOut=0;
|
||||
// int contactCapacity = MAX_VERTS;
|
||||
//int numContactsOut=0;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -3488,7 +3500,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
//add contact point
|
||||
|
||||
int contactIndex = nGlobalContactsOut;
|
||||
//int contactIndex = nGlobalContactsOut;
|
||||
b3Contact4& newContact = hostContacts.at(nGlobalContactsOut);
|
||||
nGlobalContactsOut++;
|
||||
newContact.m_batchIdx = 0;//i;
|
||||
@@ -3511,7 +3523,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
resultPointOnBWorld.w = -depth;
|
||||
newContact.m_worldPosB[0] = resultPointOnBWorld;
|
||||
b3Vector3 resultPointOnAWorld = resultPointOnBWorld+depth*sepAxis2;
|
||||
//b3Vector3 resultPointOnAWorld = resultPointOnBWorld+depth*sepAxis2;
|
||||
newContact.m_worldNormalOnB = sepAxis2;
|
||||
newContact.m_worldNormalOnB.w = (b3Scalar)1;
|
||||
} else
|
||||
@@ -3527,7 +3539,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
|
||||
|
||||
int result = computeContactConvexConvex( hostPairs,
|
||||
int result;
|
||||
result = computeContactConvexConvex( hostPairs,
|
||||
pairIndex,
|
||||
bodyIndexA, bodyIndexB,
|
||||
collidableIndexA, collidableIndexB,
|
||||
@@ -3893,7 +3906,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3Int4> triangleConvexPairsOutHost;
|
||||
triangleConvexPairsOutHost.resize(maxTriConvexPairCapacity);
|
||||
|
||||
int numTriConvexPairsOutHost=0;
|
||||
//int numTriConvexPairsOutHost=0;
|
||||
numConcavePairs = 0;
|
||||
//m_numConcavePairsOut
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ inline void project(const b3ConvexPolyhedronData& hull, const float4& pos, cons
|
||||
{
|
||||
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
|
||||
//b3Scalar dp = pt.dot(dir);
|
||||
b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
//b3Vector3 vertex = vertices[hull.m_vertexOffset+i];
|
||||
b3Scalar dp = dot3F4((float4&)vertices[hull.m_vertexOffset+i],localDir);
|
||||
//b3Assert(dp==dpL);
|
||||
if(dp < min) min = dp;
|
||||
@@ -113,7 +113,7 @@ inline void project(const b3ConvexPolyhedronData& hull, const float4& pos, cons
|
||||
max += offset;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static bool TestSepAxis(const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
const float4& posA,const b3Quaternion& ornA,
|
||||
const float4& posB,const b3Quaternion& ornB,
|
||||
@@ -143,7 +143,7 @@ static bool TestSepAxis(const b3ConvexPolyhedronData& hullA, const b3ConvexPolyh
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
@@ -198,11 +198,11 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
{
|
||||
b3Scalar squaredDistance = B3_LARGE_FLOAT;
|
||||
b3Scalar delta = -1e30f;//b3Scalar(0.);
|
||||
b3Scalar prevDelta = -1e30f;//b3Scalar(0.);
|
||||
// b3Scalar prevDelta = -1e30f;//b3Scalar(0.);
|
||||
|
||||
b3Scalar margin = marginA + marginB;
|
||||
b3Scalar bestDeltaN = -1e30f;
|
||||
b3Vector3 bestSepAxis= b3MakeVector3(0,0,0);
|
||||
// b3Scalar bestDeltaN = -1e30f;
|
||||
// b3Vector3 bestSepAxis= b3MakeVector3(0,0,0);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ typedef b3AlignedObjectArray<b3BvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
|
||||
|
||||
///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
|
||||
///It is used by the b3BvhTriangleMeshShape as midphase, and by the b3MultiSapBroadphase.
|
||||
///It is used by the b3BvhTriangleMeshShape as midphase
|
||||
///It is recommended to use quantization for better performance and lower memory requirements.
|
||||
B3_ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh
|
||||
{
|
||||
|
||||
@@ -196,7 +196,7 @@ void b3GpuRaycast::castRaysHost(const b3AlignedObjectArray<b3RayInfo>& rays, b3A
|
||||
{
|
||||
|
||||
const b3Vector3& pos = bodies[b].m_pos;
|
||||
const b3Quaternion& orn = bodies[b].m_quat;
|
||||
//const b3Quaternion& orn = bodies[b].m_quat;
|
||||
|
||||
switch (collidables[bodies[b].m_collidableIdx].m_shapeType)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ void getInfo2Point2Point(b3GpuGenericConstraint* constraint, b3GpuConstraintInfo
|
||||
info->m_J1linearAxis[2*info->rowskip+2] = 1;
|
||||
|
||||
b3Vector3 a1 = trA.getBasis()*constraint->getPivotInA();
|
||||
b3Vector3 a1a = b3QuatRotate(trA.getRotation(),constraint->getPivotInA());
|
||||
//b3Vector3 a1a = b3QuatRotate(trA.getRotation(),constraint->getPivotInA());
|
||||
|
||||
{
|
||||
b3Vector3* angular0 = (b3Vector3*)(info->m_J1angularAxis);
|
||||
|
||||
@@ -576,7 +576,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyData* bodies,b3InertiaD
|
||||
for( i=0; i<numManifolds; i++)
|
||||
{
|
||||
|
||||
float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
//float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)contactConstraints[i].m_bodyA;
|
||||
int bIdx = (int)contactConstraints[i].m_bodyB;
|
||||
b3RigidBodyData& bodyA = bodies[aIdx];
|
||||
@@ -650,7 +650,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyData* bodies,b3InertiaD
|
||||
}
|
||||
for (int iter = 0;iter<maxIter;iter++)
|
||||
{
|
||||
int i=0;
|
||||
//int i=0;
|
||||
|
||||
//solve friction
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<b3GpuChildShap
|
||||
for (int i=0;i<childShapes->size();i++)
|
||||
{
|
||||
int childColIndex = childShapes->at(i).m_shapeIndex;
|
||||
b3Collidable& childCol = getCollidableCpu(childColIndex);
|
||||
//b3Collidable& childCol = getCollidableCpu(childColIndex);
|
||||
b3SapAabb aabbLoc =m_data->m_localShapeAABBCPU->at(childColIndex);
|
||||
|
||||
b3Vector3 childLocalAabbMin=b3MakeVector3(aabbLoc.m_min[0],aabbLoc.m_min[1],aabbLoc.m_min[2]);
|
||||
@@ -832,7 +832,7 @@ void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphase
|
||||
//swap buffer
|
||||
m_data->m_currentContactBuffer=1-m_data->m_currentContactBuffer;
|
||||
|
||||
int curSize = m_data->m_pBufContactBuffersGPU[m_data->m_currentContactBuffer]->size();
|
||||
//int curSize = m_data->m_pBufContactBuffersGPU[m_data->m_currentContactBuffer]->size();
|
||||
|
||||
int maxTriConvexPairCapacity = m_data->m_config.m_maxTriConvexPairCapacity;
|
||||
int numTriConvexPairsOut=0;
|
||||
|
||||
@@ -84,7 +84,7 @@ struct b3GpuPgsJacobiSolverInternalData
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
static b3Transform getWorldTransform(b3RigidBodyData* rb)
|
||||
{
|
||||
b3Transform newTrans;
|
||||
@@ -98,7 +98,7 @@ static const b3Matrix3x3& getInvInertiaTensorWorld(b3InertiaData* inertia)
|
||||
return inertia->m_invInertiaWorld;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
static const b3Vector3& getLinearVelocity(b3RigidBodyData* rb)
|
||||
{
|
||||
@@ -254,7 +254,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
}
|
||||
}
|
||||
|
||||
int totalBodies = 0;
|
||||
// int totalBodies = 0;
|
||||
int totalNumRows = 0;
|
||||
//b3RigidBody* rb0=0,*rb1=0;
|
||||
//if (1)
|
||||
@@ -604,9 +604,9 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
// b3ContactSolverInfo info = infoGlobal;
|
||||
|
||||
|
||||
int numNonContactPool = m_tmpSolverNonContactConstraintPool.size();
|
||||
int numConstraintPool = m_tmpSolverContactConstraintPool.size();
|
||||
int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size();
|
||||
// int numNonContactPool = m_tmpSolverNonContactConstraintPool.size();
|
||||
// int numConstraintPool = m_tmpSolverContactConstraintPool.size();
|
||||
// int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size();
|
||||
|
||||
|
||||
return 0.f;
|
||||
@@ -858,7 +858,7 @@ static b3AlignedObjectArray<int> curUsed;
|
||||
|
||||
inline int b3GpuPgsConstraintSolver::sortConstraintByBatch3( b3BatchConstraint* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies)
|
||||
{
|
||||
int sz = sizeof(b3BatchConstraint);
|
||||
//int sz = sizeof(b3BatchConstraint);
|
||||
|
||||
B3_PROFILE("sortConstraintByBatch3");
|
||||
|
||||
@@ -892,7 +892,7 @@ inline int b3GpuPgsConstraintSolver::sortConstraintByBatch3( b3BatchConstraint*
|
||||
#endif
|
||||
|
||||
int numValidConstraints = 0;
|
||||
int unprocessedConstraintIndex = 0;
|
||||
// int unprocessedConstraintIndex = 0;
|
||||
|
||||
int batchIdx = 0;
|
||||
|
||||
@@ -1032,7 +1032,7 @@ void b3GpuPgsConstraintSolver::solveJoints(int numBodies, b3OpenCLArray<b3RigidB
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal)
|
||||
{
|
||||
B3_PROFILE("solveGroupCacheFriendlyFinish");
|
||||
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||
// int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||
// int i,j;
|
||||
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ b3GpuPgsContactSolver::b3GpuPgsContactSolver(cl_context ctx,cl_device_id device,
|
||||
m_data->m_offsets = new b3OpenCLArray<unsigned int>( ctx,m_data->m_queue,B3_SOLVER_N_CELLS);
|
||||
m_data->m_offsets->resize(B3_SOLVER_N_CELLS);
|
||||
const char* additionalMacros = "";
|
||||
const char* srcFileNameForCaching="";
|
||||
//const char* srcFileNameForCaching="";
|
||||
|
||||
|
||||
|
||||
@@ -556,26 +556,8 @@ static bool b3ContactCmp(const b3Contact4& p, const b3Contact4& q)
|
||||
|
||||
|
||||
|
||||
static const int gridTable4x4[] =
|
||||
{
|
||||
0,1,17,16,
|
||||
1,2,18,19,
|
||||
17,18,32,3,
|
||||
16,19,3,34
|
||||
};
|
||||
|
||||
static const int gridTable8x8[] =
|
||||
{
|
||||
0, 2, 3, 16, 17, 18, 19, 1,
|
||||
66, 64, 80, 67, 82, 81, 65, 83,
|
||||
131,144,128,130,147,129,145,146,
|
||||
208,195,194,192,193,211,210,209,
|
||||
21, 22, 23, 5, 4, 6, 7, 20,
|
||||
86, 85, 69, 87, 70, 68, 84, 71,
|
||||
151,133,149,150,135,148,132,134,
|
||||
197,27,214,213,212,199,198,196
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -583,6 +565,30 @@ static const int gridTable8x8[] =
|
||||
#define USE_SPATIAL_BATCHING 1
|
||||
#define USE_4x4_GRID 1
|
||||
|
||||
#ifndef USE_SPATIAL_BATCHING
|
||||
static const int gridTable4x4[] =
|
||||
{
|
||||
0,1,17,16,
|
||||
1,2,18,19,
|
||||
17,18,32,3,
|
||||
16,19,3,34
|
||||
};
|
||||
static const int gridTable8x8[] =
|
||||
{
|
||||
0, 2, 3, 16, 17, 18, 19, 1,
|
||||
66, 64, 80, 67, 82, 81, 65, 83,
|
||||
131,144,128,130,147,129,145,146,
|
||||
208,195,194,192,193,211,210,209,
|
||||
21, 22, 23, 5, 4, 6, 7, 20,
|
||||
86, 85, 69, 87, 70, 68, 84, 71,
|
||||
151,133,149,150,135,148,132,134,
|
||||
197,27,214,213,212,199,198,196
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void SetSortDataCPU(b3Contact4* gContact, b3RigidBodyData* gBodies, b3SortData* gSortDataOut, int nContacts,float scale,const b3Int4& nSplit,int staticIdx)
|
||||
{
|
||||
@@ -597,7 +603,6 @@ void SetSortDataCPU(b3Contact4* gContact, b3RigidBodyData* gBodies, b3SortData*
|
||||
int bIdx = abs(bPtrAndSignBit);
|
||||
|
||||
bool aStatic = (aPtrAndSignBit<0) ||(aPtrAndSignBit==staticIdx);
|
||||
bool bStatic = (bPtrAndSignBit<0) ||(bPtrAndSignBit==staticIdx);
|
||||
|
||||
#if USE_SPATIAL_BATCHING
|
||||
int idx = (aStatic)? bIdx: aIdx;
|
||||
@@ -609,6 +614,8 @@ void SetSortDataCPU(b3Contact4* gContact, b3RigidBodyData* gBodies, b3SortData*
|
||||
int newIndex = (xIdx+yIdx*nSplit.x+zIdx*nSplit.x*nSplit.y);
|
||||
|
||||
#else//USE_SPATIAL_BATCHING
|
||||
bool bStatic = (bPtrAndSignBit<0) ||(bPtrAndSignBit==staticIdx);
|
||||
|
||||
#if USE_4x4_GRID
|
||||
int aa = aIdx&3;
|
||||
int bb = bIdx&3;
|
||||
@@ -797,7 +804,7 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
|
||||
|
||||
const b3OpenCLArray<b3RigidBodyData>* bodyNative = bodyBuf;
|
||||
//const b3OpenCLArray<b3RigidBodyData>* bodyNative = bodyBuf;
|
||||
|
||||
|
||||
{
|
||||
@@ -1033,7 +1040,7 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
}
|
||||
|
||||
|
||||
bool compareGPU = false;
|
||||
// bool compareGPU = false;
|
||||
if (nContacts)
|
||||
{
|
||||
if (!gCpuBatchContacts)
|
||||
@@ -1070,7 +1077,7 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
{
|
||||
m_data->m_batchSizes.resize(B3_MAX_NUM_BATCHES);
|
||||
int totalNumConstraints = cpuContacts.size();
|
||||
int simdWidth =numBodies+1;//-1;//64;//-1;//32;
|
||||
//int simdWidth =numBodies+1;//-1;//64;//-1;//32;
|
||||
int numBatches = sortConstraintByBatch3( &cpuContacts[0], totalNumConstraints, totalNumConstraints+1,csCfg.m_staticIdx ,numBodies,&m_data->m_batchSizes[0]); // on GPU
|
||||
maxNumBatches = b3Max(numBatches,maxNumBatches);
|
||||
static int globalMaxBatch = 0;
|
||||
@@ -1138,17 +1145,17 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
B3_PROFILE("copyToHost");
|
||||
m_data->m_pBufContactOutGPU->copyToHost(cpuContacts);
|
||||
}
|
||||
b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
// b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
// b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
|
||||
|
||||
|
||||
int numNonzeroGrid=0;
|
||||
// int numNonzeroGrid=0;
|
||||
|
||||
{
|
||||
m_data->m_batchSizes.resize(B3_MAX_NUM_BATCHES);
|
||||
int totalNumConstraints = cpuContacts.size();
|
||||
int simdWidth =numBodies+1;//-1;//64;//-1;//32;
|
||||
// int simdWidth =numBodies+1;//-1;//64;//-1;//32;
|
||||
int numBatches = sortConstraintByBatch3( &cpuContacts[0], totalNumConstraints, totalNumConstraints+1,csCfg.m_staticIdx ,numBodies,&m_data->m_batchSizes[0]); // on GPU
|
||||
maxNumBatches = b3Max(numBatches,maxNumBatches);
|
||||
static int globalMaxBatch = 0;
|
||||
@@ -1420,7 +1427,7 @@ inline int b3GpuPgsContactSolver::sortConstraintByBatch2( b3Contact4* cs, int nu
|
||||
idxSrc[i] = i;
|
||||
|
||||
int numValidConstraints = 0;
|
||||
int unprocessedConstraintIndex = 0;
|
||||
// int unprocessedConstraintIndex = 0;
|
||||
|
||||
int batchIdx = 0;
|
||||
|
||||
@@ -1588,7 +1595,7 @@ inline int b3GpuPgsContactSolver::sortConstraintByBatch3( b3Contact4* cs, int nu
|
||||
#endif
|
||||
|
||||
int numValidConstraints = 0;
|
||||
int unprocessedConstraintIndex = 0;
|
||||
// int unprocessedConstraintIndex = 0;
|
||||
|
||||
int batchIdx = 0;
|
||||
|
||||
|
||||
@@ -87,11 +87,12 @@ public:
|
||||
|
||||
|
||||
b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue, int pairCapacity)
|
||||
:m_nIterations(4),
|
||||
:
|
||||
m_context(ctx),
|
||||
m_device(device),
|
||||
m_queue(queue),
|
||||
m_batchSizes(ctx,queue)
|
||||
m_batchSizes(ctx,queue),
|
||||
m_nIterations(4)
|
||||
{
|
||||
m_sort32 = new b3RadixSort32CL(ctx,device,queue);
|
||||
m_scan = new b3PrefixScanCL(ctx,device,queue,B3_SOLVER_N_CELLS);
|
||||
@@ -108,7 +109,7 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue,
|
||||
m_offsets = new b3OpenCLArray<unsigned int>( ctx,queue,B3_SOLVER_N_CELLS);
|
||||
m_offsets->resize(B3_SOLVER_N_CELLS);
|
||||
const char* additionalMacros = "";
|
||||
const char* srcFileNameForCaching="";
|
||||
// const char* srcFileNameForCaching="";
|
||||
|
||||
|
||||
|
||||
@@ -356,17 +357,32 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
b3AlignedObjectArray<b3RigidBodyData>& m_bodies;
|
||||
b3AlignedObjectArray<b3InertiaData>& m_shapes;
|
||||
b3AlignedObjectArray<b3GpuConstraint4>& m_constraints;
|
||||
b3AlignedObjectArray<int>* m_batchSizes;
|
||||
int m_cellIndex;
|
||||
int m_curWgidx;
|
||||
int m_start;
|
||||
int m_nConstraints;
|
||||
bool m_solveFriction;
|
||||
int m_maxNumBatches;
|
||||
*/
|
||||
|
||||
struct SolveTask// : public ThreadPool::Task
|
||||
{
|
||||
SolveTask(b3AlignedObjectArray<b3RigidBodyData>& bodies, b3AlignedObjectArray<b3InertiaData>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
|
||||
int start, int nConstraints,int maxNumBatches,b3AlignedObjectArray<int>* wgUsedBodies, int curWgidx, b3AlignedObjectArray<int>* batchSizes, int cellIndex)
|
||||
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ),m_maxNumBatches(maxNumBatches),
|
||||
m_curWgidx(curWgidx),
|
||||
: m_bodies( bodies ), m_shapes( shapes ),
|
||||
m_constraints( constraints ),
|
||||
m_batchSizes(batchSizes),
|
||||
m_cellIndex(cellIndex)
|
||||
m_cellIndex(cellIndex),
|
||||
m_curWgidx(curWgidx),
|
||||
m_start( start ),
|
||||
m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ),
|
||||
m_maxNumBatches(maxNumBatches)
|
||||
{}
|
||||
|
||||
unsigned short int getType(){ return 0; }
|
||||
@@ -388,7 +404,7 @@ struct SolveTask// : public ThreadPool::Task
|
||||
float frictionCoeff = m_constraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)m_constraints[i].m_bodyA;
|
||||
int bIdx = (int)m_constraints[i].m_bodyB;
|
||||
int localBatch = m_constraints[i].m_batchIdx;
|
||||
// int localBatch = m_constraints[i].m_batchIdx;
|
||||
b3RigidBodyData& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = m_bodies[bIdx];
|
||||
|
||||
@@ -604,7 +620,7 @@ void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyData>* body
|
||||
}
|
||||
const int start = offsetsHost[cellIdx];
|
||||
int numConstraintsInCell = numConstraintsHost[cellIdx];
|
||||
const int end = start + numConstraintsInCell;
|
||||
// const int end = start + numConstraintsInCell;
|
||||
|
||||
SolveTask task( bodyNative, shapeNative, constraintNative, start, numConstraintsInCell ,maxNumBatches,usedBodies,wgIdx,batchSizes,cellIdx);
|
||||
task.m_solveFriction = false;
|
||||
@@ -640,7 +656,7 @@ void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyData>* body
|
||||
|
||||
const int start = offsetsHost[cellIdx];
|
||||
int numConstraintsInCell = numConstraintsHost[cellIdx];
|
||||
const int end = start + numConstraintsInCell;
|
||||
// const int end = start + numConstraintsInCell;
|
||||
|
||||
SolveTask task( bodyNative, shapeNative, constraintNative, start, numConstraintsInCell,maxNumBatches, 0,0,batchSizes,cellIdx);
|
||||
task.m_solveFriction = true;
|
||||
@@ -688,7 +704,7 @@ void checkConstraintBatch(const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
|
||||
int cellBatch = batchId;
|
||||
const int nn = B3_SOLVER_N_CELLS;
|
||||
int numWorkItems = 64*nn/B3_SOLVER_N_BATCHES;
|
||||
// int numWorkItems = 64*nn/B3_SOLVER_N_BATCHES;
|
||||
|
||||
b3AlignedObjectArray<unsigned int> gN;
|
||||
m_numConstraints->copyToHost(gN);
|
||||
@@ -697,7 +713,7 @@ void checkConstraintBatch(const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
int nSplitX = B3_SOLVER_N_SPLIT_X;
|
||||
int nSplitY = B3_SOLVER_N_SPLIT_Y;
|
||||
|
||||
int bIdx = batchId;
|
||||
// int bIdx = batchId;
|
||||
|
||||
b3AlignedObjectArray<b3GpuConstraint4> cpuConstraints;
|
||||
constraint->copyToHost(cpuConstraints);
|
||||
@@ -932,7 +948,7 @@ void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyData>* bodyB
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const ConstraintCfg& cfg )
|
||||
{
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraintNative =0;
|
||||
// b3OpenCLArray<b3GpuConstraint4>* constraintNative =0;
|
||||
contactCOut->resize(nContacts);
|
||||
struct CB
|
||||
{
|
||||
@@ -1099,7 +1115,6 @@ void b3Solver::sortContacts( const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void b3Solver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* nNative, b3OpenCLArray<unsigned int>* offsetsNative, int staticIdx )
|
||||
{
|
||||
|
||||
@@ -1122,7 +1137,7 @@ void b3Solver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContact
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( contacts->getBufferCL() ),
|
||||
b3BufferInfoCL( m_contactBuffer2->getBufferCL()),
|
||||
@@ -1132,7 +1147,7 @@ void b3Solver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContact
|
||||
, b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ void bDNA::initCmpFlags(bDNA *memDNA)
|
||||
// this ptr should be the file data
|
||||
|
||||
|
||||
assert(!m_Names.size() == 0 && "SDNA empty!");
|
||||
assert(!(m_Names.size() == 0));// && "SDNA empty!");
|
||||
mCMPFlags.resize(mStructs.size(), FDF_NONE);
|
||||
|
||||
|
||||
@@ -348,7 +348,8 @@ static int name_is_array(char* name, int* dim1, int* dim2) {
|
||||
void bDNA::init(char *data, int len, bool swap)
|
||||
{
|
||||
int *intPtr=0;short *shtPtr=0;
|
||||
char *cp = 0;int dataLen =0;long nr=0;
|
||||
char *cp = 0;int dataLen =0;
|
||||
//long nr=0;
|
||||
intPtr = (int*)data;
|
||||
|
||||
/*
|
||||
|
||||
@@ -391,7 +391,8 @@ void bFile::swapDNA(char* ptr)
|
||||
char* data = &ptr[20];
|
||||
// void bDNA::init(char *data, int len, bool swap)
|
||||
int *intPtr=0;short *shtPtr=0;
|
||||
char *cp = 0;int dataLen =0;long nr=0;
|
||||
char *cp = 0;int dataLen =0;
|
||||
//long nr=0;
|
||||
intPtr = (int*)data;
|
||||
|
||||
/*
|
||||
@@ -540,7 +541,7 @@ void bFile::writeFile(const char* fileName)
|
||||
void bFile::preSwap()
|
||||
{
|
||||
|
||||
const bool brokenDNA = (mFlags&FD_BROKEN_DNA)!=0;
|
||||
//const bool brokenDNA = (mFlags&FD_BROKEN_DNA)!=0;
|
||||
//FD_ENDIAN_SWAP
|
||||
//byte 8 determines the endianness of the file, little (v) versus big (V)
|
||||
int littleEndian= 1;
|
||||
@@ -1173,7 +1174,7 @@ void bFile::resolvePointersMismatch()
|
||||
int p = 0;
|
||||
while (blockLen-- > 0)
|
||||
{
|
||||
b3PointerUid dp = {0};
|
||||
b3PointerUid dp = {{0}};
|
||||
safeSwapPtr((char*)dp.m_uniqueIds, oldPtr);
|
||||
|
||||
void **tptr = (void**)(newPtr + p * ptrMem);
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
BP_FP_INT_TYPE addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
||||
BP_FP_INT_TYPE addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner, int collisionFilterGroup, int collisionFilterMask,btDispatcher* dispatcher);
|
||||
void removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher);
|
||||
void updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
||||
SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;}
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
void processAllOverlappingPairs(btOverlapCallback* callback);
|
||||
|
||||
//Broadphase Interface
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr , int collisionFilterGroup, int collisionFilterMask,btDispatcher* dispatcher);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||
@@ -228,16 +228,16 @@ void btAxisSweep3<BP_FP_INT_TYPE>::debugPrintAxis(int axis, bool checkCardinalit
|
||||
#endif //DEBUG_BROADPHASE
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
btBroadphaseProxy* btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy)
|
||||
btBroadphaseProxy* btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, int collisionFilterGroup, int collisionFilterMask,btDispatcher* dispatcher)
|
||||
{
|
||||
(void)shapeType;
|
||||
BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy);
|
||||
BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr,collisionFilterGroup,collisionFilterMask,dispatcher);
|
||||
|
||||
Handle* handle = getHandle(handleId);
|
||||
|
||||
if (m_raycastAccelerator)
|
||||
{
|
||||
btBroadphaseProxy* rayProxy = m_raycastAccelerator->createProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,0);
|
||||
btBroadphaseProxy* rayProxy = m_raycastAccelerator->createProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,dispatcher);
|
||||
handle->m_dbvtProxy = rayProxy;
|
||||
}
|
||||
return handle;
|
||||
@@ -502,7 +502,7 @@ void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
|
||||
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy)
|
||||
BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner, int collisionFilterGroup, int collisionFilterMask,btDispatcher* dispatcher)
|
||||
{
|
||||
// quantize the bounds
|
||||
BP_FP_INT_TYPE min[3], max[3];
|
||||
@@ -520,7 +520,6 @@ BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVector3&
|
||||
pHandle->m_clientObject = pOwner;
|
||||
pHandle->m_collisionFilterGroup = collisionFilterGroup;
|
||||
pHandle->m_collisionFilterMask = collisionFilterMask;
|
||||
pHandle->m_multiSapParentProxy = multiSapProxy;
|
||||
|
||||
// compute current limit of edge arrays
|
||||
BP_FP_INT_TYPE limit = static_cast<BP_FP_INT_TYPE>(m_numHandles * 2);
|
||||
|
||||
@@ -53,7 +53,7 @@ class btBroadphaseInterface
|
||||
public:
|
||||
virtual ~btBroadphaseInterface() {}
|
||||
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy) =0;
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher) =0;
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)=0;
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)=0;
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const =0;
|
||||
|
||||
@@ -101,10 +101,10 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//Usually the client btCollisionObject or Rigidbody class
|
||||
void* m_clientObject;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
void* m_multiSapParentProxy;
|
||||
int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
|
||||
int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
|
||||
|
||||
btVector3 m_aabbMin;
|
||||
btVector3 m_aabbMax;
|
||||
@@ -115,18 +115,17 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
}
|
||||
|
||||
//used for memory pools
|
||||
btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
|
||||
btBroadphaseProxy() :m_clientObject(0)
|
||||
{
|
||||
}
|
||||
|
||||
btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
|
||||
btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
:m_clientObject(userPtr),
|
||||
m_collisionFilterGroup(collisionFilterGroup),
|
||||
m_collisionFilterMask(collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax)
|
||||
{
|
||||
m_multiSapParentProxy = multiSapParentProxy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -168,10 +168,9 @@ btBroadphaseProxy* btDbvtBroadphase::createProxy( const btVector3& aabbMin,
|
||||
const btVector3& aabbMax,
|
||||
int /*shapeType*/,
|
||||
void* userPtr,
|
||||
short int collisionFilterGroup,
|
||||
short int collisionFilterMask,
|
||||
btDispatcher* /*dispatcher*/,
|
||||
void* /*multiSapProxy*/)
|
||||
int collisionFilterGroup,
|
||||
int collisionFilterMask,
|
||||
btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
btDbvtProxy* proxy=new(btAlignedAlloc(sizeof(btDbvtProxy),16)) btDbvtProxy( aabbMin,aabbMax,userPtr,
|
||||
collisionFilterGroup,
|
||||
|
||||
@@ -47,7 +47,7 @@ struct btDbvtProxy : btBroadphaseProxy
|
||||
btDbvtProxy* links[2];
|
||||
int stage;
|
||||
/* ctor */
|
||||
btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||
btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr, int collisionFilterGroup, int collisionFilterMask) :
|
||||
btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
{
|
||||
links[0]=links[1]=0;
|
||||
@@ -105,7 +105,7 @@ struct btDbvtBroadphase : btBroadphaseInterface
|
||||
void optimize();
|
||||
|
||||
/* btBroadphaseInterface Implementation */
|
||||
btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
||||
btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr, int collisionFilterGroup, int collisionFilterMask,btDispatcher* dispatcher);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0));
|
||||
|
||||
@@ -1,489 +0,0 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "btMultiSapBroadphase.h"
|
||||
|
||||
#include "btSimpleBroadphase.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
#include "btQuantizedBvh.h"
|
||||
|
||||
/// btSapBroadphaseArray m_sapBroadphases;
|
||||
|
||||
/// btOverlappingPairCache* m_overlappingPairs;
|
||||
extern int gOverlappingPairs;
|
||||
|
||||
/*
|
||||
class btMultiSapSortedOverlappingPairCache : public btSortedOverlappingPairCache
|
||||
{
|
||||
public:
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
return btSortedOverlappingPairCache::addOverlappingPair((btBroadphaseProxy*)proxy0->m_multiSapParentProxy,(btBroadphaseProxy*)proxy1->m_multiSapParentProxy);
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
btMultiSapBroadphase::btMultiSapBroadphase(int /*maxProxies*/,btOverlappingPairCache* pairCache)
|
||||
:m_overlappingPairs(pairCache),
|
||||
m_optimizedAabbTree(0),
|
||||
m_ownsPairCache(false),
|
||||
m_invalidPair(0)
|
||||
{
|
||||
if (!m_overlappingPairs)
|
||||
{
|
||||
m_ownsPairCache = true;
|
||||
void* mem = btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16);
|
||||
m_overlappingPairs = new (mem)btSortedOverlappingPairCache();
|
||||
}
|
||||
|
||||
struct btMultiSapOverlapFilterCallback : public btOverlapFilterCallback
|
||||
{
|
||||
virtual ~btMultiSapOverlapFilterCallback()
|
||||
{}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) const
|
||||
{
|
||||
btBroadphaseProxy* multiProxy0 = (btBroadphaseProxy*)childProxy0->m_multiSapParentProxy;
|
||||
btBroadphaseProxy* multiProxy1 = (btBroadphaseProxy*)childProxy1->m_multiSapParentProxy;
|
||||
|
||||
bool collides = (multiProxy0->m_collisionFilterGroup & multiProxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (multiProxy1->m_collisionFilterGroup & multiProxy0->m_collisionFilterMask);
|
||||
|
||||
return collides;
|
||||
}
|
||||
};
|
||||
|
||||
void* mem = btAlignedAlloc(sizeof(btMultiSapOverlapFilterCallback),16);
|
||||
m_filterCallback = new (mem)btMultiSapOverlapFilterCallback();
|
||||
|
||||
m_overlappingPairs->setOverlapFilterCallback(m_filterCallback);
|
||||
// mem = btAlignedAlloc(sizeof(btSimpleBroadphase),16);
|
||||
// m_simpleBroadphase = new (mem) btSimpleBroadphase(maxProxies,m_overlappingPairs);
|
||||
}
|
||||
|
||||
btMultiSapBroadphase::~btMultiSapBroadphase()
|
||||
{
|
||||
if (m_ownsPairCache)
|
||||
{
|
||||
m_overlappingPairs->~btOverlappingPairCache();
|
||||
btAlignedFree(m_overlappingPairs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax)
|
||||
{
|
||||
m_optimizedAabbTree = new btQuantizedBvh();
|
||||
m_optimizedAabbTree->setQuantizationValues(bvhAabbMin,bvhAabbMax);
|
||||
QuantizedNodeArray& nodes = m_optimizedAabbTree->getLeafNodeArray();
|
||||
for (int i=0;i<m_sapBroadphases.size();i++)
|
||||
{
|
||||
btQuantizedBvhNode node;
|
||||
btVector3 aabbMin,aabbMax;
|
||||
m_sapBroadphases[i]->getBroadphaseAabb(aabbMin,aabbMax);
|
||||
m_optimizedAabbTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0);
|
||||
m_optimizedAabbTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1);
|
||||
int partId = 0;
|
||||
node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | i;
|
||||
nodes.push_back(node);
|
||||
}
|
||||
m_optimizedAabbTree->buildInternal();
|
||||
}
|
||||
|
||||
btBroadphaseProxy* btMultiSapBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* /*ignoreMe*/)
|
||||
{
|
||||
//void* ignoreMe -> we could think of recursive multi-sap, if someone is interested
|
||||
|
||||
void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16);
|
||||
btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin, aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask);
|
||||
m_multiSapProxies.push_back(proxy);
|
||||
|
||||
///this should deal with inserting/removal into child broadphases
|
||||
setAabb(proxy,aabbMin,aabbMax,dispatcher);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::destroyProxy(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
///not yet
|
||||
btAssert(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase)
|
||||
{
|
||||
void* mem = btAlignedAlloc(sizeof(btBridgeProxy),16);
|
||||
btBridgeProxy* bridgeProxyRef = new(mem) btBridgeProxy;
|
||||
bridgeProxyRef->m_childProxy = childProxy;
|
||||
bridgeProxyRef->m_childBroadphase = childBroadphase;
|
||||
parentMultiSapProxy->m_bridgeProxies.push_back(bridgeProxyRef);
|
||||
}
|
||||
|
||||
|
||||
bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax);
|
||||
bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax)
|
||||
{
|
||||
return
|
||||
amin.getX() >= bmin.getX() && amax.getX() <= bmax.getX() &&
|
||||
amin.getY() >= bmin.getY() && amax.getY() <= bmax.getY() &&
|
||||
amin.getZ() >= bmin.getZ() && amax.getZ() <= bmax.getZ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void btMultiSapBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const
|
||||
{
|
||||
btMultiSapProxy* multiProxy = static_cast<btMultiSapProxy*>(proxy);
|
||||
aabbMin = multiProxy->m_aabbMin;
|
||||
aabbMax = multiProxy->m_aabbMax;
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin,const btVector3& aabbMax)
|
||||
{
|
||||
for (int i=0;i<m_multiSapProxies.size();i++)
|
||||
{
|
||||
rayCallback.process(m_multiSapProxies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)
|
||||
{
|
||||
btMultiSapProxy* multiProxy = static_cast<btMultiSapProxy*>(proxy);
|
||||
multiProxy->m_aabbMin = aabbMin;
|
||||
multiProxy->m_aabbMax = aabbMax;
|
||||
|
||||
|
||||
// bool fullyContained = false;
|
||||
// bool alreadyInSimple = false;
|
||||
|
||||
|
||||
|
||||
|
||||
struct MyNodeOverlapCallback : public btNodeOverlapCallback
|
||||
{
|
||||
btMultiSapBroadphase* m_multiSap;
|
||||
btMultiSapProxy* m_multiProxy;
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
MyNodeOverlapCallback(btMultiSapBroadphase* multiSap,btMultiSapProxy* multiProxy,btDispatcher* dispatcher)
|
||||
:m_multiSap(multiSap),
|
||||
m_multiProxy(multiProxy),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void processNode(int /*nodeSubPart*/, int broadphaseIndex)
|
||||
{
|
||||
btBroadphaseInterface* childBroadphase = m_multiSap->getBroadphaseArray()[broadphaseIndex];
|
||||
|
||||
int containingBroadphaseIndex = -1;
|
||||
//already found?
|
||||
for (int i=0;i<m_multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
|
||||
if (m_multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
|
||||
{
|
||||
containingBroadphaseIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (containingBroadphaseIndex<0)
|
||||
{
|
||||
//add it
|
||||
btBroadphaseProxy* childProxy = childBroadphase->createProxy(m_multiProxy->m_aabbMin,m_multiProxy->m_aabbMax,m_multiProxy->m_shapeType,m_multiProxy->m_clientObject,m_multiProxy->m_collisionFilterGroup,m_multiProxy->m_collisionFilterMask, m_dispatcher,m_multiProxy);
|
||||
m_multiSap->addToChildBroadphase(m_multiProxy,childProxy,childBroadphase);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MyNodeOverlapCallback myNodeCallback(this,multiProxy,dispatcher);
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_optimizedAabbTree)
|
||||
m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
|
||||
|
||||
int i;
|
||||
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btVector3 worldAabbMin,worldAabbMax;
|
||||
multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
|
||||
bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
if (!overlapsBroadphase)
|
||||
{
|
||||
//remove it now
|
||||
btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[i];
|
||||
|
||||
btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
|
||||
bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
|
||||
|
||||
multiProxy->m_bridgeProxies.swap( i,multiProxy->m_bridgeProxies.size()-1);
|
||||
multiProxy->m_bridgeProxies.pop_back();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
if (1)
|
||||
{
|
||||
|
||||
//find broadphase that contain this multiProxy
|
||||
int numChildBroadphases = getBroadphaseArray().size();
|
||||
for (int i=0;i<numChildBroadphases;i++)
|
||||
{
|
||||
btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
|
||||
btVector3 worldAabbMin,worldAabbMax;
|
||||
childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
|
||||
bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
|
||||
// fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
int containingBroadphaseIndex = -1;
|
||||
|
||||
//if already contains this
|
||||
|
||||
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
|
||||
{
|
||||
containingBroadphaseIndex = i;
|
||||
}
|
||||
alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase);
|
||||
}
|
||||
|
||||
if (overlapsBroadphase)
|
||||
{
|
||||
if (containingBroadphaseIndex<0)
|
||||
{
|
||||
btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,childBroadphase);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (containingBroadphaseIndex>=0)
|
||||
{
|
||||
//remove
|
||||
btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex];
|
||||
|
||||
btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
|
||||
bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
|
||||
|
||||
multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1);
|
||||
multiProxy->m_bridgeProxies.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force)
|
||||
///hopefully we don't end up with many entries here (can assert/provide feedback on stats)
|
||||
if (0)//!multiProxy->m_bridgeProxies.size())
|
||||
{
|
||||
///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
|
||||
///this is needed to be able to calculate the aabb overlap
|
||||
btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
|
||||
}
|
||||
}
|
||||
|
||||
if (!multiProxy->m_bridgeProxies.size())
|
||||
{
|
||||
///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
|
||||
///this is needed to be able to calculate the aabb overlap
|
||||
btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//update
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i];
|
||||
bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher);
|
||||
}
|
||||
|
||||
}
|
||||
bool stopUpdating=false;
|
||||
|
||||
|
||||
|
||||
class btMultiSapBroadphasePairSortPredicate
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) const
|
||||
{
|
||||
btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* bProxy0 = b1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* bProxy1 = b1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
|
||||
return aProxy0 > bProxy0 ||
|
||||
(aProxy0 == bProxy0 && aProxy1 > bProxy1) ||
|
||||
(aProxy0 == bProxy0 && aProxy1 == bProxy1 && a1.m_algorithm > b1.m_algorithm);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
// m_simpleBroadphase->calculateOverlappingPairs(dispatcher);
|
||||
|
||||
if (!stopUpdating && getOverlappingPairCache()->hasDeferredRemoval())
|
||||
{
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = getOverlappingPairCache()->getOverlappingPairArray();
|
||||
|
||||
// quicksort(overlappingPairArray,0,overlappingPairArray.size());
|
||||
|
||||
overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
// overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
btBroadphasePair previousPair;
|
||||
previousPair.m_pProxy0 = 0;
|
||||
previousPair.m_pProxy1 = 0;
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
btMultiSapProxy* aProxy0 = pair.m_pProxy0 ? (btMultiSapProxy*)pair.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* aProxy1 = pair.m_pProxy1 ? (btMultiSapProxy*)pair.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* bProxy0 = previousPair.m_pProxy0 ? (btMultiSapProxy*)previousPair.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* bProxy1 = previousPair.m_pProxy1 ? (btMultiSapProxy*)previousPair.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
|
||||
bool isDuplicate = (aProxy0 == bProxy0) && (aProxy1 == bProxy1);
|
||||
|
||||
previousPair = pair;
|
||||
|
||||
bool needsRemoval = false;
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = false;//callback->processOverlap(pair);
|
||||
} else
|
||||
{
|
||||
needsRemoval = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
//remove duplicate
|
||||
needsRemoval = true;
|
||||
//should have no algorithm
|
||||
btAssert(!pair.m_algorithm);
|
||||
}
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
getOverlappingPairCache()->cleanOverlappingPair(pair,dispatcher);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
pair.m_pProxy0 = 0;
|
||||
pair.m_pProxy1 = 0;
|
||||
m_invalidPair++;
|
||||
gOverlappingPairs--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
#define CLEAN_INVALID_PAIRS 1
|
||||
#ifdef CLEAN_INVALID_PAIRS
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
//overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
|
||||
overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif//CLEAN_INVALID_PAIRS
|
||||
|
||||
//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool btMultiSapBroadphase::testAabbOverlap(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1)
|
||||
{
|
||||
btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy;
|
||||
btMultiSapProxy* multiSapProxy1 = (btMultiSapProxy*)childProxy1->m_multiSapParentProxy;
|
||||
|
||||
return TestAabbAgainstAabb2(multiSapProxy0->m_aabbMin,multiSapProxy0->m_aabbMax,
|
||||
multiSapProxy1->m_aabbMin,multiSapProxy1->m_aabbMax);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::printStats()
|
||||
{
|
||||
/* printf("---------------------------------\n");
|
||||
|
||||
printf("btMultiSapBroadphase.h\n");
|
||||
printf("numHandles = %d\n",m_multiSapProxies.size());
|
||||
//find broadphase that contain this multiProxy
|
||||
int numChildBroadphases = getBroadphaseArray().size();
|
||||
for (int i=0;i<numChildBroadphases;i++)
|
||||
{
|
||||
|
||||
btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
|
||||
childBroadphase->printStats();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher)
|
||||
{
|
||||
// not yet
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef BT_MULTI_SAP_BROADPHASE
|
||||
#define BT_MULTI_SAP_BROADPHASE
|
||||
|
||||
#include "btBroadphaseInterface.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "btOverlappingPairCache.h"
|
||||
|
||||
|
||||
class btBroadphaseInterface;
|
||||
class btSimpleBroadphase;
|
||||
|
||||
|
||||
typedef btAlignedObjectArray<btBroadphaseInterface*> btSapBroadphaseArray;
|
||||
|
||||
///The btMultiSapBroadphase is a research project, not recommended to use in production. Use btAxisSweep3 or btDbvtBroadphase instead.
|
||||
///The btMultiSapBroadphase is a broadphase that contains multiple SAP broadphases.
|
||||
///The user can add SAP broadphases that cover the world. A btBroadphaseProxy can be in multiple child broadphases at the same time.
|
||||
///A btQuantizedBvh acceleration structures finds overlapping SAPs for each btBroadphaseProxy.
|
||||
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328
|
||||
///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
|
||||
class btMultiSapBroadphase :public btBroadphaseInterface
|
||||
{
|
||||
btSapBroadphaseArray m_sapBroadphases;
|
||||
|
||||
btSimpleBroadphase* m_simpleBroadphase;
|
||||
|
||||
btOverlappingPairCache* m_overlappingPairs;
|
||||
|
||||
class btQuantizedBvh* m_optimizedAabbTree;
|
||||
|
||||
|
||||
bool m_ownsPairCache;
|
||||
|
||||
btOverlapFilterCallback* m_filterCallback;
|
||||
|
||||
int m_invalidPair;
|
||||
|
||||
struct btBridgeProxy
|
||||
{
|
||||
btBroadphaseProxy* m_childProxy;
|
||||
btBroadphaseInterface* m_childBroadphase;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
struct btMultiSapProxy : public btBroadphaseProxy
|
||||
{
|
||||
|
||||
///array with all the entries that this proxy belongs to
|
||||
btAlignedObjectArray<btBridgeProxy*> m_bridgeProxies;
|
||||
btVector3 m_aabbMin;
|
||||
btVector3 m_aabbMax;
|
||||
|
||||
int m_shapeType;
|
||||
|
||||
/* void* m_userPtr;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
*/
|
||||
btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
|
||||
:btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax),
|
||||
m_shapeType(shapeType)
|
||||
{
|
||||
m_multiSapParentProxy =this;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
|
||||
|
||||
public:
|
||||
|
||||
btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0);
|
||||
|
||||
|
||||
btSapBroadphaseArray& getBroadphaseArray()
|
||||
{
|
||||
return m_sapBroadphases;
|
||||
}
|
||||
|
||||
const btSapBroadphaseArray& getBroadphaseArray() const
|
||||
{
|
||||
return m_sapBroadphases;
|
||||
}
|
||||
|
||||
virtual ~btMultiSapBroadphase();
|
||||
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0));
|
||||
|
||||
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_overlappingPairs;
|
||||
}
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_overlappingPairs;
|
||||
}
|
||||
|
||||
///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
|
||||
///will add some transform later
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
|
||||
aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
|
||||
}
|
||||
|
||||
void buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
|
||||
|
||||
virtual void printStats();
|
||||
|
||||
void quicksort (btBroadphasePairArray& a, int lo, int hi);
|
||||
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_MULTI_SAP_BROADPHASE
|
||||
@@ -169,7 +169,7 @@ typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
|
||||
|
||||
///The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
|
||||
///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase.
|
||||
///It is used by the btBvhTriangleMeshShape as midphase.
|
||||
///It is recommended to use quantization for better performance and lower memory requirements.
|
||||
ATTRIBUTE_ALIGNED16(class) btQuantizedBvh
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ btSimpleBroadphase::~btSimpleBroadphase()
|
||||
}
|
||||
|
||||
|
||||
btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* /*dispatcher*/,void* multiSapProxy)
|
||||
btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr , int collisionFilterGroup, int collisionFilterMask, btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
if (m_numHandles >= m_maxHandles)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& aabbMin,
|
||||
btAssert(aabbMin[0]<= aabbMax[0] && aabbMin[1]<= aabbMax[1] && aabbMin[2]<= aabbMax[2]);
|
||||
|
||||
int newHandleIndex = allocHandle();
|
||||
btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy);
|
||||
btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ struct btSimpleBroadphaseProxy : public btBroadphaseProxy
|
||||
|
||||
btSimpleBroadphaseProxy() {};
|
||||
|
||||
btSimpleBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy)
|
||||
:btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy)
|
||||
btSimpleBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
:btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
{
|
||||
(void)shapeType;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr , int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
|
||||
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ SET(BulletCollision_SRCS
|
||||
BroadphaseCollision/btDbvt.cpp
|
||||
BroadphaseCollision/btDbvtBroadphase.cpp
|
||||
BroadphaseCollision/btDispatcher.cpp
|
||||
BroadphaseCollision/btMultiSapBroadphase.cpp
|
||||
BroadphaseCollision/btOverlappingPairCache.cpp
|
||||
BroadphaseCollision/btQuantizedBvh.cpp
|
||||
BroadphaseCollision/btSimpleBroadphase.cpp
|
||||
@@ -110,7 +109,6 @@ SET(BroadphaseCollision_HDRS
|
||||
BroadphaseCollision/btDbvt.h
|
||||
BroadphaseCollision/btDbvtBroadphase.h
|
||||
BroadphaseCollision/btDispatcher.h
|
||||
BroadphaseCollision/btMultiSapBroadphase.h
|
||||
BroadphaseCollision/btOverlappingPairCache.h
|
||||
BroadphaseCollision/btOverlappingPairCallback.h
|
||||
BroadphaseCollision/btQuantizedBvh.h
|
||||
|
||||
@@ -108,7 +108,7 @@ btCollisionWorld::~btCollisionWorld()
|
||||
|
||||
|
||||
|
||||
void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
|
||||
btAssert(collisionObject);
|
||||
@@ -135,8 +135,7 @@ void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,sho
|
||||
collisionObject,
|
||||
collisionFilterGroup,
|
||||
collisionFilterMask,
|
||||
m_dispatcher1,0
|
||||
)) ;
|
||||
m_dispatcher1)) ;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -205,8 +205,8 @@ public:
|
||||
{
|
||||
btScalar m_closestHitFraction;
|
||||
const btCollisionObject* m_collisionObject;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
//@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback.h. Apply any of the EFlags defined there on m_flags here to invoke.
|
||||
unsigned int m_flags;
|
||||
|
||||
@@ -340,8 +340,8 @@ public:
|
||||
struct ConvexResultCallback
|
||||
{
|
||||
btScalar m_closestHitFraction;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
|
||||
ConvexResultCallback()
|
||||
:m_closestHitFraction(btScalar(1.)),
|
||||
@@ -410,8 +410,8 @@ public:
|
||||
///ContactResultCallback is used to report contact points
|
||||
struct ContactResultCallback
|
||||
{
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
btScalar m_closestDistanceThreshold;
|
||||
|
||||
ContactResultCallback()
|
||||
@@ -483,7 +483,7 @@ public:
|
||||
const btCollisionObjectWrapper* colObjWrap,
|
||||
ConvexResultCallback& resultCallback, btScalar allowedPenetration);
|
||||
|
||||
virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
virtual void addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
|
||||
btCollisionObjectArray& getCollisionObjectArray()
|
||||
{
|
||||
|
||||
@@ -579,13 +579,13 @@ btCollisionShape* btCollisionWorldImporter::convertCollisionShape( btCollisionS
|
||||
btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData;
|
||||
btCompoundShape* compoundShape = createCompoundShape();
|
||||
|
||||
btCompoundShapeChildData* childShapeDataArray = &compoundData->m_childShapePtr[0];
|
||||
//btCompoundShapeChildData* childShapeDataArray = &compoundData->m_childShapePtr[0];
|
||||
|
||||
|
||||
btAlignedObjectArray<btCollisionShape*> childShapes;
|
||||
for (int i=0;i<compoundData->m_numChildShapes;i++)
|
||||
{
|
||||
btCompoundShapeChildData* ptr = &compoundData->m_childShapePtr[i];
|
||||
//btCompoundShapeChildData* ptr = &compoundData->m_childShapePtr[i];
|
||||
|
||||
btCollisionShapeData* cd = compoundData->m_childShapePtr[i].m_childShape;
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ subject to the following restrictions:
|
||||
|
||||
btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped)
|
||||
: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
|
||||
m_isSwapped(isSwapped),
|
||||
m_btConvexTriangleCallback(ci.m_dispatcher1,body0Wrap,body1Wrap,isSwapped)
|
||||
m_btConvexTriangleCallback(ci.m_dispatcher1,body0Wrap,body1Wrap,isSwapped),
|
||||
m_isSwapped(isSwapped)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_ghostObject->hasContactResponse() && (callback.hasHit() && needsCollision(m_ghostObject, callback.m_hitCollisionObject)) || runonce == true)
|
||||
if ((m_ghostObject->hasContactResponse() && (callback.hasHit() && needsCollision(m_ghostObject, callback.m_hitCollisionObject))) || runonce == true)
|
||||
{
|
||||
// we dropped a fraction of the height -> hit floor
|
||||
btScalar fraction = (m_currentPosition.getY() - callback.m_hitPointWorld.getY()) / 2;
|
||||
@@ -751,7 +751,7 @@ void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWo
|
||||
m_wasOnGround = onGround();
|
||||
|
||||
//btVector3 lvel = m_walkDirection;
|
||||
btScalar c = 0.0f;
|
||||
//btScalar c = 0.0f;
|
||||
|
||||
if (m_walkDirection.length2() > 0)
|
||||
{
|
||||
|
||||
@@ -1100,8 +1100,6 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
|
||||
|
||||
int frictionIndex = m_tmpSolverContactConstraintPool.size();
|
||||
btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expandNonInitializing();
|
||||
btRigidBody* rb0 = btRigidBody::upcast(colObj0);
|
||||
btRigidBody* rb1 = btRigidBody::upcast(colObj1);
|
||||
solverConstraint.m_solverBodyIdA = solverBodyIdA;
|
||||
solverConstraint.m_solverBodyIdB = solverBodyIdB;
|
||||
|
||||
@@ -1113,9 +1111,9 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
|
||||
rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin();
|
||||
rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin();
|
||||
|
||||
btVector3 vel1;// = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0);
|
||||
btVector3 vel2;// = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0);
|
||||
|
||||
btVector3 vel1;
|
||||
btVector3 vel2;
|
||||
|
||||
solverBodyA->getVelocityInLocalPointNoDelta(rel_pos1,vel1);
|
||||
solverBodyB->getVelocityInLocalPointNoDelta(rel_pos2,vel2 );
|
||||
|
||||
@@ -1126,8 +1124,6 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
|
||||
|
||||
|
||||
|
||||
// const btVector3& pos1 = cp.getPositionWorldOnA();
|
||||
// const btVector3& pos2 = cp.getPositionWorldOnB();
|
||||
|
||||
/////setup the friction constraints
|
||||
|
||||
|
||||
@@ -539,7 +539,7 @@ btVector3 btDiscreteDynamicsWorld::getGravity () const
|
||||
return m_gravity;
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void btDiscreteDynamicsWorld::addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
btCollisionWorld::addCollisionObject(collisionObject,collisionFilterGroup,collisionFilterMask);
|
||||
}
|
||||
@@ -578,14 +578,14 @@ void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
}
|
||||
|
||||
bool isDynamic = !(body->isStaticObject() || body->isKinematicObject());
|
||||
short collisionFilterGroup = isDynamic? short(btBroadphaseProxy::DefaultFilter) : short(btBroadphaseProxy::StaticFilter);
|
||||
short collisionFilterMask = isDynamic? short(btBroadphaseProxy::AllFilter) : short(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
|
||||
int collisionFilterGroup = isDynamic? int(btBroadphaseProxy::DefaultFilter) : int(btBroadphaseProxy::StaticFilter);
|
||||
int collisionFilterMask = isDynamic? int(btBroadphaseProxy::AllFilter) : int(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
|
||||
|
||||
addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
|
||||
}
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, short group, short mask)
|
||||
void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, int group, int mask)
|
||||
{
|
||||
if (!body->isStaticOrKinematicObject() && !(body->getFlags() &BT_DISABLE_WORLD_GRAVITY))
|
||||
{
|
||||
|
||||
@@ -144,11 +144,11 @@ public:
|
||||
|
||||
virtual btVector3 getGravity () const;
|
||||
|
||||
virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
|
||||
virtual void addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup=btBroadphaseProxy::StaticFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body);
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body, short group, short mask);
|
||||
virtual void addRigidBody(btRigidBody* body, int group, int mask);
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body);
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body) = 0;
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body, short group, short mask) = 0;
|
||||
virtual void addRigidBody(btRigidBody* body, int group, int mask) = 0;
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body) = 0;
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ void btSimpleDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
}
|
||||
}
|
||||
|
||||
void btSimpleDynamicsWorld::addRigidBody(btRigidBody* body, short group, short mask)
|
||||
void btSimpleDynamicsWorld::addRigidBody(btRigidBody* body, int group, int mask)
|
||||
{
|
||||
body->setGravity(m_gravity);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body);
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body, short group, short mask);
|
||||
virtual void addRigidBody(btRigidBody* body, int group, int mask);
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace {
|
||||
bottom_out = -displacement.cross(top_out) + rotation_matrix * bottom_in;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void InverseSpatialTransform(const btMatrix3x3 &rotation_matrix,
|
||||
const btVector3 &displacement,
|
||||
const btVector3 &top_in,
|
||||
@@ -81,6 +82,8 @@ namespace {
|
||||
top_out = a_top.cross(b_top);
|
||||
bottom_out = a_bottom.cross(b_top) + a_top.cross(b_bottom);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1765,7 +1768,6 @@ void btMultiBody::goToSleep()
|
||||
|
||||
void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep)
|
||||
{
|
||||
int num_links = getNumLinks();
|
||||
extern bool gDisableDeactivation;
|
||||
if (!m_canSleep || gDisableDeactivation)
|
||||
{
|
||||
|
||||
@@ -602,7 +602,7 @@ void btMultiBodyConstraintSolver::setupMultiBodyTorsionalFrictionConstraint(btMu
|
||||
|
||||
relaxation = infoGlobal.m_sor;
|
||||
|
||||
btScalar invTimeStep = btScalar(1)/infoGlobal.m_timeStep;
|
||||
// btScalar invTimeStep = btScalar(1)/infoGlobal.m_timeStep;
|
||||
|
||||
|
||||
if (multiBodyA)
|
||||
@@ -817,7 +817,6 @@ void btMultiBodyConstraintSolver::setupMultiBodyTorsionalFrictionConstraint(btMu
|
||||
|
||||
{
|
||||
|
||||
btScalar positionalError = 0.f;
|
||||
btScalar velocityError = restitution - rel_vel;// * damping; //note for friction restitution is always set to 0 (check above) so it is acutally velocityError = -rel_vel for friction
|
||||
|
||||
if (penetration>0)
|
||||
|
||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btSerializer.h"
|
||||
|
||||
|
||||
void btMultiBodyDynamicsWorld::addMultiBody(btMultiBody* body, short group, short mask)
|
||||
void btMultiBodyDynamicsWorld::addMultiBody(btMultiBody* body, int group, int mask)
|
||||
{
|
||||
m_multiBodies.push_back(body);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
virtual ~btMultiBodyDynamicsWorld ();
|
||||
|
||||
virtual void addMultiBody(btMultiBody* body, short group= btBroadphaseProxy::DefaultFilter, short mask=btBroadphaseProxy::AllFilter);
|
||||
virtual void addMultiBody(btMultiBody* body, int group= btBroadphaseProxy::DefaultFilter, int mask=btBroadphaseProxy::AllFilter);
|
||||
|
||||
virtual void removeMultiBody(btMultiBody* body);
|
||||
|
||||
|
||||
@@ -123,8 +123,9 @@ static inline T average(const btAlignedObjectArray<T>& items)
|
||||
return(sum(items)/n);
|
||||
}
|
||||
|
||||
#if 0
|
||||
//
|
||||
static inline btScalar tetravolume(const btVector3& x0,
|
||||
inline static btScalar tetravolume(const btVector3& x0,
|
||||
const btVector3& x1,
|
||||
const btVector3& x2,
|
||||
const btVector3& x3)
|
||||
@@ -134,6 +135,7 @@ static inline btScalar tetravolume(const btVector3& x0,
|
||||
const btVector3 c=x3-x0;
|
||||
return(btDot(a,btCross(b,c)));
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
#if 0
|
||||
|
||||
@@ -422,7 +422,7 @@ static inline btVector3 BaryCoord( const btVector3& a,
|
||||
}
|
||||
|
||||
//
|
||||
static btScalar ImplicitSolve( btSoftBody::ImplicitFn* fn,
|
||||
inline static btScalar ImplicitSolve( btSoftBody::ImplicitFn* fn,
|
||||
const btVector3& a,
|
||||
const btVector3& b,
|
||||
const btScalar accuracy,
|
||||
@@ -451,6 +451,25 @@ static btScalar ImplicitSolve( btSoftBody::ImplicitFn* fn,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
inline static void EvaluateMedium( const btSoftBodyWorldInfo* wfi,
|
||||
const btVector3& x,
|
||||
btSoftBody::sMedium& medium)
|
||||
{
|
||||
medium.m_velocity = btVector3(0,0,0);
|
||||
medium.m_pressure = 0;
|
||||
medium.m_density = wfi->air_density;
|
||||
if(wfi->water_density>0)
|
||||
{
|
||||
const btScalar depth=-(btDot(x,wfi->water_normal)+wfi->water_offset);
|
||||
if(depth>0)
|
||||
{
|
||||
medium.m_density = wfi->water_density;
|
||||
medium.m_pressure = depth*wfi->water_density*wfi->m_gravity.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
static inline btVector3 NormalizeAny(const btVector3& v)
|
||||
{
|
||||
@@ -504,23 +523,7 @@ static inline btScalar VolumeOf( const btVector3& x0,
|
||||
}
|
||||
|
||||
//
|
||||
static void EvaluateMedium( const btSoftBodyWorldInfo* wfi,
|
||||
const btVector3& x,
|
||||
btSoftBody::sMedium& medium)
|
||||
{
|
||||
medium.m_velocity = btVector3(0,0,0);
|
||||
medium.m_pressure = 0;
|
||||
medium.m_density = wfi->air_density;
|
||||
if(wfi->water_density>0)
|
||||
{
|
||||
const btScalar depth=-(btDot(x,wfi->water_normal)+wfi->water_offset);
|
||||
if(depth>0)
|
||||
{
|
||||
medium.m_density = wfi->water_density;
|
||||
medium.m_pressure = depth*wfi->water_density*wfi->m_gravity.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
static inline void ApplyClampedForce( btSoftBody::Node& n,
|
||||
|
||||
@@ -125,7 +125,7 @@ void btSoftMultiBodyDynamicsWorld::solveSoftBodiesConstraints( btScalar timeStep
|
||||
|
||||
}
|
||||
|
||||
void btSoftMultiBodyDynamicsWorld::addSoftBody(btSoftBody* body,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void btSoftMultiBodyDynamicsWorld::addSoftBody(btSoftBody* body, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
m_softBodies.push_back(body);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
virtual void debugDrawWorld();
|
||||
|
||||
void addSoftBody(btSoftBody* body,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
void addSoftBody(btSoftBody* body, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
|
||||
void removeSoftBody(btSoftBody* body);
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm
|
||||
// bool m_ownManifold;
|
||||
// btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
btSoftBody* m_softBody;
|
||||
btCollisionObject* m_rigidCollisionObject;
|
||||
//btSoftBody* m_softBody;
|
||||
//btCollisionObject* m_rigidCollisionObject;
|
||||
|
||||
///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean
|
||||
bool m_isSwapped;
|
||||
|
||||
@@ -125,7 +125,7 @@ void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints( btScalar timeStep )
|
||||
|
||||
}
|
||||
|
||||
void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body,short int collisionFilterGroup,short int collisionFilterMask)
|
||||
void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body, int collisionFilterGroup, int collisionFilterMask)
|
||||
{
|
||||
m_softBodies.push_back(body);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
virtual void debugDrawWorld();
|
||||
|
||||
void addSoftBody(btSoftBody* body,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
void addSoftBody(btSoftBody* body, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter);
|
||||
|
||||
void removeSoftBody(btSoftBody* body);
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm
|
||||
bool m_ownManifold;
|
||||
btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
btSoftBody* m_softBody0;
|
||||
btSoftBody* m_softBody1;
|
||||
// btSoftBody* m_softBody0;
|
||||
// btSoftBody* m_softBody1;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -185,7 +185,7 @@ struct btSparseSdf
|
||||
{
|
||||
++nprobes;
|
||||
++ncells;
|
||||
int sz = sizeof(Cell);
|
||||
//int sz = sizeof(Cell);
|
||||
if (ncells>m_clampCells)
|
||||
{
|
||||
static int numResets=0;
|
||||
|
||||
@@ -52,7 +52,6 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h"
|
||||
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
|
||||
|
||||
///Math library & Utils
|
||||
|
||||
Reference in New Issue
Block a user