# HG changeset patch # User Ritor1 # Date 1378464152 -21600 # Node ID dec48a15139022e12b0d74b1f624e304f3ec7f5b # Parent 61458df2cb4f6015be5de6c59eb39927dc772e93# Parent 270627b54ed42c852928838a321290f3f44da11f Слияние diff -r 61458df2cb4f -r dec48a151390 Math.h --- a/Math.h Fri Sep 06 16:42:23 2013 +0600 +++ b/Math.h Fri Sep 06 16:42:32 2013 +0600 @@ -1,11 +1,7 @@ #pragma once + #include #include -#include -#include -#include -#include - /* 186 */ #pragma pack(push, 1) @@ -28,26 +24,20 @@ }; #pragma pack(pop) - int fixpoint_sub0(int, int); int fixpoint_div(int, int); int fixpoint_mul(int, int); int fixpoint_from_float(float value); -#ifndef ROUNDING_EPSILON -#define ROUNDING_EPSILON 0.0000001 -#endif - - template -int bankersRounding( +inline int bankersRounding( const FloatType& value ) { assert("Method unsupported for this type" && false); return value; } -template<> static int bankersRounding(const float& inValue) +template<> inline int bankersRounding(const float& inValue) { union Cast { @@ -61,8 +51,7 @@ #pragma push_macro("max") #undef max - -template<> static int bankersRounding(const double& inValue) +template<> inline int bankersRounding(const double& inValue) { double maxValue = std::numeric_limits::max(); assert(maxValue - 6755399441055744.0 >= inValue); @@ -75,8 +64,6 @@ c.d = inValue + 6755399441055744.0; return c.l; } - - #pragma pop_macro("max") -extern struct stru193_math *stru_5C6E00; \ No newline at end of file +extern struct stru193_math *stru_5C6E00; diff -r 61458df2cb4f -r dec48a151390 VectorTypes.cpp --- a/VectorTypes.cpp Fri Sep 06 16:42:23 2013 +0600 +++ b/VectorTypes.cpp Fri Sep 06 16:42:32 2013 +0600 @@ -1,6 +1,7 @@ #include #include "mm7_data.h" +#include "Math.h" //----- (004621DA) -------------------------------------------------------- uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z) @@ -25,14 +26,14 @@ template void Vec3::Normalize_float() { - long double x = this->x; - long double y = this->y; - long double z = this->z; - long double s = sqrtl(x * x + y * y + z * z); + double x = this->x; + double y = this->y; + double z = this->z; + double s = sqrt(x * x + y * y + z * z); - this->x = (T)(x / s); - this->y = (T)(y / s); - this->z = (T)(z / s); + this->x = bankersRounding(x / s); + this->y = bankersRounding(y / s); + this->z = bankersRounding(z / s); } //----- (0043AA99) --------------------------------------------------------