MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / InitQuery

Method InitQuery

Engine/lib/opcode/OPC_OBBCollider.cpp:176–335  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * 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 * \

Source from the content-addressed store, hash-verified

174 */
175///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
176BOOL 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;

Callers

nothing calls this directly

Calls 11

SkipPrimitiveTestsFunction · 0.85
TemporalCoherenceEnabledFunction · 0.85
FirstContactEnabledFunction · 0.85
GetContactStatusFunction · 0.85
IsCacheValidFunction · 0.85
GetEntryMethod · 0.80
InitQueryFunction · 0.70
Matrix4x4Class · 0.50
Matrix3x3Class · 0.50
ResetMethod · 0.45
IsInsideMethod · 0.45

Tested by

no test coverage detected