X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FAABB.h;h=5b482c4cc701ae9fe6fa9eb8d568bb5b56508f87;hb=7cf057b5b3a28c3896af27cb725fbf0b4f1459c2;hp=a0e3436194fd57dbee28b06682babc553ef6edd2;hpb=03b142b877e19a2355e1a79e279e024922d44655;p=orbi.git diff --git a/src/world/AABB.h b/src/world/AABB.h index a0e3436..5b482c4 100644 --- a/src/world/AABB.h +++ b/src/world/AABB.h @@ -13,9 +13,9 @@ class AABB { public: constexpr AABB() { } constexpr AABB(Vector pos, Vector size) - : lt(pos), rb(pos + size) { } + : size(size), lt(pos), rb(pos + size) { } constexpr AABB(float x, float y, float w, float h) - : lt(x, y), rb(x + w, y + h) { } + : size(w, h), lt(x, y), rb(x + w, y + h) { } public: float Left() const { return lt.x; } @@ -26,16 +26,17 @@ public: Vector Position() const { return lt; } Vector Center() const { return lt + HalfSize(); } Vector HalfSize() const { return Size() / 2.0f; } - Vector Size() const { return rb - lt; } + Vector Size() const { return size; } public: - void Move(Vector delta) { lt += delta; rb += delta; } + void Move(Vector delta) { lt += delta; rb = lt + size; } void Resize(Vector size) { *this = AABB(lt, size); } bool Intersects(const AABB &other) const; bool Intersects(const AABB &other, Collision &) const; private: + Vector size; Vector lt; Vector rb;