diff VectorTypes.cpp @ 1528:270627b54ed4

Fix Vec3<T>::Normalize_float().
author yoctozepto
date Fri, 06 Sep 2013 09:29:17 +0200
parents 4055b09160ae
children 7a9477135943
line wrap: on
line diff
--- a/VectorTypes.cpp	Fri Sep 06 09:29:12 2013 +0200
+++ b/VectorTypes.cpp	Fri Sep 06 09:29:17 2013 +0200
@@ -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) --------------------------------------------------------