diff --git a/openVulkanoCpp/Math/DenseVector3i.hpp b/openVulkanoCpp/Math/DenseVector3i.hpp index df46dea..dc062f5 100644 --- a/openVulkanoCpp/Math/DenseVector3i.hpp +++ b/openVulkanoCpp/Math/DenseVector3i.hpp @@ -86,9 +86,9 @@ namespace openVulkanoCpp::Math constexpr T Data() const { return data; } - [[nodiscard]] constexpr int X() const { return static_cast(data & BITMASK); } - [[nodiscard]] constexpr int Y() const { return static_cast((data >> (2 * BITS)) & BITMASK); } - [[nodiscard]] constexpr int Z() const { return static_cast((data >> BITS) & BITMASK); } + [[nodiscard]] constexpr int X() const { int v = data & BITMASK; if (v > MAX_VALUE) v |= ~BITMASK; return reinterpret_cast(v); } + [[nodiscard]] constexpr int Y() const { int v = (data >> (2 * BITS)) & BITMASK; if (v > MAX_VALUE_Y) v |= ~BITMASK; return reinterpret_cast(v); } + [[nodiscard]] constexpr int Z() const { int v = (data >> BITS) & BITMASK; if (v > MAX_VALUE) v |= ~BITMASK; return reinterpret_cast(v); } void SetX(int x) {