////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Initializes a collision query : * - reset stats & contact status * - setup matrices * - check temporal coherence * * \param cache [in/out] a box cache * \param box [in] obb in local space * \
| 174 | */ |
| 175 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 176 | BOOL OBBCollider::InitQuery(OBBCache& cache, const OBB& box, const Matrix4x4* worldb, const Matrix4x4* worldm) |
| 177 | { |
| 178 | // 1) Call the base method |
| 179 | VolumeCollider::InitQuery(); |
| 180 | |
| 181 | // 2) Compute obb in world space |
| 182 | mBoxExtents = box.mExtents; |
| 183 | |
| 184 | Matrix4x4 WorldB; |
| 185 | |
| 186 | if(worldb) |
| 187 | { |
| 188 | WorldB = Matrix4x4( box.mRot * Matrix3x3(*worldb) ); |
| 189 | WorldB.SetTrans(box.mCenter * *worldb); |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | WorldB = box.mRot; |
| 194 | WorldB.SetTrans(box.mCenter); |
| 195 | } |
| 196 | |
| 197 | // Setup matrices |
| 198 | Matrix4x4 InvWorldB; |
| 199 | InvertPRMatrix(InvWorldB, WorldB); |
| 200 | |
| 201 | if(worldm) |
| 202 | { |
| 203 | Matrix4x4 InvWorldM; |
| 204 | InvertPRMatrix(InvWorldM, *worldm); |
| 205 | |
| 206 | Matrix4x4 WorldBtoM = WorldB * InvWorldM; |
| 207 | Matrix4x4 WorldMtoB = *worldm * InvWorldB; |
| 208 | |
| 209 | mRModelToBox = WorldMtoB; WorldMtoB.GetTrans(mTModelToBox); |
| 210 | mRBoxToModel = WorldBtoM; WorldBtoM.GetTrans(mTBoxToModel); |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | mRModelToBox = InvWorldB; InvWorldB.GetTrans(mTModelToBox); |
| 215 | mRBoxToModel = WorldB; WorldB.GetTrans(mTBoxToModel); |
| 216 | } |
| 217 | |
| 218 | // 3) Setup destination pointer |
| 219 | mTouchedPrimitives = &cache.TouchedPrimitives; |
| 220 | |
| 221 | // 4) Special case: 1-triangle meshes [Opcode 1.3] |
| 222 | if(mCurrentModel && mCurrentModel->HasSingleNode()) |
| 223 | { |
| 224 | if(!SkipPrimitiveTests()) |
| 225 | { |
| 226 | // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0. |
| 227 | mTouchedPrimitives->Reset(); |
| 228 | |
| 229 | // Perform overlap test between the unique triangle and the box (and set contact status if needed) |
| 230 | OBB_PRIM(udword(0), OPC_CONTACT) |
| 231 | |
| 232 | // Return immediately regardless of status |
| 233 | return TRUE; |
nothing calls this directly
no test coverage detected