From 352134ba9e39b8d995ca4657c821915af01c74bc Mon Sep 17 00:00:00 2001 From: mjagdis Date: Fri, 1 Nov 2024 22:18:50 +0000 Subject: Convert double to ints with floor rather than truncating (#5572) Signed-off-by: Mike Jagdis --- src/Vector3.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Vector3.h b/src/Vector3.h index 0e275e9b3..b48f35786 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -30,13 +30,20 @@ public: // tolua_end // Conversion constructors where U is not the same as T leaving the copy-constructor implicitly generated - template ::value>::type> - constexpr Vector3(const Vector3 & a_Rhs): + template ::value) && ((!std::is_integral::value) || (std::is_integral::value)), bool> = true> + constexpr Vector3(const Vector3 & a_Rhs): x(static_cast(a_Rhs.x)), y(static_cast(a_Rhs.y)), z(static_cast(a_Rhs.z)) { } + template ::value) && ((std::is_integral::value) && (!std::is_integral::value)), bool> = true> + constexpr Vector3(const Vector3 & a_Rhs): + x(static_cast(std::floor(a_Rhs.x))), + y(static_cast(std::floor(a_Rhs.y))), + z(static_cast(std::floor(a_Rhs.z))) + { + } // tolua_begin inline void Set(T a_x, T a_y, T a_z) -- cgit v1.2.3