diff options
Diffstat (limited to '')
-rw-r--r-- | src/math/Rect.h | 19 | ||||
-rw-r--r-- | src/math/Vector.h | 13 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/math/Rect.h b/src/math/Rect.h index fd1bd05e..326bb479 100644 --- a/src/math/Rect.h +++ b/src/math/Rect.h @@ -26,6 +26,25 @@ public: if(v.y < top) top = v.y; if(v.y > bottom) bottom = v.y; } + void ContainRect(const CRect &r){ + if(r.left < left) left = r.left; + if(r.right > right) right = r.right; + if(r.top < top) top = r.top; + if(r.bottom > bottom) bottom = r.bottom; + } + + bool IsPointInside(const CVector2D &p){ + return p.x >= left && + p.x <= right && + p.y >= top && + p.y <= bottom; + } + bool IsPointInside(const CVector2D &p, float extraRadius){ + return p.x >= left-extraRadius && + p.x <= right+extraRadius && + p.y >= top-extraRadius && + p.y <= bottom+extraRadius; + } void Translate(float x, float y){ left += x; diff --git a/src/math/Vector.h b/src/math/Vector.h index 44e646e9..5918a5d1 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -9,11 +9,6 @@ public: #ifdef RWCORE_H CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {} - RwV3d toRwV3d(void) const { - RwV3d vecRw = { this->x, this->y, this->z }; - return vecRw; - } - operator RwV3d (void) const { RwV3d vecRw = { this->x, this->y, this->z }; return vecRw; @@ -22,10 +17,6 @@ public: operator RwV3d *(void) { return (RwV3d*)this; } - - operator RwV3d &(void) { - return *((RwV3d*)this); - } #endif // (0,1,0) means no rotation. So get right vector and its atan float Heading(void) const { return Atan2(-x, y); } @@ -95,6 +86,10 @@ public: return x == right.x && y == right.y && z == right.z; } + const bool operator!=(CVector const &right) { + return x != right.x || y != right.y || z != right.z; + } + bool IsZero(void) const { return x == 0.0f && y == 0.0f && z == 0.0f; } }; |