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

Method castRay

Engine/source/ts/tsCollision.cpp:165–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165bool TSShapeInstance::castRay(const Point3F & a, const Point3F & b, RayInfo * rayInfo, S32 dl)
166{
167 // if dl==-1, nothing to do
168 if (dl==-1)
169 return false;
170
171 AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRay");
172
173 // get subshape and object detail
174 const TSDetail * detail = &mShape->details[dl];
175 S32 ss = detail->subShapeNum;
176 S32 od = detail->objectDetailNum;
177
178 // This detail has no geometry to hit.
179 if ( ss < 0 )
180 return false;
181
182 S32 start = mShape->subShapeFirstObject[ss];
183 S32 end = mShape->subShapeNumObjects[ss] + start;
184 RayInfo saveRay;
185 saveRay.t = 1.0f;
186 const MatrixF * saveMat = NULL;
187 bool found = false;
188 if (start<end)
189 {
190 Point3F ta, tb;
191
192 // set up for first object's node
193 MatrixF mat;
194 const MatrixF * previousMat = &mMeshObjects[start].getTransform();
195 mat = *previousMat;
196 mat.inverse();
197 mat.mulP(a,&ta);
198 mat.mulP(b,&tb);
199
200 // run through objects and collide
201 for (S32 i=start; i<end; i++)
202 {
203 MeshObjectInstance * mesh = &mMeshObjects[i];
204
205 if (od >= mesh->object->numMeshes)
206 continue;
207
208 if (&mesh->getTransform() != previousMat)
209 {
210 // different node from before, set up for this node
211 previousMat = &mesh->getTransform();
212
213 if (previousMat != NULL)
214 {
215 mat = *previousMat;
216 mat.inverse();
217 mat.mulP(a,&ta);
218 mat.mulP(b,&tb);
219 }
220 }
221 // collide...
222 if (mesh->castRay(od,ta,tb,rayInfo, mMaterialList))

Callers

nothing calls this directly

Calls 5

mulPMethod · 0.80
mulVMethod · 0.80
sizeMethod · 0.45
getTransformMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected