mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Even less double usage
This commit is contained in:
parent
10bd6222be
commit
f108f5e5e6
@ -1009,7 +1009,7 @@ static double PhysicsComp_YPosAt(int t, float u) {
|
|||||||
double PhysicsComp_CalcMaxHeight(float u) {
|
double PhysicsComp_CalcMaxHeight(float u) {
|
||||||
/* equation below comes from solving diff(x(t, u))= 0 */
|
/* equation below comes from solving diff(x(t, u))= 0 */
|
||||||
/* We only work in discrete timesteps, so test both rounded up and down */
|
/* 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_floor = PhysicsComp_YPosAt((int)t, u);
|
||||||
double value_ceil = PhysicsComp_YPosAt((int)t + 1, u);
|
double value_ceil = PhysicsComp_YPosAt((int)t + 1, u);
|
||||||
return max(value_floor, value_ceil);
|
return max(value_floor, value_ceil);
|
||||||
|
@ -23,11 +23,10 @@
|
|||||||
cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal;
|
cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal;
|
||||||
|
|
||||||
static float CalcBlendFactor(float x) {
|
static float CalcBlendFactor(float x) {
|
||||||
/* return -0.05 + 0.22 * (Math_Log(x) * 0.25f); */
|
float blend = -0.13f + 0.28f * ((float)Math_Log2(x) * 0.17329f);
|
||||||
double blend = -0.13 + 0.28 * (Math_Log(x) * 0.25);
|
if (blend < 0.0f) blend = 0.0f;
|
||||||
if (blend < 0.0) blend = 0.0;
|
if (blend > 1.0f) blend = 1.0f;
|
||||||
if (blend > 1.0) blend = 1.0;
|
return blend;
|
||||||
return (float)blend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EnvRenderer_AxisSize() (EnvRenderer_Legacy ? 128 : 2048)
|
#define EnvRenderer_AxisSize() (EnvRenderer_Legacy ? 128 : 2048)
|
||||||
@ -467,7 +466,7 @@ void EnvRenderer_RenderWeather(float delta) {
|
|||||||
pos.y = max(World.Height, pos.y);
|
pos.y = max(World.Height, pos.y);
|
||||||
|
|
||||||
weather_accumulator += delta;
|
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 (dx = -WEATHER_EXTENT; dx <= WEATHER_EXTENT; dx++) {
|
||||||
for (dz = -WEATHER_EXTENT; dz <= WEATHER_EXTENT; dz++) {
|
for (dz = -WEATHER_EXTENT; dz <= WEATHER_EXTENT; dz++) {
|
||||||
|
@ -591,13 +591,3 @@ double Math_Log2(double x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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;
|
|
||||||
}
|
|
||||||
|
@ -33,14 +33,11 @@ float Math_SinF(float x);
|
|||||||
float Math_CosF(float x);
|
float Math_CosF(float x);
|
||||||
double Math_Atan2(double x, double y);
|
double Math_Atan2(double x, double y);
|
||||||
|
|
||||||
/* Computes loge(x). Can also be used to approximate logy(x). */
|
/* Computes log2(x). Can also be used to approximate log_y(x). */
|
||||||
/* e.g. for log3(x), use: Math_Log(x)/log(3) */
|
/* e.g. for log3(x), use: log2(x)/log2(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) */
|
|
||||||
double Math_Log2(double x);
|
double Math_Log2(double x);
|
||||||
/* Computes 2^x. Can also be used to approximate y^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);
|
double Math_Exp2(double x);
|
||||||
|
|
||||||
int Math_Floor(float value);
|
int Math_Floor(float value);
|
||||||
|
@ -671,7 +671,7 @@ static void NotchyGen_PlantTrees(void) {
|
|||||||
treeX += Random_Next(&rnd, 6) - Random_Next(&rnd, 6);
|
treeX += Random_Next(&rnd, 6) - Random_Next(&rnd, 6);
|
||||||
treeZ += 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;
|
treeY = heightmap[treeZ * World.Width + treeX] + 1;
|
||||||
if (treeY >= World.Height) continue;
|
if (treeY >= World.Height) continue;
|
||||||
treeHeight = 5 + Random_Next(&rnd, 3);
|
treeHeight = 5 + Random_Next(&rnd, 3);
|
||||||
|
@ -435,7 +435,7 @@ static void Gamepad_Update(struct GamepadState* pad, float delta) {
|
|||||||
{
|
{
|
||||||
if (!Input.Pressed[btn]) continue;
|
if (!Input.Pressed[btn]) continue;
|
||||||
pad->holdtime[btn - GAMEPAD_BEG_BTN] += delta;
|
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 */
|
/* Held for over a second, trigger a fake press */
|
||||||
pad->holdtime[btn - GAMEPAD_BEG_BTN] = 0;
|
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;
|
if (x == 0 && y == 0) return;
|
||||||
|
|
||||||
int sensi = Gamepad_AxisSensitivity[axis];
|
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);
|
Event_RaisePadAxis(&ControllerEvents.AxisUpdate, port, axis, x * scale, y * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user