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

Method Collide

Engine/lib/opcode/OPC_SphereCollider.cpp:93–148  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Generic collision query for generic OPCODE models. After the call, access the results: * - with GetContactStatus() * - with GetNbTouchedPrimitives() * - with GetTouchedPrimitives() * * \param cache

Source from the content-addressed store, hash-verified

91 */
92///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93bool SphereCollider::Collide(SphereCache& cache, const Sphere& sphere, const Model& model, const Matrix4x4* worlds, const Matrix4x4* worldm)
94{
95 // Checkings
96 if(!Setup(&model)) return false;
97
98 // Init collision query
99 if(InitQuery(cache, sphere, worlds, worldm)) return true;
100
101 if(!model.HasLeafNodes())
102 {
103 if(model.IsQuantized())
104 {
105 const AABBQuantizedNoLeafTree* Tree = (const AABBQuantizedNoLeafTree*)model.GetTree();
106
107 // Setup dequantization coeffs
108 mCenterCoeff = Tree->mCenterCoeff;
109 mExtentsCoeff = Tree->mExtentsCoeff;
110
111 // Perform collision query
112 if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
113 else _Collide(Tree->GetNodes());
114 }
115 else
116 {
117 const AABBNoLeafTree* Tree = (const AABBNoLeafTree*)model.GetTree();
118
119 // Perform collision query
120 if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
121 else _Collide(Tree->GetNodes());
122 }
123 }
124 else
125 {
126 if(model.IsQuantized())
127 {
128 const AABBQuantizedTree* Tree = (const AABBQuantizedTree*)model.GetTree();
129
130 // Setup dequantization coeffs
131 mCenterCoeff = Tree->mCenterCoeff;
132 mExtentsCoeff = Tree->mExtentsCoeff;
133
134 // Perform collision query
135 if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
136 else _Collide(Tree->GetNodes());
137 }
138 else
139 {
140 const AABBCollisionTree* Tree = (const AABBCollisionTree*)model.GetTree();
141
142 // Perform collision query
143 if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
144 else _Collide(Tree->GetNodes());
145 }
146 }
147 return true;
148}
149
150///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 9

SkipPrimitiveTestsFunction · 0.85
FirstContactEnabledFunction · 0.85
TemporalCoherenceEnabledFunction · 0.85
GetContactStatusFunction · 0.85
GetNbTrianglesMethod · 0.80
GetTriangleIndexMethod · 0.80
SetupFunction · 0.70
InitQueryFunction · 0.70
ResetMethod · 0.45

Tested by

no test coverage detected