diff --git a/src/EntityComponents.c b/src/EntityComponents.c index 82fe1b60c..962713385 100644 --- a/src/EntityComponents.c +++ b/src/EntityComponents.c @@ -1009,7 +1009,7 @@ static double PhysicsComp_YPosAt(int t, float u) { double PhysicsComp_CalcMaxHeight(float u) { /* equation below comes from solving diff(x(t, u))= 0 */ /* We only work in discrete timesteps, so test both rounded up and down */ - double t = 49.49831645 * Math_Log(0.247483075 * u + 0.9899323); + double t = 34.30961849 * Math_Log2(0.247483075 * u + 0.9899323); double value_floor = PhysicsComp_YPosAt((int)t, u); double value_ceil = PhysicsComp_YPosAt((int)t + 1, u); return max(value_floor, value_ceil); diff --git a/src/EnvRenderer.c b/src/EnvRenderer.c index 0f0eea7c4..74b0f13fc 100644 --- a/src/EnvRenderer.c +++ b/src/EnvRenderer.c @@ -23,11 +23,10 @@ cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal; static float CalcBlendFactor(float x) { - /* return -0.05 + 0.22 * (Math_Log(x) * 0.25f); */ - double blend = -0.13 + 0.28 * (Math_Log(x) * 0.25); - if (blend < 0.0) blend = 0.0; - if (blend > 1.0) blend = 1.0; - return (float)blend; + float blend = -0.13f + 0.28f * ((float)Math_Log2(x) * 0.17329f); + if (blend < 0.0f) blend = 0.0f; + if (blend > 1.0f) blend = 1.0f; + return blend; } #define EnvRenderer_AxisSize() (EnvRenderer_Legacy ? 128 : 2048) @@ -467,7 +466,7 @@ void EnvRenderer_RenderWeather(float delta) { pos.y = max(World.Height, pos.y); weather_accumulator += delta; - particles = weather == WEATHER_RAINY && (weather_accumulator >= 0.25 || moved); + particles = weather == WEATHER_RAINY && (weather_accumulator >= 0.25f || moved); for (dx = -WEATHER_EXTENT; dx <= WEATHER_EXTENT; dx++) { for (dz = -WEATHER_EXTENT; dz <= WEATHER_EXTENT; dz++) { diff --git a/src/ExtMath.c b/src/ExtMath.c index c97a88153..49dd6976b 100644 --- a/src/ExtMath.c +++ b/src/ExtMath.c @@ -590,14 +590,4 @@ double Math_Log2(double x) { return exponent + Log2Stage1(doi.d); } -#endif - -/* Uses the property that - * log_e(x) = log_2(x) * log_e(2). - * - * Associated math function: log_e(x) - * Allowed input range: anything - */ -double Math_Log(double x) { - return Math_Log2(x) * LOGE2; -} +#endif \ No newline at end of file diff --git a/src/ExtMath.h b/src/ExtMath.h index 4907a416f..f02db6399 100644 --- a/src/ExtMath.h +++ b/src/ExtMath.h @@ -33,14 +33,11 @@ float Math_SinF(float x); float Math_CosF(float x); double Math_Atan2(double x, double y); -/* Computes loge(x). Can also be used to approximate logy(x). */ -/* e.g. for log3(x), use: Math_Log(x)/log(3) */ -double Math_Log(double x); -/* Computes log2(x). Can also be used to approximate log2(x). */ -/* e.g. for log3(x), use: Math_Log2(x)/log2(3) */ +/* Computes log2(x). Can also be used to approximate log_y(x). */ +/* e.g. for log3(x), use: log2(x)/log2(3) */ double Math_Log2(double x); /* Computes 2^x. Can also be used to approximate y^x. */ -/* e.g. for 3^x, use: Math_Exp2(log2(3)*x) */ +/* e.g. for 3^x, use: exp2(log2(3)*x) */ double Math_Exp2(double x); int Math_Floor(float value); diff --git a/src/Generator.c b/src/Generator.c index 7ad9649a6..94b0029fa 100644 --- a/src/Generator.c +++ b/src/Generator.c @@ -671,7 +671,7 @@ static void NotchyGen_PlantTrees(void) { treeX += Random_Next(&rnd, 6) - Random_Next(&rnd, 6); treeZ += Random_Next(&rnd, 6) - Random_Next(&rnd, 6); - if (!World_ContainsXZ(treeX, treeZ) || Random_Float(&rnd) >= 0.25) continue; + if (!World_ContainsXZ(treeX, treeZ) || Random_Float(&rnd) >= 0.25f) continue; treeY = heightmap[treeZ * World.Width + treeX] + 1; if (treeY >= World.Height) continue; treeHeight = 5 + Random_Next(&rnd, 3); diff --git a/src/Input.c b/src/Input.c index 3b6cb7448..8bc4c4aaa 100644 --- a/src/Input.c +++ b/src/Input.c @@ -435,7 +435,7 @@ static void Gamepad_Update(struct GamepadState* pad, float delta) { { if (!Input.Pressed[btn]) continue; pad->holdtime[btn - GAMEPAD_BEG_BTN] += delta; - if (pad->holdtime[btn - GAMEPAD_BEG_BTN] < 1.0) continue; + if (pad->holdtime[btn - GAMEPAD_BEG_BTN] < 1.0f) continue; /* Held for over a second, trigger a fake press */ pad->holdtime[btn - GAMEPAD_BEG_BTN] = 0; @@ -458,7 +458,7 @@ void Gamepad_SetAxis(int port, int axis, float x, float y, float delta) { if (x == 0 && y == 0) return; int sensi = Gamepad_AxisSensitivity[axis]; - float scale = delta * 60.0 * axis_sensiFactor[sensi]; + float scale = delta * 60.0f * axis_sensiFactor[sensi]; Event_RaisePadAxis(&ControllerEvents.AxisUpdate, port, axis, x * scale, y * scale); }