From 43588cae17aadc65ba01fe915a3c8c2f25b01949 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Fri, 12 Mar 2021 23:33:29 +0000 Subject: [PATCH] Fix snapped implementation, it was not snapping size correctly --- util/math/rect3i.h | 5 ++++- util/math/vector3i.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/util/math/rect3i.h b/util/math/rect3i.h index c1a7308d..5d778580 100644 --- a/util/math/rect3i.h +++ b/util/math/rect3i.h @@ -239,7 +239,10 @@ public: } inline Rect3i snapped(int step) const { - return Rect3i(pos.floordiv(step) * step, size.floordiv(step) * step); + Rect3i r = downscaled(step); + r.pos *= step; + r.size *= step; + return r; } }; diff --git a/util/math/vector3i.h b/util/math/vector3i.h index de46dc1d..40e9fe1a 100644 --- a/util/math/vector3i.h +++ b/util/math/vector3i.h @@ -91,6 +91,12 @@ struct Vector3i { z -= other.z; } + _FORCE_INLINE_ void operator*=(const int s) { + x *= s; + y *= s; + z *= s; + } + _FORCE_INLINE_ Vector3i operator-() const { return Vector3i(-x, -y, -z); }