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

Method castRay

Engine/source/T3D/tsStatic.cpp:1158–1207  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1156
1157//----------------------------------------------------------------------------
1158bool TSStatic::castRay(const Point3F& start, const Point3F& end, RayInfo* info)
1159{
1160 if (mCollisionType == None)
1161 return false;
1162
1163 if (!mShapeInstance)
1164 return false;
1165
1166 if (mCollisionType == Bounds)
1167 {
1168 F32 fst;
1169 if (!mObjBox.collideLine(start, end, &fst, &info->normal))
1170 return false;
1171
1172 info->t = fst;
1173 info->object = this;
1174 info->point.interpolate(start, end, fst);
1175 info->material = NULL;
1176 return true;
1177 }
1178 else
1179 {
1180 RayInfo shortest = *info;
1181 RayInfo localInfo;
1182 shortest.t = 1e8f;
1183 localInfo.generateTexCoord = info->generateTexCoord;
1184
1185 for (U32 i = 0; i < mLOSDetails.size(); i++)
1186 {
1187 mShapeInstance->animate(mLOSDetails[i]);
1188
1189 if (mShapeInstance->castRayOpcode(mLOSDetails[i], start, end, &localInfo))
1190 {
1191 localInfo.object = this;
1192
1193 if (localInfo.t < shortest.t)
1194 shortest = localInfo;
1195 }
1196 }
1197
1198 if (shortest.object == this)
1199 {
1200 // Copy out the shortest time...
1201 *info = shortest;
1202 return true;
1203 }
1204 }
1205
1206 return false;
1207}
1208
1209bool TSStatic::castRayRendered(const Point3F& start, const Point3F& end, RayInfo* info)
1210{

Callers

nothing calls this directly

Calls 5

collideLineMethod · 0.80
castRayOpcodeMethod · 0.80
interpolateMethod · 0.45
sizeMethod · 0.45
animateMethod · 0.45

Tested by

no test coverage detected