Use SM_ALIGN. Cleanup spacing.
This commit is contained in:
+103
-102
@@ -12,54 +12,54 @@ enum PolygonMode { POLYGON_FILL, POLYGON_LINE };
|
|||||||
struct RageVector2
|
struct RageVector2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageVector2() {}
|
RageVector2() {}
|
||||||
RageVector2( const float * f ) { x=f[0]; y=f[1]; }
|
RageVector2( const float * f ) { x=f[0]; y=f[1]; }
|
||||||
RageVector2( float x1, float y1 ) { x=x1; y=y1; }
|
RageVector2( float x1, float y1 ) { x=x1; y=y1; }
|
||||||
|
|
||||||
// casting
|
// casting
|
||||||
operator float* () { return &x; };
|
operator float* () { return &x; };
|
||||||
operator const float* () const { return &x; };
|
operator const float* () const { return &x; };
|
||||||
|
|
||||||
// assignment operators
|
// assignment operators
|
||||||
RageVector2& operator += ( const RageVector2& other ) { x+=other.x; y+=other.y; return *this; }
|
RageVector2& operator += ( const RageVector2& other ) { x+=other.x; y+=other.y; return *this; }
|
||||||
RageVector2& operator -= ( const RageVector2& other ) { x-=other.x; y-=other.y; return *this; }
|
RageVector2& operator -= ( const RageVector2& other ) { x-=other.x; y-=other.y; return *this; }
|
||||||
RageVector2& operator *= ( float f ) { x*=f; y*=f; return *this; }
|
RageVector2& operator *= ( float f ) { x*=f; y*=f; return *this; }
|
||||||
RageVector2& operator /= ( float f ) { x/=f; y/=f; return *this; }
|
RageVector2& operator /= ( float f ) { x/=f; y/=f; return *this; }
|
||||||
|
|
||||||
// binary operators
|
// binary operators
|
||||||
RageVector2 operator + ( const RageVector2& other ) const { return RageVector2( x+other.x, y+other.y ); }
|
RageVector2 operator + ( const RageVector2& other ) const { return RageVector2( x+other.x, y+other.y ); }
|
||||||
RageVector2 operator - ( const RageVector2& other ) const { return RageVector2( x-other.x, y-other.y ); }
|
RageVector2 operator - ( const RageVector2& other ) const { return RageVector2( x-other.x, y-other.y ); }
|
||||||
RageVector2 operator * ( float f ) const { return RageVector2( x*f, y*f ); }
|
RageVector2 operator * ( float f ) const { return RageVector2( x*f, y*f ); }
|
||||||
RageVector2 operator / ( float f ) const { return RageVector2( x/f, y/f ); }
|
RageVector2 operator / ( float f ) const { return RageVector2( x/f, y/f ); }
|
||||||
|
|
||||||
friend RageVector2 operator * ( float f, const RageVector2& other ) { return other*f; }
|
friend RageVector2 operator * ( float f, const RageVector2& other ) { return other*f; }
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RageVector3
|
struct RageVector3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageVector3() {}
|
RageVector3() {}
|
||||||
RageVector3( const float * f ) { x=f[0]; y=f[1]; z=f[2]; }
|
RageVector3( const float * f ) { x=f[0]; y=f[1]; z=f[2]; }
|
||||||
RageVector3( float x1, float y1, float z1 ) { x=x1; y=y1; z=z1; }
|
RageVector3( float x1, float y1, float z1 ) { x=x1; y=y1; z=z1; }
|
||||||
|
|
||||||
// casting
|
// casting
|
||||||
operator float* () { return &x; };
|
operator float* () { return &x; };
|
||||||
operator const float* () const { return &x; };
|
operator const float* () const { return &x; };
|
||||||
|
|
||||||
// assignment operators
|
// assignment operators
|
||||||
RageVector3& operator += ( const RageVector3& other ) { x+=other.x; y+=other.y; z+=other.z; return *this; }
|
RageVector3& operator += ( const RageVector3& other ) { x+=other.x; y+=other.y; z+=other.z; return *this; }
|
||||||
RageVector3& operator -= ( const RageVector3& other ) { x-=other.x; y-=other.y; z-=other.z; return *this; }
|
RageVector3& operator -= ( const RageVector3& other ) { x-=other.x; y-=other.y; z-=other.z; return *this; }
|
||||||
RageVector3& operator *= ( float f ) { x*=f; y*=f; z*=f; return *this; }
|
RageVector3& operator *= ( float f ) { x*=f; y*=f; z*=f; return *this; }
|
||||||
RageVector3& operator /= ( float f ) { x/=f; y/=f; z/=f; return *this; }
|
RageVector3& operator /= ( float f ) { x/=f; y/=f; z/=f; return *this; }
|
||||||
|
|
||||||
// binary operators
|
// binary operators
|
||||||
RageVector3 operator + ( const RageVector3& other ) const { return RageVector3( x+other.x, y+other.y, z+other.z ); }
|
RageVector3 operator + ( const RageVector3& other ) const { return RageVector3( x+other.x, y+other.y, z+other.z ); }
|
||||||
RageVector3 operator - ( const RageVector3& other ) const { return RageVector3( x-other.x, y-other.y, z-other.z ); }
|
RageVector3 operator - ( const RageVector3& other ) const { return RageVector3( x-other.x, y-other.y, z-other.z ); }
|
||||||
RageVector3 operator * ( float f ) const { return RageVector3( x*f, y*f, z*f ); }
|
RageVector3 operator * ( float f ) const { return RageVector3( x*f, y*f, z*f ); }
|
||||||
RageVector3 operator / ( float f ) const { return RageVector3( x/f, y/f, z/f ); }
|
RageVector3 operator / ( float f ) const { return RageVector3( x/f, y/f, z/f ); }
|
||||||
|
|
||||||
friend RageVector3 operator * ( float f, const RageVector3& other ) { return other*f; }
|
friend RageVector3 operator * ( float f, const RageVector3& other ) { return other*f; }
|
||||||
|
|
||||||
@@ -70,63 +70,63 @@ public:
|
|||||||
struct RageVector4
|
struct RageVector4
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageVector4() {}
|
RageVector4() {}
|
||||||
RageVector4( const float * f ) { x=f[0]; y=f[1]; z=f[2]; w=f[3]; }
|
RageVector4( const float * f ) { x=f[0]; y=f[1]; z=f[2]; w=f[3]; }
|
||||||
RageVector4( float x1, float y1, float z1, float w1 ) { x=x1; y=y1; z=z1; w=w1; }
|
RageVector4( float x1, float y1, float z1, float w1 ) { x=x1; y=y1; z=z1; w=w1; }
|
||||||
|
|
||||||
// casting
|
// casting
|
||||||
operator float* () { return &x; };
|
operator float* () { return &x; };
|
||||||
operator const float* () const { return &x; };
|
operator const float* () const { return &x; };
|
||||||
|
|
||||||
// assignment operators
|
// assignment operators
|
||||||
RageVector4& operator += ( const RageVector4& other ) { x+=other.x; y+=other.y; z+=other.z; w+=other.w; return *this; }
|
RageVector4& operator += ( const RageVector4& other ) { x+=other.x; y+=other.y; z+=other.z; w+=other.w; return *this; }
|
||||||
RageVector4& operator -= ( const RageVector4& other ) { x-=other.x; y-=other.y; z-=other.z; w-=other.w; return *this; }
|
RageVector4& operator -= ( const RageVector4& other ) { x-=other.x; y-=other.y; z-=other.z; w-=other.w; return *this; }
|
||||||
RageVector4& operator *= ( float f ) { x*=f; y*=f; z*=f; w*=f; return *this; }
|
RageVector4& operator *= ( float f ) { x*=f; y*=f; z*=f; w*=f; return *this; }
|
||||||
RageVector4& operator /= ( float f ) { x/=f; y/=f; z/=f; w/=f; return *this; }
|
RageVector4& operator /= ( float f ) { x/=f; y/=f; z/=f; w/=f; return *this; }
|
||||||
|
|
||||||
// binary operators
|
// binary operators
|
||||||
RageVector4 operator + ( const RageVector4& other ) const { return RageVector4( x+other.x, y+other.y, z+other.z, w+other.w ); }
|
RageVector4 operator + ( const RageVector4& other ) const { return RageVector4( x+other.x, y+other.y, z+other.z, w+other.w ); }
|
||||||
RageVector4 operator - ( const RageVector4& other ) const { return RageVector4( x-other.x, y-other.y, z-other.z, w-other.w ); }
|
RageVector4 operator - ( const RageVector4& other ) const { return RageVector4( x-other.x, y-other.y, z-other.z, w-other.w ); }
|
||||||
RageVector4 operator * ( float f ) const { return RageVector4( x*f, y*f, z*f, w*f ); }
|
RageVector4 operator * ( float f ) const { return RageVector4( x*f, y*f, z*f, w*f ); }
|
||||||
RageVector4 operator / ( float f ) const { return RageVector4( x/f, y/f, z/f, w/f ); }
|
RageVector4 operator / ( float f ) const { return RageVector4( x/f, y/f, z/f, w/f ); }
|
||||||
|
|
||||||
friend RageVector4 operator * ( float f, const RageVector4& other ) { return other*f; }
|
friend RageVector4 operator * ( float f, const RageVector4& other ) { return other*f; }
|
||||||
|
|
||||||
float x, y, z, w;
|
float x, y, z, w;
|
||||||
} ALIGN(16);
|
} SM_ALIGN(16);
|
||||||
|
|
||||||
struct RageColor
|
struct RageColor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageColor() {}
|
RageColor() : r(0), g(0), b(0), a(0) {}
|
||||||
RageColor( const float * f ) { r=f[0]; g=f[1]; b=f[2]; a=f[3]; }
|
RageColor( const float * f ) { r=f[0]; g=f[1]; b=f[2]; a=f[3]; }
|
||||||
RageColor( float r1, float g1, float b1, float a1 ) { r=r1; g=g1; b=b1; a=a1; }
|
RageColor( float r1, float g1, float b1, float a1 ) { r=r1; g=g1; b=b1; a=a1; }
|
||||||
|
|
||||||
// casting
|
// casting
|
||||||
operator float* () { return &r; };
|
operator float* () { return &r; };
|
||||||
operator const float* () const { return &r; };
|
operator const float* () const { return &r; };
|
||||||
|
|
||||||
// assignment operators
|
// assignment operators
|
||||||
RageColor& operator += ( const RageColor& other ) { r+=other.r; g+=other.g; b+=other.b; a+=other.a; return *this; }
|
RageColor& operator += ( const RageColor& other ) { r+=other.r; g+=other.g; b+=other.b; a+=other.a; return *this; }
|
||||||
RageColor& operator -= ( const RageColor& other ) { r-=other.r; g-=other.g; b-=other.b; a-=other.a; return *this; }
|
RageColor& operator -= ( const RageColor& other ) { r-=other.r; g-=other.g; b-=other.b; a-=other.a; return *this; }
|
||||||
RageColor& operator *= ( const RageColor& other ) { r*=other.r; g*=other.g; b*=other.b; a*=other.a; return *this; }
|
RageColor& operator *= ( const RageColor& other ) { r*=other.r; g*=other.g; b*=other.b; a*=other.a; return *this; }
|
||||||
RageColor& operator *= ( float f ) { r*=f; g*=f; b*=f; a*=f; return *this; }
|
RageColor& operator *= ( float f ) { r*=f; g*=f; b*=f; a*=f; return *this; }
|
||||||
/* Divide is rarely useful: you can always use multiplication, and you don't have to
|
/* Divide is rarely useful: you can always use multiplication, and you don't have to
|
||||||
* worry about div/0. */
|
* worry about div/0. */
|
||||||
// RageColor& operator /= ( float f ) { r/=f; g/=f; b/=f; a/=f; return *this; }
|
// RageColor& operator /= ( float f ) { r/=f; g/=f; b/=f; a/=f; return *this; }
|
||||||
|
|
||||||
// binary operators
|
// binary operators
|
||||||
RageColor operator + ( const RageColor& other ) const { return RageColor( r+other.r, g+other.g, b+other.b, a+other.a ); }
|
RageColor operator + ( const RageColor& other ) const { return RageColor( r+other.r, g+other.g, b+other.b, a+other.a ); }
|
||||||
RageColor operator - ( const RageColor& other ) const { return RageColor( r-other.r, g-other.g, b-other.b, a-other.a ); }
|
RageColor operator - ( const RageColor& other ) const { return RageColor( r-other.r, g-other.g, b-other.b, a-other.a ); }
|
||||||
RageColor operator * ( const RageColor& other ) const { return RageColor( r*other.r, g*other.g, b*other.b, a*other.a ); }
|
RageColor operator * ( const RageColor& other ) const { return RageColor( r*other.r, g*other.g, b*other.b, a*other.a ); }
|
||||||
RageColor operator * ( float f ) const { return RageColor( r*f, g*f, b*f, a*f ); }
|
RageColor operator * ( float f ) const { return RageColor( r*f, g*f, b*f, a*f ); }
|
||||||
// Divide is useful for using with the SCALE macro
|
// Divide is useful for using with the SCALE macro
|
||||||
RageColor operator / ( float f ) const { return RageColor( r/f, g/f, b/f, a/f ); }
|
RageColor operator / ( float f ) const { return RageColor( r/f, g/f, b/f, a/f ); }
|
||||||
|
|
||||||
friend RageColor operator * ( float f, const RageColor& other ) { return other*f; } // What is this for? Did I add this? -Chris
|
friend RageColor operator * ( float f, const RageColor& other ) { return other*f; } // What is this for? Did I add this? -Chris
|
||||||
|
|
||||||
bool operator == ( const RageColor& other ) const { return r==other.r && g==other.g && b==other.b && a==other.a; }
|
bool operator == ( const RageColor& other ) const { return r==other.r && g==other.g && b==other.b && a==other.a; }
|
||||||
bool operator != ( const RageColor& other ) const { return !operator==(other); }
|
bool operator != ( const RageColor& other ) const { return !operator==(other); }
|
||||||
|
|
||||||
bool FromString( const CString &str )
|
bool FromString( const CString &str )
|
||||||
{
|
{
|
||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
} ALIGN(16);
|
} SM_ALIGN(16);
|
||||||
|
|
||||||
/* Convert floating-point 0..1 value to integer 0..255 value. *
|
/* Convert floating-point 0..1 value to integer 0..255 value. *
|
||||||
*
|
*
|
||||||
@@ -196,29 +196,30 @@ public:
|
|||||||
|
|
||||||
RageVColor() { }
|
RageVColor() { }
|
||||||
RageVColor(const RageColor &rc) { *this = rc; }
|
RageVColor(const RageColor &rc) { *this = rc; }
|
||||||
RageVColor &operator= (const RageColor &rc) {
|
RageVColor &operator= (const RageColor &rc)
|
||||||
|
{
|
||||||
r = FTOC(rc.r); g = FTOC(rc.g); b = FTOC(rc.b); a = FTOC(rc.a);
|
r = FTOC(rc.r); g = FTOC(rc.g); b = FTOC(rc.b); a = FTOC(rc.a);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace SM
|
namespace StepMania
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
class Rect
|
class Rect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Rect() {};
|
Rect() {};
|
||||||
Rect(T l, T t, T r, T b) { left = l, top = t, right = r, bottom = b; };
|
Rect(T l, T t, T r, T b) { left = l, top = t, right = r, bottom = b; };
|
||||||
|
|
||||||
T GetWidth() const { return right-left; };
|
T GetWidth() const { return right-left; };
|
||||||
T GetHeight() const { return bottom-top; };
|
T GetHeight() const { return bottom-top; };
|
||||||
T GetCenterX() const { return (left+right)/2; };
|
T GetCenterX() const { return (left+right)/2; };
|
||||||
T GetCenterY() const { return (top+bottom)/2; };
|
T GetCenterY() const { return (top+bottom)/2; };
|
||||||
|
|
||||||
bool operator==( const Rect &other ) const
|
bool operator==( const Rect &other ) const
|
||||||
{
|
{
|
||||||
#define COMPARE( x ) if( x != other.x ) return false;
|
#define COMPARE( x ) if( x != other.x ) return false
|
||||||
COMPARE( left );
|
COMPARE( left );
|
||||||
COMPARE( top );
|
COMPARE( top );
|
||||||
COMPARE( right );
|
COMPARE( right );
|
||||||
@@ -228,20 +229,20 @@ public:
|
|||||||
}
|
}
|
||||||
bool operator!=( const Rect &other ) const { return !operator==(other); }
|
bool operator!=( const Rect &other ) const { return !operator==(other); }
|
||||||
|
|
||||||
T left, top, right, bottom;
|
T left, top, right, bottom;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
typedef SM::Rect<int> RectI;
|
typedef StepMania::Rect<int> RectI;
|
||||||
typedef SM::Rect<float> RectF;
|
typedef StepMania::Rect<float> RectF;
|
||||||
|
|
||||||
/* Structure for our custom vertex type. Note that these data structes
|
/* Structure for our custom vertex type. Note that these data structes
|
||||||
* have the same layout that D3D expects. */
|
* have the same layout that D3D expects. */
|
||||||
struct RageSpriteVertex // has color
|
struct RageSpriteVertex // has color
|
||||||
{
|
{
|
||||||
RageVector3 p; // position
|
RageVector3 p; // position
|
||||||
RageVector3 n; // normal
|
RageVector3 n; // normal
|
||||||
RageVColor c; // diffuse color
|
RageVColor c; // diffuse color
|
||||||
RageVector2 t; // texture coordinates
|
RageVector2 t; // texture coordinates
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -254,11 +255,11 @@ struct RageModelVertex // doesn't have color. Relies on material color
|
|||||||
t(0,0),
|
t(0,0),
|
||||||
TextureMatrixScale(1,1)
|
TextureMatrixScale(1,1)
|
||||||
{ }
|
{ }
|
||||||
RageVector3 p; // position
|
RageVector3 p; // position
|
||||||
RageVector3 n; // normal
|
RageVector3 n; // normal
|
||||||
RageVector2 t; // texture coordinates
|
RageVector2 t; // texture coordinates
|
||||||
int8_t bone;
|
int8_t bone;
|
||||||
RageVector2 TextureMatrixScale; // usually 1,1
|
RageVector2 TextureMatrixScale; // usually 1,1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -271,26 +272,26 @@ struct RageModelVertex // doesn't have color. Relies on material color
|
|||||||
struct RageMatrix
|
struct RageMatrix
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageMatrix() {};
|
RageMatrix() {};
|
||||||
RageMatrix( const float *f ) { for(int i=0; i<4; i++) for(int j=0; j<4; j++) m[j][i]=f[j*4+i]; }
|
RageMatrix( const float *f ) { for(int i=0; i<4; i++) for(int j=0; j<4; j++) m[j][i]=f[j*4+i]; }
|
||||||
RageMatrix( const RageMatrix& other ) { for(int i=0; i<4; i++) for(int j=0; j<4; j++) m[j][i]=other.m[j][i]; }
|
RageMatrix( const RageMatrix& other ) { for(int i=0; i<4; i++) for(int j=0; j<4; j++) m[j][i]=other.m[j][i]; }
|
||||||
RageMatrix( float v00, float v01, float v02, float v03,
|
RageMatrix( float v00, float v01, float v02, float v03,
|
||||||
float v10, float v11, float v12, float v13,
|
float v10, float v11, float v12, float v13,
|
||||||
float v20, float v21, float v22, float v23,
|
float v20, float v21, float v22, float v23,
|
||||||
float v30, float v31, float v32, float v33 );
|
float v30, float v31, float v32, float v33 );
|
||||||
|
|
||||||
// access grants
|
// access grants
|
||||||
float& operator () ( int iRow, int iCol ) { return m[iCol][iRow]; }
|
float& operator () ( int iRow, int iCol ) { return m[iCol][iRow]; }
|
||||||
float operator () ( int iRow, int iCol ) const { return m[iCol][iRow]; }
|
float operator () ( int iRow, int iCol ) const { return m[iCol][iRow]; }
|
||||||
|
|
||||||
// casting operators
|
// casting operators
|
||||||
operator float* () { return m[0]; }
|
operator float* () { return m[0]; }
|
||||||
operator const float* () const { return m[0]; }
|
operator const float* () const { return m[0]; }
|
||||||
|
|
||||||
RageMatrix GetTranspose() const;
|
RageMatrix GetTranspose() const;
|
||||||
|
|
||||||
float m[4][4];
|
float m[4][4];
|
||||||
} ALIGN(16);
|
} SM_ALIGN(16);
|
||||||
|
|
||||||
RageColor scale( float x, float l1, float h1, const RageColor &a, const RageColor &b );
|
RageColor scale( float x, float l1, float h1, const RageColor &a, const RageColor &b );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user