30 #include"../CollisionPairInserter.h"
55 mFullBoxBoxTest (true),
56 mFullPrimBoxTest (true),
57 collisionPairInserter(0)
114 #ifdef __MESHMERIZER_H__
122 static Point* SVCallback(
const Point& sv,
udword& previndex,
udword user_data)
124 CollisionHull* Hull = (CollisionHull*)user_data;
125 previndex = Hull->ComputeSupportingVertex(sv, previndex);
126 return (Point*)&Hull->GetVerts()[previndex];
134 static GJKEngine GJK;
135 static bool GJKInitDone=
false;
138 GJK.Enable(GJK_BACKUP_PROCEDURE);
139 GJK.Enable(GJK_DEGENERATE);
140 GJK.Enable(GJK_HILLCLIMBING);
143 GJK.SetCallbackObj0(Local::SVCallback);
144 GJK.SetCallbackObj1(Local::SVCallback);
147 Collide = GJK.Collide(*world0, *world1, &cache.SepVector);
152 SVE.SetCallbackObj0(Local::SVCallback);
153 SVE.SetCallbackObj1(Local::SVCallback);
156 Collide = SVE.Collide(*world0, *world1, &cache.SepVector);
173 cache.HullTest =
false;
174 #endif // __MESHMERIZER_H__
187 Status =
Collide(T0, T1, world0, world1, &cache);
193 Status =
Collide(T0, T1, world0, world1, &cache);
202 Status =
Collide(T0, T1, world0, world1, &cache);
208 Status =
Collide(T0, T1, world0, world1, &cache);
212 #ifdef __MESHMERIZER_H__
223 cache.HullTest =
true;
258 Matrix4x4 World0to1 = world0 ? (*world0 * InvWorld1) : InvWorld1;
259 Matrix4x4 World1to0 = world1 ? (*world1 * InvWorld0) : InvWorld0;
281 for(
udword j=0; j<3; j++){
319 if(!cache)
return false;
330 #define UPDATE_CACHE \
331 if(cache && GetContactStatus()) \
333 cache->id0 = mPairs.GetEntry(0); \
334 cache->id1 = mPairs.GetEntry(1); \
358 _Collide(tree0->GetNodes(), tree1->GetNodes());
386 _Collide(tree0->GetNodes(), tree1->GetNodes());
463 _Collide(tree0->GetNodes(), tree1->GetNodes());
476 #define ALTERNATIVE_CODE
491 if(!
BoxBoxOverlap(b0->mAABB.mExtents, b0->mAABB.mCenter, b1->mAABB.mExtents, b1->mAABB.mCenter))
return;
493 if(b0->IsLeaf() && b1->IsLeaf()) {
PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
return; }
495 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->
GetSize() > b1->
GetSize())))
510 #ifdef ALTERNATIVE_CODE
521 if(!
BoxBoxOverlap(b0->mAABB.mExtents, b0->mAABB.mCenter, b1->mAABB.mExtents, b1->mAABB.mCenter))
532 PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
541 else if(b1->IsLeaf())
549 _Collide(b0->GetNeg(), b1->GetNeg());
551 _Collide(b0->GetNeg(), b1->GetPos());
553 _Collide(b0->GetPos(), b1->GetNeg());
555 _Collide(b0->GetPos(), b1->GetPos());
693 #define FETCH_LEAF(prim_index, imesh, rot, trans) \
694 mLeafIndex = prim_index; \
696 VertexPointers VP; imesh->GetTriangle(VP, prim_index); \
698 TransformPoint(mLeafVerts[0], *VP.Vertex[0], rot, trans); \
699 TransformPoint(mLeafVerts[1], *VP.Vertex[1], rot, trans); \
700 TransformPoint(mLeafVerts[2], *VP.Vertex[2], rot, trans);
712 if(!
BoxBoxOverlap(
a->mAABB.mExtents,
a->mAABB.mCenter,
b->mAABB.mExtents,
b->mAABB.mCenter))
return;
715 BOOL BHasPosLeaf =
b->HasPosLeaf();
716 BOOL BHasNegLeaf =
b->HasNegLeaf();
809 if(b0->IsLeaf() && b1->IsLeaf()) {
PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
return; }
811 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->
GetSize() > b1->
GetSize())))
817 _Collide(b0->GetNeg(), b1, nega, negPa,
b, Pb);
822 Box = &b0->GetPos()->mAABB;
825 _Collide(b0->GetPos(), b1, posa, posPa,
b, Pb);
833 _Collide(b0, b1->GetNeg(),
a, Pa, negb, negPb);
838 Box = &b1->GetPos()->mAABB;
841 _Collide(b0, b1->GetPos(),
a, Pa, posb, posPb);
929 BOOL BHasPosLeaf =
b->HasPosLeaf();
930 BOOL BHasNegLeaf =
b->HasNegLeaf();