////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Generic collision query for generic OPCODE models. After the call, access the results with: * - GetContactStatus() * - GetNbPairs() * - GetPairs() * * \param cache [in] collision cache for model
| 88 | */ |
| 89 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 90 | bool AABBTreeCollider::Collide(BVTCache& cache, const Matrix4x4* world0, const Matrix4x4* world1) |
| 91 | { |
| 92 | // Checkings |
| 93 | if(!cache.Model0 || !cache.Model1) return false; |
| 94 | if(cache.Model0->HasLeafNodes()!=cache.Model1->HasLeafNodes()) return false; |
| 95 | if(cache.Model0->IsQuantized()!=cache.Model1->IsQuantized()) return false; |
| 96 | |
| 97 | /* |
| 98 | |
| 99 | Rules: |
| 100 | - perform hull test |
| 101 | - when hulls collide, disable hull test |
| 102 | - if meshes overlap, reset countdown |
| 103 | - if countdown reaches 0, enable hull test |
| 104 | |
| 105 | */ |
| 106 | |
| 107 | #ifdef __MESHMERIZER_H__ |
| 108 | // Handle hulls |
| 109 | if(cache.HullTest) |
| 110 | { |
| 111 | if(cache.Model0->GetHull() && cache.Model1->GetHull()) |
| 112 | { |
| 113 | struct Local |
| 114 | { |
| 115 | static Point* SVCallback(const Point& sv, udword& previndex, udword user_data) |
| 116 | { |
| 117 | CollisionHull* Hull = (CollisionHull*)user_data; |
| 118 | previndex = Hull->ComputeSupportingVertex(sv, previndex); |
| 119 | return (Point*)&Hull->GetVerts()[previndex]; |
| 120 | } |
| 121 | }; |
| 122 | |
| 123 | bool Collide; |
| 124 | |
| 125 | if(0) |
| 126 | { |
| 127 | static GJKEngine GJK; |
| 128 | static bool GJKInitDone=false; |
| 129 | if(!GJKInitDone) |
| 130 | { |
| 131 | GJK.Enable(GJK_BACKUP_PROCEDURE); |
| 132 | GJK.Enable(GJK_DEGENERATE); |
| 133 | GJK.Enable(GJK_HILLCLIMBING); |
| 134 | GJKInitDone = true; |
| 135 | } |
| 136 | GJK.SetCallbackObj0(Local::SVCallback); |
| 137 | GJK.SetCallbackObj1(Local::SVCallback); |
| 138 | GJK.SetUserData0(udword(cache.Model0->GetHull())); |
| 139 | GJK.SetUserData1(udword(cache.Model1->GetHull())); |
| 140 | Collide = GJK.Collide(*world0, *world1, &cache.SepVector); |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | static SVEngine SVE; |
| 145 | SVE.SetCallbackObj0(Local::SVCallback); |
| 146 | SVE.SetCallbackObj1(Local::SVCallback); |
| 147 | SVE.SetUserData0(udword(cache.Model0->GetHull())); |
nothing calls this directly
no test coverage detected