This commit is contained in:
IlyaShurupov 2024-10-08 14:23:49 +03:00
parent 49cfe70c0d
commit 72c4740f82
18 changed files with 592 additions and 203 deletions

View file

@ -122,11 +122,11 @@ namespace tp {
// pos
Vec2<Type> p1() const { return pos; }
Vec2<Type> p2() const { return { pos.x, pos.y + size.y }; }
// pos + size
Vec2<Type> p3() const { return pos + size; }
Vec2<Type> p2() const { return { pos.x, pos.y + size.y }; }
Vec2<Type> p4() const { return { pos.x + size.x, pos.y }; }
inline bool isAbove(const Rect<Type>& rect) const { return (pos.y + size.y < rect.pos.y); }
@ -165,6 +165,21 @@ namespace tp {
return { pos + val, size - val * 2 };
}
void expand(const Vec2<Type>& point) {
pos.x = min(point.x, pos.x);
pos.y = min(point.y, pos.y);
auto p = pos + size;
p.x = max(point.x, p.x);
p.y = max(point.y, p.y);
size = p - pos;
}
void expand(const Rect<Type>& rect) {
expand(rect.pos);
expand(rect.pos + rect.size);
}
// if only one point isInside
bool clampOutside(Vec2<Type>& v1, Vec2<Type>& v2) {
bool const in1 = isInside(v1);
@ -268,6 +283,10 @@ namespace tp {
Type z;
Type w;
};
struct {
Type width;
Type height;
};
};
};
}