+ CMake build system fix under Windows: don't define _WINDOWS to allow Glut console demo to build properly
+ Allow user to enable useConvexConservativeDistanceUtil . Use dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true; (see Demos/Benchmarks/Benchmark4 (convex objects falling down) + Fix for plane drawing (just wire-frame) + Gimpact: use collision margin of 0.07 for demo (because BULLET_TRIANGLE_COLLISION is used) + replace dot,cross,distance,angle,triple in btVector3 by btDot, btCross,btDistance,btAngle,btDistance to avoid naming conflicts + Some fixes in GJK penetration depth normal direction (broken in a previous commit) + fix in calculateDiffAxisAngleQuaternion to make ConvexConservativeDistanceUtil work properly + allow debug drawing to debug btContinuousConvexCollision + add comment/warning that btTriangleMesh::findOrAddVertex is an internal method, users should use addTriangle instead
This commit is contained in:
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
||||
|
||||
class btPersistentManifold;
|
||||
|
||||
//#define USE_SEPDISTANCE_UTIL 1
|
||||
#define USE_SEPDISTANCE_UTIL 1
|
||||
|
||||
/// SpuContactManifoldCollisionAlgorithm provides contact manifold and should be processed on SPU.
|
||||
ATTRIBUTE_ALIGNED16(class) SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm
|
||||
|
||||
@@ -52,6 +52,9 @@ subject to the following restrictions:
|
||||
#endif
|
||||
#endif //__SPU__
|
||||
|
||||
int gSkippedCol = 0;
|
||||
int gProcessedCol = 0;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
/// software caching
|
||||
#if USE_SOFTWARE_CACHE
|
||||
@@ -624,8 +627,11 @@ SIMD_FORCE_INLINE void dmaAndSetupCollisionObjects(SpuCollisionPairInput& collis
|
||||
|
||||
cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2));
|
||||
|
||||
collisionPairInput.m_worldTransform0 = lsMem.getColObj0()->getWorldTransform();
|
||||
collisionPairInput.m_worldTransform1 = lsMem.getColObj1()->getWorldTransform();
|
||||
btCollisionObject* ob0 = lsMem.getColObj0();
|
||||
btCollisionObject* ob1 = lsMem.getColObj1();
|
||||
|
||||
collisionPairInput.m_worldTransform0 = ob0->getWorldTransform();
|
||||
collisionPairInput.m_worldTransform1 = ob1->getWorldTransform();
|
||||
}
|
||||
|
||||
|
||||
@@ -998,6 +1004,11 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
lsMem.getColObj0()->getFriction(),lsMem.getColObj1()->getFriction(),
|
||||
collisionPairInput.m_isSwapped);
|
||||
|
||||
|
||||
float distance=0.f;
|
||||
btVector3 normalInB;
|
||||
|
||||
|
||||
|
||||
if (//!gUseEpa &&
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
@@ -1007,7 +1018,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
//#define USE_PE_BOX_BOX 1
|
||||
#define USE_PE_BOX_BOX 1
|
||||
#ifdef USE_PE_BOX_BOX
|
||||
{
|
||||
|
||||
@@ -1032,9 +1043,9 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
float distanceThreshold = FLT_MAX;//0.0f;//FLT_MAX;//use epsilon?
|
||||
|
||||
|
||||
float distance = boxBoxDistance(resultNormal,resultClosestBoxPointA,resultClosestBoxPointB, boxA, transformA, boxB,transformB,distanceThreshold);
|
||||
distance = boxBoxDistance(resultNormal,resultClosestBoxPointA,resultClosestBoxPointB, boxA, transformA, boxB,transformB,distanceThreshold);
|
||||
|
||||
btVector3 normalInB = -getBtVector3(resultNormal);
|
||||
normalInB = -getBtVector3(resultNormal);
|
||||
|
||||
if(distance < spuManifold->getContactBreakingThreshold())
|
||||
{
|
||||
@@ -1094,9 +1105,13 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
|
||||
lsMem.needsDmaPutContactManifoldAlgo = true;
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
btScalar sepDist = distance+spuManifold->getContactBreakingThreshold();
|
||||
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(normalInB,sepDist,collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1);
|
||||
btScalar sepDist2 = distance+spuManifold->getContactBreakingThreshold();
|
||||
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(normalInB,sepDist2,collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1);
|
||||
#endif //USE_SEPDISTANCE_UTIL
|
||||
gProcessedCol++;
|
||||
} else
|
||||
{
|
||||
gSkippedCol++;
|
||||
}
|
||||
|
||||
spuContacts.flush();
|
||||
@@ -1138,13 +1153,15 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
}
|
||||
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
#if defined (__SPU__) || defined (USE_LIBSPE2)
|
||||
if (lsMem.needsDmaPutContactManifoldAlgo)
|
||||
{
|
||||
dmaSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
dmaPpuAddress2 = (ppu_address_t)pair.m_algorithm;
|
||||
cellDmaLargePut(&lsMem.gSpuContactManifoldAlgo, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
|
||||
cellDmaLargePut(&lsMem.gSpuContactManifoldAlgoBuffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
|
||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||
}
|
||||
#endif
|
||||
#endif //#ifdef USE_SEPDISTANCE_UTIL
|
||||
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ eStatus::_ Evaluate(const tShape& shapearg,const btVector3& guess)
|
||||
lastw[clastw=(clastw+1)&3]=w;
|
||||
}
|
||||
/* Check for termination */
|
||||
const btScalar omega=dot(m_ray,w)/rl;
|
||||
const btScalar omega=btDot(m_ray,w)/rl;
|
||||
alpha=btMax(omega,alpha);
|
||||
if(((rl-alpha)-(GJK_ACCURARY*rl))<=0)
|
||||
{/* Return old simplex */
|
||||
@@ -287,9 +287,9 @@ bool EncloseOrigin()
|
||||
{
|
||||
btVector3 axis=btVector3(0,0,0);
|
||||
axis[i]=1;
|
||||
if(btFabs(dot(axis,d))>0)
|
||||
if(btFabs(btDot(axis,d))>0)
|
||||
{
|
||||
const btVector3 p=cross(d,axis);
|
||||
const btVector3 p=btCross(d,axis);
|
||||
appendvertice(*m_simplex, p);
|
||||
if(EncloseOrigin()) return(true);
|
||||
removevertice(*m_simplex);
|
||||
@@ -302,7 +302,7 @@ bool EncloseOrigin()
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
const btVector3 n=cross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
const btVector3 n=btCross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
m_simplex->c[2]->w-m_simplex->c[0]->w);
|
||||
const btScalar l=n.length();
|
||||
if(l>0)
|
||||
@@ -357,7 +357,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
const btScalar l=d.length2();
|
||||
if(l>GJK_SIMPLEX2_EPS)
|
||||
{
|
||||
const btScalar t(l>0?-dot(a,d)/l:0);
|
||||
const btScalar t(l>0?-btDot(a,d)/l:0);
|
||||
if(t>=1) { w[0]=0;w[1]=1;m=2;return(b.length2()); }
|
||||
else if(t<=0) { w[0]=1;w[1]=0;m=1;return(a.length2()); }
|
||||
else { w[0]=1-(w[1]=t);m=3;return((a+d*t).length2()); }
|
||||
@@ -372,7 +372,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
static const U imd3[]={1,2,0};
|
||||
const btVector3* vt[]={&a,&b,&c};
|
||||
const btVector3 dl[]={a-b,b-c,c-a};
|
||||
const btVector3 n=cross(dl[0],dl[1]);
|
||||
const btVector3 n=btCross(dl[0],dl[1]);
|
||||
const btScalar l=n.length2();
|
||||
if(l>GJK_SIMPLEX3_EPS)
|
||||
{
|
||||
@@ -381,7 +381,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
U subm;
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
if(dot(*vt[i],cross(dl[i],n))>0)
|
||||
if(btDot(*vt[i],btCross(dl[i],n))>0)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar subd(projectorigin(*vt[i],*vt[j],subw,subm));
|
||||
@@ -397,13 +397,13 @@ static btScalar projectorigin( const btVector3& a,
|
||||
}
|
||||
if(mindist<0)
|
||||
{
|
||||
const btScalar d=dot(a,n);
|
||||
const btScalar d=btDot(a,n);
|
||||
const btScalar s=btSqrt(l);
|
||||
const btVector3 p=n*(d/l);
|
||||
mindist = p.length2();
|
||||
m = 7;
|
||||
w[0] = (cross(dl[1],b-p)).length()/s;
|
||||
w[1] = (cross(dl[2],c-p)).length()/s;
|
||||
w[0] = (btCross(dl[1],b-p)).length()/s;
|
||||
w[1] = (btCross(dl[2],c-p)).length()/s;
|
||||
w[2] = 1-(w[0]+w[1]);
|
||||
}
|
||||
return(mindist);
|
||||
@@ -420,7 +420,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
const btVector3* vt[]={&a,&b,&c,&d};
|
||||
const btVector3 dl[]={a-d,b-d,c-d};
|
||||
const btScalar vl=det(dl[0],dl[1],dl[2]);
|
||||
const bool ng=(vl*dot(a,cross(b-c,a-b)))<=0;
|
||||
const bool ng=(vl*btDot(a,btCross(b-c,a-b)))<=0;
|
||||
if(ng&&(btFabs(vl)>GJK_SIMPLEX4_EPS))
|
||||
{
|
||||
btScalar mindist=-1;
|
||||
@@ -429,7 +429,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar s=vl*dot(d,cross(dl[i],dl[j]));
|
||||
const btScalar s=vl*btDot(d,btCross(dl[i],dl[j]));
|
||||
if(s>0)
|
||||
{
|
||||
const btScalar subd=projectorigin(*vt[i],*vt[j],d,subw,subm);
|
||||
@@ -577,7 +577,7 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
|
||||
bool valid=true;
|
||||
best->pass = (U1)(++pass);
|
||||
gjk.getsupport(best->n,*w);
|
||||
const btScalar wdist=dot(best->n,w->w)-best->d;
|
||||
const btScalar wdist=btDot(best->n,w->w)-best->d;
|
||||
if(wdist>EPA_ACCURACY)
|
||||
{
|
||||
for(U j=0;(j<3)&&valid;++j)
|
||||
@@ -604,11 +604,11 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
|
||||
m_result.c[0] = outer.c[0];
|
||||
m_result.c[1] = outer.c[1];
|
||||
m_result.c[2] = outer.c[2];
|
||||
m_result.p[0] = cross( outer.c[1]->w-projection,
|
||||
m_result.p[0] = btCross( outer.c[1]->w-projection,
|
||||
outer.c[2]->w-projection).length();
|
||||
m_result.p[1] = cross( outer.c[2]->w-projection,
|
||||
m_result.p[1] = btCross( outer.c[2]->w-projection,
|
||||
outer.c[0]->w-projection).length();
|
||||
m_result.p[2] = cross( outer.c[0]->w-projection,
|
||||
m_result.p[2] = btCross( outer.c[0]->w-projection,
|
||||
outer.c[1]->w-projection).length();
|
||||
const btScalar sum=m_result.p[0]+m_result.p[1]+m_result.p[2];
|
||||
m_result.p[0] /= sum;
|
||||
@@ -642,18 +642,18 @@ sFace* newface(sSV* a,sSV* b,sSV* c,bool forced)
|
||||
face->c[0] = a;
|
||||
face->c[1] = b;
|
||||
face->c[2] = c;
|
||||
face->n = cross(b->w-a->w,c->w-a->w);
|
||||
face->n = btCross(b->w-a->w,c->w-a->w);
|
||||
const btScalar l=face->n.length();
|
||||
const bool v=l>EPA_ACCURACY;
|
||||
face->p = btMin(btMin(
|
||||
dot(a->w,cross(face->n,a->w-b->w)),
|
||||
dot(b->w,cross(face->n,b->w-c->w))),
|
||||
dot(c->w,cross(face->n,c->w-a->w))) /
|
||||
btDot(a->w,btCross(face->n,a->w-b->w)),
|
||||
btDot(b->w,btCross(face->n,b->w-c->w))),
|
||||
btDot(c->w,btCross(face->n,c->w-a->w))) /
|
||||
(v?l:1);
|
||||
face->p = face->p>=-EPA_INSIDE_EPS?0:face->p;
|
||||
if(v)
|
||||
{
|
||||
face->d = dot(a->w,face->n)/l;
|
||||
face->d = btDot(a->w,face->n)/l;
|
||||
face->n /= l;
|
||||
if(forced||(face->d>=-EPA_PLANE_EPS))
|
||||
{
|
||||
@@ -691,7 +691,7 @@ bool expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon)
|
||||
if(f->pass!=pass)
|
||||
{
|
||||
const U e1=i1m3[e];
|
||||
if((dot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
if((btDot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
{
|
||||
sFace* nf=newface(f->c[e1],f->c[e],w,false);
|
||||
if(nf)
|
||||
|
||||
Reference in New Issue
Block a user