aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Client/Source/Phy2DLite/Arbiter.cpp38
-rw-r--r--Client/Source/Phy2DLite/Arbiter.h16
-rw-r--r--Client/Source/Phy2DLite/Body.cpp6
-rw-r--r--Client/Source/Phy2DLite/Body.h14
-rw-r--r--Client/Source/Phy2DLite/Collide.cpp26
-rw-r--r--Client/Source/Phy2DLite/Constants.h2
-rw-r--r--Client/Source/Phy2DLite/Joint.cpp2
-rw-r--r--Client/Source/Phy2DLite/Joint.h6
-rw-r--r--Client/Source/Phy2DLite/Math.h52
-rw-r--r--Client/Source/Phy2DLite/Settings.h12
-rw-r--r--Client/Source/Phy2DLite/Tests/test.cpp23
-rw-r--r--Client/Source/Phy2DLite/World.cpp4
-rw-r--r--Client/Source/Phy2DLite/World.h2
13 files changed, 101 insertions, 102 deletions
diff --git a/Client/Source/Phy2DLite/Arbiter.cpp b/Client/Source/Phy2DLite/Arbiter.cpp
index 567e6f7..d29bace 100644
--- a/Client/Source/Phy2DLite/Arbiter.cpp
+++ b/Client/Source/Phy2DLite/Arbiter.cpp
@@ -73,10 +73,10 @@ void Arbiter::Update(Contact* newContacts, int numNewContacts)
}
-void Arbiter::PreStep(number inv_dt)
+void Arbiter::PreStep(fixed inv_dt)
{
- const number k_allowedPenetration = _0_01;
- number k_biasFactor = World::positionCorrection ? _0_2 : _0;
+ const fixed k_allowedPenetration = _0_01;
+ fixed k_biasFactor = World::positionCorrection ? _0_2 : _0;
for (int i = 0; i < numContacts; ++i)
{
@@ -86,18 +86,18 @@ void Arbiter::PreStep(number inv_dt)
Vec2 r2 = c->position - body2->position;
// Precompute normal mass, tangent mass, and bias.
- number rn1 = Dot(r1, c->normal);
- number rn2 = Dot(r2, c->normal);
- number kNormal = body1->invMass + body2->invMass;
+ fixed rn1 = Dot(r1, c->normal);
+ fixed rn2 = Dot(r2, c->normal);
+ fixed kNormal = body1->invMass + body2->invMass;
kNormal += body1->invI * (Dot(r1, r1) - rn1 * rn1) + body2->invI * (Dot(r2, r2) - rn2 * rn2);
- c->massNormal = (number)_1 / kNormal;
+ c->massNormal = (fixed)_1 / kNormal;
Vec2 tangent = Cross(c->normal, _1);
- number rt1 = Dot(r1, tangent);
- number rt2 = Dot(r2, tangent);
- number kTangent = body1->invMass + body2->invMass;
+ fixed rt1 = Dot(r1, tangent);
+ fixed rt2 = Dot(r2, tangent);
+ fixed kTangent = body1->invMass + body2->invMass;
kTangent += body1->invI * (Dot(r1, r1) - rt1 * rt1) + body2->invI * (Dot(r2, r2) - rt2 * rt2);
- c->massTangent = (number)_1 / kTangent;
+ c->massTangent = (fixed)_1 / kTangent;
c->bias = -k_biasFactor * inv_dt * Min(_0, c->separation + k_allowedPenetration);
@@ -130,14 +130,14 @@ void Arbiter::ApplyImpulse()
Vec2 dv = b2->velocity + Cross(b2->angularVelocity, c->r2) - b1->velocity - Cross(b1->angularVelocity, c->r1);
// Compute normal impulse
- number vn = Dot(dv, c->normal);
+ fixed vn = Dot(dv, c->normal);
- number dPn = c->massNormal * (-vn + c->bias);
+ fixed dPn = c->massNormal * (-vn + c->bias);
if (World::accumulateImpulses)
{
// Clamp the accumulated impulse
- number Pn0 = c->Pn;
+ fixed Pn0 = c->Pn;
c->Pn = Max(Pn0 + dPn, _0);
dPn = c->Pn - Pn0;
}
@@ -159,22 +159,22 @@ void Arbiter::ApplyImpulse()
dv = b2->velocity + Cross(b2->angularVelocity, c->r2) - b1->velocity - Cross(b1->angularVelocity, c->r1);
Vec2 tangent = Cross(c->normal, _1);
- number vt = Dot(dv, tangent);
- number dPt = c->massTangent * (-vt);
+ fixed vt = Dot(dv, tangent);
+ fixed dPt = c->massTangent * (-vt);
if (World::accumulateImpulses)
{
// Compute friction impulse
- number maxPt = friction * c->Pn;
+ fixed maxPt = friction * c->Pn;
// Clamp friction
- number oldTangentImpulse = c->Pt;
+ fixed oldTangentImpulse = c->Pt;
c->Pt = Clamp(oldTangentImpulse + dPt, -maxPt, maxPt);
dPt = c->Pt - oldTangentImpulse;
}
else
{
- number maxPt = friction * dPn;
+ fixed maxPt = friction * dPn;
dPt = Clamp(dPt, -maxPt, maxPt);
}
diff --git a/Client/Source/Phy2DLite/Arbiter.h b/Client/Source/Phy2DLite/Arbiter.h
index 167978f..1934c65 100644
--- a/Client/Source/Phy2DLite/Arbiter.h
+++ b/Client/Source/Phy2DLite/Arbiter.h
@@ -27,12 +27,12 @@ namespace Phy2D
Vec2 position;
Vec2 normal;
Vec2 r1, r2;
- number separation;
- number Pn; // accumulated normal impulse
- number Pt; // accumulated tangent impulse
- number Pnb; // accumulated normal impulse for position bias
- number massNormal, massTangent;
- number bias;
+ fixed separation;
+ fixed Pn; // accumulated normal impulse
+ fixed Pt; // accumulated tangent impulse
+ fixed Pnb; // accumulated normal impulse for position bias
+ fixed massNormal, massTangent;
+ fixed bias;
FeaturePair feature;
};
@@ -62,7 +62,7 @@ namespace Phy2D
void Update(Contact* contacts, int numContacts);
- void PreStep(number inv_dt);
+ void PreStep(fixed inv_dt);
void ApplyImpulse();
Contact contacts[MAX_POINTS];
@@ -72,7 +72,7 @@ namespace Phy2D
Body* body2;
// Combined friction
- number friction;
+ fixed friction;
};
// This is used by std::set
diff --git a/Client/Source/Phy2DLite/Body.cpp b/Client/Source/Phy2DLite/Body.cpp
index 993c3f8..7b1c3e3 100644
--- a/Client/Source/Phy2DLite/Body.cpp
+++ b/Client/Source/Phy2DLite/Body.cpp
@@ -20,7 +20,7 @@ Body::Body()
invI = _0;
}
-void Body::Set(const Vec2& w, number m)
+void Body::Set(const Vec2& w, fixed m)
{
position.Set(_0, _0);
rotation = _0;
@@ -35,9 +35,9 @@ void Body::Set(const Vec2& w, number m)
if (mass < NUMBER_MAX)
{
- invMass = (number)_1 / mass;
+ invMass = (fixed)_1 / mass;
I = mass * (width.x * width.x + width.y * width.y) / _12;
- invI = (number)_1 / I;
+ invI = (fixed)_1 / I;
}
else
{
diff --git a/Client/Source/Phy2DLite/Body.h b/Client/Source/Phy2DLite/Body.h
index 050c719..c3d746a 100644
--- a/Client/Source/Phy2DLite/Body.h
+++ b/Client/Source/Phy2DLite/Body.h
@@ -8,7 +8,7 @@ namespace Phy2D
struct Body
{
Body();
- void Set(const Vec2& w, number m);
+ void Set(const Vec2& w, fixed m);
void AddForce(const Vec2& f)
{
@@ -16,19 +16,19 @@ namespace Phy2D
}
Vec2 position;
- number rotation;
+ fixed rotation;
Vec2 velocity;
- number angularVelocity;
+ fixed angularVelocity;
Vec2 force;
- number torque;
+ fixed torque;
Vec2 width;
- number friction;
- number mass, invMass;
- number I, invI;
+ fixed friction;
+ fixed mass, invMass;
+ fixed I, invI;
};
} \ No newline at end of file
diff --git a/Client/Source/Phy2DLite/Collide.cpp b/Client/Source/Phy2DLite/Collide.cpp
index 116a72e..271dc7a 100644
--- a/Client/Source/Phy2DLite/Collide.cpp
+++ b/Client/Source/Phy2DLite/Collide.cpp
@@ -49,14 +49,14 @@ void Flip(FeaturePair& fp)
}
int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2],
- const Vec2& normal, number offset, char clipEdge)
+ const Vec2& normal, fixed offset, char clipEdge)
{
// Start with no output points
int numOut = 0;
// Calculate the distance of end points to the line
- number distance0 = Dot(normal, vIn[0].v) - offset;
- number distance1 = Dot(normal, vIn[1].v) - offset;
+ fixed distance0 = Dot(normal, vIn[0].v) - offset;
+ fixed distance1 = Dot(normal, vIn[1].v) - offset;
// If the points are behind the plane
if (distance0 <= _0) vOut[numOut++] = vIn[0];
@@ -66,7 +66,7 @@ int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2],
if (distance0 * distance1 < _0)
{
// Find intersection point of edge and plane
- number interp = distance0 / (distance0 - distance1);
+ fixed interp = distance0 / (distance0 - distance1);
vOut[numOut].v = vIn[0].v + interp * (vIn[1].v - vIn[0].v);
if (distance0 > _0)
{
@@ -184,7 +184,7 @@ namespace Phy2D
// Find best axis
Axis axis;
- number separation;
+ fixed separation;
Vec2 normal;
// Box A faces
@@ -192,8 +192,8 @@ namespace Phy2D
separation = faceA.x;
normal = dA.x > _0 ? RotA.col1 : -RotA.col1;
- const number relativeTol = _0_95;
- const number absoluteTol = _0_01;
+ const fixed relativeTol = _0_95;
+ const fixed absoluteTol = _0_01;
if (faceA.y > relativeTol * separation + absoluteTol * hA.y)
{
@@ -220,7 +220,7 @@ namespace Phy2D
// Setup clipping plane data based on the separating axis
Vec2 frontNormal, sideNormal;
ClipVertex incidentEdge[2];
- number front, negSide, posSide;
+ fixed front, negSide, posSide;
char negEdge, posEdge;
// Compute the clipping lines and the line segment to be clipped.
@@ -231,7 +231,7 @@ namespace Phy2D
frontNormal = normal;
front = Dot(posA, frontNormal) + hA.x;
sideNormal = RotA.col2;
- number side = Dot(posA, sideNormal);
+ fixed side = Dot(posA, sideNormal);
negSide = -side + hA.y;
posSide = side + hA.y;
negEdge = EDGE3;
@@ -245,7 +245,7 @@ namespace Phy2D
frontNormal = normal;
front = Dot(posA, frontNormal) + hA.y;
sideNormal = RotA.col1;
- number side = Dot(posA, sideNormal);
+ fixed side = Dot(posA, sideNormal);
negSide = -side + hA.x;
posSide = side + hA.x;
negEdge = EDGE2;
@@ -259,7 +259,7 @@ namespace Phy2D
frontNormal = -normal;
front = Dot(posB, frontNormal) + hB.x;
sideNormal = RotB.col2;
- number side = Dot(posB, sideNormal);
+ fixed side = Dot(posB, sideNormal);
negSide = -side + hB.y;
posSide = side + hB.y;
negEdge = EDGE3;
@@ -273,7 +273,7 @@ namespace Phy2D
frontNormal = -normal;
front = Dot(posB, frontNormal) + hB.y;
sideNormal = RotB.col1;
- number side = Dot(posB, sideNormal);
+ fixed side = Dot(posB, sideNormal);
negSide = -side + hB.x;
posSide = side + hB.x;
negEdge = EDGE2;
@@ -307,7 +307,7 @@ namespace Phy2D
int numContacts = 0;
for (int i = 0; i < 2; ++i)
{
- number separation = Dot(frontNormal, clipPoints2[i].v) - front;
+ fixed separation = Dot(frontNormal, clipPoints2[i].v) - front;
if (separation <= 0)
{
diff --git a/Client/Source/Phy2DLite/Constants.h b/Client/Source/Phy2DLite/Constants.h
index fcd889a..f116ca8 100644
--- a/Client/Source/Phy2DLite/Constants.h
+++ b/Client/Source/Phy2DLite/Constants.h
@@ -5,7 +5,7 @@
namespace Phy2D
{
#if NUMBER_ALIAS == NUMBER_FPM
-#define CONSTANT(name, value) static number name = number::from_raw_value(value)
+#define CONSTANT(name, value) static fixed name = fixed::from_raw_value(value)
CONSTANT(_1, 65536);
CONSTANT(_n1, -65536);
diff --git a/Client/Source/Phy2DLite/Joint.cpp b/Client/Source/Phy2DLite/Joint.cpp
index 71375d0..b7fb560 100644
--- a/Client/Source/Phy2DLite/Joint.cpp
+++ b/Client/Source/Phy2DLite/Joint.cpp
@@ -24,7 +24,7 @@ void Joint::Set(Body* b1, Body* b2, const Vec2& anchor)
biasFactor = _0_2;
}
-void Joint::PreStep(number inv_dt)
+void Joint::PreStep(fixed inv_dt)
{
// Pre-compute anchors, mass matrix, and bias.
Mat22 Rot1(body1->rotation);
diff --git a/Client/Source/Phy2DLite/Joint.h b/Client/Source/Phy2DLite/Joint.h
index f88e287..c65bf0b 100644
--- a/Client/Source/Phy2DLite/Joint.h
+++ b/Client/Source/Phy2DLite/Joint.h
@@ -18,7 +18,7 @@ namespace Phy2D
void Set(Body* body1, Body* body2, const Vec2& anchor);
- void PreStep(number inv_dt);
+ void PreStep(fixed inv_dt);
void ApplyImpulse();
Mat22 M;
@@ -28,8 +28,8 @@ namespace Phy2D
Vec2 P; // accumulated impulse
Body* body1;
Body* body2;
- number biasFactor;
- number softness;
+ fixed biasFactor;
+ fixed softness;
};
}
diff --git a/Client/Source/Phy2DLite/Math.h b/Client/Source/Phy2DLite/Math.h
index 7e10b73..987b55a 100644
--- a/Client/Source/Phy2DLite/Math.h
+++ b/Client/Source/Phy2DLite/Math.h
@@ -14,9 +14,9 @@ namespace Phy2D
struct Vec2
{
Vec2() {}
- Vec2(number x, number y) : x(x), y(y) {}
+ Vec2(fixed x, fixed y) : x(x), y(y) {}
- void Set(number x_, number y_) { x = x_; y = y_; }
+ void Set(fixed x_, fixed y_) { x = x_; y = y_; }
Vec2 operator -() { return Vec2(-x, -y); }
@@ -30,12 +30,12 @@ namespace Phy2D
x -= v.x; y -= v.y;
}
- void operator *= (number a)
+ void operator *= (fixed a)
{
x *= a; y *= a;
}
- number Length() const
+ fixed Length() const
{
return SQRT(x * x + y * y);
}
@@ -45,15 +45,15 @@ namespace Phy2D
return std::to_string((float)x) + "," + std::to_string((float)y);
}
- number x, y;
+ fixed x, y;
};
struct Mat22
{
Mat22() {}
- Mat22(number angle)
+ Mat22(fixed angle)
{
- number c = COS(angle), s = SIN(angle);
+ fixed c = COS(angle), s = SIN(angle);
col1.x = c; col2.x = -s;
col1.y = s; col2.y = c;
}
@@ -67,11 +67,11 @@ namespace Phy2D
Mat22 Invert() const
{
- number a = col1.x, b = col2.x, c = col1.y, d = col2.y;
+ fixed a = col1.x, b = col2.x, c = col1.y, d = col2.y;
Mat22 B;
- number det = a * d - b * c;
+ fixed det = a * d - b * c;
assert(det != _0);
- det = (number)_1 / det;
+ det = (fixed)_1 / det;
B.col1.x = det * d; B.col2.x = -det * b;
B.col1.y = -det * c; B.col2.y = det * a;
return B;
@@ -80,22 +80,22 @@ namespace Phy2D
Vec2 col1, col2;
};
- inline number Dot(const Vec2& a, const Vec2& b)
+ inline fixed Dot(const Vec2& a, const Vec2& b)
{
return a.x * b.x + a.y * b.y;
}
- inline number Cross(const Vec2& a, const Vec2& b)
+ inline fixed Cross(const Vec2& a, const Vec2& b)
{
return a.x * b.y - a.y * b.x;
}
- inline Vec2 Cross(const Vec2& a, number s)
+ inline Vec2 Cross(const Vec2& a, fixed s)
{
return Vec2(s * a.y, -s * a.x);
}
- inline Vec2 Cross(number s, const Vec2& a)
+ inline Vec2 Cross(fixed s, const Vec2& a)
{
return Vec2(-s * a.y, s * a.x);
}
@@ -115,7 +115,7 @@ namespace Phy2D
return Vec2(a.x - b.x, a.y - b.y);
}
- inline Vec2 operator * (number s, const Vec2& v)
+ inline Vec2 operator * (fixed s, const Vec2& v)
{
return Vec2(s * v.x, s * v.y);
}
@@ -130,7 +130,7 @@ namespace Phy2D
return Mat22(A * B.col1, A * B.col2);
}
- inline number Abs(number a)
+ inline fixed Abs(fixed a)
{
return a > _0 ? a : -a;
}
@@ -145,22 +145,22 @@ namespace Phy2D
return Mat22(Abs(A.col1), Abs(A.col2));
}
- inline number Sign(number x)
+ inline fixed Sign(fixed x)
{
return x < _0 ? -_1 : _1;
}
- inline number Min(number a, number b)
+ inline fixed Min(fixed a, fixed b)
{
return a < b ? a : b;
}
- inline number Max(number a, number b)
+ inline fixed Max(fixed a, fixed b)
{
return a > b ? a : b;
}
- inline number Clamp(number a, number low, number high)
+ inline fixed Clamp(fixed a, fixed low, fixed high)
{
return Max(low, Min(a, high));
}
@@ -172,18 +172,18 @@ namespace Phy2D
b = tmp;
}
- //// Random number in range [-1,1]
- //inline number Random()
+ //// Random fixed in range [-1,1]
+ //inline fixed Random()
//{
- // number r = (number)rand();
+ // fixed r = (fixed)rand();
// r /= RAND_MAX;
- // r = (number)2.0f * r - _1;
+ // r = (fixed)2.0f * r - _1;
// return r;
//}
- //inline number Random(number lo, number hi)
+ //inline fixed Random(fixed lo, fixed hi)
//{
- // number r = (number)rand();
+ // fixed r = (fixed)rand();
// r /= RAND_MAX;
// r = (hi - lo) * r + lo;
// return r;
diff --git a/Client/Source/Phy2DLite/Settings.h b/Client/Source/Phy2DLite/Settings.h
index 73639ef..9345b32 100644
--- a/Client/Source/Phy2DLite/Settings.h
+++ b/Client/Source/Phy2DLite/Settings.h
@@ -18,7 +18,7 @@ namespace Phy2D
#if NUMBER_ALIAS == NUMBER_FLOAT
-typedef float number;
+typedef float fixed;
#define NUMBER_MAX (FLT_MAX)
#define NUMBER_MIN (FLT_MIN)
#define SQRT(a) (sqrt((a)))
@@ -28,7 +28,7 @@ typedef float number;
#elif NUMBER_ALIAS == NUMBER_LIBFIX
// 同时一定要开启内联函数扩展,否则执行效率会非常低
-typedef Fix16 number;
+typedef Fix16 fixed;
#define NUMBER_MAX (fix16_maximum)
#define NUMBER_MIN (fix16_minimum)
#define SQRT(a) ((a).sqrt())
@@ -83,13 +83,13 @@ struct Limits<fpm::fixed_8_24>
static constexpr fpm::fixed_8_24 max() noexcept { return fpm::fixed_8_24::from_raw_value(2147483647); }
};
-typedef fpm::fixed_16_16 number;
-#define NUMBER_MAX (Limits<number>::max())
-#define NUMBER_MIN (Limits<number>::min())
+typedef fpm::fixed_16_16 fixed;
+#define NUMBER_MAX (Limits<fixed>::max())
+#define NUMBER_MIN (Limits<fixed>::min())
#define SQRT(a) (fpm::sqrt((a)))
#define SIN(a) (fpm::sin((a)))
#define COS(a) (fpm::cos((a)))
-#define PI (number::pi())
+#define PI (fixed::pi())
#endif
diff --git a/Client/Source/Phy2DLite/Tests/test.cpp b/Client/Source/Phy2DLite/Tests/test.cpp
index 6456b75..c2dbc54 100644
--- a/Client/Source/Phy2DLite/Tests/test.cpp
+++ b/Client/Source/Phy2DLite/Tests/test.cpp
@@ -13,7 +13,6 @@
#include "../Phy2D.h"
#include "glad/glad.h"
-using namespace std;
using namespace Phy2D;
namespace
@@ -92,7 +91,7 @@ static void Demo1(Body* b, Joint* j)
float x, y;
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
world.Add(b);
++b; ++numBodies;
@@ -108,7 +107,7 @@ static void Demo2(Body* b, Joint* j)
Body* b1 = b + 0;
b1->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
b1->friction = 0.2f;
- b1->position.Set(0.0f, (number)-0.5f * b1->width.y);
+ b1->position.Set(0.0f, (fixed)-0.5f * b1->width.y);
b1->rotation = 0.0f;
world.Add(b1);
@@ -131,7 +130,7 @@ static void Demo2(Body* b, Joint* j)
static void Demo3(Body* b, Joint* j)
{
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
world.Add(b);
++b; ++numBodies;
@@ -179,7 +178,7 @@ static void Demo4(Body* b, Joint* j)
{
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
b->friction = 0.2f;
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
b->rotation = 0.0f;
world.Add(b);
++b; ++numBodies;
@@ -201,7 +200,7 @@ static void Demo5(Body* b, Joint* j)
{
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
b->friction = 0.2f;
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
b->rotation = 0.0f;
world.Add(b);
++b; ++numBodies;
@@ -234,7 +233,7 @@ static void Demo6(Body* b, Joint* j)
{
Body* b1 = b + 0;
b1->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
- b1->position.Set(0.0f, (number)-0.5f * b1->width.y);
+ b1->position.Set(0.0f, (fixed)-0.5f * b1->width.y);
world.Add(b1);
Body* b2 = b + 1;
@@ -270,7 +269,7 @@ static void Demo7(Body* b, Joint* j)
{
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
b->friction = 0.2f;
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
b->rotation = 0.0f;
world.Add(b);
++b; ++numBodies;
@@ -292,7 +291,7 @@ static void Demo7(Body* b, Joint* j)
float dampingRatio = 0.7f;
// frequency in radians
- float omega = (number)2.0f * PI * frequencyHz;
+ float omega = (fixed)2.0f * PI * frequencyHz;
// damping coefficient
float d = 2.0f * mass * dampingRatio * omega;
@@ -326,7 +325,7 @@ static void Demo8(Body* b, Joint* j)
{
Body* b1 = b;
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
world.Add(b);
++b; ++numBodies;
@@ -403,7 +402,7 @@ static void Demo9(Body* b, Joint* j)
{
b->Set(Vec2(100.0f, 20.0f), NUMBER_MAX);
b->friction = 0.2f;
- b->position.Set(0.0f, (number)-0.5f * b->width.y);
+ b->position.Set(0.0f, (fixed)-0.5f * b->width.y);
b->rotation = 0.0f;
world.Add(b);
@@ -418,7 +417,7 @@ static void Demo9(Body* b, Joint* j)
float dampingRatio = 0.7f;
// frequency in radians
- float omega = (number) 2.0f * PI * frequencyHz;
+ float omega = (fixed) 2.0f * PI * frequencyHz;
// damping coefficient
float d = 2.0f * mass * dampingRatio * omega;
diff --git a/Client/Source/Phy2DLite/World.cpp b/Client/Source/Phy2DLite/World.cpp
index 8852f1f..f20be5f 100644
--- a/Client/Source/Phy2DLite/World.cpp
+++ b/Client/Source/Phy2DLite/World.cpp
@@ -71,9 +71,9 @@ void World::BroadPhase()
}
}
-void World::Step(number dt)
+void World::Step(fixed dt)
{
- number inv_dt = dt > _0 ? _1 / dt : _0;
+ fixed inv_dt = dt > _0 ? _1 / dt : _0;
// Determine overlapping bodies and update contact points.
BroadPhase();
diff --git a/Client/Source/Phy2DLite/World.h b/Client/Source/Phy2DLite/World.h
index 63bd983..3982d55 100644
--- a/Client/Source/Phy2DLite/World.h
+++ b/Client/Source/Phy2DLite/World.h
@@ -19,7 +19,7 @@ namespace Phy2D
void Add(Joint* joint);
void Clear();
- void Step(number dt);
+ void Step(fixed dt);
void BroadPhase();