Added proper hit test with rotation and pivoting
This commit is contained in:
+7
-2
@@ -80,6 +80,7 @@ struct Line {
|
||||
Vec2<float> start;
|
||||
Vec2<float> end;
|
||||
|
||||
Line() = default;
|
||||
Line(Vec2<float> start, Vec2<float> end) : start(start), end(end) {}
|
||||
|
||||
bool intersects(const Line &other) const {
|
||||
@@ -98,7 +99,7 @@ struct Line {
|
||||
struct Rect {
|
||||
Line diagonal; // from top-left to bottom-right
|
||||
|
||||
Rect(Vec2<float> a, Vec2<float> b) : diagonal(a, b) {
|
||||
Rect(Vec2<float> a, Vec2<float> b) {
|
||||
diagonal.start = {
|
||||
MIN(a.x, b.x),
|
||||
MIN(a.y, b.y)
|
||||
@@ -109,7 +110,11 @@ struct Rect {
|
||||
};
|
||||
}
|
||||
|
||||
static Rect from_size(Vec2<float> position, Vec2<float> size) {
|
||||
static Rect from(Vec2<float> size) {
|
||||
return Rect({0, 0}, size);
|
||||
}
|
||||
|
||||
static Rect from(Vec2<float> position, Vec2<float> size) {
|
||||
return Rect(position, position + size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user