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

Method castRayRendered

Engine/source/ts/tsCollision.cpp:252–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252bool TSShapeInstance::castRayRendered(const Point3F & a, const Point3F & b, RayInfo * rayInfo, S32 dl)
253{
254 // if dl==-1, nothing to do
255 if (dl==-1)
256 return false;
257
258 AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRayRendered");
259
260 // get subshape and object detail
261 const TSDetail * detail = &mShape->details[dl];
262 S32 ss = detail->subShapeNum;
263 S32 od = detail->objectDetailNum;
264
265 if ( ss == -1 )
266 return false;
267
268 S32 start = mShape->subShapeFirstObject[ss];
269 S32 end = mShape->subShapeNumObjects[ss] + start;
270 RayInfo saveRay;
271 saveRay.t = 1.0f;
272 const MatrixF * saveMat = NULL;
273 bool found = false;
274 if (start<end)
275 {
276 Point3F ta, tb;
277
278 // set up for first object's node
279 MatrixF mat;
280 const MatrixF * previousMat = &mMeshObjects[start].getTransform();
281 mat = *previousMat;
282 mat.inverse();
283 mat.mulP(a,&ta);
284 mat.mulP(b,&tb);
285
286 // run through objects and collide
287 for (S32 i=start; i<end; i++)
288 {
289 MeshObjectInstance * mesh = &mMeshObjects[i];
290
291 if (od >= mesh->object->numMeshes)
292 continue;
293
294 if (&mesh->getTransform() != previousMat)
295 {
296 // different node from before, set up for this node
297 previousMat = &mesh->getTransform();
298
299 if (previousMat != NULL)
300 {
301 mat = *previousMat;
302 mat.inverse();
303 mat.mulP(a,&ta);
304 mat.mulP(b,&tb);
305 }
306 }
307 // collide...
308 if (mesh->castRayRendered(od,ta,tb,rayInfo, mMaterialList))
309 {

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