MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / PhysicsComp_CalcMaxHeight

Function PhysicsComp_CalcMaxHeight

src/EntityComponents.c:1003–1010  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001}
1002
1003double PhysicsComp_CalcMaxHeight(float u) {
1004 /* equation below comes from solving diff(x(t, u))= 0 */
1005 /* We only work in discrete timesteps, so test both rounded up and down */
1006 double t = 34.30961849 * Math_Log2(0.247483075 * u + 0.9899323);
1007 double value_floor = PhysicsComp_YPosAt((int)t, u);
1008 double value_ceil = PhysicsComp_YPosAt((int)t + 1, u);
1009 return max(value_floor, value_ceil);
1010}
1011
1012/* Calculates the jump velocity required such that when user presses
1013the jump binding they will be able to jump up to the given height. */

Callers 2

LocalPlayer_JumpHeightFunction · 0.85

Calls 2

Math_Log2Function · 0.85
PhysicsComp_YPosAtFunction · 0.85

Tested by

no test coverage detected