From ec75c28444d6e198f3ba9b713b34be28b49ac57c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 5 Jun 2017 11:35:40 +0000 Subject: [PATCH] [DEV] faster divede vec3 --- etk/math/Vector3D.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/etk/math/Vector3D.hpp b/etk/math/Vector3D.hpp index fbc8e76..61743c7 100644 --- a/etk/math/Vector3D.hpp +++ b/etk/math/Vector3D.hpp @@ -131,8 +131,8 @@ namespace etk { * @return Local reference of the vector */ Vector3D& operator/=(const Vector3D& _val) { - if (_val != 0) { - return *this *= float(1.0) / _val; + if (_val != 0.0f) { + return *this *= 1.0f / _val; } return *this; } @@ -142,10 +142,11 @@ namespace etk { * @return Local reference of the vector */ Vector3D& operator/=(const T& _val) { - if (_val != 0) { - m_floats[0] /= _val; - m_floats[1] /= _val; - m_floats[2] /= _val; + if (_val != 0.0f) { + float tmpVal = 1.0f / _val; + m_floats[0] *= tmpVal; + m_floats[1] *= tmpVal; + m_floats[2] *= tmpVal; return *this; } return *this; @@ -172,7 +173,7 @@ namespace etk { * @return Length value */ float length() const { - #if __CPP_objERSION__ >= 2011 && !defined(__STDCPP_LLVM__) + #if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__) return std::sqrt(length2()); #else return sqrt(length2());