diff --git a/src/ClassiCube.vcxproj.filters b/src/ClassiCube.vcxproj.filters
index 6ce7e2312..17be9e4a5 100644
--- a/src/ClassiCube.vcxproj.filters
+++ b/src/ClassiCube.vcxproj.filters
@@ -761,9 +761,6 @@
Source Files\Utils
-
- Source Files
-
Source Files\Platform
@@ -776,6 +773,9 @@
Source Files\Platform
+
+ Source Files\Window
+
diff --git a/src/ExtMath.c b/src/ExtMath.c
index 6e270cb3a..452504867 100644
--- a/src/ExtMath.c
+++ b/src/ExtMath.c
@@ -42,9 +42,6 @@ float sqrtf(float x) {
float Math_Mod1(float x) { return x - (int)x; /* fmodf(x, 1); */ }
int Math_AbsI(int x) { return abs(x); /* MSVC intrinsic */ }
-float Math_SinF(float x) { return (float)Math_Sin(x); }
-float Math_CosF(float x) { return (float)Math_Cos(x); }
-
int Math_Floor(float value) {
int valueI = (int)value;
return valueI > value ? valueI - 1 : valueI;
@@ -156,8 +153,8 @@ float Random_Float(RNGState* seed) {
/* TODO: Properly investigate this issue */
/* double make_dreamcast_build_compile(void) { fabs(4); } */
-double Math_Sin(double x) { return sinf(x); }
-double Math_Cos(double x) { return cosf(x); }
+float Math_SinF(float x) { return sinf(x); }
+float Math_CosF(float x) { return cosf(x); }
double Math_Exp2(double x) { return exp2(x); }
double Math_Log2(double x) { return log2(x); }
#else
@@ -270,11 +267,11 @@ static double SinStage3(double x) {
* Associated math function: sin(x)
* Allowed input range: anything
*/
-double Math_Sin(double x) {
+float Math_SinF(float x) {
double x_div_pi;
x_div_pi = x * DIV_2_PI;
- return SinStage3(x_div_pi - Floord(x_div_pi));
+ return (float)SinStage3(x_div_pi - Floord(x_div_pi));
}
/************
@@ -287,11 +284,11 @@ double Math_Sin(double x) {
* Associated math function: cos(x)
* Allowed input range: anything
*/
-double Math_Cos(double x) {
+float Math_CosF(float x) {
double x_div_pi_shifted;
x_div_pi_shifted = x * DIV_2_PI + 0.25;
- return SinStage3(x_div_pi_shifted - Floord(x_div_pi_shifted));
+ return (float)SinStage3(x_div_pi_shifted - Floord(x_div_pi_shifted));
}
/************
diff --git a/src/ExtMath.h b/src/ExtMath.h
index a4a689cc0..c0f636b9e 100644
--- a/src/ExtMath.h
+++ b/src/ExtMath.h
@@ -27,10 +27,8 @@ float Math_SqrtF(float x);
float Math_Mod1(float x);
int Math_AbsI(int x);
-CC_API double Math_Sin(double x);
-CC_API double Math_Cos(double x);
-float Math_SinF(float x);
-float Math_CosF(float x);
+CC_API float Math_SinF(float x);
+CC_API float Math_CosF(float x);
/* Computes atan2(y, x), intended primarily for angle calculation*/
/* Note that accuracy is only up to around 4 decimal places */
float Math_Atan2f(float x, float y);
diff --git a/src/FancyLighting.c b/src/FancyLighting.c
index 0a9547b2d..d9429fc31 100644
--- a/src/FancyLighting.c
+++ b/src/FancyLighting.c
@@ -62,13 +62,13 @@ static void InitPalette(PackedCol* palette, float shaded, PackedCol ambientColor
else {
curLerp = lampLevel / (float)(FANCY_LIGHTING_LEVELS - 1);
curLerp *= (MATH_PI / 2);
- curLerp = Math_Cos(curLerp);
+ curLerp = Math_CosF(curLerp);
lampColor = PackedCol_Lerp(0, Env.LampLightCol, 1 - curLerp);
}
curLerp = lavaLevel / (float)(FANCY_LIGHTING_LEVELS - 1);
curLerp *= (MATH_PI / 2);
- curLerp = Math_Cos(curLerp);
+ curLerp = Math_CosF(curLerp);
lavaColor = PackedCol_Lerp(0, Env.LavaLightCol, 1 - curLerp);
diff --git a/src/Model.c b/src/Model.c
index 24040b3cb..d14888d11 100644
--- a/src/Model.c
+++ b/src/Model.c
@@ -139,8 +139,8 @@ void Model_SetupState(struct Model* model, struct Entity* e) {
Models.Cols[5] = Models.Cols[4];
yawDelta = e->Yaw - e->RotY;
- Models.cosHead = (float)Math_Cos(yawDelta * MATH_DEG2RAD);
- Models.sinHead = (float)Math_Sin(yawDelta * MATH_DEG2RAD);
+ Models.cosHead = Math_CosF(yawDelta * MATH_DEG2RAD);
+ Models.sinHead = Math_SinF(yawDelta * MATH_DEG2RAD);
Models.Active = model;
}
@@ -233,9 +233,9 @@ void Model_DrawRotate(float angleX, float angleY, float angleZ, struct ModelPart
struct ModelVertex* src = &model->vertices[part->offset];
struct VertexTextured* dst = &Models.Vertices[model->index];
- float cosX = (float)Math_Cos(-angleX), sinX = (float)Math_Sin(-angleX);
- float cosY = (float)Math_Cos(-angleY), sinY = (float)Math_Sin(-angleY);
- float cosZ = (float)Math_Cos(-angleZ), sinZ = (float)Math_Sin(-angleZ);
+ float cosX = Math_CosF(-angleX), sinX = Math_SinF(-angleX);
+ float cosY = Math_CosF(-angleY), sinY = Math_SinF(-angleY);
+ float cosZ = Math_CosF(-angleZ), sinZ = Math_SinF(-angleZ);
float t, x = part->rotX, y = part->rotY, z = part->rotZ;
struct ModelVertex v;
@@ -1938,9 +1938,9 @@ static void SpiderModel_Draw(struct Entity* e) {
Model_DrawPart(&spider_link);
Model_DrawPart(&spider_end);
- rotX = (float)Math_Sin(e->Anim.WalkTime) * e->Anim.Swing * MATH_PI;
- rotZ = (float)Math_Cos(e->Anim.WalkTime * 2) * e->Anim.Swing * MATH_PI / 16.0f;
- rotY = (float)Math_Sin(e->Anim.WalkTime * 2) * e->Anim.Swing * MATH_PI / 32.0f;
+ rotX = Math_SinF(e->Anim.WalkTime) * e->Anim.Swing * MATH_PI;
+ rotZ = Math_CosF(e->Anim.WalkTime * 2) * e->Anim.Swing * MATH_PI / 16.0f;
+ rotY = Math_SinF(e->Anim.WalkTime * 2) * e->Anim.Swing * MATH_PI / 32.0f;
Models.Rotation = ROTATE_ORDER_XZY;
Model_DrawRotate(rotX, quarterPi + rotY, eighthPi + rotZ, &spider_leftLeg, false);
@@ -2312,12 +2312,11 @@ static void DrawBlockTransform(struct Entity* e, float dispX, float dispY, float
}
static void HoldModel_Draw(struct Entity* e) {
- static float handBob;
- static float handIdle;
-
+ float handBob;
+ float handIdle;
RecalcProperties(e);
- handBob = (float)Math_Sin(e->Anim.WalkTime * 2.0f) * e->Anim.Swing * MATH_PI / 16.0f;
+ handBob = Math_SinF(e->Anim.WalkTime * 2.0f) * e->Anim.Swing * MATH_PI / 16.0f;
handIdle = e->Anim.RightArmX * (1.0f - e->Anim.Swing);
e->Anim.RightArmX = 0.5f + handBob + handIdle;
diff --git a/src/Vectors.c b/src/Vectors.c
index 7e3d1c292..7bee5f2c2 100644
--- a/src/Vectors.c
+++ b/src/Vectors.c
@@ -37,26 +37,26 @@ void Vec3_TransformY(Vec3* result, float y, const struct Matrix* mat) {
}
Vec3 Vec3_RotateX(Vec3 v, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
return Vec3_Create3(v.x, cosA * v.y + sinA * v.z, -sinA * v.y + cosA * v.z);
}
Vec3 Vec3_RotateY(Vec3 v, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
return Vec3_Create3(cosA * v.x - sinA * v.z, v.y, sinA * v.x + cosA * v.z);
}
Vec3 Vec3_RotateY3(float x, float y, float z, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
return Vec3_Create3(cosA * x - sinA * z, y, sinA * x + cosA * z);
}
Vec3 Vec3_RotateZ(Vec3 v, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
return Vec3_Create3(cosA * v.x + sinA * v.y, -sinA * v.x + cosA * v.y, v.z);
}
@@ -96,8 +96,8 @@ const struct Matrix Matrix_Identity = Matrix_IdentityValue;
/* Transposed, source https://open.gl/transformations */
void Matrix_RotateX(struct Matrix* result, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
*result = Matrix_Identity;
result->row2.y = cosA; result->row2.z = sinA;
@@ -105,8 +105,8 @@ void Matrix_RotateX(struct Matrix* result, float angle) {
}
void Matrix_RotateY(struct Matrix* result, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
*result = Matrix_Identity;
result->row1.x = cosA; result->row1.z = -sinA;
@@ -114,8 +114,8 @@ void Matrix_RotateY(struct Matrix* result, float angle) {
}
void Matrix_RotateZ(struct Matrix* result, float angle) {
- float cosA = (float)Math_Cos(angle);
- float sinA = (float)Math_Sin(angle);
+ float cosA = Math_CosF(angle);
+ float sinA = Math_SinF(angle);
*result = Matrix_Identity;
result->row1.x = cosA; result->row1.y = sinA;
diff --git a/src/Vorbis.c b/src/Vorbis.c
index b0a2e74d5..aa99becdf 100644
--- a/src/Vorbis.c
+++ b/src/Vorbis.c
@@ -1079,15 +1079,15 @@ void imdct_init(struct imdct_state* state, int n) {
/* setup twiddle factors */
for (k = 0, k2 = 0; k < n4; k++, k2 += 2)
{
- A[k2] = (float)Math_Cos((4*k * PI) / n);
- A[k2+1] = -(float)Math_Sin((4*k * PI) / n);
- B[k2] = (float)Math_Cos(((k2+1) * PI) / (2*n));
- B[k2+1] = (float)Math_Sin(((k2+1) * PI) / (2*n));
+ A[k2] = Math_CosF((4*k * PI) / n);
+ A[k2+1] = -Math_SinF((4*k * PI) / n);
+ B[k2] = Math_CosF(((k2+1) * PI) / (2*n));
+ B[k2+1] = Math_SinF(((k2+1) * PI) / (2*n));
}
for (k = 0, k2 = 0; k < n8; k++, k2 += 2)
{
- C[k2] = (float)Math_Cos(((k2+1) * (2*PI)) / n);
- C[k2+1] = -(float)Math_Sin(((k2+1) * (2*PI)) / n);
+ C[k2] = Math_CosF(((k2+1) * (2*PI)) / n);
+ C[k2+1] = -Math_SinF(((k2+1) * (2*PI)) / n);
}
for (k = 0; k < n8; k++)
@@ -1219,13 +1219,13 @@ static void Vorbis_CalcWindow(struct VorbisWindow* window, int blockSize) {
for (i = 0; i < n; i++)
{
- inner = Math_Sin((i + 0.5) / n * (PI/2));
- cur_window[i] = Math_Sin((PI/2) * inner * inner);
+ inner = Math_SinF((i + 0.5f) / n * (PI/2));
+ cur_window[i] = Math_SinF((PI/2) * inner * inner);
}
for (i = 0; i < n; i++)
{
- inner = Math_Sin((i + 0.5) / n * (PI/2) + (PI/2));
- prev_window[i] = Math_Sin((PI/2) * inner * inner);
+ inner = Math_SinF((i + 0.5f) / n * (PI/2) + (PI/2));
+ prev_window[i] = Math_SinF((PI/2) * inner * inner);
}
}
diff --git a/src/Widgets.c b/src/Widgets.c
index 123cb3af9..e386c378f 100644
--- a/src/Widgets.c
+++ b/src/Widgets.c
@@ -2760,7 +2760,7 @@ static void ThumbstickWidget_BuildMesh(void* widget, struct VertexTextured** ver
static int ThumbstickWidget_CalcDirs(struct ThumbstickWidget* w) {
int i, dx, dy, dirs = 0;
- double angle;
+ float angle;
for (i = 0; i < INPUT_MAX_POINTERS; i++) {
if (!(w->active & (1 << i))) continue;