summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-10 15:28:12 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-10 15:28:12 +0200
commit697fbdabf10d956e0f13bfbc9414d3db40f0c535 (patch)
treeab80ba3119d07b11da5478009b905edb702c103f /src/math
parent680af178196217bdd255d2bc851f240983144ac1 (diff)
downloadcolobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.tar.gz
colobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.tar.bz2
colobot-697fbdabf10d956e0f13bfbc9414d3db40f0c535.zip
BOOL -> bool; additional fixes in constructors/destructors
Diffstat (limited to 'src/math')
-rw-r--r--src/math/old/d3dmath.h2
-rw-r--r--src/math/old/math3d.cpp58
-rw-r--r--src/math/old/math3d.h14
3 files changed, 37 insertions, 37 deletions
diff --git a/src/math/old/d3dmath.h b/src/math/old/d3dmath.h
index 4f563e7..0cab192 100644
--- a/src/math/old/d3dmath.h
+++ b/src/math/old/d3dmath.h
@@ -47,7 +47,7 @@ const FLOAT g_EPSILON = 1.0e-5f; // Tolerance for FLOATs
//-----------------------------------------------------------------------------
// Fuzzy compares (within tolerance)
//-----------------------------------------------------------------------------
-inline BOOL D3DMath_IsZero( FLOAT a, FLOAT fTol = g_EPSILON )
+inline bool D3DMath_IsZero( FLOAT a, FLOAT fTol = g_EPSILON )
{ return ( a <= 0.0f ) ? ( a >= -fTol ) : ( a <= fTol ); }
diff --git a/src/math/old/math3d.cpp b/src/math/old/math3d.cpp
index 368cd5e..ad380af 100644
--- a/src/math/old/math3d.cpp
+++ b/src/math/old/math3d.cpp
@@ -31,9 +31,9 @@
-// Returns TRUE if two numbers are nearly equal.
+// Returns true if two numbers are nearly equal.
-BOOL IsEqual(float a, float b)
+bool IsEqual(float a, float b)
{
return Abs(a-b) < CHOUIA;
}
@@ -164,7 +164,7 @@ float NormAngle(float angle)
// Test if a angle is between two terminals.
-BOOL TestAngle(float angle, float min, float max)
+bool TestAngle(float angle, float min, float max)
{
angle = NormAngle(angle);
min = NormAngle(min);
@@ -364,14 +364,14 @@ D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist)
// Check if a point is inside a triangle.
-BOOL IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p)
+bool IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p)
{
float n, m;
- if ( p.x < a.x && p.x < b.x && p.x < c.x ) return FALSE;
- if ( p.x > a.x && p.x > b.x && p.x > c.x ) return FALSE;
- if ( p.y < a.y && p.y < b.y && p.y < c.y ) return FALSE;
- if ( p.y > a.y && p.y > b.y && p.y > c.y ) return FALSE;
+ if ( p.x < a.x && p.x < b.x && p.x < c.x ) return false;
+ if ( p.x > a.x && p.x > b.x && p.x > c.x ) return false;
+ if ( p.y < a.y && p.y < b.y && p.y < c.y ) return false;
+ if ( p.y > a.y && p.y > b.y && p.y > c.y ) return false;
if ( a.x > b.x ) Swap(a,b);
if ( a.x > c.x ) Swap(a,c);
@@ -380,18 +380,18 @@ BOOL IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p)
n = MidPoint(a, b, p.x);
m = MidPoint(a, c, p.x);
- if ( (n>p.y||p.y>m) && (n<p.y||p.y<m) ) return FALSE;
+ if ( (n>p.y||p.y>m) && (n<p.y||p.y<m) ) return false;
n = MidPoint(c, b, p.x);
m = MidPoint(c, a, p.x);
- if ( (n>p.y||p.y>m) && (n<p.y||p.y<m) ) return FALSE;
+ if ( (n>p.y||p.y>m) && (n<p.y||p.y<m) ) return false;
- return TRUE;
+ return true;
}
// Calculates the intersection "i" right "of" the plan "abc".
-BOOL Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c,
+bool Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c,
D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i)
{
float d1, d2;
@@ -404,18 +404,18 @@ BOOL Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c,
(d.y-e.y)*((b.x-a.x)*(c.z-a.z)-(c.x-a.x)*(b.z-a.z)) +
(d.z-e.z)*((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y));
- if ( d2 == 0 ) return FALSE;
+ if ( d2 == 0 ) return false;
i.x = d.x + d1/d2*(e.x-d.x);
i.y = d.y + d1/d2*(e.y-d.y);
i.z = d.z + d1/d2*(e.z-d.z);
- return TRUE;
+ return true;
}
// Calculates the intersection of the straight line passing through p (x, z)
// parallel to the y axis, with the plane abc. Returns p.y.
-BOOL IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p)
+bool IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p)
{
#if 0
D3DVECTOR d,e,i;
@@ -426,9 +426,9 @@ BOOL IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p)
e.x = p.x;
e.y = 1.0f;
e.z = p.z;
- if ( !Intersect(a,b,c,d,e,i) ) return FALSE;
+ if ( !Intersect(a,b,c,d,e,i) ) return false;
p.y = i.y;
- return TRUE;
+ return true;
#else
float d, d1, d2;
@@ -436,10 +436,10 @@ BOOL IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p)
d1 = (p.x-a.x)*(c.z-a.z) - (c.x-a.x)*(p.z-a.z);
d2 = (b.x-a.x)*(p.z-a.z) - (p.x-a.x)*(b.z-a.z);
- if ( d == 0.0f ) return FALSE;
+ if ( d == 0.0f ) return false;
p.y = a.y + d1/d*(b.y-a.y) + d2/d*(c.y-a.y);
- return TRUE;
+ return true;
#endif
}
@@ -685,7 +685,7 @@ void SmoothObject(D3DVERTEX2* pVertices, int nb)
for ( i=0 ; i<nb ; i++ )
{
- bDone[i] = TRUE;
+ bDone[i] = true;
rank = 0;
index[rank++] = i;
@@ -696,7 +696,7 @@ void SmoothObject(D3DVERTEX2* pVertices, int nb)
pVertices[j].y == pVertices[i].y &&
pVertices[j].z == pVertices[i].z )
{
- bDone[j] = TRUE;
+ bDone[j] = true;
index[rank++] = j;
if ( rank >= 100 ) break;
}
@@ -729,20 +729,20 @@ void SmoothObject(D3DVERTEX2* pVertices, int nb)
// Calculates the parameters a and b of the segment passing
// through the points p1 and p2, knowing that:
// f(x) = ax+b
-// Returns FALSE if the line is vertical.
+// Returns false if the line is vertical.
-BOOL LineFunction(FPOINT p1, FPOINT p2, float &a, float &b)
+bool LineFunction(FPOINT p1, FPOINT p2, float &a, float &b)
{
if ( D3DMath_IsZero(p1.x-p2.x) )
{
a = g_HUGE; // infinite slope!
b = p2.x;
- return FALSE;
+ return false;
}
a = (p2.y-p1.y)/(p2.x-p1.x);
b = p2.y - p2.x*a;
- return TRUE;
+ return true;
}
@@ -766,7 +766,7 @@ float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b,
// Check if two planes defined by 3 points are part of the same plan.
-BOOL IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2)
+bool IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2)
{
D3DVECTOR n1, n2;
float dist;
@@ -776,12 +776,12 @@ BOOL IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2)
if ( Abs(n1.x-n2.x) > 0.1f ||
Abs(n1.y-n2.y) > 0.1f ||
- Abs(n1.z-n2.z) > 0.1f ) return FALSE;
+ Abs(n1.z-n2.z) > 0.1f ) return false;
dist = DistancePlanPoint(plan1[0], plan1[1], plan1[2], plan2[0]);
- if ( dist > 0.1f ) return FALSE;
+ if ( dist > 0.1f ) return false;
- return TRUE;
+ return true;
}
diff --git a/src/math/old/math3d.h b/src/math/old/math3d.h
index 5c10047..f08f9a6 100644
--- a/src/math/old/math3d.h
+++ b/src/math/old/math3d.h
@@ -30,7 +30,7 @@
-BOOL IsEqual(float a, float b);
+bool IsEqual(float a, float b);
float Min(float a, float b);
float Min(float a, float b, float c);
@@ -51,7 +51,7 @@ void Swap(FPOINT &a, FPOINT &b);
float Mod(float a, float m);
float NormAngle(float angle);
-BOOL TestAngle(float angle, float min, float max);
+bool TestAngle(float angle, float min, float max);
float Direction(float a, float g);
FPOINT RotatePoint(FPOINT center, float angle, FPOINT p);
@@ -61,9 +61,9 @@ float RotateAngle(float x, float y);
float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2);
float MidPoint(FPOINT a, FPOINT b, float px);
D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist);
-BOOL IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p);
-BOOL Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i);
-BOOL IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p);
+bool IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p);
+bool Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i);
+bool IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p);
void RotatePoint(float cx, float cy, float angle, float &px, float &py);
void RotatePoint(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
void RotatePoint2(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
@@ -82,9 +82,9 @@ D3DVECTOR Projection(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &p)
void MappingObject( D3DVERTEX2* pVertices, int nb, float scale );
void SmoothObject( D3DVERTEX2* pVertices, int nb );
-BOOL LineFunction(FPOINT p1, FPOINT p2, float &a, float &b);
+bool LineFunction(FPOINT p1, FPOINT p2, float &a, float &b);
float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &c, const D3DVECTOR &p);
-BOOL IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2);
+bool IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2);
void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle);
void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle);