35 using namespace Opcode;
52 mFullBoxBoxTest (true),
53 mFullPrimBoxTest (true)
109 #ifdef __MESHMERIZER_H__
119 CollisionHull* Hull = (CollisionHull*)user_data;
120 previndex = Hull->ComputeSupportingVertex(sv, previndex);
121 return (
Point*)&Hull->GetVerts()[previndex];
129 static GJKEngine GJK;
130 static bool GJKInitDone=
false;
133 GJK.Enable(GJK_BACKUP_PROCEDURE);
134 GJK.Enable(GJK_DEGENERATE);
135 GJK.Enable(GJK_HILLCLIMBING);
138 GJK.SetCallbackObj0(Local::SVCallback);
139 GJK.SetCallbackObj1(Local::SVCallback);
142 Collide = GJK.Collide(*world0, *world1, &cache.SepVector);
147 SVE.SetCallbackObj0(Local::SVCallback);
148 SVE.SetCallbackObj1(Local::SVCallback);
151 Collide = SVE.Collide(*world0, *world1, &cache.SepVector);
168 cache.HullTest =
false;
169 #endif // __MESHMERIZER_H__
182 Status =
Collide(T0, T1, world0, world1, &cache);
188 Status =
Collide(T0, T1, world0, world1, &cache);
197 Status =
Collide(T0, T1, world0, world1, &cache);
203 Status =
Collide(T0, T1, world0, world1, &cache);
207 #ifdef __MESHMERIZER_H__
218 cache.HullTest =
true;
253 Matrix4x4 World0to1 = world0 ? (*world0 * InvWorld1) : InvWorld1;
254 Matrix4x4 World1to0 = world1 ? (*world1 * InvWorld0) : InvWorld0;
281 if(!cache)
return false;
292 #define UPDATE_CACHE \
293 if(cache && GetContactStatus()) \
295 cache->id0 = mPairs.GetEntry(0); \
296 cache->id1 = mPairs.GetEntry(1); \
320 _Collide(tree0->GetNodes(), tree1->GetNodes());
348 _Collide(tree0->GetNodes(), tree1->GetNodes());
425 _Collide(tree0->GetNodes(), tree1->GetNodes());
438 #define ALTERNATIVE_CODE
451 if(!
BoxBoxOverlap(b0->mAABB.mExtents, b0->mAABB.mCenter, b1->mAABB.mExtents, b1->mAABB.mCenter))
return;
453 if(b0->IsLeaf() && b1->IsLeaf()) {
PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
return; }
455 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->GetSize() > b1->GetSize())))
470 #ifdef ALTERNATIVE_CODE
481 if(!
BoxBoxOverlap(b0->mAABB.mExtents, b0->mAABB.mCenter, b1->mAABB.mExtents, b1->mAABB.mCenter))
490 PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
499 else if(b1->IsLeaf())
507 _Collide(b0->GetNeg(), b1->GetNeg());
509 _Collide(b0->GetNeg(), b1->GetPos());
511 _Collide(b0->GetPos(), b1->GetNeg());
513 _Collide(b0->GetPos(), b1->GetPos());
606 if(!
TriBoxOverlap(b->mAABB.mCenter, b->mAABB.mExtents))
return;
628 if(!
TriBoxOverlap(b->mAABB.mCenter, b->mAABB.mExtents))
return;
642 #define FETCH_LEAF(prim_index, imesh, rot, trans) \
643 mLeafIndex = prim_index; \
645 VertexPointers VP; imesh->GetTriangle(VP, prim_index); \
647 TransformPoint(mLeafVerts[0], *VP.Vertex[0], rot, trans); \
648 TransformPoint(mLeafVerts[1], *VP.Vertex[1], rot, trans); \
649 TransformPoint(mLeafVerts[2], *VP.Vertex[2], rot, trans);
661 if(!
BoxBoxOverlap(a->mAABB.mExtents, a->mAABB.mCenter, b->mAABB.mExtents, b->mAABB.mCenter))
return;
664 BOOL BHasPosLeaf = b->HasPosLeaf();
665 BOOL BHasNegLeaf = b->HasNegLeaf();
687 else _Collide(a->GetPos(), b->GetPos());
697 else _Collide(a->GetPos(), b->GetNeg());
723 else _Collide(a->GetNeg(), b->GetPos());
734 else _Collide(a->GetNeg(), b->GetNeg());
758 if(b0->IsLeaf() && b1->IsLeaf()) {
PrimTest(b0->GetPrimitive(), b1->GetPrimitive());
return; }
760 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->GetSize() > b1->GetSize())))
766 _Collide(b0->GetNeg(), b1, nega, negPa,
b, Pb);
771 Box = &b0->GetPos()->mAABB;
774 _Collide(b0->GetPos(), b1, posa, posPa,
b, Pb);
782 _Collide(b0, b1->GetNeg(),
a, Pa, negb, negPb);
787 Box = &b1->GetPos()->mAABB;
790 _Collide(b0, b1->GetPos(),
a, Pa, posb, posPb);
872 BOOL BHasPosLeaf = b->HasPosLeaf();
873 BOOL BHasNegLeaf = b->HasNegLeaf();
895 else _Collide(a->GetPos(), b->GetPos());
905 else _Collide(a->GetPos(), b->GetNeg());
931 else _Collide(a->GetNeg(), b->GetPos());
942 else _Collide(a->GetNeg(), b->GetNeg());