From 6543cc9ad1476dd62fbfbe3194fcf19412f0cbc0 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 19 Aug 2018 19:33:11 +0200 Subject: [PATCH] Reduced dependencies --- glm/ext/matrix_clip_space.hpp | 3 +-- glm/ext/quaternion_transform.hpp | 27 ------------------------ glm/ext/quaternion_transform.inl | 34 ------------------------------- glm/gtc/quaternion.hpp | 26 ++++++++++++++++++++++++ glm/gtc/quaternion.inl | 35 ++++++++++++++++++++++++++++++++ readme.md | 4 +++- 6 files changed, 65 insertions(+), 64 deletions(-) diff --git a/glm/ext/matrix_clip_space.hpp b/glm/ext/matrix_clip_space.hpp index f001c910..07ca540d 100644 --- a/glm/ext/matrix_clip_space.hpp +++ b/glm/ext/matrix_clip_space.hpp @@ -19,10 +19,9 @@ #pragma once // Dependencies -#include "../gtc/constants.hpp" +#include "../ext/scalar_constants.hpp" #include "../geometric.hpp" #include "../trigonometric.hpp" -#include "../matrix.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_EXT_matrix_clip_space extension included") diff --git a/glm/ext/quaternion_transform.hpp b/glm/ext/quaternion_transform.hpp index ddea081d..e7a5783e 100644 --- a/glm/ext/quaternion_transform.hpp +++ b/glm/ext/quaternion_transform.hpp @@ -38,33 +38,6 @@ namespace glm /// @see ext_quaternion_transform template GLM_FUNC_DECL qua rotate(qua const& q, T const& angle, vec<3, T, Q> const& axis); - - /// Build a look at quaternion based on the default handedness. - /// - /// @param direction Desired forward direction. Needs to be normalized. - /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). - template - GLM_FUNC_DECL qua quatLookAt( - vec<3, T, Q> const& direction, - vec<3, T, Q> const& up); - - /// Build a right-handed look at quaternion. - /// - /// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized. - /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). - template - GLM_FUNC_DECL qua quatLookAtRH( - vec<3, T, Q> const& direction, - vec<3, T, Q> const& up); - - /// Build a left-handed look at quaternion. - /// - /// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized. - /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). - template - GLM_FUNC_DECL qua quatLookAtLH( - vec<3, T, Q> const& direction, - vec<3, T, Q> const& up); /// @} } //namespace glm diff --git a/glm/ext/quaternion_transform.inl b/glm/ext/quaternion_transform.inl index 964495b6..b87ecb65 100644 --- a/glm/ext/quaternion_transform.inl +++ b/glm/ext/quaternion_transform.inl @@ -20,39 +20,5 @@ namespace glm return q * qua(cos(AngleRad * static_cast(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin); } - - template - GLM_FUNC_QUALIFIER qua quatLookAt(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) - { -# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT - return quatLookAtLH(direction, up); -# else - return quatLookAtRH(direction, up); -# endif - } - - template - GLM_FUNC_QUALIFIER qua quatLookAtRH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) - { - mat<3, 3, T, Q> Result; - - Result[2] = -direction; - Result[0] = normalize(cross(up, Result[2])); - Result[1] = cross(Result[2], Result[0]); - - return quat_cast(Result); - } - - template - GLM_FUNC_QUALIFIER qua quatLookAtLH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) - { - mat<3, 3, T, Q> Result; - - Result[2] = direction; - Result[0] = normalize(cross(up, Result[2])); - Result[1] = cross(Result[2], Result[0]); - - return quat_cast(Result); - } }//namespace glm diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index dd59cd47..29bda884 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -152,6 +152,32 @@ namespace glm template GLM_FUNC_DECL vec<4, bool, Q> greaterThanEqual(qua const& x, qua const& y); + /// Build a look at quaternion based on the default handedness. + /// + /// @param direction Desired forward direction. Needs to be normalized. + /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). + template + GLM_FUNC_DECL qua quatLookAt( + vec<3, T, Q> const& direction, + vec<3, T, Q> const& up); + + /// Build a right-handed look at quaternion. + /// + /// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized. + /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). + template + GLM_FUNC_DECL qua quatLookAtRH( + vec<3, T, Q> const& direction, + vec<3, T, Q> const& up); + + /// Build a left-handed look at quaternion. + /// + /// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized. + /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0). + template + GLM_FUNC_DECL qua quatLookAtLH( + vec<3, T, Q> const& direction, + vec<3, T, Q> const& up); /// @} } //namespace glm diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 84891977..9dd037ee 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -157,6 +157,41 @@ namespace glm Result[i] = x[i] >= y[i]; return Result; } + + + template + GLM_FUNC_QUALIFIER qua quatLookAt(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) + { +# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT + return quatLookAtLH(direction, up); +# else + return quatLookAtRH(direction, up); +# endif + } + + template + GLM_FUNC_QUALIFIER qua quatLookAtRH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) + { + mat<3, 3, T, Q> Result; + + Result[2] = -direction; + Result[0] = normalize(cross(up, Result[2])); + Result[1] = cross(Result[2], Result[0]); + + return quat_cast(Result); + } + + template + GLM_FUNC_QUALIFIER qua quatLookAtLH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up) + { + mat<3, 3, T, Q> Result; + + Result[2] = direction; + Result[0] = normalize(cross(up, Result[2])); + Result[1] = cross(Result[2], Result[0]); + + return quat_cast(Result); + } }//namespace glm #if GLM_CONFIG_SIMD == GLM_ENABLE diff --git a/readme.md b/readme.md index 80170091..122e46c3 100644 --- a/readme.md +++ b/readme.md @@ -65,9 +65,11 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Redesigned constexpr support which excludes both SIMD and constexpr #783 - Added detection of Visual C++ 2017 toolsets - Added identity functions #765 -- Split headers to improve compilation time #670 +- Splitted headers into EXT extensions to improve compilation time #670 +- Added separated performance tests #### Fixes: +- Fixed SIMD detection on Clang and GCC - Fixed build problems due to printf and std::clock_t #778 - Fixed int mod - Anonymous unions require C++ language extensions