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

Method castRay

Engine/source/T3D/player.cpp:5880–5924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5878//----------------------------------------------------------------------------
5879
5880bool Player::castRay(const Point3F &start, const Point3F &end, RayInfo* info)
5881{
5882 if (getDamageState() != Enabled)
5883 return false;
5884
5885 // Collide against bounding box. Need at least this for the editor.
5886 F32 st,et,fst = 0.0f,fet = 1.0f;
5887 F32 *bmin = &mObjBox.minExtents.x;
5888 F32 *bmax = &mObjBox.maxExtents.x;
5889 F32 const *si = &start.x;
5890 F32 const *ei = &end.x;
5891
5892 for (S32 i = 0; i < 3; i++) {
5893 if (*si < *ei) {
5894 if (*si > *bmax || *ei < *bmin)
5895 return false;
5896 F32 di = *ei - *si;
5897 st = (*si < *bmin)? (*bmin - *si) / di: 0.0f;
5898 et = (*ei > *bmax)? (*bmax - *si) / di: 1.0f;
5899 }
5900 else {
5901 if (*ei > *bmax || *si < *bmin)
5902 return false;
5903 F32 di = *ei - *si;
5904 st = (*si > *bmax)? (*bmax - *si) / di: 0.0f;
5905 et = (*ei < *bmin)? (*bmin - *si) / di: 1.0f;
5906 }
5907 if (st > fst) fst = st;
5908 if (et < fet) fet = et;
5909 if (fet < fst)
5910 return false;
5911 bmin++; bmax++;
5912 si++; ei++;
5913 }
5914
5915 info->normal = start - end;
5916 info->normal.normalizeSafe();
5917 getTransform().mulV( info->normal );
5918
5919 info->t = fst;
5920 info->object = this;
5921 info->point.interpolate(start,end,fst);
5922 info->material = 0;
5923 return true;
5924}
5925
5926
5927//----------------------------------------------------------------------------

Callers 15

emitParticlesMethod · 0.45
simulateMethod · 0.45
getMoveListMethod · 0.45
_testVisibilityMethod · 0.45
_validateEyePointMethod · 0.45
updatePosMethod · 0.45
getCorrectedAimMethod · 0.45
getCameraTransformMethod · 0.45
collidingWithWaterMethod · 0.45
checkDismountPositionMethod · 0.45
fallToGroundMethod · 0.45
updateActionThreadMethod · 0.45

Calls 3

mulVMethod · 0.80
normalizeSafeMethod · 0.45
interpolateMethod · 0.45

Tested by

no test coverage detected