if (dt == -1) normal tick, so we advance. else interpolate with dt as % of tick, don't advance
| 3641 | // interpolate with dt as % of tick, don't advance |
| 3642 | // |
| 3643 | MatrixF * Player::Death::fallToGround(F32 dt, const Point3F& loc, F32 curZ, F32 boxRad) |
| 3644 | { |
| 3645 | static const F32 sConformCheckDown = 4.0f; |
| 3646 | RayInfo coll; |
| 3647 | bool conformToStairs = false; |
| 3648 | Point3F pos(loc.x, loc.y, loc.z + 0.1f); |
| 3649 | Point3F below(pos.x, pos.y, loc.z - sConformCheckDown); |
| 3650 | MatrixF * retVal = NULL; |
| 3651 | |
| 3652 | PROFILE_SCOPE(ConformToGround); |
| 3653 | |
| 3654 | if (gClientContainer.castRay(pos, below, sPlayerConformMask, &coll)) |
| 3655 | { |
| 3656 | F32 adjust, height = (loc.z - coll.point.z), sink = curSink; |
| 3657 | VectorF desNormal = coll.normal; |
| 3658 | VectorF normal = curNormal; |
| 3659 | |
| 3660 | // dt >= 0 means we're interpolating and don't accel the numbers |
| 3661 | if (dt >= 0.0f) |
| 3662 | adjust = dt * TickSec; |
| 3663 | else |
| 3664 | adjust = TickSec; |
| 3665 | |
| 3666 | // Try to get them to conform to stairs by doing several LOS calls. We do this if |
| 3667 | // normal is within about 5 deg. of vertical. |
| 3668 | if (desNormal.z > 0.995f) |
| 3669 | { |
| 3670 | Point3F corners[3], downpts[3]; |
| 3671 | S32 c; |
| 3672 | |
| 3673 | for (c = 0; c < 3; c++) { // Build 3 corners to cast down from- |
| 3674 | corners[c].set(loc.x - boxRad, loc.y - boxRad, loc.z + 1.0f); |
| 3675 | if (c) // add (0,boxWidth) and (boxWidth,0) |
| 3676 | corners[c][c - 1] += (boxRad * 2.0f); |
| 3677 | downpts[c].set(corners[c].x, corners[c].y, loc.z - sConformCheckDown); |
| 3678 | } |
| 3679 | |
| 3680 | // Do the three casts- |
| 3681 | for (c = 0; c < 3; c++) |
| 3682 | if (gClientContainer.castRay(corners[c], downpts[c], sPlayerConformMask, &coll)) |
| 3683 | downpts[c] = coll.point; |
| 3684 | else |
| 3685 | break; |
| 3686 | |
| 3687 | // Do the math if everything hit below- |
| 3688 | if (c == 3) { |
| 3689 | mCross(downpts[1] - downpts[0], downpts[2] - downpts[1], &desNormal); |
| 3690 | AssertFatal(desNormal.z > 0, "Abnormality in Player::Death::fallToGround()"); |
| 3691 | downpts[2] = downpts[2] - downpts[1]; |
| 3692 | downpts[1] = downpts[1] - downpts[0]; |
| 3693 | desNormal.normalize(); |
| 3694 | conformToStairs = true; |
| 3695 | } |
| 3696 | } |
| 3697 | |
| 3698 | // Move normal in direction we want- |
| 3699 | F32 * cur = normal, * des = desNormal; |
| 3700 | for (S32 i = 0; i < 3; i++) |