From ac6fd195102641f53c161cec4f560b69cedbf241 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 8 Feb 2011 23:54:58 +0000 Subject: [PATCH 01/11] Added comment with slerp equation --- glm/gtc/quaternion.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index a445c182..df9d65d4 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -327,6 +327,7 @@ namespace quaternion{ q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); } + // (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle)) template inline detail::tquat mix ( From 957185408fba6407e169363ad972b4016a317b11 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 10 Feb 2011 16:48:39 +0000 Subject: [PATCH 02/11] Fixed typo, removed warnings --- doc/pages.doxy | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/doc/pages.doxy b/doc/pages.doxy index 0e5a9f9f..25f70528 100644 --- a/doc/pages.doxy +++ b/doc/pages.doxy @@ -9,15 +9,15 @@ This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (Raytracing / Rasterisation), image processing, physic simulations and any context that requires a simple and convenient mathematics library. - \note The Doxygen-generated documentation will often state that a type or function - is defined in a namespace that is a child of the \link glm glm \endlink namespace. - Please ignore this; you can access all publicly available types as direct children - of the glm namespace. - GLM is written as a platform independent library with no dependence and officially supports the following compilers: 1. GCC 3.4 and higher 2. LLVM 2.3 through GCC 4.2 front-end and higher 3. Visual Studio 2005 and higher + + \note The Doxygen-generated documentation will often state that a type or function + is defined in a namespace that is a child of the \link glm glm \endlink namespace. + Please ignore this; All publicly available types and functions can be accessed as a direct children + of the glm namespace. The source code is licenced under the MIT licence. @@ -67,7 +67,7 @@ int foo() The \ref core "GLM" represents only what GLSL's core provides in terms of types and functions (to the best of GLM's ability to replicate them). All that is needed to use the core - is to #include . + is to include . \ref gtc "GTC extensions" are functions and types that add onto the core. These are considered reasonably stable, with their APIs not changing much between @@ -79,7 +79,7 @@ int foo() is why they are marked "experimental". Like GTC extensions, each experimental extension is included with a separate header file. - All the extensions can be included at once by default with #include + All the extensions can be included at once by default by including but this is not recommanded as it will reduce compilation speed for many unused features. All of GLM is defined as direct children of the glm namespace, including extensions. @@ -255,8 +255,8 @@ void foo() GLM's functions are defined in headers, so they are defined with C++'s "inline" delcaration. This does not require the compiler to inline them, however. - If you want to force the compiler to inline the function, using whatever capabilities that the compiler provides to do so, - you can define GLM_FORCE_INLINE before any inclusion of . + To force the compiler to inline the function, using whatever capabilities that the compiler provides to do so, + GLM_FORCE_INLINE can be defined before any inclusion of . \code #define GLM_FORCE_INLINE @@ -281,7 +281,7 @@ void foo() \section advanced_compatibility Compatibility Compilers have some language extensions that GLM will automatically take advantage of them when they are enabled. - The #define GLM_FORCE_CXX98 can switch off these extensions, forcing GLM to operate on pure C++98. + GLM_FORCE_CXX98 can switch off these extensions, forcing GLM to operate on pure C++98. \code #define GLM_FORCE_CXX98 @@ -394,9 +394,10 @@ void foo() \section faq7 Should I use 'using namespace glm;'? - This is unwise. There is every chance that are that if 'using namespace glm;' is called, name collisions will happen. GLSL names for functions are fairly generic, so it is entirely likely that there is another function called, for example, \link glm::sqrt sqrt \endlink. + This is unwise. Chances are that if 'using namespace glm;' is called, name collisions will happen. + GLSL names for functions are fairly generic, so it is entirely likely that there is another function called, for example, \link glm::sqrt sqrt \endlink. - If you need frequent use of particular types, you can bring them into the global + For frequent use of particular types, they can be brough into the global namespace with a 'using' declaration like this: /code @@ -409,9 +410,11 @@ void foo() GLM is mainly designed to be convenient; that's why it is written against GLSL specification. - The 80-20 rule suggests that 80% of a program's performance comes from 20% of its code. Therefore, one must first identify which 20% of the code is impacting the performance. + The 80-20 rule suggests that 80% of a program's performance comes from 20% of its code. + Therefore, one should first identify which 20% of the code is impacting the performance. - In general, if one identifies certain math code to be a performance bottleneck, the only way to solve this is to write specialized code for those particular math needs. So no canned library solution would be suitable. + In general, if one identifies certain math code to be a performance bottleneck, the only way to solve this is to write specialized code for those particular math needs. + So no canned library solution would be suitable. That being said, GLM can provides some descent performances alternatives based on approximations or SIMD instructions. **/ @@ -603,27 +606,30 @@ glm::vec3 lighting( \page pg_reference References OpenGL 4.1 core specification: - http://www.opengl.org/registry/doc/glspec41.core.20100725.pdf + http://www.opengl.org/registry/doc/glspec41.core.20100725.pdf GLSL 4.10 specification: - http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.clean.pdf + http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.clean.pdf GLU 1.3 specification: - http://www.opengl.org/documentation/specs/glu/glu1_3.pdf + http://www.opengl.org/documentation/specs/glu/glu1_3.pdf GLM HEAD snapshot: - http://ogl-math.git.sourceforge.net/git/gitweb.cgi?p=ogl-math/ogl-math;a=snapshot;h=HEAD;sf=tgz + http://ogl-math.git.sourceforge.net/git/gitweb.cgi?p=ogl-math/ogl-math;a=snapshot;h=HEAD;sf=tgz - GLM Trac, for bug report and feature request: + GLM bug tracker: https://sourceforge.net/apps/trac/ogl-math GLM website: http://glm.g-truc.net + GLM OpenGL SDK page: + http://www.opengl.org/sdk/libs/GLM/ + G-Truc Creation page: - http://www.g-truc.net/project-0016.html + http://www.g-truc.net/project-0016.html The OpenGL Toolkits forum to ask questions about GLM: - http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=postlist&Board=10&page=1 + http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=postlist&Board=10&page=1 **/ From 0bac9eae9108a7c2d4e096de018b478779d01884 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 17 Feb 2011 01:36:59 +0000 Subject: [PATCH 03/11] Fixed inline, ticket #45 --- glm/gtx/simd_vec4.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index ae5a250f..e8261fcb 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -285,7 +285,7 @@ namespace glm //{ // return max(-a, a); //} - detail::fvec4SIMD abs + inline detail::fvec4SIMD abs ( detail::fvec4SIMD const & x ) From 4943efd56f1060720f53a6e8b76b3e61522f9821 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 2 Mar 2011 18:17:33 +0000 Subject: [PATCH 04/11] Updated post --- doc/src/data.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/src/data.xml b/doc/src/data.xml index ad4af96a..e8cb0a23 100644 --- a/doc/src/data.xml +++ b/doc/src/data.xml @@ -148,10 +148,12 @@ - + + + + - - GLM 0.9.1.0 (zip,) + GLM 0.9.1.0 (zip) GLM 0.9.1.0 (7z) GLM 0.9.1 manual Submit a bug report @@ -169,10 +171,10 @@ This version also improves the SIMD extensions and it fixes many bugs. - GLM 0.9.1.B (zip,) + GLM 0.9.1.B (zip) GLM 0.9.1.B (7z) GLM 0.9.1 manual - GLM 0.9.0.8 (zip,) + GLM 0.9.0.8 (zip) GLM 0.9.0.8 (7z) GLM 0.9.0 manual Submit a bug report From 39639b2b382cf371abc44450be5e100d92003d6f Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 3 Mar 2011 10:52:05 +0000 Subject: [PATCH 05/11] Added post 61 --- doc/src/data.xml | 55 +++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/doc/src/data.xml b/doc/src/data.xml index e8cb0a23..b3afe3c6 100644 --- a/doc/src/data.xml +++ b/doc/src/data.xml @@ -149,9 +149,20 @@ - - - + + Finally, GLM 0.9.1 branch is reaching the status of stable with + GLM 0.9.1.0. + + + From GLM 0.9.1 beta, mainly bugs has been fixed. GLM has evolved on many sides since GLM 0.9.0: + Improved documentation (manual and doxygen), better test framework, simplified setup/options/configration of GLM and new experimental SIMD API. + + + GLM 0.9.1.0 is not 100% backward compatile with + GLM 0.9.0.8 + but mainly advanced usages should be affected by the differencies. + Have a look at the GLM manual for more information on how to use GLM 0.9.1. + GLM 0.9.1.0 (zip) GLM 0.9.1.0 (7z) @@ -159,26 +170,26 @@ Submit a bug report - - - The stable version, GLM 0.9.0.8, adds the operator * for quaternion products and deprecated the cross function previously used for the same purpose. - Also, it clarifies that GLM is a header only library when a user try to build it. Once more, there is nothing to build. - - - The development version, GLM 0.9.1 beta, provides an improved API documentation by - Alfonse Reinheart, - author of a great OpenGL tutorial which uses GLM. - This version also improves the SIMD extensions and it fixes many bugs. - + + + The stable version, GLM 0.9.0.8, adds the operator * for quaternion products and deprecated the cross function previously used for the same purpose. + Also, it clarifies that GLM is a header only library when a user try to build it. Once more, there is nothing to build. + + + The development version, GLM 0.9.1 beta, provides an improved API documentation by + Alfonse Reinheart, + author of a great OpenGL tutorial which uses GLM. + This version also improves the SIMD extensions and it fixes many bugs. + - GLM 0.9.1.B (zip) - GLM 0.9.1.B (7z) - GLM 0.9.1 manual - GLM 0.9.0.8 (zip) - GLM 0.9.0.8 (7z) - GLM 0.9.0 manual - Submit a bug report - + GLM 0.9.1.B (zip) + GLM 0.9.1.B (7z) + GLM 0.9.1 manual + GLM 0.9.0.8 (zip) + GLM 0.9.0.8 (7z) + GLM 0.9.0 manual + Submit a bug report + From 1b91fe779026defa8e693a50a5958b1db71e8ff8 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 3 Mar 2011 10:53:20 +0000 Subject: [PATCH 06/11] Started removing GLMvalType --- glm/core/type_vec4.hpp | 1 - glm/glm.hpp | 2 +- glm/gtx/vector_query.hpp | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 803bf685..7257ceb0 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -15,7 +15,6 @@ #include "type_int.hpp" #include "type_size.hpp" #include "_swizzle.hpp" -#include "_detail.hpp" namespace glm { diff --git a/glm/glm.hpp b/glm/glm.hpp index 2c47cabb..6a117e7f 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -13,7 +13,7 @@ #define glm_glm //! TODO: to delete -#define GLMvalType typename genType::value_type +//#define GLMvalType typename genType::value_type #include #include diff --git a/glm/gtx/vector_query.hpp b/glm/gtx/vector_query.hpp index 776a99ed..f531cf07 100644 --- a/glm/gtx/vector_query.hpp +++ b/glm/gtx/vector_query.hpp @@ -41,15 +41,15 @@ namespace glm bool areCollinear( const genType & v0, const genType & v1, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + typename genType::value_type const epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are opposites. //! From GLM_GTX_vector_query extensions. template bool areOpposite( - const genType & v0, - const genType & v1, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v0, + genType const & v1, + typename genType::value_type const epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are orthogonals. //! From GLM_GTX_vector_query extensions. From debd1af2255a9e7946f6e7ebcbd3959b19120442 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 3 Mar 2011 11:00:12 +0000 Subject: [PATCH 07/11] Fixed logo url --- doc/man.doxy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man.doxy b/doc/man.doxy index a0f71f99..cf235dd5 100644 --- a/doc/man.doxy +++ b/doc/man.doxy @@ -44,7 +44,7 @@ PROJECT_BRIEF = # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. -PROJECT_LOGO = G:/git/ogl-math/doc/image/logo-mini.png +PROJECT_LOGO = ./image/logo-mini.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -80,7 +80,7 @@ OUTPUT_LANGUAGE = English # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. -BRIEF_MEMBER_DESC = YES +BRIEF_MEMBER_DESC = NO # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. From 7ca74e2b4db3e28acf4fb85435d39113c5e9666b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 9 Mar 2011 09:51:19 +0000 Subject: [PATCH 08/11] Fixed pick implementation... again --- glm/gtc/matrix_transform.inl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 1263ce53..bc0a65ac 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -338,8 +338,13 @@ namespace matrix_transform if(!(delta.x > T(0) && delta.y > T(0))) return Result; // Error + detail::tvec3 Temp( + (T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, + (T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y, + T(0)); + // Translate and scale the picked region to the entire window - Result = translate(Result, (T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, (T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y, T(0)); + Result = translate(Result, Temp); return scale(Result, T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)); } From 453607acec02ec7c4c52a154d76e3e4c5f6aa8db Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 9 Mar 2011 09:54:35 +0000 Subject: [PATCH 09/11] Typo --- glm/gtc/matrix_transform.inl | 52 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index bc0a65ac..93d845e6 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -144,13 +144,15 @@ namespace matrix_transform } template - inline detail::tmat4x4 ortho( + inline detail::tmat4x4 ortho + ( valType const & left, valType const & right, valType const & bottom, valType const & top, valType const & zNear, - valType const & zFar) + valType const & zFar + ) { detail::tmat4x4 Result(1); Result[0][0] = valType(2) / (right - left); @@ -179,13 +181,15 @@ namespace matrix_transform } template - inline detail::tmat4x4 frustum( + inline detail::tmat4x4 frustum + ( valType const & left, valType const & right, valType const & bottom, valType const & top, valType const & nearVal, - valType const & farVal) + valType const & farVal + ) { detail::tmat4x4 Result(0); Result[0][0] = (valType(2) * nearVal) / (right - left); @@ -199,11 +203,13 @@ namespace matrix_transform } template - inline detail::tmat4x4 perspective( + inline detail::tmat4x4 perspective + ( valType const & fovy, valType const & aspect, valType const & zNear, - valType const & zFar) + valType const & zFar + ) { valType range = tan(radians(fovy / valType(2))) * zNear; valType left = -range * aspect; @@ -244,10 +250,12 @@ namespace matrix_transform } template - inline detail::tmat4x4 infinitePerspective( + inline detail::tmat4x4 infinitePerspective + ( T fovy, T aspect, - T zNear) + T zNear + ) { T range = tan(radians(fovy / T(2))) * zNear; T left = -range * aspect; @@ -265,10 +273,12 @@ namespace matrix_transform } template - inline detail::tmat4x4 tweakedInfinitePerspective( + inline detail::tmat4x4 tweakedInfinitePerspective + ( T fovy, T aspect, - T zNear) + T zNear + ) { T range = tan(radians(fovy / T(2))) * zNear; T left = -range * aspect; @@ -286,11 +296,13 @@ namespace matrix_transform } template - inline detail::tvec3 project( + inline detail::tvec3 project + ( detail::tvec3 const & obj, detail::tmat4x4 const & model, detail::tmat4x4 const & proj, - detail::tvec4 const & viewport) + detail::tvec4 const & viewport + ) { detail::tvec4 tmp = detail::tvec4(obj, T(1)); tmp = model * tmp; @@ -305,11 +317,13 @@ namespace matrix_transform } template - inline detail::tvec3 unProject( + inline detail::tvec3 unProject + ( detail::tvec3 const & win, detail::tmat4x4 const & model, detail::tmat4x4 const & proj, - detail::tvec4 const & viewport) + detail::tvec4 const & viewport + ) { detail::tmat4x4 inverse = glm::inverse(proj * model); @@ -349,10 +363,12 @@ namespace matrix_transform } template - inline detail::tmat4x4 lookAt( - const detail::tvec3& eye, - const detail::tvec3& center, - const detail::tvec3& up) + inline detail::tmat4x4 lookAt + ( + detail::tvec3 const & eye, + detail::tvec3 const & center, + detail::tvec3 const & up + ) { detail::tvec3 f = normalize(center - eye); detail::tvec3 u = normalize(up); From e106bd62cf61fdf8d6e9c82f8569eb3127bcfbb8 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 9 Mar 2011 10:09:45 +0000 Subject: [PATCH 10/11] Fixed ticket #69, missing namespace --- glm/core/type_int.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/core/type_int.hpp b/glm/core/type_int.hpp index 6903c2b0..3bad8ce4 100644 --- a/glm/core/type_int.hpp +++ b/glm/core/type_int.hpp @@ -88,7 +88,7 @@ namespace glm #elif(GLM_PRECISION & GLM_PRECISION_LOWP_INT) typedef precision::lowp_int int_t; #else - typedef mediump_int int_t; + typedef precision::mediump_int int_t; # pragma message("GLM message: Precisson undefined for signed integer number."); #endif//GLM_PRECISION From 8f517b7505d4333427bdf7c5967cda39b252f2cf Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 9 Mar 2011 11:54:06 +0000 Subject: [PATCH 11/11] Removed define GLMvaltype --- glm/glm.hpp | 3 - glm/gtx/spline.hpp | 30 +++++----- glm/gtx/spline.inl | 72 ++++++++++++----------- glm/gtx/vector_query.hpp | 34 +++++------ glm/gtx/vector_query.inl | 123 ++++++++++++++++++++++++--------------- 5 files changed, 148 insertions(+), 114 deletions(-) diff --git a/glm/glm.hpp b/glm/glm.hpp index 6a117e7f..394ecf4b 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -12,9 +12,6 @@ #ifndef glm_glm #define glm_glm -//! TODO: to delete -//#define GLMvalType typename genType::value_type - #include #include #include diff --git a/glm/gtx/spline.hpp b/glm/gtx/spline.hpp index d00bf572..e791d1dc 100644 --- a/glm/gtx/spline.hpp +++ b/glm/gtx/spline.hpp @@ -36,31 +36,31 @@ namespace glm //! From GLM_GTX_spline extension. template genType catmullRom( - const genType& v1, - const genType& v2, - const genType& v3, - const genType& v4, - const GLMvalType& s); + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s); //! Return a point from a hermite curve. //! From GLM_GTX_spline extension. template genType hermite( - const genType& v1, - const genType& t1, - const genType& v2, - const genType& t2, - const GLMvalType& s); + genType const & v1, + genType const & t1, + genType const & v2, + genType const & t2, + typename genType::value_type const & s); //! Return a point from a cubic curve. //! From GLM_GTX_spline extension. template genType cubic( - const genType& v1, - const genType& v2, - const genType& v3, - const genType& v4, - const GLMvalType& s); + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s); ///@} diff --git a/glm/gtx/spline.inl b/glm/gtx/spline.inl index 7d94b12b..a0c49b4a 100644 --- a/glm/gtx/spline.inl +++ b/glm/gtx/spline.inl @@ -12,53 +12,59 @@ namespace gtx{ namespace spline { template - inline genType catmullRom( - const genType& v1, - const genType& v2, - const genType& v3, - const genType& v4, - const GLMvalType& s) + inline genType catmullRom + ( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s + ) { - GLMvalType s1 = s; - GLMvalType s2 = optimum_pow::pow2(s); - GLMvalType s3 = optimum_pow::pow3(s); + typename genType::value_type s1 = s; + typename genType::value_type s2 = optimum_pow::pow2(s); + typename genType::value_type s3 = optimum_pow::pow3(s); - GLMvalType f1 = -s3 + GLMvalType(2) * s2 - s; - GLMvalType f2 = GLMvalType(3) * s3 - GLMvalType(5) * s2 + GLMvalType(2); - GLMvalType f3 = GLMvalType(-3) * s3 + GLMvalType(4) * s2 + s; - GLMvalType f4 = s3 - s2; + typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; + typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); + typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; + typename genType::value_type f4 = s3 - s2; - return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / GLMvalType(2); + return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); } template - inline genType hermite( - const genType& v1, - const genType& t1, - const genType& v2, - const genType& t2, - const GLMvalType& s) + inline genType hermite + ( + genType const & v1, + genType const & t1, + genType const & v2, + genType const & t2, + typename genType::value_type const & s + ) { - GLMvalType s1 = s; - GLMvalType s2 = optimum_pow::pow2(s); - GLMvalType s3 = optimum_pow::pow3(s); + typename genType::value_type s1 = s; + typename genType::value_type s2 = optimum_pow::pow2(s); + typename genType::value_type s3 = optimum_pow::pow3(s); - GLMvalType f1 = GLMvalType(2) * s3 - GLMvalType(3) * s2 + GLMvalType(1); - GLMvalType f2 = GLMvalType(-2) * s3 + GLMvalType(3) * s2; - GLMvalType f3 = s3 - GLMvalType(2) * s2 + s; - GLMvalType f4 = s3 - s2; + typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); + typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; + typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; + typename genType::value_type f4 = s3 - s2; return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; } template - inline genType cubic( - const genType& v1, - const genType& v2, - const genType& v3, - const genType& v4, - const GLMvalType& s) + inline genType cubic + ( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s + ) { return ((v1 * s + v2) * s + v3) * s + v4; } diff --git a/glm/gtx/vector_query.hpp b/glm/gtx/vector_query.hpp index f531cf07..47fac281 100644 --- a/glm/gtx/vector_query.hpp +++ b/glm/gtx/vector_query.hpp @@ -39,9 +39,9 @@ namespace glm //! From GLM_GTX_vector_query extensions. template bool areCollinear( - const genType & v0, - const genType & v1, - typename genType::value_type const epsilon = std::numeric_limits::epsilon()); + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are opposites. //! From GLM_GTX_vector_query extensions. @@ -49,45 +49,45 @@ namespace glm bool areOpposite( genType const & v0, genType const & v1, - typename genType::value_type const epsilon = std::numeric_limits::epsilon()); + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are orthogonals. //! From GLM_GTX_vector_query extensions. template bool areOrthogonal( - const genType & v0, - const genType & v1, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if a vector is normalized. //! From GLM_GTX_vector_query extensions. template bool isNormalized( - const genType & v, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if a vector is null. //! From GLM_GTX_vector_query extensions. template bool isNull( - const genType& v, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are orthonormal. //! From GLM_GTX_vector_query extensions. template bool areOrthonormal( - const genType & v0, - const genType & v1, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); //! Check if two vectors are similar. //! From GLM_GTX_vector_query extensions. template bool areSimilar( - const genType& v0, - const genType& v1, - const GLMvalType epsilon = std::numeric_limits::epsilon()); + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); ///@} diff --git a/glm/gtx/vector_query.inl b/glm/gtx/vector_query.inl index b1e76ae2..f9d02199 100644 --- a/glm/gtx/vector_query.inl +++ b/glm/gtx/vector_query.inl @@ -17,77 +17,100 @@ namespace gtx{ namespace vector_query { template - inline bool areCollinear( - const detail::tvec2& v0, - const detail::tvec2& v1, - const T epsilon) + inline bool areCollinear + ( + detail::tvec2 const & v0, + detail::tvec2 const & v1, + T const & epsilon + ) { return length(cross(detail::tvec3(v0, T(0)), detail::tvec3(v1, T(0)))) < epsilon; } template - inline bool areCollinear( - const detail::tvec3& v0, - const detail::tvec3& v1, - const T epsilon) + inline bool areCollinear + ( + detail::tvec3 const & v0, + detail::tvec3 const & v1, + T const & epsilon + ) { return length(cross(v0, v1)) < epsilon; } template - inline bool areCollinear( - const detail::tvec4& v0, - const detail::tvec4& v1, - const T epsilon) + inline bool areCollinear + ( + detail::tvec4 const & v0, + detail::tvec4 const & v1, + T const & epsilon + ) { return length(cross(detail::tvec3(v0), detail::tvec3(v1))) < epsilon; } template - inline bool areOpposite( - const genType& v0, - const genType& v1, - const GLMvalType epsilon) + inline bool areOpposite + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) { assert(isNormalized(v0) && isNormalized(v1)); - return((genType::value_type(1) + dot(v0, v1)) <= epsilon); + return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon); } template - inline bool areOrthogonal( - const genType& v0, - const genType& v1, - const GLMvalType epsilon) + inline bool areOrthogonal + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) { - return abs(dot(v0, v1)) <= max(GLMvalType(1), length(v0)) * max(GLMvalType(1), length(v1)) * epsilon; + return abs(dot(v0, v1)) <= max( + typename genType::value_type(1), + length(v0)) * max( + typename genType::value_type(1), + length(v1)) * epsilon; } template - inline bool isNormalized( - const genType& v, - const GLMvalType epsilon) + inline bool isNormalized + ( + genType const & v, + typename genType::value_type const & epsilon + ) { return abs(length(v) - GLMvalType(1)) <= GLMvalType(2) * epsilon; } template - inline bool isNull(const genType& v, const GLMvalType epsilon) + inline bool isNull + ( + genType const & v, + typename genType::value_type const & epsilon + ) { return length(v) <= epsilon; } template - inline bool isCompNull( - const T s, - const T epsilon) + inline bool isCompNull + ( + T const & s, + T const & epsilon + ) { return abs(s) < epsilon; } template - inline detail::tvec2 isCompNull( - const detail::tvec2& v, - const T epsilon) + inline detail::tvec2 isCompNull + ( + detail::tvec2 const & v, + T const & epsilon) { return detail::tvec2( (abs(v.x) < epsilon), @@ -95,9 +118,11 @@ namespace vector_query } template - inline detail::tvec3 isCompNull( - const detail::tvec3& v, - const T epsilon) + inline detail::tvec3 isCompNull + ( + detail::tvec3 const & v, + T const & epsilon + ) { return detail::tvec3( abs(v.x) < epsilon, @@ -106,9 +131,11 @@ namespace vector_query } template - inline detail::tvec4 isCompNull( - const detail::tvec4& v, - const T epsilon) + inline detail::tvec4 isCompNull + ( + detail::tvec4 const & v, + T const & epsilon + ) { return detail::tvec4( abs(v.x) < epsilon, @@ -118,19 +145,23 @@ namespace vector_query } template - inline bool areOrthonormal( - const genType& v0, - const genType& v1, - const GLMvalType epsilon) + inline bool areOrthonormal + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) { return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); } template - inline bool areSimilar( - const genType& v0, - const genType& v1, - const GLMvalType epsilon) + inline bool areSimilar + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) { bool similar = true; for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)