Added proper hit test with rotation and pivoting

This commit is contained in:
2026-05-20 20:56:25 +01:00
parent 75b1bc5dbd
commit 6ff16e3db4
7 changed files with 181 additions and 35 deletions
+7 -2
View File
@@ -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);
}