changeset 1530:dec48a151390

Слияние
author Ritor1
date Fri, 06 Sep 2013 16:42:32 +0600
parents 61458df2cb4f (current diff) 270627b54ed4 (diff)
children 2ae4c5a5b4e5
files
diffstat 2 files changed, 13 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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 <cassert>
 #include <limits>
-#include <float.h>
-#include <cmath>
-#include <cstdlib>
-#include <ciso646>
-
 
 /*  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 <typename FloatType>
-int bankersRounding(
+inline int bankersRounding(
   const FloatType& value
   ) {
     assert("Method unsupported for this type" && false);
     return value;
 }
 
-template<> static int bankersRounding<float>(const float& inValue)
+template<> inline int bankersRounding<float>(const float& inValue)
 {
   union Cast
   {
@@ -61,8 +51,7 @@
 
 #pragma push_macro("max")
 #undef max
-
-template<> static int bankersRounding<double>(const double& inValue)
+template<> inline int bankersRounding<double>(const double& inValue)
 {
   double maxValue = std::numeric_limits<int>::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;
--- 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 <utility>
 
 #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 <class T>
 void Vec3<T>::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) --------------------------------------------------------