diff --git a/src/Client/Client.vcxproj b/src/Client/Client.vcxproj
index f455afd0f..8447aa07d 100644
--- a/src/Client/Client.vcxproj
+++ b/src/Client/Client.vcxproj
@@ -148,7 +148,7 @@
5.02
Default
main
- d3d9.lib;opengl32.lib;ucrtd.lib;vcruntimed.lib;dbghelp.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies)
+ d3d9.lib;opengl32.lib;libucrt.lib;libvcruntime.lib;dbghelp.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies)
@@ -175,7 +175,7 @@
true
true
main
- d3d9.lib;opengl32.lib;ucrtd.lib;vcruntimed.lib;dbghelp.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies)
+ d3d9.lib;opengl32.lib;libucrt.lib;libvcruntime.lib;dbghelp.lib;ws2_32.lib;Wininet.lib;%(AdditionalDependencies)
diff --git a/src/Client/Deflate.c b/src/Client/Deflate.c
index 209ad24bd..b19d93b79 100644
--- a/src/Client/Deflate.c
+++ b/src/Client/Deflate.c
@@ -205,15 +205,15 @@ static void Huffman_Build(HuffmanTable* table, UInt8* bitLens, Int32 count) {
UInt16 bl_offsets[INFLATE_MAX_BITS];
for (i = 1; i < INFLATE_MAX_BITS; i++) {
code = (code + bl_count[i - 1]) << 1;
- bl_offsets[i] = (UInt16)offset;
- table->FirstCodewords[i] = (UInt16)code;
- table->FirstOffsets[i] = (UInt16)offset;
-
+ bl_offsets[i] = offset;
+ table->FirstCodewords[i] = code;
+ table->FirstOffsets[i] = offset;
offset += bl_count[i];
+
/* Last codeword is actually: code + (bl_count[i] - 1) */
/* When decoding we peform < against this value though, so we need to add 1 here */
if (bl_count[i]) {
- table->EndCodewords[i] = (UInt16)(code + bl_count[i]);
+ table->EndCodewords[i] = code + bl_count[i];
} else {
table->EndCodewords[i] = 0;
}
@@ -224,7 +224,7 @@ static void Huffman_Build(HuffmanTable* table, UInt8* bitLens, Int32 count) {
for (i = 0; i < count; i++, value++) {
Int32 len = bitLens[i];
if (len == 0) continue;
- table->Values[bl_offsets[len]] = (UInt16)value;
+ table->Values[bl_offsets[len]] = value;
/* Computes the accelerated lookup table values for this codeword
* For example, assume len = 4 and codeword = 0100
diff --git a/src/Client/ExtMath.c b/src/Client/ExtMath.c
index 8d3fc6aef..9de6449bd 100644
--- a/src/Client/ExtMath.c
+++ b/src/Client/ExtMath.c
@@ -3,19 +3,20 @@
/* TODO: Replace with own functions that don't rely on stdlib */
-Real32 Math_AbsF(Real32 x) { return fabsf(x); }
-Real32 Math_SinF(Real32 x) { return sinf(x); }
-Real32 Math_CosF(Real32 x) { return cosf(x); }
-Real32 Math_TanF(Real32 x) { return tanf(x); }
-Real32 Math_SqrtF(Real32 x) { return sqrtf(x); }
-Real32 Math_Mod1(Real32 x) { return x - (Int32)x; /* fmodf(x, 1); */ }
+Real32 Math_AbsF(Real32 x) { return fabsf(x); /* MSVC intrinsic */ }
+Real32 Math_SqrtF(Real32 x) { return sqrtf(x); /* MSVC intrinsic */ }
+Real32 Math_Mod1(Real32 x) { return x - (Int32)x; /* fmodf(x, 1); */ }
+Int32 Math_AbsI(Int32 x) { return abs(x); /* MSVC intrinsic */ }
+Real64 Math_Sin(Real64 x) { return sin(x); }
+Real64 Math_Cos(Real64 x) { return cos(x); }
Real64 Math_Log(Real64 x) { return log(x); }
Real64 Math_Exp(Real64 x) { return exp(x); }
-Real64 Math_Asin(Real64 x) { return asin(x); }
-Real64 Math_Atan2(Real64 y, Real64 x) { return atan2(y, x); }
-Int32 Math_AbsI(Int32 x) { return abs(x); }
+Real32 Math_SinF(Real32 x) { return (Real32)Math_Sin(x); }
+Real32 Math_CosF(Real32 x) { return (Real32)Math_Cos(x); }
+Real32 Math_TanF(Real32 x) { return tanf(x); }
+
Int32 Math_Floor(Real32 value) {
Int32 valueI = (Int32)value;
return valueI > value ? valueI - 1 : valueI;
@@ -76,4 +77,32 @@ Int32 Math_AccumulateWheelDelta(Real32* accmulator, Real32 delta) {
Int32 steps = (Int32)*accmulator;
*accmulator -= steps;
return steps;
+}
+
+/* Not the most precise Tan(x), but within 10^-15 of answer, so good enough for here */
+Real64 Math_FastTan(Real64 angle) {
+ Real64 cosA = Math_Cos(angle), sinA = Math_Sin(angle);
+ if (cosA < -0.00000001 || cosA > 0.00000001) return sinA / cosA;
+
+ /* tan line is parallel to y axis, infinite gradient */
+ Int32 sign = Math_Sign(sinA);
+ if (cosA != 0.0) sign *= Math_Sign(cosA);
+ return sign * MATH_POS_INF;
+}
+
+Real64 Math_FastLog(Real64 x) {
+ /* x = 2^exp * mantissa */
+ /* so log(x) = log(2^exp) + log(mantissa) */
+ /* so log(x) = exp*log(2) + log(mantissa) */
+
+ /* now need to work out log(mantissa) */
+}
+
+Real64 Math_FastExp(Real64 x) {
+ /* let x = k*log(2) + f, where k is integer */
+ /* so exp(x) = exp(k*log(2)) * exp(f) */
+ /* so exp(x) = exp(log(2^k)) * exp(f) */
+ /* so exp(x) = 2^k * exp(f) */
+
+ /* now need to work out exp(f) */
}
\ No newline at end of file
diff --git a/src/Client/ExtMath.h b/src/Client/ExtMath.h
index 681e9020f..4d99b1e53 100644
--- a/src/Client/ExtMath.h
+++ b/src/Client/ExtMath.h
@@ -15,18 +15,19 @@
#define Math_Packed2Deg(x) ((x) * 360.0f / 256.0f)
Real32 Math_AbsF(Real32 x);
-Real32 Math_SinF(Real32 x);
-Real32 Math_CosF(Real32 x);
-Real32 Math_TanF(Real32 x);
Real32 Math_SqrtF(Real32 x);
Real32 Math_Mod1(Real32 x);
+Int32 Math_AbsI(Int32 x);
+
+Real64 Math_Sin(Real64 x);
+Real64 Math_Cos(Real64 x);
+Real32 Math_SinF(Real32 x);
+Real32 Math_CosF(Real32 x);
Real64 Math_Log(Real64 x);
Real64 Math_Exp(Real64 x);
-Real64 Math_Asin(Real64 x);
-Real64 Math_Atan2(Real64 y, Real64 x);
+Real64 Math_FastTan(Real64 x);
-Int32 Math_AbsI(Int32 x);
Int32 Math_Floor(Real32 value);
Int32 Math_Ceil(Real32 value);
Int32 Math_Log2(Int32 value);
diff --git a/src/Client/HeldBlockRenderer.c b/src/Client/HeldBlockRenderer.c
index 7b5351c3a..15a4c3cc1 100644
--- a/src/Client/HeldBlockRenderer.c
+++ b/src/Client/HeldBlockRenderer.c
@@ -108,12 +108,12 @@ static void HeldBlockRenderer_DigAnimation(void) {
held_entity.Position.X -= Math_SinF(sqrtLerpPI) * 0.4f;
held_entity.Position.Y += Math_SinF((sqrtLerpPI * 2)) * 0.2f;
- held_entity.Position.Z -= sinHalfCircle * 0.2f;
+ held_entity.Position.Z -= sinHalfCircle * 0.2f;
Real32 sinHalfCircleWeird = Math_SinF(t * t * MATH_PI);
- held_entity.RotY -= Math_SinF(sqrtLerpPI) * 80.0f;
+ held_entity.RotY -= Math_SinF(sqrtLerpPI) * 80.0f;
held_entity.HeadY -= Math_SinF(sqrtLerpPI) * 80.0f;
- held_entity.RotX += sinHalfCircleWeird * 20.0f;
+ held_entity.RotX += sinHalfCircleWeird * 20.0f;
}
static void HeldBlockRenderer_ResetAnim(bool setLastHeld, Real64 period) {
diff --git a/src/Client/Vectors.c b/src/Client/Vectors.c
index 33303cf5c..ede4436ea 100644
--- a/src/Client/Vectors.c
+++ b/src/Client/Vectors.c
@@ -152,10 +152,10 @@ Vector3 Vector3_GetDirVector(Real32 yawRad, Real32 pitchRad) {
return Vector3_Create3(x, y, z);
}
-void Vector3_GetHeading(Vector3 dir, Real32* yaw, Real32* pitch) {
+/*void Vector3_GetHeading(Vector3 dir, Real32* yaw, Real32* pitch) {
*pitch = (Real32)Math_Asin(-dir.Y);
*yaw = (Real32)Math_Atan2(dir.X, -dir.Z);
-}
+}*/
Matrix Matrix_Identity = {
@@ -250,7 +250,7 @@ void Matrix_OrthographicOffCenter(Matrix* result, Real32 left, Real32 right, Rea
}
void Matrix_PerspectiveFieldOfView(Matrix* result, Real32 fovy, Real32 aspect, Real32 zNear, Real32 zFar) {
- Real32 c = zNear * Math_TanF(0.5f * fovy);
+ Real32 c = zNear * (Real32)Math_FastTan(0.5f * fovy);
Matrix_PerspectiveOffCenter(result, -c * aspect, c * aspect, -c, c, zNear, zFar);
}
diff --git a/src/Client/Vectors.h b/src/Client/Vectors.h
index 6e692bd97..24efe960d 100644
--- a/src/Client/Vectors.h
+++ b/src/Client/Vectors.h
@@ -68,7 +68,7 @@ void Vector3I_Max(Vector3I* result, Vector3I* a, Vector3I* b);
Vector3 Vector3_GetDirVector(Real32 yawRad, Real32 pitchRad);
/* Returns the yaw and pitch of the given direction vector.
NOTE: This is not an identity function. Returned pitch is always within [-90, 90] degrees.*/
-void Vector3_GetHeading(Vector3 dir, Real32* yawRad, Real32* pitchRad);
+/*void Vector3_GetHeading(Vector3 dir, Real32* yawRad, Real32* pitchRad);*/
void Matrix_RotateX(Matrix* result, Real32 angle);
void Matrix_RotateY(Matrix* result, Real32 angle);