From 5bd2688eb01bb9456b80f751ac0a502f0dfb39b6 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 5 Apr 2012 22:29:50 +0200 Subject: Fixes for GCC and removal of extern inline (#12) --- src/math3d.cpp | 50 ++++++++++----------- src/math3d.h | 134 ++++++++++++++++++++++++++++----------------------------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/math3d.cpp b/src/math3d.cpp index 492c9b3..9aa5f89 100644 --- a/src/math3d.cpp +++ b/src/math3d.cpp @@ -24,9 +24,9 @@ #include #include "struct.h" -#include "D3DEngine.h" -#include "D3DMath.h" -#include "D3DUtil.h" +#include "d3dengine.h" +#include "d3dmath.h" +#include "d3dutil.h" #include "math3d.h" @@ -41,23 +41,23 @@ BOOL IsEqual(float a, float b) // Returns the minimum value. -inline float Min(float a, float b) +float Min(float a, float b) { if ( a <= b ) return a; else return b; } -inline float Min(float a, float b, float c) +float Min(float a, float b, float c) { return Min( Min(a,b), c ); } -inline float Min(float a, float b, float c, float d) +float Min(float a, float b, float c, float d) { return Min( Min(a,b), Min(c,d) ); } -inline float Min(float a, float b, float c, float d, float e) +float Min(float a, float b, float c, float d, float e) { return Min( Min(a,b), Min(c,d), e ); } @@ -65,23 +65,23 @@ inline float Min(float a, float b, float c, float d, float e) // Returns the maximum value. -inline float Max(float a, float b) +float Max(float a, float b) { if ( a >= b ) return a; else return b; } -inline float Max(float a, float b, float c) +float Max(float a, float b, float c) { return Max( Max(a,b), c ); } -inline float Max(float a, float b, float c, float d) +float Max(float a, float b, float c, float d) { return Max( Max(a,b), Max(c,d) ); } -inline float Max(float a, float b, float c, float d, float e) +float Max(float a, float b, float c, float d, float e) { return Max( Max(a,b), Max(c,d), e ); } @@ -89,7 +89,7 @@ inline float Max(float a, float b, float c, float d, float e) // Returns the normalized value (0 .. 1). -inline float Norm(float a) +float Norm(float a) { if ( a < 0.0f ) return 0.0f; if ( a > 1.0f ) return 1.0f; @@ -99,7 +99,7 @@ inline float Norm(float a) // Returns the absolute value of a number. -inline float Abs(float a) +float Abs(float a) { return (float)fabs(a); } @@ -107,7 +107,7 @@ inline float Abs(float a) // Swaps two integers. -inline void Swap(int &a, int &b) +void Swap(int &a, int &b) { int c; @@ -118,7 +118,7 @@ inline void Swap(int &a, int &b) // Swaps two real numbers. -inline void Swap(float &a, float &b) +void Swap(float &a, float &b) { float c; @@ -129,7 +129,7 @@ inline void Swap(float &a, float &b) // Permutes two points. -inline void Swap(FPOINT &a, FPOINT &b) +void Swap(FPOINT &a, FPOINT &b) { FPOINT c; @@ -142,14 +142,14 @@ inline void Swap(FPOINT &a, FPOINT &b) // Mod(8.1, 4) = 0.1 // Mod(n, 1) = fractional part of n -inline float Mod(float a, float m) +float Mod(float a, float m) { return a - ((int)(a/m))*m; } // Returns a normalized angle, that is in other words between 0 and 2 * PI. -inline float NormAngle(float angle) +float NormAngle(float angle) { angle = Mod(angle, PI*2.0f); if ( angle < 0.0f ) @@ -547,7 +547,7 @@ D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length ) // Returns the distance between two points. -inline float Length(FPOINT a, FPOINT b) +float Length(FPOINT a, FPOINT b) { return sqrtf( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); @@ -555,21 +555,21 @@ inline float Length(FPOINT a, FPOINT b) // Returns the hypotenuse of a right triangle. -inline float Length(float x, float y) +float Length(float x, float y) { return sqrtf( (x*x) + (y*y) ); } // Returns the length of a vector. -inline float Length(const D3DVECTOR &u) +float Length(const D3DVECTOR &u) { return sqrtf( (u.x*u.x) + (u.y*u.y) + (u.z*u.z) ); } // Returns the distance between two points. -inline float Length(const D3DVECTOR &a, const D3DVECTOR &b) +float Length(const D3DVECTOR &a, const D3DVECTOR &b) { return sqrtf( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + @@ -578,7 +578,7 @@ inline float Length(const D3DVECTOR &a, const D3DVECTOR &b) // Returns the distance "a flat" between two points. -inline float Length2d(const D3DVECTOR &a, const D3DVECTOR &b) +float Length2d(const D3DVECTOR &a, const D3DVECTOR &b) { return sqrtf( (a.x-b.x)*(a.x-b.x) + (a.z-b.z)*(a.z-b.z) ); @@ -612,7 +612,7 @@ float Angle( D3DVECTOR u, D3DVECTOR v ) // Returns the product of two vectors. -inline D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v ) +D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v ) { return D3DVECTOR( u.y*v.z - u.z*v.y, u.z*v.x - u.x*v.z, @@ -846,7 +846,7 @@ float Neutral(float value, float dead) // Calculates a value (radians) proportional between a and b (degrees). -inline float Prop(int a, int b, float p) +float Prop(int a, int b, float p) { float aa, bb; diff --git a/src/math3d.h b/src/math3d.h index 2235496..ce7eee3 100644 --- a/src/math3d.h +++ b/src/math3d.h @@ -31,76 +31,76 @@ -extern BOOL IsEqual(float a, float b); +BOOL IsEqual(float a, float b); -extern float Min(float a, float b); -extern float Min(float a, float b, float c); -extern float Min(float a, float b, float c, float d); -extern float Min(float a, float b, float c, float d, float e); +float Min(float a, float b); +float Min(float a, float b, float c); +float Min(float a, float b, float c, float d); +float Min(float a, float b, float c, float d, float e); -extern float Max(float a, float b); -extern float Max(float a, float b, float c); -extern float Max(float a, float b, float c, float d); -extern float Max(float a, float b, float c, float d, float e); +float Max(float a, float b); +float Max(float a, float b, float c); +float Max(float a, float b, float c, float d); +float Max(float a, float b, float c, float d, float e); -extern float Norm(float a); -extern float Abs(float a); +float Norm(float a); +float Abs(float a); -extern void Swap(int &a, int &b); -extern void Swap(float &a, float &b); -extern void Swap(FPOINT &a, FPOINT &b); - -extern float Mod(float a, float m); -extern float NormAngle(float angle); -extern BOOL TestAngle(float angle, float min, float max); - -extern float Direction(float a, float g); -extern FPOINT RotatePoint(FPOINT center, float angle, FPOINT p); -extern FPOINT RotatePoint(float angle, FPOINT p); -extern FPOINT RotatePoint(float angle, float dist); -extern float RotateAngle(float x, float y); -extern float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2); -extern float MidPoint(FPOINT a, FPOINT b, float px); -extern D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist); -extern BOOL IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p); -extern BOOL Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i); -extern BOOL IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p); -extern void RotatePoint(float cx, float cy, float angle, float &px, float &py); -extern void RotatePoint(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p); -extern void RotatePoint2(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p); -extern D3DVECTOR RotateView(D3DVECTOR center, float angleH, float angleV, float dist); -extern D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length ); -extern float Length(FPOINT a, FPOINT b); -extern float Length(float x, float y); -extern float Length(const D3DVECTOR &u); -extern float Length(const D3DVECTOR &a, const D3DVECTOR &b); -extern float Length2d(const D3DVECTOR &a, const D3DVECTOR &b); -extern float Angle( D3DVECTOR u, D3DVECTOR v ); -extern D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v ); -extern D3DVECTOR ComputeNormal( D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3 ); -extern D3DVECTOR Transform(const D3DMATRIX &m, D3DVECTOR p); -extern D3DVECTOR Projection(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &p); - -extern void MappingObject( D3DVERTEX2* pVertices, int nb, float scale ); -extern void SmoothObject( D3DVERTEX2* pVertices, int nb ); -extern BOOL LineFunction(FPOINT p1, FPOINT p2, float &a, float &b); -extern float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &c, const D3DVECTOR &p); -extern BOOL IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2); -extern void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle); -extern void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle); - -extern float Rand(); -extern float Neutral(float value, float dead); - -extern float Prop(int a, int b, float p); -extern float Smooth(float actual, float hope, float time); -extern float Bounce(float progress, float middle=0.3f, float bounce=0.4f); - -extern D3DCOLOR RetColor(float intensity); -extern D3DCOLOR RetColor(D3DCOLORVALUE intensity); -extern D3DCOLORVALUE RetColor(D3DCOLOR intensity); - -extern void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest); -extern void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest); +void Swap(int &a, int &b); +void Swap(float &a, float &b); +void Swap(FPOINT &a, FPOINT &b); + +float Mod(float a, float m); +float NormAngle(float angle); +BOOL TestAngle(float angle, float min, float max); + +float Direction(float a, float g); +FPOINT RotatePoint(FPOINT center, float angle, FPOINT p); +FPOINT RotatePoint(float angle, FPOINT p); +FPOINT RotatePoint(float angle, float dist); +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); +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); +D3DVECTOR RotateView(D3DVECTOR center, float angleH, float angleV, float dist); +D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length ); +float Length(FPOINT a, FPOINT b); +float Length(float x, float y); +float Length(const D3DVECTOR &u); +float Length(const D3DVECTOR &a, const D3DVECTOR &b); +float Length2d(const D3DVECTOR &a, const D3DVECTOR &b); +float Angle( D3DVECTOR u, D3DVECTOR v ); +D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v ); +D3DVECTOR ComputeNormal( D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3 ); +D3DVECTOR Transform(const D3DMATRIX &m, D3DVECTOR p); +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); +float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &c, const D3DVECTOR &p); +BOOL IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2); +void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle); +void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle); + +float Rand(); +float Neutral(float value, float dead); + +float Prop(int a, int b, float p); +float Smooth(float actual, float hope, float time); +float Bounce(float progress, float middle=0.3f, float bounce=0.4f); + +D3DCOLOR RetColor(float intensity); +D3DCOLOR RetColor(D3DCOLORVALUE intensity); +D3DCOLORVALUE RetColor(D3DCOLOR intensity); + +void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest); +void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest); #endif //_MATH3D_H_ -- cgit v1.2.3-1-g7c22