diff options
Diffstat (limited to 'Client/Source')
-rw-r--r-- | Client/Source/Phy2DLite/Constants.h | 1 | ||||
-rw-r--r-- | Client/Source/Phy2DLite/Joint.h | 5 | ||||
-rw-r--r-- | Client/Source/Phy2DLite/Math.h | 11 | ||||
-rw-r--r-- | Client/Source/float2fixed/main.cpp | 2 |
4 files changed, 11 insertions, 8 deletions
diff --git a/Client/Source/Phy2DLite/Constants.h b/Client/Source/Phy2DLite/Constants.h index aa50e8c..fcd889a 100644 --- a/Client/Source/Phy2DLite/Constants.h +++ b/Client/Source/Phy2DLite/Constants.h @@ -8,6 +8,7 @@ namespace Phy2D #define CONSTANT(name, value) static number name = number::from_raw_value(value) CONSTANT(_1, 65536);
+ CONSTANT(_n1, -65536);
CONSTANT(_0, 0);
CONSTANT(_0_01, 655);
CONSTANT(_0_2, 13107);
diff --git a/Client/Source/Phy2DLite/Joint.h b/Client/Source/Phy2DLite/Joint.h index 2efe876..f88e287 100644 --- a/Client/Source/Phy2DLite/Joint.h +++ b/Client/Source/Phy2DLite/Joint.h @@ -1,6 +1,7 @@ #pragma once
#include "Math.h"
+#include "Constants.h"
namespace Phy2D { @@ -11,8 +12,8 @@ namespace Phy2D { Joint() : body1(0), body2(0), - P(0.0f, 0.0f), - biasFactor(0.2f), softness(0.0f) + P(_0, _0), + biasFactor(_0_2), softness(_0) {} void Set(Body* body1, Body* body2, const Vec2& anchor); diff --git a/Client/Source/Phy2DLite/Math.h b/Client/Source/Phy2DLite/Math.h index 9c0ff8f..7e10b73 100644 --- a/Client/Source/Phy2DLite/Math.h +++ b/Client/Source/Phy2DLite/Math.h @@ -6,6 +6,7 @@ #include <string> #include "Settings.h" +#include "Constants.h" namespace Phy2D { @@ -69,8 +70,8 @@ namespace Phy2D number a = col1.x, b = col2.x, c = col1.y, d = col2.y; Mat22 B; number det = a * d - b * c; - assert(det != 0.0f); - det = (number)1.0f / det; + assert(det != _0); + det = (number)_1 / det; B.col1.x = det * d; B.col2.x = -det * b; B.col1.y = -det * c; B.col2.y = det * a; return B; @@ -131,7 +132,7 @@ namespace Phy2D inline number Abs(number a) { - return a > 0.0f ? a : -a; + return a > _0 ? a : -a; } inline Vec2 Abs(const Vec2& a) @@ -146,7 +147,7 @@ namespace Phy2D inline number Sign(number x) { - return (float) x < 0.0f ? -1.0f : 1.0f; + return x < _0 ? -_1 : _1; } inline number Min(number a, number b) @@ -176,7 +177,7 @@ namespace Phy2D //{ // number r = (number)rand(); // r /= RAND_MAX; - // r = (number)2.0f * r - 1.0f; + // r = (number)2.0f * r - _1; // return r; //} diff --git a/Client/Source/float2fixed/main.cpp b/Client/Source/float2fixed/main.cpp index 5c4fa40..cc92bd1 100644 --- a/Client/Source/float2fixed/main.cpp +++ b/Client/Source/float2fixed/main.cpp @@ -8,7 +8,7 @@ typedef fpm::fixed_16_16 fixed16; int main()
{
- fixed16 n = 0.95f;
+ fixed16 n = -1.0f;
cout << n.raw_value();
getchar();
|