Simple cleanup of Shapes, removes old style format.

Reviewed By: wraitii
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D1809
This was SVN commit r22213.
This commit is contained in:
Vladislav Belov 2019-04-22 21:53:11 +00:00
parent eae5f11c5e
commit 285db48813
2 changed files with 120 additions and 168 deletions

View File

@ -29,18 +29,18 @@ CRect::CRect(const CPos &pos) :
{
}
CRect::CRect(const CSize &size) :
CRect::CRect(const CSize& size) :
left(0.f), top(0.f), right(size.cx), bottom(size.cy)
{
}
CRect::CRect(const CPos &upperleft, const CPos &bottomright) :
CRect::CRect(const CPos& upperleft, const CPos& bottomright) :
left(upperleft.x), top(upperleft.y), right(bottomright.x), bottom(bottomright.y)
{
}
CRect::CRect(const CPos &pos, const CSize &size) :
left(pos.x), top(pos.y), right((pos.x+size.cx)), bottom((pos.y+size.cy))
CRect::CRect(const CPos& pos, const CSize& size) :
left(pos.x), top(pos.y), right(pos.x + size.cx), bottom(pos.y + size.cy)
{
}
@ -49,8 +49,7 @@ CRect::CRect(const float l, const float t, const float r, const float b) :
{
}
// =
CRect& CRect::operator = (const CRect& a)
CRect& CRect::operator=(const CRect& a)
{
left = a.left;
top = a.top;
@ -59,71 +58,60 @@ CRect& CRect::operator = (const CRect& a)
return *this;
}
// ==
bool CRect::operator ==(const CRect &a) const
bool CRect::operator==(const CRect &a) const
{
return (left==a.left &&
top==a.top &&
right==a.right &&
bottom==a.bottom);
return (left == a.left &&
top == a.top &&
right == a.right &&
bottom == a.bottom);
}
// !=
bool CRect::operator != (const CRect& a) const
bool CRect::operator!=(const CRect& a) const
{
return !(*this==a);
return !(*this == a);
}
// - (the unary operator)
CRect CRect::operator - (void) const
CRect CRect::operator-() const
{
return CRect(-left, -top, -right, -bottom);
}
// + (the unary operator)
CRect CRect::operator + (void) const
CRect CRect::operator+() const
{
return *this;
}
// +
CRect CRect::operator + (const CRect& a) const
CRect CRect::operator+(const CRect& a) const
{
return CRect(left+a.left, top+a.top, right+a.right, bottom+a.bottom);
return CRect(left + a.left, top + a.top, right + a.right, bottom + a.bottom);
}
// +
CRect CRect::operator + (const CPos& a) const
CRect CRect::operator+(const CPos& a) const
{
return CRect(left+a.x, top+a.y, right+a.x, bottom+a.y);
return CRect(left + a.x, top + a.y, right + a.x, bottom + a.y);
}
// +
CRect CRect::operator + (const CSize& a) const
CRect CRect::operator+(const CSize& a) const
{
return CRect(left+a.cx, top+a.cy, right+a.cx, bottom+a.cy);
return CRect(left + a.cx, top + a.cy, right + a.cx, bottom + a.cy);
}
// -
CRect CRect::operator - (const CRect& a) const
CRect CRect::operator-(const CRect& a) const
{
return CRect(left-a.left, top-a.top, right-a.right, bottom-a.bottom);
return CRect(left - a.left, top - a.top, right - a.right, bottom - a.bottom);
}
// -
CRect CRect::operator - (const CPos& a) const
CRect CRect::operator-(const CPos& a) const
{
return CRect(left-a.x, top-a.y, right-a.x, bottom-a.y);
return CRect(left - a.x, top - a.y, right - a.x, bottom - a.y);
}
// -
CRect CRect::operator - (const CSize& a) const
CRect CRect::operator-(const CSize& a) const
{
return CRect(left-a.cx, top-a.cy, right-a.cx, bottom-a.cy);
return CRect(left - a.cx, top - a.cy, right - a.cx, bottom - a.cy);
}
// +=
void CRect::operator +=(const CRect& a)
void CRect::operator+=(const CRect& a)
{
left += a.left;
top += a.top;
@ -131,8 +119,7 @@ void CRect::operator +=(const CRect& a)
bottom += a.bottom;
}
// +=
void CRect::operator +=(const CPos& a)
void CRect::operator+=(const CPos& a)
{
left += a.x;
top += a.y;
@ -140,8 +127,7 @@ void CRect::operator +=(const CPos& a)
bottom += a.y;
}
// +=
void CRect::operator +=(const CSize& a)
void CRect::operator+=(const CSize& a)
{
left += a.cx;
top += a.cy;
@ -149,8 +135,7 @@ void CRect::operator +=(const CSize& a)
bottom += a.cy;
}
// -=
void CRect::operator -=(const CRect& a)
void CRect::operator-=(const CRect& a)
{
left -= a.left;
top -= a.top;
@ -158,8 +143,7 @@ void CRect::operator -=(const CRect& a)
bottom -= a.bottom;
}
// -=
void CRect::operator -=(const CPos& a)
void CRect::operator-=(const CPos& a)
{
left -= a.x;
top -= a.y;
@ -167,8 +151,7 @@ void CRect::operator -=(const CPos& a)
bottom -= a.y;
}
// -=
void CRect::operator -=(const CSize& a)
void CRect::operator-=(const CSize& a)
{
left -= a.cx;
top -= a.cy;
@ -188,7 +171,7 @@ float CRect::GetHeight() const
CSize CRect::GetSize() const
{
return CSize(right-left, bottom-top);
return CSize(right - left, bottom - top);
}
CPos CRect::TopLeft() const
@ -213,7 +196,7 @@ CPos CRect::BottomRight() const
CPos CRect::CenterPoint() const
{
return CPos((left+right)/2.f, (top+bottom)/2.f);
return CPos((left + right) / 2.f, (top + bottom) / 2.f);
}
bool CRect::PointInside(const CPos &point) const
@ -226,7 +209,7 @@ bool CRect::PointInside(const CPos &point) const
CRect CRect::Scale(float x, float y) const
{
return CRect(left*x, top*y, right*x, bottom*y);
return CRect(left * x, top * y, right * x, bottom * y);
}
/*************************************************************************/
@ -239,89 +222,76 @@ CPos::CPos(const CSize& s) : x(s.cx), y(s.cy)
{
}
CPos::CPos(const float &_x, const float &_y) : x(_x), y(_y)
CPos::CPos(const float px, const float py) : x(px), y(py)
{
}
// =
CPos& CPos::operator = (const CPos& a)
CPos& CPos::operator=(const CPos& a)
{
x = a.x;
y = a.y;
return *this;
}
// ==
bool CPos::operator ==(const CPos &a) const
bool CPos::operator==(const CPos &a) const
{
return (x==a.x && y==a.y);
return x == a.x && y == a.y;
}
// !=
bool CPos::operator != (const CPos& a) const
bool CPos::operator!=(const CPos& a) const
{
return !(*this==a);
return !(*this == a);
}
// - (the unary operator)
CPos CPos::operator - (void) const
CPos CPos::operator-() const
{
return CPos(-x, -y);
}
// + (the unary operator)
CPos CPos::operator + (void) const
CPos CPos::operator+() const
{
return *this;
}
// +
CPos CPos::operator + (const CPos& a) const
CPos CPos::operator+(const CPos& a) const
{
return CPos(x+a.x, y+a.y);
return CPos(x + a.x, y + a.y);
}
// +
CPos CPos::operator + (const CSize& a) const
CPos CPos::operator+(const CSize& a) const
{
return CPos(x+a.cx, y+a.cy);
return CPos(x + a.cx, y + a.cy);
}
// -
CPos CPos::operator - (const CPos& a) const
CPos CPos::operator-(const CPos& a) const
{
return CPos(x-a.x, y-a.y);
return CPos(x - a.x, y - a.y);
}
// -
CPos CPos::operator - (const CSize& a) const
CPos CPos::operator-(const CSize& a) const
{
return CPos(x-a.cx, y-a.cy);
return CPos(x - a.cx, y - a.cy);
}
// +=
void CPos::operator +=(const CPos& a)
void CPos::operator+=(const CPos& a)
{
x += a.x;
y += a.y;
}
// +=
void CPos::operator +=(const CSize& a)
void CPos::operator+=(const CSize& a)
{
x += a.cx;
y += a.cy;
}
// -=
void CPos::operator -=(const CPos& a)
void CPos::operator-=(const CPos& a)
{
x -= a.x;
y -= a.y;
}
// -=
void CPos::operator -=(const CSize& a)
void CPos::operator-=(const CSize& a)
{
x -= a.cx;
y -= a.cy;
@ -341,89 +311,76 @@ CSize::CSize(const CPos &pos) : cx(pos.x), cy(pos.y)
{
}
CSize::CSize(const float &_cx, const float &_cy) : cx(_cx), cy(_cy)
CSize::CSize(const float sx, const float sy) : cx(sx), cy(sy)
{
}
// =
CSize& CSize::operator = (const CSize& a)
CSize& CSize::operator=(const CSize& a)
{
cx = a.cx;
cy = a.cy;
return *this;
}
// ==
bool CSize::operator ==(const CSize &a) const
bool CSize::operator==(const CSize &a) const
{
return (cx==a.cx && cy==a.cy);
return cx == a.cx && cy == a.cy;
}
// !=
bool CSize::operator != (const CSize& a) const
bool CSize::operator!=(const CSize& a) const
{
return !(*this==a);
return !(*this == a);
}
// - (the unary operator)
CSize CSize::operator - (void) const
CSize CSize::operator-() const
{
return CSize(-cx, -cy);
}
// + (the unary operator)
CSize CSize::operator + (void) const
CSize CSize::operator+() const
{
return *this;
}
// +
CSize CSize::operator + (const CSize& a) const
CSize CSize::operator+(const CSize& a) const
{
return CSize(cx+a.cx, cy+a.cy);
return CSize(cx + a.cx, cy + a.cy);
}
// -
CSize CSize::operator - (const CSize& a) const
CSize CSize::operator-(const CSize& a) const
{
return CSize(cx-a.cx, cy-a.cy);
return CSize(cx - a.cx, cy - a.cy);
}
// /
CSize CSize::operator / (const float& a) const
CSize CSize::operator/(const float a) const
{
return CSize(cx/a, cy/a);
return CSize(cx / a, cy / a);
}
// *
CSize CSize::operator * (const float& a) const
CSize CSize::operator*(const float a) const
{
return CSize(cx*a, cy*a);
return CSize(cx * a, cy * a);
}
// +=
void CSize::operator +=(const CSize& a)
void CSize::operator+=(const CSize& a)
{
cx += a.cx;
cy += a.cy;
}
// -=
void CSize::operator -=(const CSize& a)
void CSize::operator-=(const CSize& a)
{
cx -= a.cx;
cy -= a.cy;
}
// /=
void CSize::operator /=(const float& a)
void CSize::operator/=(const float a)
{
cx /= a;
cy /= a;
}
// *=
void CSize::operator *=(const float& a)
void CSize::operator*=(const float a)
{
cx *= a;
cy *= a;

View File

@ -33,8 +33,6 @@ class CSize;
* Rectangle class used for screen rectangles. It's very similar to the MS
* CRect, but with FLOATS because it's meant to be used with OpenGL which
* takes float values.
*
* Changed to floats 2004-08-31 /GL
*/
class CRect
{
@ -46,26 +44,25 @@ public:
CRect(const CPos &pos, const CSize &size);
CRect(const float l, const float t, const float r, const float b);
// Operators
CRect& operator = (const CRect& a);
bool operator == (const CRect& a) const;
bool operator != (const CRect& a) const;
CRect operator - (void) const;
CRect operator + (void) const;
CRect& operator=(const CRect& a);
bool operator==(const CRect& a) const;
bool operator!=(const CRect& a) const;
CRect operator-() const;
CRect operator+() const;
CRect operator + (const CRect& a) const;
CRect operator + (const CPos& a) const;
CRect operator + (const CSize& a) const;
CRect operator - (const CRect& a) const;
CRect operator - (const CPos& a) const;
CRect operator - (const CSize& a) const;
CRect operator+(const CRect& a) const;
CRect operator+(const CPos& a) const;
CRect operator+(const CSize& a) const;
CRect operator-(const CRect& a) const;
CRect operator-(const CPos& a) const;
CRect operator-(const CSize& a) const;
void operator += (const CRect& a);
void operator += (const CPos& a);
void operator += (const CSize& a);
void operator -= (const CRect& a);
void operator -= (const CPos& a);
void operator -= (const CSize& a);
void operator+=(const CRect& a);
void operator+=(const CPos& a);
void operator+=(const CSize& a);
void operator-=(const CRect& a);
void operator-=(const CPos& a);
void operator-=(const CSize& a);
/**
* @return Width of Rectangle
@ -137,24 +134,23 @@ class CPos
public:
CPos();
CPos(const CSize &pos);
CPos(const float &_x, const float &_y);
CPos(const float px, const float py);
// Operators
CPos& operator = (const CPos& a);
bool operator == (const CPos& a) const;
bool operator != (const CPos& a) const;
CPos operator - (void) const;
CPos operator + (void) const;
CPos& operator=(const CPos& a);
bool operator==(const CPos& a) const;
bool operator!=(const CPos& a) const;
CPos operator-() const;
CPos operator+() const;
CPos operator + (const CPos& a) const;
CPos operator + (const CSize& a) const;
CPos operator - (const CPos& a) const;
CPos operator - (const CSize& a) const;
CPos operator+(const CPos& a) const;
CPos operator+(const CSize& a) const;
CPos operator-(const CPos& a) const;
CPos operator-(const CSize& a) const;
void operator += (const CPos& a);
void operator += (const CSize& a);
void operator -= (const CPos& a);
void operator -= (const CSize& a);
void operator+=(const CPos& a);
void operator+=(const CSize& a);
void operator-=(const CPos& a);
void operator-=(const CSize& a);
public:
/**
@ -176,24 +172,23 @@ public:
CSize();
CSize(const CRect &rect);
CSize(const CPos &pos);
CSize(const float &_cx, const float &_cy);
CSize(const float sx, const float sy);
// Operators
CSize& operator = (const CSize& a);
bool operator == (const CSize& a) const;
bool operator != (const CSize& a) const;
CSize operator - (void) const;
CSize operator + (void) const;
CSize& operator=(const CSize& a);
bool operator==(const CSize& a) const;
bool operator!=(const CSize& a) const;
CSize operator-() const;
CSize operator+() const;
CSize operator + (const CSize& a) const;
CSize operator - (const CSize& a) const;
CSize operator / (const float &a) const;
CSize operator * (const float &a) const;
CSize operator+(const CSize& a) const;
CSize operator-(const CSize& a) const;
CSize operator/(const float a) const;
CSize operator*(const float a) const;
void operator += (const CSize& a);
void operator -= (const CSize& a);
void operator /= (const float& a);
void operator *= (const float& a);
void operator+=(const CSize& a);
void operator-=(const CSize& a);
void operator/=(const float a);
void operator*=(const float a);
public:
/**