////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Initializes a collision query : * - reset stats & contact status * - setup matrices * - check temporal coherence * * \param cache [in/out] an lss cache * \param lss [in] lss in local space *
| 160 | */ |
| 161 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 162 | BOOL LSSCollider::InitQuery(LSSCache& cache, const LSS& lss, const Matrix4x4* worldl, const Matrix4x4* worldm) |
| 163 | { |
| 164 | // 1) Call the base method |
| 165 | VolumeCollider::InitQuery(); |
| 166 | |
| 167 | // 2) Compute LSS in model space: |
| 168 | // - Precompute R^2 |
| 169 | mRadius2 = lss.mRadius * lss.mRadius; |
| 170 | // - Compute segment |
| 171 | mSeg.mP0 = lss.mP0; |
| 172 | mSeg.mP1 = lss.mP1; |
| 173 | // -> to world space |
| 174 | if(worldl) |
| 175 | { |
| 176 | mSeg.mP0 *= *worldl; |
| 177 | mSeg.mP1 *= *worldl; |
| 178 | } |
| 179 | // -> to model space |
| 180 | if(worldm) |
| 181 | { |
| 182 | // Invert model matrix |
| 183 | Matrix4x4 InvWorldM; |
| 184 | InvertPRMatrix(InvWorldM, *worldm); |
| 185 | |
| 186 | mSeg.mP0 *= InvWorldM; |
| 187 | mSeg.mP1 *= InvWorldM; |
| 188 | } |
| 189 | |
| 190 | // 3) Setup destination pointer |
| 191 | mTouchedPrimitives = &cache.TouchedPrimitives; |
| 192 | |
| 193 | // 4) Special case: 1-triangle meshes [Opcode 1.3] |
| 194 | if(mCurrentModel && mCurrentModel->HasSingleNode()) |
| 195 | { |
| 196 | if(!SkipPrimitiveTests()) |
| 197 | { |
| 198 | // We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0. |
| 199 | mTouchedPrimitives->Reset(); |
| 200 | |
| 201 | // Perform overlap test between the unique triangle and the LSS (and set contact status if needed) |
| 202 | LSS_PRIM(udword(0), OPC_CONTACT) |
| 203 | |
| 204 | // Return immediately regardless of status |
| 205 | return TRUE; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // 5) Check temporal coherence : |
| 210 | if(TemporalCoherenceEnabled()) |
| 211 | { |
| 212 | // Here we use temporal coherence |
| 213 | // => check results from previous frame before performing the collision query |
| 214 | if(FirstContactEnabled()) |
| 215 | { |
| 216 | // We're only interested in the first contact found => test the unique previously touched face |
| 217 | if(mTouchedPrimitives->GetNbEntries()) |
| 218 | { |
| 219 | // Get index of previously touched face = the first entry in the array |
nothing calls this directly
no test coverage detected