Add MathEngineTest and Commects and clean ups
This commit is contained in:
@@ -45,6 +45,21 @@ cCollision::~cCollision()
|
||||
return true; /// bounding boxes intersect
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::BoundingBox(const iVector4& a, const iVector4& b)
|
||||
{
|
||||
if ((b.x + b.z) < a.x)
|
||||
return false; /// just checking if their
|
||||
if ((a.x + a.z) < b.x)
|
||||
return false; /// bounding boxes even touch
|
||||
|
||||
if ((b.y + b.w) < a.y)
|
||||
return false;
|
||||
if ((a.y + a.w) < b.y)
|
||||
return false;
|
||||
|
||||
return true; /// bounding boxes intersect
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const Vector4& b )
|
||||
{
|
||||
Vector4 temp = a;
|
||||
@@ -57,21 +72,6 @@ cCollision::~cCollision()
|
||||
return cCollision::BoundingBox(b, a);
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const iVector4& b )
|
||||
{
|
||||
if ((b.x + b.z) < a.x)
|
||||
return false; /// just checking if their
|
||||
if ((a.x + a.z) < b.x )
|
||||
return false; /// bounding boxes even touch
|
||||
|
||||
if ((b.y + b.w) < a.y)
|
||||
return false;
|
||||
if ((a.y + a.w) < b.y)
|
||||
return false;
|
||||
|
||||
return true; /// bounding boxes intersect
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const iVector4& b )
|
||||
{
|
||||
iVector4 temp = a;
|
||||
@@ -96,28 +96,6 @@ cCollision::~cCollision()
|
||||
return cCollision::BoundingBox( b, a );
|
||||
}
|
||||
|
||||
/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const SDL_Rect& b )
|
||||
{
|
||||
Vector2 rtn;
|
||||
rtn.x = 0.0f;
|
||||
rtn.y = 0.0f;
|
||||
|
||||
/// Check if left side of b is inside of a
|
||||
if (b.x < a.x)
|
||||
rtn.x = (float)(b.x - a.x);
|
||||
/// Check if right side of b is inside of a
|
||||
if ((b.x + b.w) > (a.x + a.w))
|
||||
rtn.x = (float)((b.x + b.w) - (a.x + a.w));
|
||||
/// Check if top side of b is inside of a
|
||||
if (b.y < a.y)
|
||||
rtn.y = (float)(b.y - a.y);
|
||||
/// Check if bottom side of b is inside of a
|
||||
if ((b.y + b.h) > (a.y + a.h))
|
||||
rtn.y = (float)((b.y + b.h) - (a.y + a.h));
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const Vector4& b )
|
||||
{
|
||||
Vector2 rtn;
|
||||
@@ -154,6 +132,44 @@ cCollision::~cCollision()
|
||||
return cCollision::Inside(a, temp);
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::isInside( const signed long int x, const signed long int y, const SDL_Rect& inside )
|
||||
{
|
||||
iVector4 temp = inside;
|
||||
return cCollision::isInside(x, y, temp);
|
||||
}
|
||||
|
||||
/*static*/ const bool cCollision::isInside( const signed long int x, const signed long int y, const iVector4& inside )
|
||||
{
|
||||
bool rtn = false;
|
||||
if ((inside.x < x) && (inside.w > x)) {
|
||||
if ((inside.y < y) && (inside.z > y))
|
||||
rtn = true;
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/*static*/ const iVector2 cCollision::Inside(const SDL_Rect& a, const SDL_Rect& b)
|
||||
{
|
||||
iVector2 rtn;
|
||||
rtn.x = 0.0f;
|
||||
rtn.y = 0.0f;
|
||||
|
||||
/// Check if left side of b is inside of a
|
||||
if (b.x < a.x)
|
||||
rtn.x = (float)(b.x - a.x);
|
||||
/// Check if right side of b is inside of a
|
||||
if ((b.x + b.w) > (a.x + a.w))
|
||||
rtn.x = (float)((b.x + b.w) - (a.x + a.w));
|
||||
/// Check if top side of b is inside of a
|
||||
if (b.y < a.y)
|
||||
rtn.y = (float)(b.y - a.y);
|
||||
/// Check if bottom side of b is inside of a
|
||||
if ((b.y + b.h) > (a.y + a.h))
|
||||
rtn.y = (float)((b.y + b.h) - (a.y + a.h));
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/*static*/ const iVector2 cCollision::Inside( const iVector4& a, const iVector4& b )
|
||||
{
|
||||
iVector2 rtn;
|
||||
|
||||
Reference in New Issue
Block a user