I should have commit when I knew what changes I made.

This commit is contained in:
2019-08-21 20:12:59 -04:00
parent 05ffe20bb4
commit 1e1a33f3f9
23 changed files with 820 additions and 175 deletions
@@ -0,0 +1,136 @@
#include "cInside.hpp"
using MathEngine::cInside;
using MathEngine::Vector4;
using MathEngine::Vector2;
using MathEngine::iVector4;
using MathEngine::iVector2;
cInside::cInside()
{
}
cInside::~cInside()
{
}
/// Functions
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const Vector4& 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 = a.x - b.x;
/// Check if right side of b is inside of a
if ((b.x + b.z) > (a.x + a.z))
rtn.x = (a.x + a.z) - (b.x + b.z);
/// Check if top side of b is inside of a
if (b.y < a.y)
rtn.y = a.y - b.y;
/// Check if bottom side of b is inside of a
if ((b.y + b.w) > (a.y + a.w))
rtn.y = (a.y + a.w) - (b.y + b.w);
return rtn;
}
/*static*/ const Vector2 cInside::Inside(const SDL_Rect& a, const Vector4& b)
{
Vector4 temp = a;
return cInside::Inside(temp, b);
}
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const SDL_Rect& b)
{
Vector4 temp = b;
return cInside::Inside(a, temp);
}
/*static*/ const bool cInside::isInside(const signed long int x, const signed long int y, const SDL_Rect& inside)
{
iVector4 temp = inside;
return cInside::isInside(x, y, temp);
}
/*static*/ const bool cInside::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 cInside::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 cInside::Inside(const iVector4& a, const iVector4& b)
{
iVector2 rtn;
rtn.x = 0;
rtn.y = 0;
/// Check if left side of b is inside of a
if (b.x < a.x)
rtn.x = b.x - a.x;
/// Check if right side of b is inside of a
if ((b.x + b.z) > (a.x + a.z))
rtn.x = (b.x + b.z) - (a.x + a.z);
/// Check if top side of b is inside of a
if (b.y < a.y)
rtn.y = b.y - a.y;
/// Check if bottom side of b is inside of a
if ((b.y + b.w) > (a.y + a.w))
rtn.y = (b.y + b.w) - (a.y + a.w);
return rtn;
}
/*static*/ const iVector2 cInside::Inside(const SDL_Rect& a, const iVector4& b)
{
iVector4 temp = a;
return cInside::Inside(temp, b);
}
/*static*/ const iVector2 cInside::Inside(const iVector4& a, const SDL_Rect& b)
{
return cInside::Inside(b, a);
}
/*static*/ const Vector2 cInside::Inside(const iVector4& a, const Vector4& b)
{
Vector4 temp = a;
return cInside::Inside(temp, b);
}
/*static*/ const Vector2 cInside::Inside(const Vector4& a, const iVector4& b)
{
return cInside::Inside(b, a);
}
@@ -0,0 +1,51 @@
#ifndef _CINSIDE_HPP_
#define _CINSIDE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "Vector/Vector2.hpp"
#include "iVector/iVector2.hpp"
#include "Vector/Vector4.hpp"
#include "iVector/iVector4.hpp"
namespace MathEngine {
class EXPORT_FROM_MYDLL cInside
{
private:
cInside();
~cInside();
public:
/// Functions
/* returns the Vector2 were a over laps b */
static const Vector2 Inside(const Vector4& a, const Vector4& b);
/* returns the Vector2 were a over laps b */
static const Vector2 Inside(const SDL_Rect& a, const Vector4& b);
/* returns the Vector2 were a over laps b */
static const Vector2 Inside(const Vector4& a, const SDL_Rect& b);
/* returns true if xy are inside SDL_Rect */
static const bool isInside(const signed long int x, const signed long int y, const SDL_Rect& inside);
/* returns true if xy are inside iVector4 */
static const bool isInside(const signed long int x, const signed long int y, const iVector4& inside);
/* returns the iVector2 were a over laps b */
static const iVector2 Inside(const SDL_Rect& a, const SDL_Rect& b);
/* returns the iVector2 were a over laps b */
static const iVector2 Inside(const iVector4& a, const iVector4& b);
/* returns the iVector2 were a over laps b */
static const iVector2 Inside(const SDL_Rect& a, const iVector4& b);
/* returns the iVector2 were a over laps b */
static const iVector2 Inside(const iVector4& a, const SDL_Rect& b);
static const Vector2 Inside(const iVector4& a, const Vector4& b);
static const Vector2 Inside(const Vector4& a, const iVector4& b);
};/// END CLASS DEFINITION cInside
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _CINSIDE_HPP_