diff --git a/etk/math/Vector3D.cpp b/etk/math/Vector3D.cpp index 7146133..356399f 100644 --- a/etk/math/Vector3D.cpp +++ b/etk/math/Vector3D.cpp @@ -8,7 +8,7 @@ #include #include -std::ostream& etk::operator <<(std::ostream& _os, const ivec3& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D& _obj) { _os << "("; _os << _obj.x(); _os << ","; @@ -19,7 +19,20 @@ std::ostream& etk::operator <<(std::ostream& _os, const ivec3& _obj) { return _os; } -std::ostream& operator <<(std::ostream& _os, const vec3& _obj) { +#ifdef ETK_BUILD_LINEARMATH + std::ostream& operator <<(std::ostream& _os, const btVector3& _obj) { + _os << "("; + _os << _obj.x(); + _os << ","; + _os << _obj.y(); + _os << ","; + _os << _obj.z(); + _os << ")"; + return _os; + } +#endif + +std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D& _obj) { _os << "("; _os << _obj.x(); _os << ","; @@ -30,7 +43,7 @@ std::ostream& operator <<(std::ostream& _os, const vec3& _obj) { return _os; } -std::ostream& etk::operator <<(std::ostream& _os, const uivec3& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D& _obj) { _os << "("; _os << _obj.x(); _os << ","; @@ -41,7 +54,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const uivec3& _obj) { return _os; } -std::ostream& etk::operator <<(std::ostream& _os, const bvec3& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D& _obj) { _os << "("; _os << _obj.x(); _os << ","; @@ -53,7 +66,20 @@ std::ostream& etk::operator <<(std::ostream& _os, const bvec3& _obj) { } -std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) { + +#ifdef ETK_BUILD_LINEARMATH + std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) { + for (size_t iii = 0; iii < _obj.size(); ++iii) { + if (iii != 0) { + _os << " "; + } + _os << _obj[iii]; + } + return _os; + } +#endif + +std::ostream& etk::operator <<(std::ostream& _os, const std::vector>& _obj) { for (size_t iii = 0; iii < _obj.size(); ++iii) { if (iii != 0) { _os << " "; @@ -63,7 +89,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) return _os; } -std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const std::vector>& _obj) { for (size_t iii = 0; iii < _obj.size(); ++iii) { if (iii != 0) { _os << " "; @@ -73,7 +99,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj return _os; } -std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const std::vector>& _obj) { for (size_t iii = 0; iii < _obj.size(); ++iii) { if (iii != 0) { _os << " "; @@ -83,7 +109,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _ob return _os; } -std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _obj) { +std::ostream& etk::operator <<(std::ostream& _os, const std::vector>& _obj) { for (size_t iii = 0; iii < _obj.size(); ++iii) { if (iii != 0) { _os << " "; diff --git a/etk/math/Vector3D.hpp b/etk/math/Vector3D.hpp index fd3784d..fbc8e76 100644 --- a/etk/math/Vector3D.hpp +++ b/etk/math/Vector3D.hpp @@ -442,8 +442,7 @@ namespace etk { * @return false The Objects are NOT identical */ bool operator==(const Vector3D& _obj) const { - return ( (m_floats[3] == _obj.m_floats[3]) - && (m_floats[2] == _obj.m_floats[2]) + return ( (m_floats[2] == _obj.m_floats[2]) && (m_floats[1] == _obj.m_floats[1]) && (m_floats[0] == _obj.m_floats[0])); } @@ -454,8 +453,7 @@ namespace etk { * @return false The Objects are identical */ bool operator!=(const Vector3D& _obj) const { - return ( (m_floats[3] != _obj.m_floats[3]) - || (m_floats[2] != _obj.m_floats[2]) + return ( (m_floats[2] != _obj.m_floats[2]) || (m_floats[1] != _obj.m_floats[1]) || (m_floats[0] != _obj.m_floats[0])); } @@ -464,20 +462,18 @@ namespace etk { * @param _obj The other Vector3D to compare with */ void setMax(const Vector3D& _obj) { - btSetMax(m_floats[0], _obj.m_floats[0]); - btSetMax(m_floats[1], _obj.m_floats[1]); - btSetMax(m_floats[2], _obj.m_floats[2]); - btSetMax(m_floats[3], _obj.m_floats[3]); + m_floats[0] = std::max(m_floats[0], _obj.m_floats[0]); + m_floats[1] = std::max(m_floats[1], _obj.m_floats[1]); + m_floats[2] = std::max(m_floats[2], _obj.m_floats[2]); } /** * @brief Set each element to the min of the current values and the values of another Vector3D * @param _obj The other Vector3D to compare with */ void setMin(const Vector3D& _obj) { - btSetMin(m_floats[0], _obj.m_floats[0]); - btSetMin(m_floats[1], _obj.m_floats[1]); - btSetMin(m_floats[2], _obj.m_floats[2]); - btSetMin(m_floats[3], _obj.m_floats[3]); + m_floats[0] = std::min(m_floats[0], _obj.m_floats[0]); + m_floats[1] = std::min(m_floats[1], _obj.m_floats[1]); + m_floats[2] = std::min(m_floats[2], _obj.m_floats[2]); } /** * @brief Set Value on the vector @@ -520,12 +516,22 @@ namespace etk { } }; //! @not_in_doc + std::ostream& operator <<(std::ostream& _os, const etk::Vector3D& _obj); + //! @not_in_doc std::ostream& operator <<(std::ostream& _os, const etk::Vector3D& _obj); //! @not_in_doc std::ostream& operator <<(std::ostream& _os, const etk::Vector3D& _obj); //! @not_in_doc std::ostream& operator <<(std::ostream& _os, const etk::Vector3D& _obj); -}; + //! @not_in_doc + std::ostream& operator <<(std::ostream& _os, const std::vector>& _obj); + //! @not_in_doc + std::ostream& operator <<(std::ostream& _os, const std::vector>& _obj); + //! @not_in_doc + std::ostream& operator <<(std::ostream& _os, const std::vector>& _obj); + //! @not_in_doc + std::ostream& operator <<(std::ostream& _os, const std::vector>& _obj); +} // To siplify the writing of the code ==> this permit to have the same name with the glsl language... #ifdef ETK_BUILD_LINEARMATH @@ -539,10 +545,9 @@ using ivec3 = etk::Vector3D; //!< wrapper on etk::Vector3D to using uivec3 = etk::Vector3D; //!< wrapper on etk::Vector3D to have the same naming has OpenGL shader using bvec3 = etk::Vector3D; //!< wrapper on etk::Vector3D to have the same naming has OpenGL shader -//! @not_in_doc -std::ostream& operator <<(std::ostream& _os, const vec3& _obj); - #ifdef ETK_BUILD_LINEARMATH + std::ostream& operator <<(std::ostream& _os, const btVector3& _obj); + std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); vec3 quaternionToEulerXYZ(const btQuaternion& quat); #endif @@ -583,20 +588,6 @@ namespace etk { } } - -namespace etk { - //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); - //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); - //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); - //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); -} - - - template inline etk::Vector3D operator+(const etk::Vector3D& _vect1, const etk::Vector3D& _vect2) { return etk::Vector3D(_vect1.x() + _vect2.x(), _vect1.y() + _vect2.y(), _vect1.z() + _vect2.z());