Refactored and removed overlap check. Fixed contain check.
Overlap was built in. check for vector in rectangle was bugged. Fixed now.
This commit is contained in:
parent
72925842b7
commit
e4b7c12dbb
@ -14,19 +14,11 @@ namespace SlatedGameToolkit.Framework.Utilities
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static bool IsOverlapping(this RectangleF a, RectangleF b) {
|
||||
if (a.Left > b.Right) return false;
|
||||
if (a.Right < b.Left) return false;
|
||||
if (a.Bottom > b.Top) return false;
|
||||
if (a.Top < b.Bottom) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsWithin(this RectangleF rect, Vector2 vector) {
|
||||
if (vector.X > rect.Right) return false;
|
||||
if (vector.X < rect.Left) return false;
|
||||
if (vector.Y > rect.Top) return false;
|
||||
if (vector.Y < rect.Bottom) return false;
|
||||
public static bool Contains(this RectangleF rect, Vector2 vector) {
|
||||
if (vector.X < rect.X) return false;
|
||||
if (vector.X > rect.X + rect.Width) return false;
|
||||
if (vector.Y > rect.Y + rect.Height) return false;
|
||||
if (vector.Y < rect.Y) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user