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

Method fallToGround

Engine/source/T3D/player.cpp:3584–3686  ·  view source on GitHub ↗

if (dt == -1) normal tick, so we advance. else interpolate with dt as % of tick, don't advance

Source from the content-addressed store, hash-verified

3582// interpolate with dt as % of tick, don't advance
3583//
3584MatrixF * Player::Death::fallToGround(F32 dt, const Point3F& loc, F32 curZ, F32 boxRad)
3585{
3586 static const F32 sConformCheckDown = 4.0f;
3587 RayInfo coll;
3588 bool conformToStairs = false;
3589 Point3F pos(loc.x, loc.y, loc.z + 0.1f);
3590 Point3F below(pos.x, pos.y, loc.z - sConformCheckDown);
3591 MatrixF * retVal = NULL;
3592
3593 PROFILE_SCOPE(ConformToGround);
3594
3595 if (gClientContainer.castRay(pos, below, sPlayerConformMask, &coll))
3596 {
3597 F32 adjust, height = (loc.z - coll.point.z), sink = curSink;
3598 VectorF desNormal = coll.normal;
3599 VectorF normal = curNormal;
3600
3601 // dt >= 0 means we're interpolating and don't accel the numbers
3602 if (dt >= 0.0f)
3603 adjust = dt * TickSec;
3604 else
3605 adjust = TickSec;
3606
3607 // Try to get them to conform to stairs by doing several LOS calls. We do this if
3608 // normal is within about 5 deg. of vertical.
3609 if (desNormal.z > 0.995f)
3610 {
3611 Point3F corners[3], downpts[3];
3612 S32 c;
3613
3614 for (c = 0; c < 3; c++) { // Build 3 corners to cast down from-
3615 corners[c].set(loc.x - boxRad, loc.y - boxRad, loc.z + 1.0f);
3616 if (c) // add (0,boxWidth) and (boxWidth,0)
3617 corners[c][c - 1] += (boxRad * 2.0f);
3618 downpts[c].set(corners[c].x, corners[c].y, loc.z - sConformCheckDown);
3619 }
3620
3621 // Do the three casts-
3622 for (c = 0; c < 3; c++)
3623 if (gClientContainer.castRay(corners[c], downpts[c], sPlayerConformMask, &coll))
3624 downpts[c] = coll.point;
3625 else
3626 break;
3627
3628 // Do the math if everything hit below-
3629 if (c == 3) {
3630 mCross(downpts[1] - downpts[0], downpts[2] - downpts[1], &desNormal);
3631 AssertFatal(desNormal.z > 0, "Abnormality in Player::Death::fallToGround()");
3632 downpts[2] = downpts[2] - downpts[1];
3633 downpts[1] = downpts[1] - downpts[0];
3634 desNormal.normalize();
3635 conformToStairs = true;
3636 }
3637 }
3638
3639 // Move normal in direction we want-
3640 F32 * cur = normal, * des = desNormal;
3641 for (S32 i = 0; i < 3; i++)

Callers 1

setRenderPositionMethod · 0.80

Calls 10

accelFunction · 0.85
mFabsFunction · 0.85
mSqrtFunction · 0.85
mulVMethod · 0.80
setColumnMethod · 0.80
mCrossFunction · 0.50
castRayMethod · 0.45
setMethod · 0.45
normalizeMethod · 0.45
isZeroMethod · 0.45

Tested by

no test coverage detected