| 1690 | |
| 1691 | |
| 1692 | bool Player::getHitCorrection(const fvec3& startPos, const float startAzimuth, |
| 1693 | const fvec3& /*endPos*/, const float /*endAzimuth*/, |
| 1694 | const fvec3& startVelocity, double dt, |
| 1695 | float groundLimit, fvec3& velocity, fvec3& position, |
| 1696 | float* azimuth) { |
| 1697 | // constants |
| 1698 | static const float MinSearchStep = 0.0001f; |
| 1699 | static const int MaxSearchSteps = 7; |
| 1700 | static const int MaxSteps = 4; |
| 1701 | static const float TinyDistance = 0.0001f; |
| 1702 | |
| 1703 | fvec3 newPos; |
| 1704 | fvec3 newVelocity; |
| 1705 | float newAzimuth; |
| 1706 | float newAngVel; |
| 1707 | bool hitWall; |
| 1708 | const Obstacle* obstacle; |
| 1709 | bool expel; |
| 1710 | float timeStep = (float)dt; |
| 1711 | |
| 1712 | newPos = startPos; |
| 1713 | newVelocity = startVelocity; |
| 1714 | newAngVel = state.angVel; |
| 1715 | newAzimuth = startAzimuth; |
| 1716 | hitWall = false; |
| 1717 | |
| 1718 | bool phased = !isSolid(); |
| 1719 | |
| 1720 | for (int numSteps = 0; numSteps < MaxSteps; numSteps++) { |
| 1721 | // record position at beginning of time step |
| 1722 | fvec3 tmpPos; |
| 1723 | float tmpAzimuth; |
| 1724 | tmpAzimuth = newAzimuth; |
| 1725 | tmpPos = newPos; |
| 1726 | |
| 1727 | // get position at end of time step |
| 1728 | newAzimuth = tmpAzimuth + timeStep * newAngVel; |
| 1729 | newPos = tmpPos + (timeStep * newVelocity); |
| 1730 | if ((newPos.z < groundLimit) && (newVelocity.z < 0)) { |
| 1731 | // Hit lower limit, stop falling |
| 1732 | newPos.z = groundLimit; |
| 1733 | if ((state.status & PlayerState::Exploding) != 0) { |
| 1734 | // tank pieces reach the ground, friction |
| 1735 | // stop them, & mainly player view |
| 1736 | newPos.x = tmpPos.x; |
| 1737 | newPos.y = tmpPos.y; |
| 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | // see if we hit anything. if not then we're done. |
| 1742 | obstacle = getHitBuilding(tmpPos, tmpAzimuth, newPos, newAzimuth, |
| 1743 | phased, expel); |
| 1744 | |
| 1745 | if (!obstacle || !expel) { |
| 1746 | break; |
| 1747 | } |
| 1748 | |
| 1749 | static BZDB_float maxBumpHeight(BZDBNAMES.MAXBUMPHEIGHT); |
nothing calls this directly
no test coverage detected