diff --git a/.gitignore b/.gitignore index b726899f..f4aa2549 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ # CMake CMakeCache.txt CMakeFiles -Makefile cmake_install.cmake install_manifest.txt *.cmake @@ -43,5 +42,9 @@ Testing/* test/gtc/*.dds # Project Files +Makefile *.cbp *.user + +# Misc. +*.log diff --git a/doc/glm.docx b/doc/glm.docx index 00101b37..387d51f7 100644 Binary files a/doc/glm.docx and b/doc/glm.docx differ diff --git a/doc/glm.pdf b/doc/glm.pdf index 8b67446a..00c0b772 100644 Binary files a/doc/glm.pdf and b/doc/glm.pdf differ diff --git a/doc/man.doxy b/doc/man.doxy index d0379e34..faa82852 100644 --- a/doc/man.doxy +++ b/doc/man.doxy @@ -51,7 +51,7 @@ PROJECT_BRIEF = # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = E:/Source/G-Truc/glm/doc/logo.png +PROJECT_LOGO = D:/Source/G-Truc/glm/doc/logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is diff --git a/glm/detail/dummy.cpp b/glm/detail/dummy.cpp index 50342809..09a2ae59 100644 --- a/glm/detail/dummy.cpp +++ b/glm/detail/dummy.cpp @@ -1,232 +1,232 @@ -/////////////////////////////////////////////////////////////////////////////////// -/// OpenGL Mathematics (glm.g-truc.net) -/// -/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to deal -/// in the Software without restriction, including without limitation the rights -/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/// copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// Restrictions: -/// By making use of the Software for military purposes, you choose to make -/// a Bunny unhappy. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -/// THE SOFTWARE. -/// -/// @ref core -/// @file glm/core/dummy.cpp -/// @date 2011-01-19 / 2011-06-15 -/// @author Christophe Riccio -/// -/// GLM is a header only library. There is nothing to compile. -/// dummy.cpp exist only a wordaround for CMake file. -/////////////////////////////////////////////////////////////////////////////////// - -#define GLM_MESSAGES -#include -#include -#include - -struct material -{ - glm::vec4 emission; // Ecm - glm::vec4 ambient; // Acm - glm::vec4 diffuse; // Dcm - glm::vec4 specular; // Scm - float shininess; // Srm -}; - -struct light -{ - glm::vec4 ambient; // Acli - glm::vec4 diffuse; // Dcli - glm::vec4 specular; // Scli - glm::vec4 position; // Ppli - glm::vec4 halfVector; // Derived: Hi - glm::vec3 spotDirection; // Sdli - float spotExponent; // Srli - float spotCutoff; // Crli - // (range: [0.0,90.0], 180.0) - float spotCosCutoff; // Derived: cos(Crli) - // (range: [1.0,0.0],-1.0) - float constantAttenuation; // K0 - float linearAttenuation; // K1 - float quadraticAttenuation;// K2 -}; - - -// Sample 1 -#include // glm::vec3 -#include // glm::cross, glm::normalize - -glm::vec3 computeNormal -( - glm::vec3 const & a, - glm::vec3 const & b, - glm::vec3 const & c -) -{ - return glm::normalize(glm::cross(c - a, b - a)); -} - -typedef unsigned int GLuint; -#define GL_FALSE 0 -void glUniformMatrix4fv(GLuint, int, int, float*){} - -// Sample 2 -#include // glm::vec3 -#include // glm::vec4, glm::ivec4 -#include // glm::mat4 -#include // glm::translate, glm::rotate, glm::scale, glm::perspective -#include // glm::value_ptr -void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate) -{ - glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); - glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); - glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); - glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); - glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); - glm::mat4 MVP = Projection * View * Model; - glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); -} - -// Sample 3 -#include // glm::vec2 -#include // glm::packUnorm2x16 -#include // glm::uint -#include // glm::i8vec2, glm::i32vec2 -std::size_t const VertexCount = 4; -// Float quad geometry -std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); -glm::vec2 const PositionDataF32[VertexCount] = -{ - glm::vec2(-1.0f,-1.0f), - glm::vec2( 1.0f,-1.0f), - glm::vec2( 1.0f, 1.0f), - glm::vec2(-1.0f, 1.0f) - }; -// Half-float quad geometry -std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint); -glm::uint const PositionDataF16[VertexCount] = -{ - glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))), - glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))), - glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))), - glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f))) -}; -// 8 bits signed integer quad geometry -std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); -glm::i8vec2 const PositionDataI8[VertexCount] = -{ - glm::i8vec2(-1,-1), - glm::i8vec2( 1,-1), - glm::i8vec2( 1, 1), - glm::i8vec2(-1, 1) -}; -// 32 bits signed integer quad geometry -std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); -glm::i32vec2 const PositionDataI32[VertexCount] = -{ - glm::i32vec2 (-1,-1), - glm::i32vec2 ( 1,-1), - glm::i32vec2 ( 1, 1), - glm::i32vec2 (-1, 1) -}; - -struct intersection -{ - glm::vec4 position; - glm::vec3 normal; -}; - -/* -// Sample 4 -#include // glm::vec3 -#include // glm::normalize, glm::dot, glm::reflect -#include // glm::pow -#include // glm::vecRand3 -glm::vec3 lighting -( - intersection const & Intersection, - material const & Material, - light const & Light, - glm::vec3 const & View -) -{ - glm::vec3 Color(0.0f); - glm::vec3 LightVertor(glm::normalize( - Light.position - Intersection.position + - glm::vecRand3(0.0f, Light.inaccuracy)); - - if(!shadow(Intersection.position, Light.position, LightVertor)) - { - float Diffuse = glm::dot(Intersection.normal, LightVector); - if(Diffuse <= 0.0f) - return Color; - if(Material.isDiffuse()) - Color += Light.color() * Material.diffuse * Diffuse; - if(Material.isSpecular()) - { - glm::vec3 Reflect(glm::reflect( - glm::normalize(-LightVector), - glm::normalize(Intersection.normal))); - float Dot = glm::dot(Reflect, View); - float Base = Dot > 0.0f ? Dot : 0.0f; - float Specular = glm::pow(Base, Material.exponent); - Color += Material.specular * Specular; - } - } - return Color; -} -*/ - - -template class vecType> -T normalizeDotA(vecType const & x, vecType const & y) -{ - return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); -} - -#define GLM_TEMPLATE_GENTYPE typename T, glm::precision P, template class - -template -T normalizeDotB(vecType const & x, vecType const & y) -{ - return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); -} - -template -typename vecType::value_type normalizeDotC(vecType const & a, vecType const & b) -{ - return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b)); -} - -int main() -{ - glm::vec1 o(1); - glm::vec2 a(1); - glm::vec3 b(1); - glm::vec4 c(1); - - glm::quat q; - glm::dualquat p; - - glm::mat4 m(1); - - float a0 = normalizeDotA(a, a); - float b0 = normalizeDotB(b, b); - float c0 = normalizeDotC(c, c); - - return 0; -} +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/dummy.cpp +/// @date 2011-01-19 / 2011-06-15 +/// @author Christophe Riccio +/// +/// GLM is a header only library. There is nothing to compile. +/// dummy.cpp exist only a wordaround for CMake file. +/////////////////////////////////////////////////////////////////////////////////// + +#define GLM_MESSAGES +#include +#include +#include + +struct material +{ + glm::vec4 emission; // Ecm + glm::vec4 ambient; // Acm + glm::vec4 diffuse; // Dcm + glm::vec4 specular; // Scm + float shininess; // Srm +}; + +struct light +{ + glm::vec4 ambient; // Acli + glm::vec4 diffuse; // Dcli + glm::vec4 specular; // Scli + glm::vec4 position; // Ppli + glm::vec4 halfVector; // Derived: Hi + glm::vec3 spotDirection; // Sdli + float spotExponent; // Srli + float spotCutoff; // Crli + // (range: [0.0,90.0], 180.0) + float spotCosCutoff; // Derived: cos(Crli) + // (range: [1.0,0.0],-1.0) + float constantAttenuation; // K0 + float linearAttenuation; // K1 + float quadraticAttenuation;// K2 +}; + + +// Sample 1 +#include // glm::vec3 +#include // glm::cross, glm::normalize + +glm::vec3 computeNormal +( + glm::vec3 const & a, + glm::vec3 const & b, + glm::vec3 const & c +) +{ + return glm::normalize(glm::cross(c - a, b - a)); +} + +typedef unsigned int GLuint; +#define GL_FALSE 0 +void glUniformMatrix4fv(GLuint, int, int, float*){} + +// Sample 2 +#include // glm::vec3 +#include // glm::vec4, glm::ivec4 +#include // glm::mat4 +#include // glm::translate, glm::rotate, glm::scale, glm::perspective +#include // glm::value_ptr +void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate) +{ + glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); + glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); + glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); + glm::mat4 MVP = Projection * View * Model; + glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); +} + +// Sample 3 +#include // glm::vec2 +#include // glm::packUnorm2x16 +#include // glm::uint +#include // glm::i8vec2, glm::i32vec2 +std::size_t const VertexCount = 4; +// Float quad geometry +std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); +glm::vec2 const PositionDataF32[VertexCount] = +{ + glm::vec2(-1.0f,-1.0f), + glm::vec2( 1.0f,-1.0f), + glm::vec2( 1.0f, 1.0f), + glm::vec2(-1.0f, 1.0f) + }; +// Half-float quad geometry +std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint); +glm::uint const PositionDataF16[VertexCount] = +{ + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f))) +}; +// 8 bits signed integer quad geometry +std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); +glm::i8vec2 const PositionDataI8[VertexCount] = +{ + glm::i8vec2(-1,-1), + glm::i8vec2( 1,-1), + glm::i8vec2( 1, 1), + glm::i8vec2(-1, 1) +}; +// 32 bits signed integer quad geometry +std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); +glm::i32vec2 const PositionDataI32[VertexCount] = +{ + glm::i32vec2 (-1,-1), + glm::i32vec2 ( 1,-1), + glm::i32vec2 ( 1, 1), + glm::i32vec2 (-1, 1) +}; + +struct intersection +{ + glm::vec4 position; + glm::vec3 normal; +}; + +/* +// Sample 4 +#include // glm::vec3 +#include // glm::normalize, glm::dot, glm::reflect +#include // glm::pow +#include // glm::vecRand3 +glm::vec3 lighting +( + intersection const & Intersection, + material const & Material, + light const & Light, + glm::vec3 const & View +) +{ + glm::vec3 Color(0.0f); + glm::vec3 LightVertor(glm::normalize( + Light.position - Intersection.position + + glm::vecRand3(0.0f, Light.inaccuracy)); + + if(!shadow(Intersection.position, Light.position, LightVertor)) + { + float Diffuse = glm::dot(Intersection.normal, LightVector); + if(Diffuse <= 0.0f) + return Color; + if(Material.isDiffuse()) + Color += Light.color() * Material.diffuse * Diffuse; + if(Material.isSpecular()) + { + glm::vec3 Reflect(glm::reflect( + glm::normalize(-LightVector), + glm::normalize(Intersection.normal))); + float Dot = glm::dot(Reflect, View); + float Base = Dot > 0.0f ? Dot : 0.0f; + float Specular = glm::pow(Base, Material.exponent); + Color += Material.specular * Specular; + } + } + return Color; +} +*/ + + +template class vecType> +T normalizeDotA(vecType const & x, vecType const & y) +{ + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); +} + +#define GLM_TEMPLATE_GENTYPE typename T, glm::precision P, template class + +template +T normalizeDotB(vecType const & x, vecType const & y) +{ + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); +} + +template +typename vecType::value_type normalizeDotC(vecType const & a, vecType const & b) +{ + return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b)); +} + +int main() +{ + glm::vec1 o(1); + glm::vec2 a(1); + glm::vec3 b(1); + glm::vec4 c(1); + + glm::quat q; + glm::dualquat p; + + glm::mat4 m(1); + + float a0 = normalizeDotA(a, a); + float b0 = normalizeDotB(b, b); + float c0 = normalizeDotC(c, c); + + return 0; +} diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 0673718b..6c1663d3 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -86,7 +86,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType length(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' accepts only floating-point inputs"); return abs(x); } @@ -94,7 +94,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER T length(vecType const & v) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' accepts only floating-point inputs"); return sqrt(dot(v, v)); } @@ -103,7 +103,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType distance(genType const & p0, genType const & p1) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'distance' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'distance' accepts only floating-point inputs"); return length(p1 - p0); } @@ -118,14 +118,14 @@ namespace detail template GLM_FUNC_QUALIFIER T dot(T x, T y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); return x * y; } template class vecType> GLM_FUNC_QUALIFIER T dot(vecType const & x, vecType const & y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); return detail::compute_dot::call(x, y); } @@ -133,7 +133,7 @@ namespace detail template GLM_FUNC_QUALIFIER tvec3 cross(tvec3 const & x, tvec3 const & y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' accepts only floating-point inputs"); return tvec3( x.y * y.z - y.y * x.z, @@ -145,7 +145,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType normalize(genType const & x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); return x < genType(0) ? genType(-1) : genType(1); } @@ -153,7 +153,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType normalize(vecType const & x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); return x * inversesqrt(dot(x, x)); } @@ -182,7 +182,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType refract(genType const & I, genType const & N, genType const & eta) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' accepts only floating-point inputs"); genType const dotValue(dot(N, I)); genType const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); @@ -192,7 +192,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType refract(vecType const & I, vecType const & N, T eta) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' accepts only floating-point inputs"); T const dotValue(dot(N, I)); T const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); diff --git a/glm/detail/func_noise.hpp b/glm/detail/func_noise.hpp deleted file mode 100644 index a8270879..00000000 --- a/glm/detail/func_noise.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -/// OpenGL Mathematics (glm.g-truc.net) -/// -/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to deal -/// in the Software without restriction, including without limitation the rights -/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/// copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// Restrictions: -/// By making use of the Software for military purposes, you choose to make -/// a Bunny unhappy. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -/// THE SOFTWARE. -/// -/// @ref core -/// @file glm/detail/func_noise.hpp -/// @date 2008-08-01 / 2011-06-18 -/// @author Christophe Riccio -/// -/// @see GLSL 4.20.8 specification, section 8.13 Noise Functions -/// -/// @defgroup core_func_noise Noise functions -/// @ingroup core -/// -/// Noise functions are stochastic functions that can be used to increase visual -/// complexity. Values returned by the following noise functions give the -/// appearance of randomness, but are not truly random. -/////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "type_vec1.hpp" -#include "type_vec2.hpp" -#include "type_vec3.hpp" -#include "setup.hpp" - -namespace glm -{ - /// @addtogroup core_func_noise - /// @{ - - /// Returns a 1D noise value based on the input value x. - /// - /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise1 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions - template - GLM_FUNC_DECL typename genType::value_type noise1(genType const & x); - - /// Returns a 2D noise value based on the input value x. - /// - /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise2 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions - template - GLM_FUNC_DECL tvec2 noise2(genType const & x); - - /// Returns a 3D noise value based on the input value x. - /// - /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise3 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions - template - GLM_FUNC_DECL tvec3 noise3(genType const & x); - - /// Returns a 4D noise value based on the input value x. - /// - /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise4 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions - template - GLM_FUNC_DECL tvec4 noise4(genType const & x); - - /// @} -}//namespace glm - -#include "func_noise.inl" diff --git a/glm/detail/func_noise.inl b/glm/detail/func_noise.inl deleted file mode 100644 index 10901e69..00000000 --- a/glm/detail/func_noise.inl +++ /dev/null @@ -1,388 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -/// OpenGL Mathematics (glm.g-truc.net) -/// -/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to deal -/// in the Software without restriction, including without limitation the rights -/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/// copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// Restrictions: -/// By making use of the Software for military purposes, you choose to make -/// a Bunny unhappy. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -/// THE SOFTWARE. -/// -/// @ref core -/// @file glm/detail/func_noise.inl -/// @date 2008-08-01 / 2011-09-27 -/// @author Christophe Riccio -/////////////////////////////////////////////////////////////////////////////////// - -#include "../detail/_noise.hpp" -#include "./func_common.hpp" - -namespace glm{ -namespace detail -{ - template - GLM_FUNC_QUALIFIER tvec4 grad4(T const & j, tvec4 const & ip) - { - tvec3 pXYZ = floor(fract(tvec3(j) * tvec3(ip)) * T(7)) * ip[2] - T(1); - T pW = static_cast(1.5) - dot(abs(pXYZ), tvec3(1)); - tvec4 s = tvec4(lessThan(tvec4(pXYZ, pW), tvec4(0.0))); - pXYZ = pXYZ + (tvec3(s) * T(2) - T(1)) * s.w; - return tvec4(pXYZ, pW); - } -}//namespace detail - - template - GLM_FUNC_QUALIFIER T noise1(T const & x) - { - return noise1(tvec2(x, T(0))); - } - - template - GLM_FUNC_QUALIFIER tvec2 noise2(T const & x) - { - return tvec2( - noise1(x + T(0.0)), - noise1(x + T(1.0))); - } - - template - GLM_FUNC_QUALIFIER tvec3 noise3(T const & x) - { - return tvec3( - noise1(x - T(1.0)), - noise1(x + T(0.0)), - noise1(x + T(1.0))); - } - - template - GLM_FUNC_QUALIFIER tvec4 noise4(T const & x) - { - return tvec4( - noise1(x - T(1.0)), - noise1(x + T(0.0)), - noise1(x + T(1.0)), - noise1(x + T(2.0))); - } - - template - GLM_FUNC_QUALIFIER T noise1(tvec2 const & v) - { - tvec4 const C = tvec4( - T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0 - T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0) - T(-0.577350269189626), // -1.0 + 2.0 * C.x - T( 0.024390243902439)); // 1.0 / 41.0 - - // First corner - tvec2 i = floor(v + dot(v, tvec2(C[1]))); - tvec2 x0 = v - i + dot(i, tvec2(C[0])); - - // Other corners - //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 - //i1.y = 1.0 - i1.x; - tvec2 i1 = (x0.x > x0.y) ? tvec2(1, 0) : tvec2(0, 1); - - // x0 = x0 - 0.0 + 0.0 * C.xx ; - // x1 = x0 - i1 + 1.0 * C.xx ; - // x2 = x0 - 1.0 + 2.0 * C.xx ; - tvec4 x12 = tvec4(x0.x, x0.y, x0.x, x0.y) + tvec4(C.x, C.x, C.z, C.z); - x12 = tvec4(tvec2(x12) - i1, x12.z, x12.w); - - // Permutations - i = mod(i, T(289)); // Avoid truncation effects in permutation - tvec3 p = detail::permute( - detail::permute(i.y + tvec3(T(0), i1.y, T(1))) + i.x + tvec3(T(0), i1.x, T(1))); - - tvec3 m = max(T(0.5) - tvec3( - dot(x0, x0), - dot(tvec2(x12.x, x12.y), tvec2(x12.x, x12.y)), - dot(tvec2(x12.z, x12.w), tvec2(x12.z, x12.w))), T(0)); - - m = m * m; - m = m * m; - - // Gradients: 41 points uniformly over a line, mapped onto a diamond. - // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) - - tvec3 x = static_cast(2) * fract(p * C.w) - T(1); - tvec3 h = abs(x) - T(0.5); - tvec3 ox = floor(x + T(0.5)); - tvec3 a0 = x - ox; - - // Normalise gradients implicitly by scaling m - // Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h ); - m *= static_cast(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h); - - // Compute final noise value at P - tvec3 g; - g.x = a0.x * x0.x + h.x * x0.y; - //g.yz = a0.yz * x12.xz + h.yz * x12.yw; - g.y = a0.y * x12.x + h.y * x12.y; - g.z = a0.z * x12.z + h.z * x12.w; - return T(130) * dot(m, g); - } - - template - GLM_FUNC_QUALIFIER T noise1(tvec3 const & v) - { - tvec2 const C(1.0 / 6.0, 1.0 / 3.0); - tvec4 const D(0.0, 0.5, 1.0, 2.0); - - // First corner - tvec3 i(floor(v + dot(v, tvec3(C.y)))); - tvec3 x0(v - i + dot(i, tvec3(C.x))); - - // Other corners - tvec3 g(step(tvec3(x0.y, x0.z, x0.x), x0)); - tvec3 l(T(1) - g); - tvec3 i1(min(g, tvec3(l.z, l.x, l.y))); - tvec3 i2(max(g, tvec3(l.z, l.x, l.y))); - - // x0 = x0 - 0.0 + 0.0 * C.xxx; - // x1 = x0 - i1 + 1.0 * C.xxx; - // x2 = x0 - i2 + 2.0 * C.xxx; - // x3 = x0 - 1.0 + 3.0 * C.xxx; - tvec3 x1(x0 - i1 + C.x); - tvec3 x2(x0 - i2 + C.y); // 2.0*C.x = 1/3 = C.y - tvec3 x3(x0 - D.y); // -1.0+3.0*C.x = -0.5 = -D.y - - // Permutations - i = mod289(i); - tvec4 p(detail::permute(detail::permute(detail::permute( - i.z + tvec4(T(0), i1.z, i2.z, T(1))) + - i.y + tvec4(T(0), i1.y, i2.y, T(1))) + - i.x + tvec4(T(0), i1.x, i2.x, T(1)))); - - // Gradients: 7x7 points over a square, mapped onto an octahedron. - // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) - T n_ = static_cast(0.142857142857); // 1.0/7.0 - tvec3 ns(n_ * tvec3(D.w, D.y, D.z) - tvec3(D.x, D.z, D.x)); - - tvec4 j(p - T(49) * floor(p * ns.z * ns.z)); // mod(p,7*7) - - tvec4 x_(floor(j * ns.z)); - tvec4 y_(floor(j - T(7) * x_)); // mod(j,N) - - tvec4 x(x_ * ns.x + ns.y); - tvec4 y(y_ * ns.x + ns.y); - tvec4 h(T(1) - abs(x) - abs(y)); - - tvec4 b0(x.x, x.y, y.x, y.y); - tvec4 b1(x.z, x.w, y.z, y.w); - - // vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; - // vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; - tvec4 s0(floor(b0) * T(2) + T(1)); - tvec4 s1(floor(b1) * T(2) + T(1)); - tvec4 sh(-step(h, tvec4(0.0))); - - tvec4 a0 = tvec4(b0.x, b0.z, b0.y, b0.w) + tvec4(s0.x, s0.z, s0.y, s0.w) * tvec4(sh.x, sh.x, sh.y, sh.y); - tvec4 a1 = tvec4(b1.x, b1.z, b1.y, b1.w) + tvec4(s1.x, s1.z, s1.y, s1.w) * tvec4(sh.z, sh.z, sh.w, sh.w); - - tvec3 p0(a0.x, a0.y, h.x); - tvec3 p1(a0.z, a0.w, h.y); - tvec3 p2(a1.x, a1.y, h.z); - tvec3 p3(a1.z, a1.w, h.w); - - // Normalise gradients - tvec4 norm = taylorInvSqrt(tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - // Mix final noise value - tvec4 m = max(T(0.6) - tvec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), T(0)); - m = m * m; - return T(42) * dot(m * m, tvec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); - } - - template - GLM_FUNC_QUALIFIER T noise1(tvec4 const & v) - { - tvec4 const C( - 0.138196601125011, // (5 - sqrt(5))/20 G4 - 0.276393202250021, // 2 * G4 - 0.414589803375032, // 3 * G4 - -0.447213595499958); // -1 + 4 * G4 - - // (sqrt(5) - 1)/4 = F4, used once below - T const F4 = static_cast(0.309016994374947451); - - // First corner - tvec4 i = floor(v + dot(v, tvec4(F4))); - tvec4 x0 = v - i + dot(i, tvec4(C.x)); - - // Other corners - - // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) - tvec4 i0; - tvec3 isX = step(tvec3(x0.y, x0.z, x0.w), tvec3(x0.x)); - tvec3 isYZ = step(tvec3(x0.z, x0.w, x0.w), tvec3(x0.y, x0.y, x0.z)); - - // i0.x = dot(isX, vec3(1.0)); - //i0.x = isX.x + isX.y + isX.z; - //i0.yzw = static_cast(1) - isX; - i0 = tvec4(isX.x + isX.y + isX.z, T(1) - isX); - - // i0.y += dot(isYZ.xy, vec2(1.0)); - i0.y += isYZ.x + isYZ.y; - - //i0.zw += 1.0 - tvec2(isYZ.x, isYZ.y); - i0.z += static_cast(1) - isYZ.x; - i0.w += static_cast(1) - isYZ.y; - i0.z += isYZ.z; - i0.w += static_cast(1) - isYZ.z; - - // i0 now contains the unique values 0,1,2,3 in each channel - tvec4 i3 = clamp(i0, T(0), T(1)); - tvec4 i2 = clamp(i0 - T(1), T(0), T(1)); - tvec4 i1 = clamp(i0 - T(2), T(0), T(1)); - - // x0 = x0 - 0.0 + 0.0 * C.xxxx - // x1 = x0 - i1 + 0.0 * C.xxxx - // x2 = x0 - i2 + 0.0 * C.xxxx - // x3 = x0 - i3 + 0.0 * C.xxxx - // x4 = x0 - 1.0 + 4.0 * C.xxxx - tvec4 x1 = x0 - i1 + C.x; - tvec4 x2 = x0 - i2 + C.y; - tvec4 x3 = x0 - i3 + C.z; - tvec4 x4 = x0 + C.w; - - // Permutations - i = mod(i, T(289)); - T j0 = detail::permute(detail::permute(detail::permute(detail::permute(i.w) + i.z) + i.y) + i.x); - tvec4 j1 = detail::permute(detail::permute(detail::permute(detail::permute( - i.w + tvec4(i1.w, i2.w, i3.w, T(1))) + - i.z + tvec4(i1.z, i2.z, i3.z, T(1))) + - i.y + tvec4(i1.y, i2.y, i3.y, T(1))) + - i.x + tvec4(i1.x, i2.x, i3.x, T(1))); - - // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope - // 7*7*6 = 294, which is close to the ring size 17*17 = 289. - tvec4 ip = tvec4(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0)); - - tvec4 p0 = detail::grad4(j0, ip); - tvec4 p1 = detail::grad4(j1.x, ip); - tvec4 p2 = detail::grad4(j1.y, ip); - tvec4 p3 = detail::grad4(j1.z, ip); - tvec4 p4 = detail::grad4(j1.w, ip); - - // Normalise gradients - tvec4 norm = detail::taylorInvSqrt(tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - p4 *= taylorInvSqrt(dot(p4, p4)); - - // Mix contributions from the five corners - tvec3 m0 = max(T(0.6) - tvec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0)); - tvec2 m1 = max(T(0.6) - tvec2(dot(x3, x3), dot(x4, x4) ), T(0)); - m0 = m0 * m0; - m1 = m1 * m1; - - return T(49) * ( - dot(m0 * m0, tvec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) + - dot(m1 * m1, tvec2(dot(p3, x3), dot(p4, x4)))); - } - - template - GLM_FUNC_QUALIFIER tvec2 noise2(tvec2 const & x) - { - return tvec2( - noise1(x + tvec2(0.0)), - noise1(tvec2(0.0) - x)); - } - - template - GLM_FUNC_QUALIFIER tvec2 noise2(tvec3 const & x) - { - return tvec2( - noise1(x + tvec3(0.0)), - noise1(tvec3(0.0) - x)); - } - - template - GLM_FUNC_QUALIFIER tvec2 noise2(tvec4 const & x) - { - return tvec2( - noise1(x + tvec4(0)), - noise1(tvec4(0) - x)); - } - - template - GLM_FUNC_QUALIFIER tvec3 noise3(tvec2 const & x) - { - return tvec3( - noise1(x - tvec2(1.0)), - noise1(x + tvec2(0.0)), - noise1(x + tvec2(1.0))); - } - - template - GLM_FUNC_QUALIFIER tvec3 noise3(tvec3 const & x) - { - return tvec3( - noise1(x - tvec3(1.0)), - noise1(x + tvec3(0.0)), - noise1(x + tvec3(1.0))); - } - - template - GLM_FUNC_QUALIFIER tvec3 noise3(tvec4 const & x) - { - return tvec3( - noise1(x - tvec4(1)), - noise1(x + tvec4(0)), - noise1(x + tvec4(1))); - } - - template - GLM_FUNC_QUALIFIER tvec4 noise4(tvec2 const & x) - { - return tvec4( - noise1(x - tvec2(1)), - noise1(x + tvec2(0)), - noise1(x + tvec2(1)), - noise1(x + tvec2(2))); - } - - - template - GLM_FUNC_QUALIFIER tvec4 noise4(tvec3 const & x) - { - return tvec4( - noise1(x - tvec3(1)), - noise1(x + tvec3(0)), - noise1(x + tvec3(1)), - noise1(x + tvec3(2))); - } - - template - GLM_FUNC_QUALIFIER tvec4 noise4(tvec4 const & x) - { - return tvec4( - noise1(x - tvec4(1)), - noise1(x + tvec4(0)), - noise1(x + tvec4(1)), - noise1(x + tvec4(2))); - } - -}//namespace glm diff --git a/glm/detail/func_trigonometric.hpp b/glm/detail/func_trigonometric.hpp index d43961ba..24434977 100644 --- a/glm/detail/func_trigonometric.hpp +++ b/glm/detail/func_trigonometric.hpp @@ -58,7 +58,7 @@ namespace glm /// @see GLSL radians man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template class vecType> - GLM_FUNC_DECL vecType radians(vecType const & degrees); + GLM_FUNC_DECL GLM_CONSTEXPR vecType radians(vecType const & degrees); /// Converts radians to degrees and returns the result. /// @@ -67,7 +67,7 @@ namespace glm /// @see GLSL degrees man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template class vecType> - GLM_FUNC_DECL vecType degrees(vecType const & radians); + GLM_FUNC_DECL GLM_CONSTEXPR vecType degrees(vecType const & radians); /// The standard trigonometric sine function. /// The values returned by this function will range from [-1, 1]. diff --git a/glm/detail/func_trigonometric.inl b/glm/detail/func_trigonometric.inl index a7105250..f723de47 100644 --- a/glm/detail/func_trigonometric.inl +++ b/glm/detail/func_trigonometric.inl @@ -38,7 +38,7 @@ namespace glm { // radians template - GLM_FUNC_QUALIFIER genType radians(genType degrees) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType radians(genType degrees) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'radians' only accept floating-point input"); @@ -46,14 +46,14 @@ namespace glm } template class vecType> - GLM_FUNC_QUALIFIER vecType radians(vecType const & v) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType radians(vecType const & v) { return detail::functor1::call(radians, v); } // degrees template - GLM_FUNC_QUALIFIER genType degrees(genType radians) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType degrees(genType radians) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'degrees' only accept floating-point input"); @@ -61,7 +61,7 @@ namespace glm } template class vecType> - GLM_FUNC_QUALIFIER vecType degrees(vecType const & v) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType degrees(vecType const & v) { return detail::functor1::call(degrees, v); } diff --git a/glm/detail/precision.hpp b/glm/detail/precision.hpp index 2be5e238..32785b94 100644 --- a/glm/detail/precision.hpp +++ b/glm/detail/precision.hpp @@ -39,6 +39,15 @@ namespace glm highp, mediump, lowp, + simd, defaultp = highp }; + + template class genType> + struct type + { + static bool const is_vec = false; + static bool const is_mat = false; + static bool const is_quat = false; + }; }//namespace glm diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index b91a77ee..526abddd 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -38,15 +38,15 @@ /////////////////////////////////////////////////////////////////////////////////// // Version -#define GLM_VERSION 97 +#define GLM_VERSION 98 #define GLM_VERSION_MAJOR 0 #define GLM_VERSION_MINOR 9 -#define GLM_VERSION_PATCH 7 +#define GLM_VERSION_PATCH 8 #define GLM_VERSION_REVISION 0 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_VERSION_DISPLAYED)) # define GLM_MESSAGE_VERSION_DISPLAYED -# pragma message ("GLM: version 0.9.7.0") +# pragma message ("GLM: version 0.9.8.0") #endif//GLM_MESSAGE /////////////////////////////////////////////////////////////////////////////////// @@ -366,6 +366,121 @@ # endif//GLM_MODEL #endif//GLM_MESSAGE +/////////////////////////////////////////////////////////////////////////////////// +// Platform + +// User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_SSE3 GLM_FORCE_AVX GLM_FORCE_AVX2 + +#define GLM_ARCH_PURE 0x0000 +#define GLM_ARCH_ARM 0x0001 +#define GLM_ARCH_X86 0x0002 +#define GLM_ARCH_SSE2 0x0004 +#define GLM_ARCH_SSE3 0x0008 +#define GLM_ARCH_SSE4 0x0010 +#define GLM_ARCH_AVX 0x0020 +#define GLM_ARCH_AVX2 0x0040 + +#if defined(GLM_FORCE_PURE) +# define GLM_ARCH GLM_ARCH_PURE +#elif defined(GLM_FORCE_AVX2) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +#elif defined(GLM_FORCE_AVX) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +#elif defined(GLM_FORCE_SSE4) +# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +#elif defined(GLM_FORCE_SSE3) +# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +#elif defined(GLM_FORCE_SSE2) +# define GLM_ARCH (GLM_ARCH_SSE2) +#elif (GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM | GLM_COMPILER_GCC)) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_LINUX)) +# if(__AVX2__) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif(__AVX__) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif(__SSE3__) +# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif(__SSE2__) +# define GLM_ARCH (GLM_ARCH_SSE2) +# else +# define GLM_ARCH GLM_ARCH_PURE +# endif +#elif (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)) +# if defined(_M_ARM_FP) +# define GLM_ARCH (GLM_ARCH_ARM) +# elif defined(__AVX2__) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__AVX__) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif _M_IX86_FP == 2 +# define GLM_ARCH (GLM_ARCH_SSE2) +# else +# define GLM_ARCH (GLM_ARCH_PURE) +# endif +#elif (GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__)) +# if defined(__AVX2__) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__AVX__) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE4_1__ ) +# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE3__) +# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE2__) +# define GLM_ARCH (GLM_ARCH_SSE2) +# else +# define GLM_ARCH (GLM_ARCH_PURE) +# endif +#else +# define GLM_ARCH GLM_ARCH_PURE +#endif + +// With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is +// that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems. +// To fix, we just explicitly include intrin.h here. +#if defined(__MINGW64__) && (GLM_ARCH != GLM_ARCH_PURE) +# include +#endif + +#if GLM_ARCH & GLM_ARCH_AVX2 +# include +#endif//GLM_ARCH +#if GLM_ARCH & GLM_ARCH_AVX +# include +#endif//GLM_ARCH +#if GLM_ARCH & GLM_ARCH_SSE4 +# include +#endif//GLM_ARCH +#if GLM_ARCH & GLM_ARCH_SSE3 +# include +#endif//GLM_ARCH +#if GLM_ARCH & GLM_ARCH_SSE2 +# include +# if(GLM_COMPILER == GLM_COMPILER_VC2005) // VC2005 is missing some intrinsics, workaround + inline float _mm_cvtss_f32(__m128 A) { return A.m128_f32[0]; } + inline __m128 _mm_castpd_ps(__m128d PD) { union { __m128 ps; __m128d pd; } c; c.pd = PD; return c.ps; } + inline __m128d _mm_castps_pd(__m128 PS) { union { __m128 ps; __m128d pd; } c; c.ps = PS; return c.pd; } + inline __m128i _mm_castps_si128(__m128 PS) { union { __m128 ps; __m128i pi; } c; c.ps = PS; return c.pi; } + inline __m128 _mm_castsi128_ps(__m128i PI) { union { __m128 ps; __m128i pi; } c; c.pi = PI; return c.ps; } +# endif +#endif//GLM_ARCH + +#if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED) +# define GLM_MESSAGE_ARCH_DISPLAYED +# if(GLM_ARCH == GLM_ARCH_PURE) +# pragma message("GLM: Platform independent code") +# elif(GLM_ARCH & GLM_ARCH_ARM) +# pragma message("GLM: ARM instruction set") +# elif(GLM_ARCH & GLM_ARCH_AVX2) +# pragma message("GLM: AVX2 instruction set") +# elif(GLM_ARCH & GLM_ARCH_AVX) +# pragma message("GLM: AVX instruction set") +# elif(GLM_ARCH & GLM_ARCH_SSE3) +# pragma message("GLM: SSE3 instruction set") +# elif(GLM_ARCH & GLM_ARCH_SSE2) +# pragma message("GLM: SSE2 instruction set") +# endif//GLM_ARCH +#endif//GLM_MESSAGE + /////////////////////////////////////////////////////////////////////////////////// // C++ Version @@ -561,9 +676,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_STATIC_ASSERT 1 #else -# define GLM_HAS_STATIC_ASSERT (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010)))) #endif // N1988 @@ -585,9 +700,9 @@ # define GLM_HAS_CONSTEXPR 1 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR #else -# define GLM_HAS_CONSTEXPR (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46))) -# define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)) +# define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)))) +# define GLM_HAS_CONSTEXPR_PARTIAL (GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015))) #endif // N2672 @@ -596,9 +711,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_INITIALIZER_LISTS 1 #else -# define GLM_HAS_INITIALIZER_LISTS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2544 Unrestricted unions @@ -617,10 +732,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_DEFAULTED_FUNCTIONS 1 #else -# define GLM_HAS_DEFAULTED_FUNCTIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \ - ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12))) + ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12)))) #endif // N2118 @@ -629,9 +744,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_RVALUE_REFERENCES 1 #else -# define GLM_HAS_RVALUE_REFERENCES (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)))) #endif // N2437 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf @@ -640,10 +755,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS 1 #else -# define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC45)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2258 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf @@ -652,10 +767,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_TEMPLATE_ALIASES 1 #else -# define GLM_HAS_TEMPLATE_ALIASES (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12_1)) || \ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2930 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html @@ -664,18 +779,18 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_RANGE_FOR 1 #else -# define GLM_HAS_RANGE_FOR (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL13)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)))) #endif // #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_ASSIGNABLE 1 #else -# define GLM_HAS_ASSIGNABLE (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49))) +# define GLM_HAS_ASSIGNABLE ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49)))) #endif // @@ -685,16 +800,15 @@ #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_MAKE_SIGNED 1 #else -# define GLM_HAS_MAKE_SIGNED (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) +# define GLM_HAS_MAKE_SIGNED ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif -// #if GLM_ARCH == GLM_ARCH_PURE # define GLM_HAS_BITSCAN_WINDOWS 0 #else -# define GLM_HAS_BITSCAN_WINDOWS (GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\ - (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_LLVM | GLM_COMPILER_INTEL)) +# define GLM_HAS_BITSCAN_WINDOWS ((GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\ + (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_LLVM | GLM_COMPILER_INTEL)))) #endif // OpenMP @@ -719,121 +833,6 @@ // Not standard #define GLM_HAS_ANONYMOUS_UNION (GLM_LANG & GLM_LANG_CXXMS_FLAG) -/////////////////////////////////////////////////////////////////////////////////// -// Platform - -// User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_SSE3 GLM_FORCE_AVX GLM_FORCE_AVX2 - -#define GLM_ARCH_PURE 0x0000 -#define GLM_ARCH_ARM 0x0001 -#define GLM_ARCH_X86 0x0002 -#define GLM_ARCH_SSE2 0x0004 -#define GLM_ARCH_SSE3 0x0008 -#define GLM_ARCH_SSE4 0x0010 -#define GLM_ARCH_AVX 0x0020 -#define GLM_ARCH_AVX2 0x0040 - -#if defined(GLM_FORCE_PURE) -# define GLM_ARCH GLM_ARCH_PURE -#elif defined(GLM_FORCE_AVX2) -# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -#elif defined(GLM_FORCE_AVX) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -#elif defined(GLM_FORCE_SSE4) -# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -#elif defined(GLM_FORCE_SSE3) -# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -#elif defined(GLM_FORCE_SSE2) -# define GLM_ARCH (GLM_ARCH_SSE2) -#elif (GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM | GLM_COMPILER_GCC)) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_LINUX)) -# if(__AVX2__) -# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif(__AVX__) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif(__SSE3__) -# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif(__SSE2__) -# define GLM_ARCH (GLM_ARCH_SSE2) -# else -# define GLM_ARCH GLM_ARCH_PURE -# endif -#elif (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)) -# if defined(_M_ARM_FP) -# define GLM_ARCH (GLM_ARCH_ARM) -# elif defined(__AVX2__) -# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif defined(__AVX__) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif _M_IX86_FP == 2 -# define GLM_ARCH (GLM_ARCH_SSE2) -# else -# define GLM_ARCH (GLM_ARCH_PURE) -# endif -#elif (GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__)) -# if defined(__AVX2__) -# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif defined(__AVX__) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif defined(__SSE4_1__ ) -# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif defined(__SSE3__) -# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) -# elif defined(__SSE2__) -# define GLM_ARCH (GLM_ARCH_SSE2) -# else -# define GLM_ARCH (GLM_ARCH_PURE) -# endif -#else -# define GLM_ARCH GLM_ARCH_PURE -#endif - -// With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is -// that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems. -// To fix, we just explicitly include intrin.h here. -#if defined(__MINGW64__) && (GLM_ARCH != GLM_ARCH_PURE) -# include -#endif - -#if GLM_ARCH & GLM_ARCH_AVX2 -# include -#endif//GLM_ARCH -#if GLM_ARCH & GLM_ARCH_AVX -# include -#endif//GLM_ARCH -#if GLM_ARCH & GLM_ARCH_SSE4 -# include -#endif//GLM_ARCH -#if GLM_ARCH & GLM_ARCH_SSE3 -# include -#endif//GLM_ARCH -#if GLM_ARCH & GLM_ARCH_SSE2 -# include -# if(GLM_COMPILER == GLM_COMPILER_VC2005) // VC2005 is missing some intrinsics, workaround - inline float _mm_cvtss_f32(__m128 A) { return A.m128_f32[0]; } - inline __m128 _mm_castpd_ps(__m128d PD) { union { __m128 ps; __m128d pd; } c; c.pd = PD; return c.ps; } - inline __m128d _mm_castps_pd(__m128 PS) { union { __m128 ps; __m128d pd; } c; c.ps = PS; return c.pd; } - inline __m128i _mm_castps_si128(__m128 PS) { union { __m128 ps; __m128i pi; } c; c.ps = PS; return c.pi; } - inline __m128 _mm_castsi128_ps(__m128i PI) { union { __m128 ps; __m128i pi; } c; c.pi = PI; return c.ps; } -# endif -#endif//GLM_ARCH - -#if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED) -# define GLM_MESSAGE_ARCH_DISPLAYED -# if(GLM_ARCH == GLM_ARCH_PURE) -# pragma message("GLM: Platform independent code") -# elif(GLM_ARCH & GLM_ARCH_ARM) -# pragma message("GLM: ARM instruction set") -# elif(GLM_ARCH & GLM_ARCH_AVX2) -# pragma message("GLM: AVX2 instruction set") -# elif(GLM_ARCH & GLM_ARCH_AVX) -# pragma message("GLM: AVX instruction set") -# elif(GLM_ARCH & GLM_ARCH_SSE3) -# pragma message("GLM: SSE3 instruction set") -# elif(GLM_ARCH & GLM_ARCH_SSE2) -# pragma message("GLM: SSE2 instruction set") -# endif//GLM_ARCH -#endif//GLM_MESSAGE - /////////////////////////////////////////////////////////////////////////////////// // Static assert diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index aa0c81d7..78faf314 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -61,6 +61,10 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif private: col_type value[2]; @@ -222,6 +226,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat2x2 const & m1, tmat2x2 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; } //namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index 202839f4..b7f09d7d 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -50,6 +50,13 @@ namespace detail } }//namespace detail +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat2x2 tmat2x2::ZERO(static_cast(0)); + + template + const tmat2x2 tmat2x2::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 4cacc46c..0477c0f9 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[2]; @@ -199,6 +204,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat2x3 const & m1, tmat2x3 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 267f0c0c..23018c19 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat2x3 tmat2x3::ZERO(static_cast(0)); + + template + const tmat2x3 tmat2x3::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index d87ce074..36840f12 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[2]; @@ -201,6 +206,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat2x4 const & m1, tmat2x4 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index 766640e4..ebb9170c 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat2x4 tmat2x4::ZERO(static_cast(0)); + + template + const tmat2x4 tmat2x4::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index ac2ea0d4..06549837 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[3]; @@ -206,6 +211,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat3x2 const & m1, tmat3x2 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index d112a054..7e3ff4be 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat3x2 tmat3x2::ZERO(static_cast(0)); + + template + const tmat3x2 tmat3x2::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index 7b0945ac..4ef3708d 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -56,6 +56,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + template friend tvec3 operator/(tmat3x3 const & m, tvec3 const & v); template @@ -229,6 +234,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat3x3 const & m1, tmat3x3 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 6f936036..ec6f3eb6 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -56,6 +56,14 @@ namespace detail } }//namespace detail +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat3x3 tmat3x3::ZERO(static_cast(0)); + + template + const tmat3x3 tmat3x3::IDENTITY(static_cast(1)); +# endif + // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 8f59f2ad..f9c7b908 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[3]; @@ -206,6 +211,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat3x4 const & m1, tmat3x4 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 8862df47..16ff84d3 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat3x4 tmat3x4::ZERO(static_cast(0)); + + template + const tmat3x4 tmat3x4::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index 65666d5c..b3c27261 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[4]; @@ -211,6 +216,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat4x2 const & m1, tmat4x2 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index d012b884..187b4579 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat4x2 tmat4x2::ZERO(static_cast(0)); + + template + const tmat4x2 tmat4x2::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 55c0b516..7a870a86 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -57,6 +57,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + private: col_type value[4]; @@ -211,6 +216,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat4x3 const & m1, tmat4x3 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index e7368619..da76cdcc 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat4x3 tmat4x3::ZERO(static_cast(0)); + + template + const tmat4x3 tmat4x3::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index 5d36b490..fa585e5b 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -56,6 +56,11 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + template friend tvec4 operator/(tmat4x4 const & m, tvec4 const & v); template @@ -234,6 +239,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tmat4x4 const & m1, tmat4x4 const & m2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = true; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index c075122b..1d463836 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -92,6 +92,13 @@ namespace detail } }//namespace detail +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tmat4x4 tmat4x4::ZERO(static_cast(0)); + + template + const tmat4x4 tmat4x4::IDENTITY(static_cast(1)); +# endif // -- Constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 78e7a413..f59e1c96 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -59,6 +59,10 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type X; +# endif // -- Data -- # if GLM_HAS_ANONYMOUS_UNION @@ -116,7 +120,7 @@ namespace glm // -- Explicit basic constructors -- GLM_FUNC_DECL explicit tvec1(ctor); - GLM_FUNC_DECL explicit tvec1(T const & s); + GLM_FUNC_DECL explicit tvec1(T const & scalar); // -- Conversion vector constructors -- @@ -151,19 +155,19 @@ namespace glm template GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator+=(U const & s); + GLM_FUNC_DECL tvec1 & operator+=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator+=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator-=(U const & s); + GLM_FUNC_DECL tvec1 & operator-=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator-=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator*=(U const & s); + GLM_FUNC_DECL tvec1 & operator*=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator*=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator/=(U const & s); + GLM_FUNC_DECL tvec1 & operator/=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator/=(tvec1 const & v); @@ -177,27 +181,27 @@ namespace glm // -- Unary bit operators -- template - GLM_FUNC_DECL tvec1 & operator%=(U const & s); + GLM_FUNC_DECL tvec1 & operator%=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator%=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator&=(U const & s); + GLM_FUNC_DECL tvec1 & operator&=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator&=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator|=(U const & s); + GLM_FUNC_DECL tvec1 & operator|=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator|=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator^=(U const & s); + GLM_FUNC_DECL tvec1 & operator^=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator^=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator<<=(U const & s); + GLM_FUNC_DECL tvec1 & operator<<=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator<<=(tvec1 const & v); template - GLM_FUNC_DECL tvec1 & operator>>=(U const & s); + GLM_FUNC_DECL tvec1 & operator>>=(U const & scalar); template GLM_FUNC_DECL tvec1 & operator>>=(tvec1 const & v); }; @@ -210,91 +214,91 @@ namespace glm // -- Binary operators -- template - GLM_FUNC_DECL tvec1 operator+(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator+(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator+(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator+(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator+(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator-(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator-(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator-(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator-(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator- (tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator*(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator*(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator*(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator*(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator*(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator/(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator/(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator/(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator/(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator/(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator%(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator%(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator%(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator%(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator%(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator&(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator&(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator&(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator&(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator&(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator|(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator|(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator|(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator|(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator|(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator^(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator^(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator^(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator^(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator^(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator<<(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator<<(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator<<(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator<<(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator<<(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec1 operator>>(tvec1 const & v, T const & s); + GLM_FUNC_DECL tvec1 operator>>(tvec1 const & v, T const & scalar); template - GLM_FUNC_DECL tvec1 operator>>(T const & s, tvec1 const & v); + GLM_FUNC_DECL tvec1 operator>>(T const & scalar, tvec1 const & v); template GLM_FUNC_DECL tvec1 operator>>(tvec1 const & v1, tvec1 const & v2); @@ -309,6 +313,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec1 const & v1, tvec1 const & v2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = true; + static bool const is_mat = false; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index ea36ea95..0da79982 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -32,6 +32,13 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tvec1 tvec1::X(static_cast(1)); + + template + const tvec1 tvec1::ZERO(static_cast(0)); +# endif // -- Implicit basic constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) @@ -63,8 +70,8 @@ namespace glm {} template - GLM_FUNC_QUALIFIER tvec1::tvec1(T const & s) - : x(s) + GLM_FUNC_QUALIFIER tvec1::tvec1(T const & scalar) + : x(scalar) {} // -- Conversion vector constructors -- @@ -158,9 +165,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator+=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator+=(U const & scalar) { - this->x += static_cast(s); + this->x += static_cast(scalar); return *this; } @@ -174,9 +181,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator-=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator-=(U const & scalar) { - this->x -= static_cast(s); + this->x -= static_cast(scalar); return *this; } @@ -190,9 +197,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator*=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator*=(U const & scalar) { - this->x *= static_cast(s); + this->x *= static_cast(scalar); return *this; } @@ -206,9 +213,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator/=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator/=(U const & scalar) { - this->x /= static_cast(s); + this->x /= static_cast(scalar); return *this; } @@ -256,9 +263,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator%=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator%=(U const & scalar) { - this->x %= static_cast(s); + this->x %= static_cast(scalar); return *this; } @@ -272,9 +279,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator&=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator&=(U const & scalar) { - this->x &= static_cast(s); + this->x &= static_cast(scalar); return *this; } @@ -288,9 +295,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator|=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator|=(U const & scalar) { - this->x |= static_cast(s); + this->x |= static_cast(scalar); return *this; } @@ -304,9 +311,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator^=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator^=(U const & scalar) { - this->x ^= static_cast(s); + this->x ^= static_cast(scalar); return *this; } @@ -320,9 +327,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator<<=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator<<=(U const & scalar) { - this->x <<= static_cast(s); + this->x <<= static_cast(scalar); return *this; } @@ -336,9 +343,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator>>=(U const & s) + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator>>=(U const & scalar) { - this->x >>= static_cast(s); + this->x >>= static_cast(scalar); return *this; } @@ -362,17 +369,17 @@ namespace glm // -- Binary arithmetic operators -- template - GLM_FUNC_QUALIFIER tvec1 operator+(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator+(tvec1 const & v, T const & scalar) { return tvec1( - v.x + s); + v.x + scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator+(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator+(T const & scalar, tvec1 const & v) { return tvec1( - s + v.x); + scalar + v.x); } template @@ -384,17 +391,17 @@ namespace glm //operator- template - GLM_FUNC_QUALIFIER tvec1 operator-(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator-(tvec1 const & v, T const & scalar) { return tvec1( - v.x - s); + v.x - scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator-(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator-(T const & scalar, tvec1 const & v) { return tvec1( - s - v.x); + scalar - v.x); } template @@ -405,17 +412,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator*(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator*(tvec1 const & v, T const & scalar) { return tvec1( - v.x * s); + v.x * scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator*(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator*(T const & scalar, tvec1 const & v) { return tvec1( - s * v.x); + scalar * v.x); } template @@ -426,17 +433,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator/(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator/(tvec1 const & v, T const & scalar) { return tvec1( - v.x / s); + v.x / scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator/(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator/(T const & scalar, tvec1 const & v) { return tvec1( - s / v.x); + scalar / v.x); } template @@ -449,17 +456,17 @@ namespace glm // -- Binary bit operators -- template - GLM_FUNC_QUALIFIER tvec1 operator%(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator%(tvec1 const & v, T const & scalar) { return tvec1( - v.x % s); + v.x % scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator%(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator%(T const & scalar, tvec1 const & v) { return tvec1( - s % v.x); + scalar % v.x); } template @@ -470,17 +477,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator&(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator&(tvec1 const & v, T const & scalar) { return tvec1( - v.x & s); + v.x & scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator&(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator&(T const & scalar, tvec1 const & v) { return tvec1( - s & v.x); + scalar & v.x); } template @@ -491,17 +498,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator|(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator|(tvec1 const & v, T const & scalar) { return tvec1( - v.x | s); + v.x | scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator|(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator|(T const & scalar, tvec1 const & v) { return tvec1( - s | v.x); + scalar | v.x); } template @@ -512,17 +519,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator^(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator^(tvec1 const & v, T const & scalar) { return tvec1( - v.x ^ s); + v.x ^ scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator^(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator^(T const & scalar, tvec1 const & v) { return tvec1( - s ^ v.x); + scalar ^ v.x); } template @@ -533,17 +540,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator<<(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator<<(tvec1 const & v, T const & scalar) { return tvec1( - v.x << s); + v.x << scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator<<(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator<<(T const & scalar, tvec1 const & v) { return tvec1( - s << v.x); + scalar << v.x); } template @@ -554,17 +561,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec1 operator>>(tvec1 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec1 operator>>(tvec1 const & v, T const & scalar) { return tvec1( - v.x >> s); + v.x >> scalar); } template - GLM_FUNC_QUALIFIER tvec1 operator>>(T const & s, tvec1 const & v) + GLM_FUNC_QUALIFIER tvec1 operator>>(T const & scalar, tvec1 const & v) { return tvec1( - s >> v.x); + scalar >> v.x); } template diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 691a5e65..ddd45564 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -58,6 +58,13 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type X; + static const type Y; + static const type XY; +# endif + // -- Data -- # if GLM_HAS_ANONYMOUS_UNION @@ -116,7 +123,7 @@ namespace glm // -- Explicit basic constructors -- GLM_FUNC_DECL explicit tvec2(ctor); - GLM_FUNC_DECL explicit tvec2(T const & s); + GLM_FUNC_DECL explicit tvec2(T const & scalar); GLM_FUNC_DECL tvec2(T const & s1, T const & s2); // -- Conversion constructors -- @@ -157,25 +164,25 @@ namespace glm template GLM_FUNC_DECL tvec2& operator=(tvec2 const & v); template - GLM_FUNC_DECL tvec2& operator+=(U s); + GLM_FUNC_DECL tvec2& operator+=(U scalar); template GLM_FUNC_DECL tvec2& operator+=(tvec1 const & v); template GLM_FUNC_DECL tvec2& operator+=(tvec2 const & v); template - GLM_FUNC_DECL tvec2& operator-=(U s); + GLM_FUNC_DECL tvec2& operator-=(U scalar); template GLM_FUNC_DECL tvec2& operator-=(tvec1 const & v); template GLM_FUNC_DECL tvec2& operator-=(tvec2 const & v); template - GLM_FUNC_DECL tvec2& operator*=(U s); + GLM_FUNC_DECL tvec2& operator*=(U scalar); template GLM_FUNC_DECL tvec2& operator*=(tvec1 const & v); template GLM_FUNC_DECL tvec2& operator*=(tvec2 const & v); template - GLM_FUNC_DECL tvec2& operator/=(U s); + GLM_FUNC_DECL tvec2& operator/=(U scalar); template GLM_FUNC_DECL tvec2& operator/=(tvec1 const & v); template @@ -191,37 +198,37 @@ namespace glm // -- Unary bit operators -- template - GLM_FUNC_DECL tvec2 & operator%=(U s); + GLM_FUNC_DECL tvec2 & operator%=(U scalar); template GLM_FUNC_DECL tvec2 & operator%=(tvec1 const & v); template GLM_FUNC_DECL tvec2 & operator%=(tvec2 const & v); template - GLM_FUNC_DECL tvec2 & operator&=(U s); + GLM_FUNC_DECL tvec2 & operator&=(U scalar); template GLM_FUNC_DECL tvec2 & operator&=(tvec1 const & v); template GLM_FUNC_DECL tvec2 & operator&=(tvec2 const & v); template - GLM_FUNC_DECL tvec2 & operator|=(U s); + GLM_FUNC_DECL tvec2 & operator|=(U scalar); template GLM_FUNC_DECL tvec2 & operator|=(tvec1 const & v); template GLM_FUNC_DECL tvec2 & operator|=(tvec2 const & v); template - GLM_FUNC_DECL tvec2 & operator^=(U s); + GLM_FUNC_DECL tvec2 & operator^=(U scalar); template GLM_FUNC_DECL tvec2 & operator^=(tvec1 const & v); template GLM_FUNC_DECL tvec2 & operator^=(tvec2 const & v); template - GLM_FUNC_DECL tvec2 & operator<<=(U s); + GLM_FUNC_DECL tvec2 & operator<<=(U scalar); template GLM_FUNC_DECL tvec2 & operator<<=(tvec1 const & v); template GLM_FUNC_DECL tvec2 & operator<<=(tvec2 const & v); template - GLM_FUNC_DECL tvec2 & operator>>=(U s); + GLM_FUNC_DECL tvec2 & operator>>=(U scalar); template GLM_FUNC_DECL tvec2 & operator>>=(tvec1 const & v); template @@ -236,13 +243,13 @@ namespace glm // -- Binary operators -- template - GLM_FUNC_DECL tvec2 operator+(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator+(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator+(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator+(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator+(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator+(tvec1 const & v1, tvec2 const & v2); @@ -251,13 +258,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator+(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator-(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator-(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator-(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator-(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator-(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator-(tvec1 const & v1, tvec2 const & v2); @@ -266,13 +273,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator-(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator*(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator*(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator*(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator*(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator*(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator*(tvec1 const & v1, tvec2 const & v2); @@ -281,13 +288,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator*(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator/(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator/(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator/(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator/(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator/(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator/(tvec1 const & v1, tvec2 const & v2); @@ -299,13 +306,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator-(tvec2 const & v); template - GLM_FUNC_DECL tvec2 operator%(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator%(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator%(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator%(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator%(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator%(tvec1 const & v1, tvec2 const & v2); @@ -314,13 +321,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator%(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator&(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator&(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator&(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator&(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator&(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator&(tvec1 const & v1, tvec2 const & v2); @@ -329,13 +336,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator&(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator|(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator|(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator|(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator|(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator|(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator|(tvec1 const & v1, tvec2 const & v2); @@ -344,13 +351,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator|(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator^(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator^(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator^(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator^(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator^(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator^(tvec1 const & v1, tvec2 const & v2); @@ -359,13 +366,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator^(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator<<(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator<<(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator<<(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator<<(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator<<(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator<<(tvec1 const & v1, tvec2 const & v2); @@ -374,13 +381,13 @@ namespace glm GLM_FUNC_DECL tvec2 operator<<(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL tvec2 operator>>(tvec2 const & v, T const & s); + GLM_FUNC_DECL tvec2 operator>>(tvec2 const & v, T const & scalar); template GLM_FUNC_DECL tvec2 operator>>(tvec2 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL tvec2 operator>>(T const & s, tvec2 const & v); + GLM_FUNC_DECL tvec2 operator>>(T const & scalar, tvec2 const & v); template GLM_FUNC_DECL tvec2 operator>>(tvec1 const & v1, tvec2 const & v2); @@ -398,6 +405,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec2 const & v1, tvec2 const & v2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = true; + static bool const is_mat = false; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 622cd60b..1bcaf772 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -28,6 +28,19 @@ namespace glm { +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tvec2 tvec2::ZERO(static_cast(0), static_cast(0)); + + template + const tvec2 tvec2::X(static_cast(1), static_cast(0)); + + template + const tvec2 tvec2::Y(static_cast(0), static_cast(1)); + + template + const tvec2 tvec2::XY(static_cast(1), static_cast(1)); +# endif // -- Implicit basic constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) @@ -59,8 +72,8 @@ namespace glm {} template - GLM_FUNC_QUALIFIER tvec2::tvec2(T const & s) - : x(s), y(s) + GLM_FUNC_QUALIFIER tvec2::tvec2(T const & scalar) + : x(scalar), y(scalar) {} template @@ -174,10 +187,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+=(U scalar) { - this->x += static_cast(s); - this->y += static_cast(s); + this->x += static_cast(scalar); + this->y += static_cast(scalar); return *this; } @@ -201,10 +214,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-=(U scalar) { - this->x -= static_cast(s); - this->y -= static_cast(s); + this->x -= static_cast(scalar); + this->y -= static_cast(scalar); return *this; } @@ -228,10 +241,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator*=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator*=(U scalar) { - this->x *= static_cast(s); - this->y *= static_cast(s); + this->x *= static_cast(scalar); + this->y *= static_cast(scalar); return *this; } @@ -255,10 +268,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/=(U scalar) { - this->x /= static_cast(s); - this->y /= static_cast(s); + this->x /= static_cast(scalar); + this->y /= static_cast(scalar); return *this; } @@ -318,10 +331,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator%=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator%=(U scalar) { - this->x %= static_cast(s); - this->y %= static_cast(s); + this->x %= static_cast(scalar); + this->y %= static_cast(scalar); return *this; } @@ -345,10 +358,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator&=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator&=(U scalar) { - this->x &= static_cast(s); - this->y &= static_cast(s); + this->x &= static_cast(scalar); + this->y &= static_cast(scalar); return *this; } @@ -372,10 +385,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator|=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator|=(U scalar) { - this->x |= static_cast(s); - this->y |= static_cast(s); + this->x |= static_cast(scalar); + this->y |= static_cast(scalar); return *this; } @@ -399,10 +412,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator^=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator^=(U scalar) { - this->x ^= static_cast(s); - this->y ^= static_cast(s); + this->x ^= static_cast(scalar); + this->y ^= static_cast(scalar); return *this; } @@ -426,10 +439,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator<<=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator<<=(U scalar) { - this->x <<= static_cast(s); - this->y <<= static_cast(s); + this->x <<= static_cast(scalar); + this->y <<= static_cast(scalar); return *this; } @@ -453,10 +466,10 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator>>=(U s) + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator>>=(U scalar) { - this->x >>= static_cast(s); - this->y >>= static_cast(s); + this->x >>= static_cast(scalar); + this->y >>= static_cast(scalar); return *this; } @@ -491,11 +504,11 @@ namespace glm // -- Binary arithmetic operators -- template - GLM_FUNC_QUALIFIER tvec2 operator+(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator+(tvec2 const & v, T const & scalar) { return tvec2( - v.x + s, - v.y + s); + v.x + scalar, + v.y + scalar); } template @@ -507,11 +520,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator+(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator+(T const & scalar, tvec2 const & v) { return tvec2( - s + v.x, - s + v.y); + scalar + v.x, + scalar + v.y); } template @@ -531,11 +544,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator-(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator-(tvec2 const & v, T const & scalar) { return tvec2( - v.x - s, - v.y - s); + v.x - scalar, + v.y - scalar); } template @@ -547,11 +560,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator-(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator-(T const & scalar, tvec2 const & v) { return tvec2( - s - v.x, - s - v.y); + scalar - v.x, + scalar - v.y); } template @@ -587,11 +600,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator*(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator*(T const & scalar, tvec2 const & v) { return tvec2( - s * v.x, - s * v.y); + scalar * v.x, + scalar * v.y); } template @@ -611,11 +624,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator/(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator/(tvec2 const & v, T const & scalar) { return tvec2( - v.x / s, - v.y / s); + v.x / scalar, + v.y / scalar); } template @@ -627,11 +640,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator/(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator/(T const & scalar, tvec2 const & v) { return tvec2( - s / v.x, - s / v.y); + scalar / v.x, + scalar / v.y); } template @@ -653,11 +666,11 @@ namespace glm // -- Binary bit operators -- template - GLM_FUNC_QUALIFIER tvec2 operator%(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator%(tvec2 const & v, T const & scalar) { return tvec2( - v.x % s, - v.y % s); + v.x % scalar, + v.y % scalar); } template @@ -669,11 +682,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator%(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator%(T const & scalar, tvec2 const & v) { return tvec2( - s % v.x, - s % v.y); + scalar % v.x, + scalar % v.y); } template @@ -693,11 +706,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator&(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator&(tvec2 const & v, T const & scalar) { return tvec2( - v.x & s, - v.y & s); + v.x & scalar, + v.y & scalar); } template @@ -709,11 +722,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator&(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator&(T const & scalar, tvec2 const & v) { return tvec2( - s & v.x, - s & v.y); + scalar & v.x, + scalar & v.y); } template @@ -733,11 +746,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator|(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator|(tvec2 const & v, T const & scalar) { return tvec2( - v.x | s, - v.y | s); + v.x | scalar, + v.y | scalar); } template @@ -749,11 +762,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator|(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator|(T const & scalar, tvec2 const & v) { return tvec2( - s | v.x, - s | v.y); + scalar | v.x, + scalar | v.y); } template @@ -773,11 +786,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator^(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator^(tvec2 const & v, T const & scalar) { return tvec2( - v.x ^ s, - v.y ^ s); + v.x ^ scalar, + v.y ^ scalar); } template @@ -789,11 +802,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator^(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator^(T const & scalar, tvec2 const & v) { return tvec2( - s ^ v.x, - s ^ v.y); + scalar ^ v.x, + scalar ^ v.y); } template @@ -813,11 +826,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator<<(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator<<(tvec2 const & v, T const & scalar) { return tvec2( - v.x << s, - v.y << s); + v.x << scalar, + v.y << scalar); } template @@ -829,11 +842,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator<<(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator<<(T const & scalar, tvec2 const & v) { return tvec2( - s << v.x, - s << v.y); + scalar << v.x, + scalar << v.y); } template @@ -853,11 +866,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator>>(tvec2 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec2 operator>>(tvec2 const & v, T const & scalar) { return tvec2( - v.x >> s, - v.y >> s); + v.x >> scalar, + v.y >> scalar); } template @@ -869,11 +882,11 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec2 operator>>(T const & s, tvec2 const & v) + GLM_FUNC_QUALIFIER tvec2 operator>>(T const & scalar, tvec2 const & v) { return tvec2( - s >> v.x, - s >> v.y); + scalar >> v.x, + scalar >> v.y); } template diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 31d2acd6..d08b7c29 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -58,6 +58,17 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type X; + static const type Y; + static const type Z; + static const type XY; + static const type XZ; + static const type YZ; + static const type XYZ; +# endif + // -- Data -- # if GLM_HAS_ANONYMOUS_UNION @@ -117,7 +128,7 @@ namespace glm // -- Explicit basic constructors -- GLM_FUNC_DECL explicit tvec3(ctor); - GLM_FUNC_DECL explicit tvec3(T const & s); + GLM_FUNC_DECL explicit tvec3(T const & scalar); GLM_FUNC_DECL tvec3(T const & a, T const & b, T const & c); // -- Conversion scalar constructors -- @@ -160,15 +171,15 @@ namespace glm } template - GLM_FUNC_DECL tvec3(detail::_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & s) + GLM_FUNC_DECL tvec3(detail::_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & scalar) { - *this = tvec3(v(), s); + *this = tvec3(v(), scalar); } template - GLM_FUNC_DECL tvec3(T const & s, detail::_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) + GLM_FUNC_DECL tvec3(T const & scalar, detail::_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) { - *this = tvec3(s, v()); + *this = tvec3(scalar, v()); } # endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) @@ -179,25 +190,25 @@ namespace glm template GLM_FUNC_DECL tvec3 & operator=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator+=(U s); + GLM_FUNC_DECL tvec3 & operator+=(U scalar); template GLM_FUNC_DECL tvec3 & operator+=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator+=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator-=(U s); + GLM_FUNC_DECL tvec3 & operator-=(U scalar); template GLM_FUNC_DECL tvec3 & operator-=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator-=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator*=(U s); + GLM_FUNC_DECL tvec3 & operator*=(U scalar); template GLM_FUNC_DECL tvec3 & operator*=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator*=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator/=(U s); + GLM_FUNC_DECL tvec3 & operator/=(U scalar); template GLM_FUNC_DECL tvec3 & operator/=(tvec1 const & v); template @@ -213,37 +224,37 @@ namespace glm // -- Unary bit operators -- template - GLM_FUNC_DECL tvec3 & operator%=(U s); + GLM_FUNC_DECL tvec3 & operator%=(U scalar); template GLM_FUNC_DECL tvec3 & operator%=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator%=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator&=(U s); + GLM_FUNC_DECL tvec3 & operator&=(U scalar); template GLM_FUNC_DECL tvec3 & operator&=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator&=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator|=(U s); + GLM_FUNC_DECL tvec3 & operator|=(U scalar); template GLM_FUNC_DECL tvec3 & operator|=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator|=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator^=(U s); + GLM_FUNC_DECL tvec3 & operator^=(U scalar); template GLM_FUNC_DECL tvec3 & operator^=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator^=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator<<=(U s); + GLM_FUNC_DECL tvec3 & operator<<=(U scalar); template GLM_FUNC_DECL tvec3 & operator<<=(tvec1 const & v); template GLM_FUNC_DECL tvec3 & operator<<=(tvec3 const & v); template - GLM_FUNC_DECL tvec3 & operator>>=(U s); + GLM_FUNC_DECL tvec3 & operator>>=(U scalar); template GLM_FUNC_DECL tvec3 & operator>>=(tvec1 const & v); template @@ -258,151 +269,151 @@ namespace glm // -- Binary operators -- template - GLM_FUNC_DECL tvec3 operator+(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator+(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator+(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator+(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator+(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator+(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator+(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator+(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator+(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator-(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator-(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator-(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator-(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator-(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator-(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator-(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator-(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator-(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator*(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator*(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator*(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator*(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator*(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator*(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator*(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator*(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator*(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator/(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator/(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator/(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator/(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator/(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator/(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator/(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator/(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator/(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator%(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator%(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator%(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator%(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator%(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator%(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator%(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator%(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator%(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator&(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator&(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator&(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator&(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator&(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator&(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator&(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator&(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator&(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator|(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator|(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator|(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator|(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator|(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator|(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator|(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator|(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator|(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator^(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator^(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator^(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator^(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator^(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator^(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator^(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator^(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator^(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator<<(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator<<(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator<<(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator<<(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator<<(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator<<(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator<<(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator<<(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator<<(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL tvec3 operator>>(tvec3 const & v, T const & s); + GLM_FUNC_DECL tvec3 operator>>(tvec3 const & v, T const & scalar); template - GLM_FUNC_DECL tvec3 operator>>(tvec3 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec3 operator>>(tvec3 const & v, tvec1 const & scalar); template - GLM_FUNC_DECL tvec3 operator>>(T const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator>>(T const & scalar, tvec3 const & v); template - GLM_FUNC_DECL tvec3 operator>>(tvec1 const & s, tvec3 const & v); + GLM_FUNC_DECL tvec3 operator>>(tvec1 const & scalar, tvec3 const & v); template GLM_FUNC_DECL tvec3 operator>>(tvec3 const & v1, tvec3 const & v2); @@ -417,6 +428,16 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec3 const & v1, tvec3 const & v2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = true; + static bool const is_mat = false; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index f207e899..f231a682 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -32,6 +32,32 @@ namespace glm { + +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tvec3 tvec3::ZERO(static_cast(0), static_cast(0), static_cast(0)); + + template + const tvec3 tvec3::X(static_cast(1), static_cast(0), static_cast(0)); + + template + const tvec3 tvec3::Y(static_cast(0), static_cast(1), static_cast(0)); + + template + const tvec3 tvec3::Z(static_cast(0), static_cast(0), static_cast(1)); + + template + const tvec3 tvec3::XY(static_cast(1), static_cast(1), static_cast(0)); + + template + const tvec3 tvec3::XZ(static_cast(1), static_cast(0), static_cast(1)); + + template + const tvec3 tvec3::YZ(static_cast(0), static_cast(1), static_cast(1)); + + template + const tvec3 tvec3::XYZ(static_cast(1), static_cast(1), static_cast(1)); +# endif // -- Implicit basic constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) @@ -63,8 +89,8 @@ namespace glm {} template - GLM_FUNC_QUALIFIER tvec3::tvec3(T const & s) - : x(s), y(s), z(s) + GLM_FUNC_QUALIFIER tvec3::tvec3(T const & scalar) + : x(scalar), y(scalar), z(scalar) {} template @@ -209,11 +235,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+=(U scalar) { - this->x += static_cast(s); - this->y += static_cast(s); - this->z += static_cast(s); + this->x += static_cast(scalar); + this->y += static_cast(scalar); + this->z += static_cast(scalar); return *this; } @@ -239,11 +265,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-=(U scalar) { - this->x -= static_cast(s); - this->y -= static_cast(s); - this->z -= static_cast(s); + this->x -= static_cast(scalar); + this->y -= static_cast(scalar); + this->z -= static_cast(scalar); return *this; } @@ -269,11 +295,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*=(U scalar) { - this->x *= static_cast(s); - this->y *= static_cast(s); - this->z *= static_cast(s); + this->x *= static_cast(scalar); + this->y *= static_cast(scalar); + this->z *= static_cast(scalar); return *this; } @@ -299,11 +325,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/=(U v) { - this->x /= static_cast(s); - this->y /= static_cast(s); - this->z /= static_cast(s); + this->x /= static_cast(v); + this->y /= static_cast(v); + this->z /= static_cast(v); return *this; } @@ -367,11 +393,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator%=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator%=(U scalar) { - this->x %= s; - this->y %= s; - this->z %= s; + this->x %= scalar; + this->y %= scalar; + this->z %= scalar; return *this; } @@ -397,11 +423,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator&=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator&=(U scalar) { - this->x &= s; - this->y &= s; - this->z &= s; + this->x &= scalar; + this->y &= scalar; + this->z &= scalar; return *this; } @@ -427,11 +453,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator|=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator|=(U scalar) { - this->x |= s; - this->y |= s; - this->z |= s; + this->x |= scalar; + this->y |= scalar; + this->z |= scalar; return *this; } @@ -457,11 +483,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator^=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator^=(U scalar) { - this->x ^= s; - this->y ^= s; - this->z ^= s; + this->x ^= scalar; + this->y ^= scalar; + this->z ^= scalar; return *this; } @@ -487,11 +513,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator<<=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator<<=(U scalar) { - this->x <<= s; - this->y <<= s; - this->z <<= s; + this->x <<= scalar; + this->y <<= scalar; + this->z <<= scalar; return *this; } @@ -517,11 +543,11 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator>>=(U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator>>=(U scalar) { - this->x >>= static_cast(s); - this->y >>= static_cast(s); - this->z >>= static_cast(s); + this->x >>= static_cast(scalar); + this->y >>= static_cast(scalar); + this->z >>= static_cast(scalar); return *this; } @@ -559,39 +585,39 @@ namespace glm // -- Binary arithmetic operators -- template - GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, T const & scalar) { return tvec3( - v.x + s, - v.y + s, - v.z + s); + v.x + scalar, + v.y + scalar, + v.z + scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x + s.x, - v.y + s.x, - v.z + s.x); + v.x + scalar.x, + v.y + scalar.x, + v.z + scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator+(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator+(T const & scalar, tvec3 const & v) { return tvec3( - s + v.x, - s + v.y, - s + v.z); + scalar + v.x, + scalar + v.y, + scalar + v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator+(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator+(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x + v.x, - s.x + v.y, - s.x + v.z); + scalar.x + v.x, + scalar.x + v.y, + scalar.x + v.z); } template @@ -604,39 +630,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, T const & scalar) { return tvec3( - v.x - s, - v.y - s, - v.z - s); + v.x - scalar, + v.y - scalar, + v.z - scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x - s.x, - v.y - s.x, - v.z - s.x); + v.x - scalar.x, + v.y - scalar.x, + v.z - scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator-(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator-(T const & scalar, tvec3 const & v) { return tvec3( - s - v.x, - s - v.y, - s - v.z); + scalar - v.x, + scalar - v.y, + scalar - v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator-(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator-(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x - v.x, - s.x - v.y, - s.x - v.z); + scalar.x - v.x, + scalar.x - v.y, + scalar.x - v.z); } template @@ -649,39 +675,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, T const & scalar) { return tvec3( - v.x * s, - v.y * s, - v.z * s); + v.x * scalar, + v.y * scalar, + v.z * scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x * s.x, - v.y * s.x, - v.z * s.x); + v.x * scalar.x, + v.y * scalar.x, + v.z * scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator*(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator*(T const & scalar, tvec3 const & v) { return tvec3( - s * v.x, - s * v.y, - s * v.z); + scalar * v.x, + scalar * v.y, + scalar * v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator*(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator*(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x * v.x, - s.x * v.y, - s.x * v.z); + scalar.x * v.x, + scalar.x * v.y, + scalar.x * v.z); } template @@ -694,39 +720,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, T const & scalar) { return tvec3( - v.x / s, - v.y / s, - v.z / s); + v.x / scalar, + v.y / scalar, + v.z / scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x / s.x, - v.y / s.x, - v.z / s.x); + v.x / scalar.x, + v.y / scalar.x, + v.z / scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator/(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator/(T const & scalar, tvec3 const & v) { return tvec3( - s / v.x, - s / v.y, - s / v.z); + scalar / v.x, + scalar / v.y, + scalar / v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator/(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator/(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x / v.x, - s.x / v.y, - s.x / v.z); + scalar.x / v.x, + scalar.x / v.y, + scalar.x / v.z); } template @@ -741,39 +767,39 @@ namespace glm // -- Binary bit operators -- template - GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, T const & scalar) { return tvec3( - v.x % s, - v.y % s, - v.z % s); + v.x % scalar, + v.y % scalar, + v.z % scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x % s.x, - v.y % s.x, - v.z % s.x); + v.x % scalar.x, + v.y % scalar.x, + v.z % scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator%(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator%(T const & scalar, tvec3 const & v) { return tvec3( - s % v.x, - s % v.y, - s % v.z); + scalar % v.x, + scalar % v.y, + scalar % v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator%(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x % v.x, - s.x % v.y, - s.x % v.z); + scalar.x % v.x, + scalar.x % v.y, + scalar.x % v.z); } template @@ -786,39 +812,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, T const & scalar) { return tvec3( - v.x & s, - v.y & s, - v.z & s); + v.x & scalar, + v.y & scalar, + v.z & scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x & s.x, - v.y & s.x, - v.z & s.x); + v.x & scalar.x, + v.y & scalar.x, + v.z & scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator&(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator&(T const & scalar, tvec3 const & v) { return tvec3( - s & v.x, - s & v.y, - s & v.z); + scalar & v.x, + scalar & v.y, + scalar & v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator&(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x & v.x, - s.x & v.y, - s.x & v.z); + scalar.x & v.x, + scalar.x & v.y, + scalar.x & v.z); } template @@ -831,39 +857,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, T const & scalar) { return tvec3( - v.x | s, - v.y | s, - v.z | s); + v.x | scalar, + v.y | scalar, + v.z | scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x | s.x, - v.y | s.x, - v.z | s.x); + v.x | scalar.x, + v.y | scalar.x, + v.z | scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator|(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator|(T const & scalar, tvec3 const & v) { return tvec3( - s | v.x, - s | v.y, - s | v.z); + scalar | v.x, + scalar | v.y, + scalar | v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator|(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x | v.x, - s.x | v.y, - s.x | v.z); + scalar.x | v.x, + scalar.x | v.y, + scalar.x | v.z); } template @@ -876,39 +902,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, T const & scalar) { return tvec3( - v.x ^ s, - v.y ^ s, - v.z ^ s); + v.x ^ scalar, + v.y ^ scalar, + v.z ^ scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x ^ s.x, - v.y ^ s.x, - v.z ^ s.x); + v.x ^ scalar.x, + v.y ^ scalar.x, + v.z ^ scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator^(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator^(T const & scalar, tvec3 const & v) { return tvec3( - s ^ v.x, - s ^ v.y, - s ^ v.z); + scalar ^ v.x, + scalar ^ v.y, + scalar ^ v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator^(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x ^ v.x, - s.x ^ v.y, - s.x ^ v.z); + scalar.x ^ v.x, + scalar.x ^ v.y, + scalar.x ^ v.z); } template @@ -921,39 +947,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, T const & scalar) { return tvec3( - v.x << s, - v.y << s, - v.z << s); + v.x << scalar, + v.y << scalar, + v.z << scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x << s.x, - v.y << s.x, - v.z << s.x); + v.x << scalar.x, + v.y << scalar.x, + v.z << scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator<<(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator<<(T const & scalar, tvec3 const & v) { return tvec3( - s << v.x, - s << v.y, - s << v.z); + scalar << v.x, + scalar << v.y, + scalar << v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator<<(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x << v.x, - s.x << v.y, - s.x << v.z); + scalar.x << v.x, + scalar.x << v.y, + scalar.x << v.z); } template @@ -966,39 +992,39 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator>>(tvec3 const & v, T const & s) + GLM_FUNC_QUALIFIER tvec3 operator>>(tvec3 const & v, T const & scalar) { return tvec3( - v.x >> s, - v.y >> s, - v.z >> s); + v.x >> scalar, + v.y >> scalar, + v.z >> scalar); } template - GLM_FUNC_QUALIFIER tvec3 operator>>(tvec3 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec3 operator>>(tvec3 const & v, tvec1 const & scalar) { return tvec3( - v.x >> s.x, - v.y >> s.x, - v.z >> s.x); + v.x >> scalar.x, + v.y >> scalar.x, + v.z >> scalar.x); } template - GLM_FUNC_QUALIFIER tvec3 operator>>(T const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator>>(T const & scalar, tvec3 const & v) { return tvec3( - s >> v.x, - s >> v.y, - s >> v.z); + scalar >> v.x, + scalar >> v.y, + scalar >> v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator>>(tvec1 const & s, tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3 operator>>(tvec1 const & scalar, tvec3 const & v) { return tvec3( - s.x >> v.x, - s.x >> v.y, - s.x >> v.z); + scalar.x >> v.x, + scalar.x >> v.y, + scalar.x >> v.z); } template diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index c2d9f60e..489ef6f8 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -46,8 +46,8 @@ namespace glm{ namespace detail { - template - struct simd + template + struct simd_data { typedef T type[4]; }; @@ -56,19 +56,19 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_SSE2) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m128 type; }; template <> - struct simd + struct simd_data { typedef __m128i type; }; template <> - struct simd + struct simd_data { typedef __m128i type; }; @@ -76,7 +76,7 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_AVX) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m256d type; }; @@ -84,13 +84,13 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_AVX2) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m256i type; }; template <> - struct simd + struct simd_data { typedef __m256i type; }; @@ -112,16 +112,35 @@ namespace detail static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type X; + static const type Y; + static const type Z; + static const type W; + static const type XY; + static const type XZ; + static const type XW; + static const type YZ; + static const type YW; + static const type ZW; + static const type XYZ; + static const type XYW; + static const type XZW; + static const type YZW; + static const type XYZW; +# endif + // -- Data -- -# if GLM_HAS_ANONYMOUS_UNION +# if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS union { struct { T x, y, z, w;}; struct { T r, g, b, a; }; struct { T s, t, p, q; }; - typename detail::simd::type data; + typename detail::simd_data::type data; # ifdef GLM_SWIZZLE _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) @@ -174,7 +193,7 @@ namespace detail // -- Explicit basic constructors -- GLM_FUNC_DECL explicit tvec4(ctor); - GLM_FUNC_DECL explicit tvec4(T s); + GLM_FUNC_DECL explicit tvec4(T scalar); GLM_FUNC_DECL tvec4(T a, T b, T c, T d); // -- Conversion scalar constructors -- @@ -360,13 +379,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator+(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator+(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator+(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator+(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator+(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator+(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator+(tvec4 const & v1, tvec4 const & v2); @@ -375,13 +394,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator-(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator-(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator-(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator-(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator-(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator-(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator-(tvec4 const & v1, tvec4 const & v2); @@ -390,13 +409,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator*(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator*(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator*(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator*(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator*(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator*(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator*(tvec4 const & v1, tvec4 const & v2); @@ -405,13 +424,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator/(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator/(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator/(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator/(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator/(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator/(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator/(tvec4 const & v1, tvec4 const & v2); @@ -426,13 +445,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator%(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator%(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator%(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator%(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator%(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator%(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator%(tvec4 const & v1, tvec4 const & v2); @@ -441,13 +460,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator&(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator&(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator&(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator&(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator&(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator&(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator&(tvec4 const & v1, tvec4 const & v2); @@ -456,13 +475,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator|(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator|(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator|(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator|(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator|(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator|(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator|(tvec4 const & v1, tvec4 const & v2); @@ -471,13 +490,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator^(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator^(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator^(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator^(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator^(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator^(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator^(tvec4 const & v1, tvec4 const & v2); @@ -486,13 +505,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator<<(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator<<(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator<<(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v1, tvec4 const & v2); @@ -501,13 +520,13 @@ namespace detail GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v, T scalar); template - GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v, tvec1 const & s); + GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v, tvec1 const & scalar); template GLM_FUNC_DECL tvec4 operator>>(T scalar, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator>>(tvec1 const & s, tvec4 const & v); + GLM_FUNC_DECL tvec4 operator>>(tvec1 const & scalar, tvec4 const & v); template GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v1, tvec4 const & v2); @@ -522,6 +541,16 @@ namespace detail template GLM_FUNC_DECL bool operator!=(tvec4 const & v1, tvec4 const & v2); + + // -- Is type -- + + template + struct type + { + static bool const is_vec = true; + static bool const is_mat = false; + static bool const is_quat = false; + }; }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 7518748e..23b8c8b3 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -32,6 +32,72 @@ namespace glm { + +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tvec4 tvec4::ZERO + (static_cast(0), static_cast(0), static_cast(0), static_cast(0)); + + template + const tvec4 tvec4::X + (static_cast(1), static_cast(0), static_cast(0), static_cast(0)); + + template + const tvec4 tvec4::Y + (static_cast(0), static_cast(1), static_cast(0), static_cast(0)); + + template + const tvec4 tvec4::Z + (static_cast(0), static_cast(0), static_cast(1), static_cast(0)); + + template + const tvec4 tvec4::W + (static_cast(0), static_cast(0), static_cast(0), static_cast(1)); + + template + const tvec4 tvec4::XY + (static_cast(1), static_cast(1), static_cast(0), static_cast(0)); + + template + const tvec4 tvec4::XZ + (static_cast(1), static_cast(0), static_cast(1), static_cast(0)); + + template + const tvec4 tvec4::XW + (static_cast(1), static_cast(0), static_cast(0), static_cast(1)); + + template + const tvec4 tvec4::YZ + (static_cast(0), static_cast(1), static_cast(1), static_cast(0)); + + template + const tvec4 tvec4::YW + (static_cast(0), static_cast(1), static_cast(0), static_cast(1)); + + template + const tvec4 tvec4::ZW + (static_cast(0), static_cast(0), static_cast(1), static_cast(1)); + + template + const tvec4 tvec4::XYZ + (static_cast(1), static_cast(1), static_cast(1), static_cast(0)); + + template + const tvec4 tvec4::XYW + (static_cast(1), static_cast(1), static_cast(0), static_cast(1)); + + template + const tvec4 tvec4::XZW + (static_cast(1), static_cast(0), static_cast(1), static_cast(1)); + + template + const tvec4 tvec4::YZW + (static_cast(0), static_cast(1), static_cast(1), static_cast(1)); + + template + const tvec4 tvec4::XYZW + (static_cast(1), static_cast(1), static_cast(1), static_cast(1)); +# endif // -- Implicit basic constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) @@ -63,8 +129,8 @@ namespace glm {} template - GLM_FUNC_QUALIFIER tvec4::tvec4(T s) - : x(s), y(s), z(s), w(s) + GLM_FUNC_QUALIFIER tvec4::tvec4(T scalar) + : x(scalar), y(scalar), z(scalar), w(scalar) {} template @@ -341,12 +407,12 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(U v) { - this->x *= static_cast(s); - this->y *= static_cast(s); - this->z *= static_cast(s); - this->w *= static_cast(s); + this->x *= static_cast(v); + this->y *= static_cast(v); + this->z *= static_cast(v); + this->w *= static_cast(v); return *this; } @@ -374,12 +440,12 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(U v) { - this->x /= static_cast(s); - this->y /= static_cast(s); - this->z /= static_cast(s); - this->w /= static_cast(s); + this->x /= static_cast(v); + this->y /= static_cast(v); + this->z /= static_cast(v); + this->w /= static_cast(v); return *this; } @@ -780,43 +846,43 @@ namespace glm // -- Binary bit operators -- template - GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, T s) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, T scalar) { return tvec4( - v.x % s, - v.y % s, - v.z % s, - v.w % s); + v.x % scalar, + v.y % scalar, + v.z % scalar, + v.w % scalar); } template - GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x % s.x, - v.y % s.x, - v.z % s.x, - v.w % s.x); + v.x % scalar.x, + v.y % scalar.x, + v.z % scalar.x, + v.w % scalar.x); } template - GLM_FUNC_QUALIFIER tvec4 operator%(T s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator%(T scalar, tvec4 const & v) { return tvec4( - s % v.x, - s % v.y, - s % v.z, - s % v.w); + scalar % v.x, + scalar % v.y, + scalar % v.z, + scalar % v.w); } template - GLM_FUNC_QUALIFIER tvec4 operator%(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x % v.x, - s.x % v.y, - s.x % v.z, - s.x % v.w); + scalar.x % v.x, + scalar.x % v.y, + scalar.x % v.z, + scalar.x % v.w); } template @@ -830,43 +896,43 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, T s) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, T scalar) { return tvec4( - v.x & s, - v.y & s, - v.z & s, - v.w & s); + v.x & scalar, + v.y & scalar, + v.z & scalar, + v.w & scalar); } template - GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x & s.x, - v.y & s.x, - v.z & s.x, - v.w & s.x); + v.x & scalar.x, + v.y & scalar.x, + v.z & scalar.x, + v.w & scalar.x); } template - GLM_FUNC_QUALIFIER tvec4 operator&(T s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator&(T scalar, tvec4 const & v) { return tvec4( - s & v.x, - s & v.y, - s & v.z, - s & v.w); + scalar & v.x, + scalar & v.y, + scalar & v.z, + scalar & v.w); } template - GLM_FUNC_QUALIFIER tvec4 operator&(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x & v.x, - s.x & v.y, - s.x & v.z, - s.x & v.w); + scalar.x & v.x, + scalar.x & v.y, + scalar.x & v.z, + scalar.x & v.w); } template @@ -880,43 +946,43 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, T s) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, T scalar) { return tvec4( - v.x | s, - v.y | s, - v.z | s, - v.w | s); + v.x | scalar, + v.y | scalar, + v.z | scalar, + v.w | scalar); } template - GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x | s.x, - v.y | s.x, - v.z | s.x, - v.w | s.x); + v.x | scalar.x, + v.y | scalar.x, + v.z | scalar.x, + v.w | scalar.x); } template - GLM_FUNC_QUALIFIER tvec4 operator|(T s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator|(T scalar, tvec4 const & v) { return tvec4( - s | v.x, - s | v.y, - s | v.z, - s | v.w); + scalar | v.x, + scalar | v.y, + scalar | v.z, + scalar | v.w); } template - GLM_FUNC_QUALIFIER tvec4 operator|(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x | v.x, - s.x | v.y, - s.x | v.z, - s.x | v.w); + scalar.x | v.x, + scalar.x | v.y, + scalar.x | v.z, + scalar.x | v.w); } template @@ -930,23 +996,23 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, T s) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, T scalar) { return tvec4( - v.x ^ s, - v.y ^ s, - v.z ^ s, - v.w ^ s); + v.x ^ scalar, + v.y ^ scalar, + v.z ^ scalar, + v.w ^ scalar); } template - GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x ^ s.x, - v.y ^ s.x, - v.z ^ s.x, - v.w ^ s.x); + v.x ^ scalar.x, + v.y ^ scalar.x, + v.z ^ scalar.x, + v.w ^ scalar.x); } template @@ -960,13 +1026,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator^(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x ^ v.x, - s.x ^ v.y, - s.x ^ v.z, - s.x ^ v.w); + scalar.x ^ v.x, + scalar.x ^ v.y, + scalar.x ^ v.z, + scalar.x ^ v.w); } template @@ -990,13 +1056,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator<<(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x << s.x, - v.y << s.x, - v.z << s.x, - v.w << s.x); + v.x << scalar.x, + v.y << scalar.x, + v.z << scalar.x, + v.w << scalar.x); } template @@ -1010,13 +1076,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator<<(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x << v.x, - s.x << v.y, - s.x << v.z, - s.x << v.w); + scalar.x << v.x, + scalar.x << v.y, + scalar.x << v.z, + scalar.x << v.w); } template @@ -1040,13 +1106,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator>>(tvec4 const & v, tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec4 const & v, tvec1 const & scalar) { return tvec4( - v.x >> s.x, - v.y >> s.x, - v.z >> s.x, - v.w >> s.x); + v.x >> scalar.x, + v.y >> scalar.x, + v.z >> scalar.x, + v.w >> scalar.x); } template @@ -1060,13 +1126,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator>>(tvec1 const & s, tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec1 const & scalar, tvec4 const & v) { return tvec4( - s.x >> v.x, - s.x >> v.y, - s.x >> v.z, - s.x >> v.w); + scalar.x >> v.x, + scalar.x >> v.y, + scalar.x >> v.z, + scalar.x >> v.w); } template diff --git a/glm/detail/type_vec4_sse2.inl b/glm/detail/type_vec4_sse2.inl index 623db81a..968e9fed 100644 --- a/glm/detail/type_vec4_sse2.inl +++ b/glm/detail/type_vec4_sse2.inl @@ -34,14 +34,7 @@ namespace glm{ # if !GLM_HAS_DEFAULTED_FUNCTIONS template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() + GLM_FUNC_QUALIFIER tvec4::tvec4() # ifndef GLM_FORCE_NO_CTOR_INIT : data(_mm_setzero_ps()) # endif @@ -49,28 +42,18 @@ namespace glm{ # endif//!GLM_HAS_DEFAULTED_FUNCTIONS template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : - data(_mm_set1_ps(s)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : + GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : data(_mm_set1_ps(s)) {} template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : - data(_mm_set_ps(d, c, b, a)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : + GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : data(_mm_set_ps(d, c, b, a)) {} template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); return *this; @@ -78,7 +61,7 @@ namespace glm{ template <> template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) { this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); return *this; @@ -86,31 +69,7 @@ namespace glm{ template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); - return *this; - } - - template <> - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); return *this; diff --git a/glm/ext.hpp b/glm/ext.hpp index bdf050a9..5f662761 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -90,7 +90,7 @@ #include "./gtx/dual_quaternion.hpp" #include "./gtx/euler_angles.hpp" #include "./gtx/extend.hpp" -#include "./gtx/extented_min_max.hpp" +#include "./gtx/extended_min_max.hpp" #include "./gtx/fast_exponential.hpp" #include "./gtx/fast_square_root.hpp" #include "./gtx/fast_trigonometry.hpp" diff --git a/glm/gtc/constants.hpp b/glm/gtc/constants.hpp index ae1fb622..786467ad 100644 --- a/glm/gtc/constants.hpp +++ b/glm/gtc/constants.hpp @@ -57,147 +57,147 @@ namespace glm /// Return the epsilon constant for floating point types. /// @see gtc_constants template - GLM_FUNC_DECL genType epsilon(); + GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon(); /// Return 0. /// @see gtc_constants template - GLM_FUNC_DECL genType zero(); + GLM_FUNC_DECL GLM_CONSTEXPR genType zero(); /// Return 1. /// @see gtc_constants template - GLM_FUNC_DECL genType one(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one(); /// Return the pi constant. /// @see gtc_constants template - GLM_FUNC_DECL genType pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType pi(); /// Return pi * 2. /// @see gtc_constants template - GLM_FUNC_DECL genType two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_pi(); /// Return square root of pi. /// @see gtc_constants template - GLM_FUNC_DECL genType root_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_pi(); /// Return pi / 2. /// @see gtc_constants template - GLM_FUNC_DECL genType half_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType half_pi(); /// Return pi / 2 * 3. /// @see gtc_constants template - GLM_FUNC_DECL genType three_over_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType three_over_two_pi(); /// Return pi / 4. /// @see gtc_constants template - GLM_FUNC_DECL genType quarter_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType quarter_pi(); /// Return 1 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_pi(); /// Return 1 / (pi * 2). /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_two_pi(); /// Return 2 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType two_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_pi(); /// Return 4 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType four_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType four_over_pi(); /// Return 2 / sqrt(pi). /// @see gtc_constants template - GLM_FUNC_DECL genType two_over_root_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_root_pi(); /// Return 1 / sqrt(2). /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_root_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_root_two(); /// Return sqrt(pi / 2). /// @see gtc_constants template - GLM_FUNC_DECL genType root_half_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_half_pi(); /// Return sqrt(2 * pi). /// @see gtc_constants template - GLM_FUNC_DECL genType root_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_two_pi(); /// Return sqrt(ln(4)). /// @see gtc_constants template - GLM_FUNC_DECL genType root_ln_four(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_ln_four(); /// Return e constant. /// @see gtc_constants template - GLM_FUNC_DECL genType e(); + GLM_FUNC_DECL GLM_CONSTEXPR genType e(); /// Return Euler's constant. /// @see gtc_constants template - GLM_FUNC_DECL genType euler(); + GLM_FUNC_DECL GLM_CONSTEXPR genType euler(); /// Return sqrt(2). /// @see gtc_constants template - GLM_FUNC_DECL genType root_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_two(); /// Return sqrt(3). /// @see gtc_constants template - GLM_FUNC_DECL genType root_three(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_three(); /// Return sqrt(5). /// @see gtc_constants template - GLM_FUNC_DECL genType root_five(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_five(); /// Return ln(2). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_two(); /// Return ln(10). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_ten(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ten(); /// Return ln(ln(2)). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_ln_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ln_two(); /// Return 1 / 3. /// @see gtc_constants template - GLM_FUNC_DECL genType third(); + GLM_FUNC_DECL GLM_CONSTEXPR genType third(); /// Return 2 / 3. /// @see gtc_constants template - GLM_FUNC_DECL genType two_thirds(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_thirds(); /// Return the golden ratio constant. /// @see gtc_constants template - GLM_FUNC_DECL genType golden_ratio(); + GLM_FUNC_DECL GLM_CONSTEXPR genType golden_ratio(); /// @} } //namespace glm diff --git a/glm/gtc/constants.inl b/glm/gtc/constants.inl index a5de153b..8214f606 100644 --- a/glm/gtc/constants.inl +++ b/glm/gtc/constants.inl @@ -35,175 +35,175 @@ namespace glm { template - GLM_FUNC_QUALIFIER genType epsilon() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon() { return std::numeric_limits::epsilon(); } template - GLM_FUNC_QUALIFIER genType zero() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType zero() { return genType(0); } template - GLM_FUNC_QUALIFIER genType one() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one() { return genType(1); } template - GLM_FUNC_QUALIFIER genType pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi() { return genType(3.14159265358979323846264338327950288); } template - GLM_FUNC_QUALIFIER genType two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_pi() { return genType(6.28318530717958647692528676655900576); } template - GLM_FUNC_QUALIFIER genType root_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_pi() { return genType(1.772453850905516027); } template - GLM_FUNC_QUALIFIER genType half_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType half_pi() { return genType(1.57079632679489661923132169163975144); } template - GLM_FUNC_QUALIFIER genType three_over_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType three_over_two_pi() { return genType(4.71238898038468985769396507491925432); } template - GLM_FUNC_QUALIFIER genType quarter_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType quarter_pi() { return genType(0.785398163397448309615660845819875721); } template - GLM_FUNC_QUALIFIER genType one_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_pi() { return genType(0.318309886183790671537767526745028724); } template - GLM_FUNC_QUALIFIER genType one_over_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_two_pi() { return genType(0.159154943091895335768883763372514362); } template - GLM_FUNC_QUALIFIER genType two_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_pi() { return genType(0.636619772367581343075535053490057448); } template - GLM_FUNC_QUALIFIER genType four_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType four_over_pi() { return genType(1.273239544735162686151070106980114898); } template - GLM_FUNC_QUALIFIER genType two_over_root_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_root_pi() { return genType(1.12837916709551257389615890312154517); } template - GLM_FUNC_QUALIFIER genType one_over_root_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_root_two() { return genType(0.707106781186547524400844362104849039); } template - GLM_FUNC_QUALIFIER genType root_half_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_half_pi() { return genType(1.253314137315500251); } template - GLM_FUNC_QUALIFIER genType root_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two_pi() { return genType(2.506628274631000502); } template - GLM_FUNC_QUALIFIER genType root_ln_four() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_ln_four() { return genType(1.17741002251547469); } template - GLM_FUNC_QUALIFIER genType e() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType e() { return genType(2.71828182845904523536); } template - GLM_FUNC_QUALIFIER genType euler() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType euler() { return genType(0.577215664901532860606); } template - GLM_FUNC_QUALIFIER genType root_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two() { return genType(1.41421356237309504880168872420969808); } template - GLM_FUNC_QUALIFIER genType root_three() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_three() { return genType(1.73205080756887729352744634150587236); } template - GLM_FUNC_QUALIFIER genType root_five() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_five() { return genType(2.23606797749978969640917366873127623); } template - GLM_FUNC_QUALIFIER genType ln_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_two() { return genType(0.693147180559945309417232121458176568); } template - GLM_FUNC_QUALIFIER genType ln_ten() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ten() { return genType(2.30258509299404568401799145468436421); } template - GLM_FUNC_QUALIFIER genType ln_ln_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ln_two() { return genType(-0.3665129205816643); } template - GLM_FUNC_QUALIFIER genType third() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType third() { return genType(0.3333333333333333333333333333333333333333); } template - GLM_FUNC_QUALIFIER genType two_thirds() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_thirds() { return genType(0.666666666666666666666666666666666666667); } template - GLM_FUNC_QUALIFIER genType golden_ratio() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType golden_ratio() { return genType(1.61803398874989484820458683436563811); } diff --git a/glm/gtc/matrix_inverse.inl b/glm/gtc/matrix_inverse.inl index d88a3319..d2437d5d 100644 --- a/glm/gtc/matrix_inverse.inl +++ b/glm/gtc/matrix_inverse.inl @@ -35,23 +35,24 @@ namespace glm template GLM_FUNC_QUALIFIER tmat3x3 affineInverse(tmat3x3 const & m) { - tmat3x3 Result(m); - Result[2] = tvec3(0, 0, 1); - Result = transpose(Result); - tvec3 Translation = Result * tvec3(-tvec2(m[2]), m[2][2]); - Result[2] = Translation; - return Result; + tmat2x2 const Inv(inverse(tmat2x2(m))); + + return tmat3x3( + tvec3(Inv[0], static_cast(0)), + tvec3(Inv[1], static_cast(0)), + tvec3(-Inv * tvec2(m[2]), static_cast(1))); } template GLM_FUNC_QUALIFIER tmat4x4 affineInverse(tmat4x4 const & m) { - tmat4x4 Result(m); - Result[3] = tvec4(0, 0, 0, 1); - Result = transpose(Result); - tvec4 Translation = Result * tvec4(-tvec3(m[3]), m[3][3]); - Result[3] = Translation; - return Result; + tmat3x3 const Inv(inverse(tmat3x3(m))); + + return tmat4x4( + tvec4(Inv[0], static_cast(0)), + tvec4(Inv[1], static_cast(0)), + tvec4(Inv[2], static_cast(0)), + tvec4(-Inv * tvec3(m[3]), static_cast(1))); } template diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index d4ff3cfe..b9f8098c 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -186,7 +186,6 @@ namespace glm T near, T far); - /// Creates a matrix for a right handed, symetric perspective-view frustum. /// /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians. diff --git a/glm/gtc/packing.hpp b/glm/gtc/packing.hpp index 8808aa4f..b016eb15 100644 --- a/glm/gtc/packing.hpp +++ b/glm/gtc/packing.hpp @@ -472,6 +472,136 @@ namespace glm /// @see uint32 packF2x11_1x10(vec3 const & v) GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p); + + /// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values. + /// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value. + /// Then, the results are packed into the returned 32-bit unsigned integer. + /// + /// The first vector component specifies the 11 least-significant bits of the result; + /// the last component specifies the 10 most-significant bits. + /// + /// @see gtc_packing + /// @see vec3 unpackF3x9_E1x5(uint32 const & p) + GLM_FUNC_DECL uint32 packF3x9_E1x5(vec3 const & v); + + /// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value . + /// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector. + /// + /// The first component of the returned vector will be extracted from the least significant bits of the input; + /// the last component will be extracted from the most significant bits. + /// + /// @see gtc_packing + /// @see uint32 packF3x9_E1x5(vec3 const & v) + GLM_FUNC_DECL vec3 unpackF3x9_E1x5(uint32 p); + + /// Returns an unsigned integer vector obtained by converting the components of a floating-point vector + /// to the 16-bit floating-point representation found in the OpenGL Specification. + /// The first vector component specifies the 16 least-significant bits of the result; + /// the forth component specifies the 16 most-significant bits. + /// + /// @see gtc_packing + /// @see vecType unpackHalf(vecType const & p) + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + template class vecType> + GLM_FUNC_DECL vecType packHalf(vecType const & v); + + /// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values. + /// The first component of the vector is obtained from the 16 least-significant bits of v; + /// the forth component is obtained from the 16 most-significant bits of v. + /// + /// @see gtc_packing + /// @see vecType packHalf(vecType const & v) + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + template class vecType> + GLM_FUNC_DECL vecType unpackHalf(vecType const & p); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vecType unpackUnorm(vecType const & p); + template class vecType> + GLM_FUNC_DECL vecType packUnorm(vecType const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see vecType packUnorm(vecType const & v) + template class vecType> + GLM_FUNC_DECL vecType unpackUnorm(vecType const & v); + + /// Convert each component of the normalized floating-point vector into signed integer values. + /// + /// @see gtc_packing + /// @see vecType unpackSnorm(vecType const & p); + template class vecType> + GLM_FUNC_DECL vecType packSnorm(vecType const & v); + + /// Convert each signed integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see vecType packSnorm(vecType const & v) + template class vecType> + GLM_FUNC_DECL vecType unpackSnorm(vecType const & v); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vec2 unpackUnorm2x4(uint8 p) + GLM_FUNC_DECL uint8 packUnorm2x4(vec2 const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see uint8 packUnorm2x4(vec2 const & v) + GLM_FUNC_DECL vec2 unpackUnorm2x4(uint8 p); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vec4 unpackUnorm4x4(uint16 p) + GLM_FUNC_DECL uint16 packUnorm4x4(vec4 const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see uint16 packUnorm4x4(vec4 const & v) + GLM_FUNC_DECL vec4 unpackUnorm4x4(uint16 p); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vec3 unpackUnorm1x5_1x6_1x5(uint16 p) + GLM_FUNC_DECL uint16 packUnorm1x5_1x6_1x5(vec3 const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see uint16 packUnorm1x5_1x6_1x5(vec3 const & v) + GLM_FUNC_DECL vec3 unpackUnorm1x5_1x6_1x5(uint16 p); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vec4 unpackUnorm3x5_1x1(uint16 p) + GLM_FUNC_DECL uint16 packUnorm3x5_1x1(vec4 const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see uint16 packUnorm3x5_1x1(vec4 const & v) + GLM_FUNC_DECL vec4 unpackUnorm3x5_1x1(uint16 p); + + /// Convert each component of the normalized floating-point vector into unsigned integer values. + /// + /// @see gtc_packing + /// @see vec3 unpackUnorm2x3_1x2(uint8 p) + GLM_FUNC_DECL uint8 packUnorm2x3_1x2(vec3 const & v); + + /// Convert each unsigned integer components of a vector to normalized floating-point values. + /// + /// @see gtc_packing + /// @see uint8 packUnorm2x3_1x2(vec3 const & v) + GLM_FUNC_DECL vec3 unpackUnorm2x3_1x2(uint8 p); /// @} }// namespace glm diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index 58b1d59b..5c6667af 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -36,6 +36,7 @@ #include "../vec4.hpp" #include "../detail/type_half.hpp" #include +#include namespace glm{ namespace detail @@ -224,6 +225,62 @@ namespace detail // return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22); // } + union u3u3u2 + { + struct + { + uint x : 3; + uint y : 3; + uint z : 2; + } data; + uint8 pack; + }; + + union u4u4 + { + struct + { + uint x : 4; + uint y : 4; + } data; + uint8 pack; + }; + + union u4u4u4u4 + { + struct + { + uint x : 4; + uint y : 4; + uint z : 4; + uint w : 4; + } data; + uint16 pack; + }; + + union u5u6u5 + { + struct + { + uint x : 5; + uint y : 6; + uint z : 5; + } data; + uint16 pack; + }; + + union u5u5u5u1 + { + struct + { + uint x : 5; + uint y : 5; + uint z : 5; + uint w : 1; + } data; + uint16 pack; + }; + union u10u10u10u2 { struct @@ -248,6 +305,99 @@ namespace detail uint32 pack; }; + union u9u9u9e5 + { + struct + { + uint x : 9; + uint y : 9; + uint z : 9; + uint w : 5; + } data; + uint32 pack; + }; + + template class vecType> + struct compute_half + {}; + + template + struct compute_half + { + GLM_FUNC_QUALIFIER static tvec1 pack(tvec1 const & v) + { + int16 const Unpacked(detail::toFloat16(v.x)); + return tvec1(reinterpret_cast(Unpacked)); + } + + GLM_FUNC_QUALIFIER static tvec1 unpack(tvec1 const & v) + { + return tvec1(detail::toFloat32(reinterpret_cast(v.x))); + } + }; + + template + struct compute_half + { + GLM_FUNC_QUALIFIER static tvec2 pack(tvec2 const & v) + { + tvec2 const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y)); + return tvec2( + reinterpret_cast(Unpacked.x), + reinterpret_cast(Unpacked.y)); + } + + GLM_FUNC_QUALIFIER static tvec2 unpack(tvec2 const & v) + { + return tvec2( + detail::toFloat32(reinterpret_cast(v.x)), + detail::toFloat32(reinterpret_cast(v.y))); + } + }; + + template + struct compute_half + { + GLM_FUNC_QUALIFIER static tvec3 pack(tvec3 const & v) + { + tvec3 const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z)); + return tvec3( + reinterpret_cast(Unpacked.x), + reinterpret_cast(Unpacked.y), + reinterpret_cast(Unpacked.z)); + } + + GLM_FUNC_QUALIFIER static tvec3 unpack(tvec3 const & v) + { + return tvec3( + detail::toFloat32(reinterpret_cast(v.x)), + detail::toFloat32(reinterpret_cast(v.y)), + detail::toFloat32(reinterpret_cast(v.z))); + } + }; + + template + struct compute_half + { + GLM_FUNC_QUALIFIER static tvec4 pack(tvec4 const & v) + { + tvec4 const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w)); + return tvec4( + reinterpret_cast(Unpacked.x), + reinterpret_cast(Unpacked.y), + reinterpret_cast(Unpacked.z), + reinterpret_cast(Unpacked.w)); + } + + GLM_FUNC_QUALIFIER static tvec4 unpack(tvec4 const & v) + { + return tvec4( + detail::toFloat32(reinterpret_cast(v.x)), + detail::toFloat32(reinterpret_cast(v.y)), + detail::toFloat32(reinterpret_cast(v.z)), + detail::toFloat32(reinterpret_cast(v.w))); + } + }; }//namespace detail GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float v) @@ -300,7 +450,7 @@ namespace detail Unpack * 0.00787401574803149606299212598425f, // 1.0f / 127.0f -1.0f, 1.0f); } - + GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float s) { return static_cast(round(clamp(s, 0.0f, 1.0f) * 65535.0f)); @@ -451,24 +601,23 @@ namespace detail GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v) { - detail::i10i10i10i2 Result; - Result.data.x = int(round(clamp(v.x, 0.0f, 1.0f) * 1023.f)); - Result.data.y = int(round(clamp(v.y, 0.0f, 1.0f) * 1023.f)); - Result.data.z = int(round(clamp(v.z, 0.0f, 1.0f) * 1023.f)); - Result.data.w = int(round(clamp(v.w, 0.0f, 1.0f) * 3.f)); + uvec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(1023.f, 1023.f, 1023.f, 3.f))); + + detail::u10u10u10u2 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + Result.data.z = Unpack.z; + Result.data.w = Unpack.w; return Result.pack; } GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v) { - detail::i10i10i10i2 Unpack; + vec4 const ScaleFactors(1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 3.f); + + detail::u10u10u10u2 Unpack; Unpack.pack = v; - vec4 Result; - Result.x = float(Unpack.data.x) / 1023.f; - Result.y = float(Unpack.data.y) / 1023.f; - Result.z = float(Unpack.data.z) / 1023.f; - Result.w = float(Unpack.data.w) / 3.f; - return Result; + return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactors; } GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v) @@ -487,4 +636,171 @@ namespace detail detail::packed10bitToFloat(v >> 22)); } + GLM_FUNC_QUALIFIER uint32 packF3x9_E1x5(vec3 const & v) + { + float const SharedExpMax = (pow(2.0f, 9.0f - 1.0f) / pow(2.0f, 9.0f)) * pow(2.0f, 31.f - 15.f); + vec3 const Color = clamp(v, 0.0f, SharedExpMax); + float const MaxColor = max(Color.x, max(Color.y, Color.z)); + + float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f; + float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 16.f - 9.f)) + 0.5f); + float const ExpShared = MaxShared == pow(2.0f, 9.0f) ? ExpSharedP + 1.0f : ExpSharedP; + + uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f)); + + detail::u9u9u9e5 Unpack; + Unpack.data.x = ColorComp.x; + Unpack.data.y = ColorComp.y; + Unpack.data.z = ColorComp.z; + Unpack.data.w = uint(ExpShared); + return Unpack.pack; + } + + GLM_FUNC_QUALIFIER vec3 unpackF3x9_E1x5(uint32 v) + { + detail::u9u9u9e5 Unpack; + Unpack.pack = v; + + return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * pow(2.0f, Unpack.data.w - 15.f - 9.f); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType packHalf(vecType const & v) + { + return detail::compute_half::pack(v); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType unpackHalf(vecType const & v) + { + return detail::compute_half::unpack(v); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType packUnorm(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "uintType must be an integer type"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "floatType must be a floating point type"); + + return vecType(round(clamp(v, static_cast(0), static_cast(1)) * static_cast(std::numeric_limits::max()))); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType unpackUnorm(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "uintType must be an integer type"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "floatType must be a floating point type"); + + return vecType(v) * (static_cast(1) / static_cast(std::numeric_limits::max())); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType packSnorm(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "uintType must be an integer type"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "floatType must be a floating point type"); + + return vecType(round(clamp(v , static_cast(-1), static_cast(1)) * static_cast(std::numeric_limits::max()))); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType unpackSnorm(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "uintType must be an integer type"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "floatType must be a floating point type"); + + return clamp(vecType(v) * (static_cast(1) / static_cast(std::numeric_limits::max())), static_cast(-1), static_cast(1)); + } + + GLM_FUNC_QUALIFIER uint8 packUnorm2x4(vec2 const & v) + { + u32vec2 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f)); + detail::u4u4 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + return Result.pack; + } + + GLM_FUNC_QUALIFIER vec2 unpackUnorm2x4(uint8 v) + { + float const ScaleFactor(1.f / 15.f); + detail::u4u4 Unpack; + Unpack.pack = v; + return vec2(Unpack.data.x, Unpack.data.y) * ScaleFactor; + } + + GLM_FUNC_QUALIFIER uint16 packUnorm4x4(vec4 const & v) + { + u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f)); + detail::u4u4u4u4 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + Result.data.z = Unpack.z; + Result.data.w = Unpack.w; + return Result.pack; + } + + GLM_FUNC_QUALIFIER vec4 unpackUnorm4x4(uint16 v) + { + float const ScaleFactor(1.f / 15.f); + detail::u4u4u4u4 Unpack; + Unpack.pack = v; + return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor; + } + + GLM_FUNC_QUALIFIER uint16 packUnorm1x5_1x6_1x5(vec3 const & v) + { + u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(15.f, 31.f, 15.f))); + detail::u5u6u5 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + Result.data.z = Unpack.z; + return Result.pack; + } + + GLM_FUNC_QUALIFIER vec3 unpackUnorm1x5_1x6_1x5(uint16 v) + { + vec3 const ScaleFactor(1.f / 15.f, 1.f / 31.f, 1.f / 15.f); + detail::u5u6u5 Unpack; + Unpack.pack = v; + return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor; + } + + GLM_FUNC_QUALIFIER uint16 packUnorm3x5_1x1(vec4 const & v) + { + u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(15.f, 15.f, 15.f, 1.f))); + detail::u5u5u5u1 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + Result.data.z = Unpack.z; + Result.data.w = Unpack.w; + return Result.pack; + } + + GLM_FUNC_QUALIFIER vec4 unpackUnorm3x5_1x1(uint16 v) + { + vec4 const ScaleFactor(1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f); + detail::u5u5u5u1 Unpack; + Unpack.pack = v; + return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor; + } + + GLM_FUNC_QUALIFIER uint8 packUnorm2x3_1x2(vec3 const & v) + { + u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(7.f, 7.f, 3.f))); + detail::u3u3u2 Result; + Result.data.x = Unpack.x; + Result.data.y = Unpack.y; + Result.data.z = Unpack.z; + return Result.pack; + } + + GLM_FUNC_QUALIFIER vec3 unpackUnorm2x3_1x2(uint8 v) + { + vec3 const ScaleFactor(1.f / 7.f, 1.f / 7.f, 1.f / 3.f); + detail::u3u3u2 Unpack; + Unpack.pack = v; + return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor; + } }//namespace glm + diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 71817dfa..f5711c64 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -76,6 +76,26 @@ namespace glm T x, y, z, w; +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; + static const type X; + static const type Y; + static const type Z; + static const type W; + static const type XY; + static const type XZ; + static const type XW; + static const type YZ; + static const type YW; + static const type ZW; + static const type XYZ; + static const type XYW; + static const type XZW; + static const type YZW; + static const type XYZW; +# endif + // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC @@ -374,6 +394,16 @@ namespace glm template GLM_FUNC_DECL tvec4 notEqual(tquat const & x, tquat const & y); /// @} + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = false; + static bool const is_quat = true; + }; } //namespace glm #include "quaternion.inl" diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 4c8565bc..4ee7f802 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -49,6 +49,73 @@ namespace detail }; }//namespace detail +# ifdef GLM_STATIC_CONST_MEMBERS + template + const tquat tquat::ZERO + (static_cast(0), static_cast(0), static_cast(0), static_cast(0)); + + template const tquat tquat::IDENTITY; + + template + const tquat tquat::X + (static_cast(0), static_cast(1), static_cast(0), static_cast(0)); + + template + const tquat tquat::Y + (static_cast(0), static_cast(0), static_cast(1), static_cast(0)); + + template + const tquat tquat::Z + (static_cast(0), static_cast(0), static_cast(0), static_cast(1)); + + template + const tquat tquat::W + (static_cast(1), static_cast(0), static_cast(0), static_cast(0)); + + template + const tquat tquat::XY + (static_cast(0), static_cast(1), static_cast(1), static_cast(0)); + + template + const tquat tquat::XZ + (static_cast(0), static_cast(0), static_cast(1), static_cast(1)); + + template + const tquat tquat::XW + (static_cast(1), static_cast(1), static_cast(0), static_cast(0)); + + template + const tquat tquat::YZ + (static_cast(0), static_cast(0), static_cast(1), static_cast(1)); + + template + const tquat tquat::YW + (static_cast(1), static_cast(0), static_cast(1), static_cast(0)); + + template + const tquat tquat::ZW + (static_cast(1), static_cast(0), static_cast(0), static_cast(1)); + + template + const tquat tquat::XYZ + (static_cast(0), static_cast(1), static_cast(1), static_cast(1)); + + template + const tquat tquat::XYW + (static_cast(1), static_cast(1), static_cast(1), static_cast(0)); + + template + const tquat tquat::XZW + (static_cast(1), static_cast(1), static_cast(0), static_cast(1)); + + template + const tquat tquat::YZW + (static_cast(1), static_cast(0), static_cast(1), static_cast(1)); + + template + const tquat tquat::XYZW + (static_cast(1), static_cast(1), static_cast(1), static_cast(1)); +# endif // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC diff --git a/glm/gtc/random.hpp b/glm/gtc/random.hpp index a9254c01..7e77202e 100644 --- a/glm/gtc/random.hpp +++ b/glm/gtc/random.hpp @@ -60,13 +60,20 @@ namespace glm /// /// @param Min /// @param Max - /// @tparam genType Value type. Currently supported: half (not recommanded), float or double scalars and vectors. + /// @tparam genType Value type. Currently supported: float or double scalars. /// @see gtc_random template GLM_FUNC_DECL genTYpe linearRand( genTYpe Min, genTYpe Max); + /// Generate random numbers in the interval [Min, Max], according a linear distribution + /// + /// @param Min + /// @param Max + /// @tparam T Value type. Currently supported: float or double. + /// @tparam vecType A vertor type: tvec1, tvec2, tvec3, tvec4 or compatible + /// @see gtc_random template class vecType> GLM_FUNC_DECL vecType linearRand( vecType const & Min, diff --git a/glm/gtc/reciprocal.hpp b/glm/gtc/reciprocal.hpp index 72480788..916dfb40 100644 --- a/glm/gtc/reciprocal.hpp +++ b/glm/gtc/reciprocal.hpp @@ -56,77 +56,107 @@ namespace glm /// Secant function. /// hypotenuse / adjacent or 1 / cos(x) /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType sec(genType const & angle); + GLM_FUNC_DECL genType sec(genType angle); /// Cosecant function. /// hypotenuse / opposite or 1 / sin(x) /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType csc(genType const & angle); + GLM_FUNC_DECL genType csc(genType angle); /// Cotangent function. /// adjacent / opposite or 1 / tan(x) /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType cot(genType const & angle); + GLM_FUNC_DECL genType cot(genType angle); /// Inverse secant function. /// + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType asec(genType const & x); + GLM_FUNC_DECL genType asec(genType x); /// Inverse cosecant function. /// + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType acsc(genType const & x); + GLM_FUNC_DECL genType acsc(genType x); /// Inverse cotangent function. /// + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType acot(genType const & x); + GLM_FUNC_DECL genType acot(genType x); /// Secant hyperbolic function. /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType sech(genType const & angle); + GLM_FUNC_DECL genType sech(genType angle); /// Cosecant hyperbolic function. /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType csch(genType const & angle); + GLM_FUNC_DECL genType csch(genType angle); /// Cotangent hyperbolic function. /// + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType coth(genType const & angle); + GLM_FUNC_DECL genType coth(genType angle); /// Inverse secant hyperbolic function. /// + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. + /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType asech(genType const & x); + GLM_FUNC_DECL genType asech(genType x); /// Inverse cosecant hyperbolic function. /// - /// @see gtc_reciprocal - template - GLM_FUNC_DECL genType acsch(genType const & x); - - /// Inverse cotangent hyperbolic function. + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. /// /// @see gtc_reciprocal template - GLM_FUNC_DECL genType acoth(genType const & x); + GLM_FUNC_DECL genType acsch(genType x); + + /// Inverse cotangent hyperbolic function. + /// + /// @return Return an angle expressed in radians. + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see gtc_reciprocal + template + GLM_FUNC_DECL genType acoth(genType x); /// @} }//namespace glm diff --git a/glm/gtc/round.inl b/glm/gtc/round.inl index 255dec66..94fdd54b 100644 --- a/glm/gtc/round.inl +++ b/glm/gtc/round.inl @@ -104,10 +104,7 @@ namespace detail GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple) { if(Source > genType(0)) - { - genType Tmp = Source - genType(1); - return Tmp + (Multiple - std::fmod(Tmp, Multiple)); - } + return Source + (Multiple - std::fmod(Source, Multiple)); else return Source + std::fmod(-Source, Multiple); } @@ -152,10 +149,7 @@ namespace detail if(Source >= genType(0)) return Source - std::fmod(Source, Multiple); else - { - genType Tmp = Source + genType(1); - return Tmp - std::fmod(Tmp, Multiple) - Multiple; - } + return Source - std::fmod(Source, Multiple) - Multiple; } }; diff --git a/glm/gtx/component_wise.hpp b/glm/gtx/component_wise.hpp index d5b3d818..4f90c4ff 100644 --- a/glm/gtx/component_wise.hpp +++ b/glm/gtx/component_wise.hpp @@ -54,29 +54,37 @@ namespace glm /// @addtogroup gtx_component_wise /// @{ + /// Convert an integer vector to a normalized float vector. + /// If the parameter value type is already a floating precision type, the value is passed through. + /// @see gtx_component_wise + template class vecType> + GLM_FUNC_DECL vecType compNormalize(vecType const & v); + + /// Convert a normalized float vector to an integer vector. + /// If the parameter value type is already a floating precision type, the value is passed through. + /// @see gtx_component_wise + template class vecType> + GLM_FUNC_DECL vecType compScale(vecType const & v); + /// Add all vector components together. /// @see gtx_component_wise template - GLM_FUNC_DECL typename genType::value_type compAdd( - genType const & v); + GLM_FUNC_DECL typename genType::value_type compAdd(genType const & v); /// Multiply all vector components together. /// @see gtx_component_wise template - GLM_FUNC_DECL typename genType::value_type compMul( - genType const & v); + GLM_FUNC_DECL typename genType::value_type compMul(genType const & v); /// Find the minimum value between single vector components. /// @see gtx_component_wise template - GLM_FUNC_DECL typename genType::value_type compMin( - genType const & v); + GLM_FUNC_DECL typename genType::value_type compMin(genType const & v); /// Find the maximum value between single vector components. /// @see gtx_component_wise template - GLM_FUNC_DECL typename genType::value_type compMax( - genType const & v); + GLM_FUNC_DECL typename genType::value_type compMax(genType const & v); /// @} }//namespace glm diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index f944faeb..42a641da 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -30,8 +30,95 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm +#include + +namespace glm{ +namespace detail { + template class vecType, bool isInteger, bool signedType> + struct compute_compNormalize + {}; + + template class vecType> + struct compute_compNormalize + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + floatType const Min = static_cast(std::numeric_limits::min()); + floatType const Max = static_cast(std::numeric_limits::max()); + return (vecType(v) - Min) / (Max - Min) * static_cast(2) - static_cast(1); + } + }; + + template class vecType> + struct compute_compNormalize + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + return vecType(v) / static_cast(std::numeric_limits::max()); + } + }; + + template class vecType> + struct compute_compNormalize + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + return v; + } + }; + + template class vecType, bool isInteger, bool signedType> + struct compute_compScale + {}; + + template class vecType> + struct compute_compScale + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + floatType const Max = static_cast(std::numeric_limits::max()) + static_cast(0.5); + vecType const Scaled(v * Max); + vecType const Result(Scaled - static_cast(0.5)); + return Result; + } + }; + + template class vecType> + struct compute_compScale + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + return vecType(vecType(v) * static_cast(std::numeric_limits::max())); + } + }; + + template class vecType> + struct compute_compScale + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + { + return v; + } + }; +}//namespace detail + + template class vecType> + GLM_FUNC_QUALIFIER vecType compNormalize(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'compNormalize' accepts only floating-point types for 'floatType' template parameter"); + + return detail::compute_compNormalize::is_integer, std::numeric_limits::is_signed>::call(v); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType compScale(vecType const & v) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'compScale' accepts only floating-point types for 'floatType' template parameter"); + + return detail::compute_compScale::is_integer, std::numeric_limits::is_signed>::call(v); + } + template class vecType> GLM_FUNC_QUALIFIER T compAdd(vecType const & v) { diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index 1c26b34d..02786f47 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -292,6 +292,16 @@ namespace glm #endif /// @} + + // -- Is type -- + + template + struct type + { + static bool const is_vec = false; + static bool const is_mat = false; + static bool const is_quat = true; + }; } //namespace glm #include "dual_quaternion.inl" diff --git a/glm/gtx/extented_min_max.hpp b/glm/gtx/extended_min_max.hpp similarity index 97% rename from glm/gtx/extented_min_max.hpp rename to glm/gtx/extended_min_max.hpp index 08d56f17..dacf5d42 100644 --- a/glm/gtx/extented_min_max.hpp +++ b/glm/gtx/extended_min_max.hpp @@ -24,8 +24,8 @@ /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// -/// @ref gtx_extented_min_max -/// @file glm/gtx/extented_min_max.hpp +/// @ref gtx_extended_min_max +/// @file glm/gtx/extended_min_max.hpp /// @date 2007-03-14 / 2011-06-07 /// @author Christophe Riccio /// @@ -159,4 +159,4 @@ namespace glm /// @} }//namespace glm -#include "extented_min_max.inl" +#include "extended_min_max.inl" diff --git a/glm/gtx/extented_min_max.inl b/glm/gtx/extended_min_max.inl similarity index 98% rename from glm/gtx/extented_min_max.inl rename to glm/gtx/extended_min_max.inl index e54c8479..f8dd0e20 100644 --- a/glm/gtx/extented_min_max.inl +++ b/glm/gtx/extended_min_max.inl @@ -24,8 +24,8 @@ /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// -/// @ref gtx_extented_min_max -/// @file glm/gtx/extented_min_max.inl +/// @ref gtx_extended_min_max +/// @file glm/gtx/extended_min_max.inl /// @date 2007-03-14 / 2011-06-07 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/glm/gtx/float_notmalize.inl b/glm/gtx/float_notmalize.inl new file mode 100644 index 00000000..361c8829 --- /dev/null +++ b/glm/gtx/float_notmalize.inl @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_float_normalize +/// @file glm/gtx/float_normalize.inl +/// @date 2015-09-25 / 2015-09-25 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm +{ + template class vecType> + GLM_FUNC_QUALIFIER vecType floatNormalize(vecType const & v) + { + return vecType(v) / static_cast(std::numeric_limits::max()); + } + +}//namespace glm diff --git a/glm/gtx/hash.hpp b/glm/gtx/hash.hpp index cd44028c..02030987 100644 --- a/glm/gtx/hash.hpp +++ b/glm/gtx/hash.hpp @@ -41,10 +41,6 @@ #pragma once -#if !GLM_HAS_CXX11_STL -# error "GLM_GTX_hash requires C++11 standard library support" -#endif - #include #include "../vec2.hpp" @@ -67,96 +63,100 @@ #include "../mat4x3.hpp" #include "../mat4x4.hpp" +#if !GLM_HAS_CXX11_STL +# error "GLM_GTX_hash requires C++11 standard library support" +#endif + namespace std { template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tvec1 &v) const; + GLM_FUNC_DECL size_t operator()(glm::tvec1 const & v) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tvec2 &v) const; + GLM_FUNC_DECL size_t operator()(glm::tvec2 const & v) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tvec3 &v) const; + GLM_FUNC_DECL size_t operator()(glm::tvec3 const & v) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tvec4 &v) const; + GLM_FUNC_DECL size_t operator()(glm::tvec4 const & v) const; }; template struct hash> { - GLM_FUNC_DECL size_t operator()(const glm::tquat &q) const; + GLM_FUNC_DECL size_t operator()(glm::tquat const & q) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tdualquat &q) const; + GLM_FUNC_DECL size_t operator()(glm::tdualquat const & q) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat2x2 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat2x2 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat2x3 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat2x3 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat2x4 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat2x4 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat3x2 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat3x2 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat3x3 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat3x3 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat3x4 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat3x4 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat4x2 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat4x2 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat4x3 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat4x3 const & m) const; }; template - struct hash> + struct hash > { - GLM_FUNC_DECL size_t operator()(const glm::tmat4x4 &m) const; + GLM_FUNC_DECL size_t operator()(glm::tmat4x4 const & m) const; }; } // namespace std diff --git a/glm/gtx/hash.inl b/glm/gtx/hash.inl index bba2c1ed..8aa299e1 100644 --- a/glm/gtx/hash.inl +++ b/glm/gtx/hash.inl @@ -52,16 +52,14 @@ namespace detail namespace std { template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tvec1 &v) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec1 const & v) const { hash hasher; return hasher(v.x); } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tvec2 &v) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec2 const & v) const { size_t seed = 0; hash hasher; @@ -71,8 +69,7 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tvec3 &v) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec3 const & v) const { size_t seed = 0; hash hasher; @@ -83,8 +80,7 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tvec4 &v) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec4 const & v) const { size_t seed = 0; hash hasher; @@ -96,8 +92,7 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tquat &q) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tquat const & q) const { size_t seed = 0; hash hasher; @@ -109,55 +104,50 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tdualquat &q) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tdualquat const & q) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(q.real)); glm::detail::hash_combine(seed, hasher(q.dual)); return seed; } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat2x2 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x2 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); return seed; } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat2x3 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x3 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); return seed; } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat2x4 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x4 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); return seed; } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat3x2 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x2 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); @@ -165,11 +155,10 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat3x3 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x3 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); @@ -177,11 +166,10 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat3x4 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x4 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); @@ -189,11 +177,10 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat4x2 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x2 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); @@ -202,11 +189,10 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat4x3 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x3 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); @@ -215,11 +201,10 @@ namespace std } template - GLM_FUNC_QUALIFIER size_t - hash>::operator()(const glm::tmat4x4 &m) const + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x4 const & m) const { size_t seed = 0; - hash> hasher; + hash> hasher; glm::detail::hash_combine(seed, hasher(m[0])); glm::detail::hash_combine(seed, hasher(m[1])); glm::detail::hash_combine(seed, hasher(m[2])); diff --git a/glm/gtx/matrix_decompose.hpp b/glm/gtx/matrix_decompose.hpp index 735b4288..e7fc83e2 100644 --- a/glm/gtx/matrix_decompose.hpp +++ b/glm/gtx/matrix_decompose.hpp @@ -36,7 +36,7 @@ /// /// @brief Decomposes a model matrix to translations, rotation and scale components /// -/// need to be included to use these functionalities. +/// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// #pragma once diff --git a/glm/gtx/quaternion.hpp b/glm/gtx/quaternion.hpp index 34d940a1..b34c3be8 100644 --- a/glm/gtx/quaternion.hpp +++ b/glm/gtx/quaternion.hpp @@ -57,7 +57,7 @@ namespace glm /// @addtogroup gtx_quaternion /// @{ - //! Compute a cross product between a quaternion and a vector. + /// Compute a cross product between a quaternion and a vector. /// /// @see gtx_quaternion template diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 7467b42d..b405cc5e 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -249,6 +249,9 @@ namespace glm T cosTheta = dot(orig, dest); tvec3 rotationAxis; + if(cosTheta >= static_cast(1) - epsilon()) + return quat(); + if(cosTheta < static_cast(-1) + epsilon()) { // special case when vectors in opposite directions : diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index 04198333..e1567610 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -83,6 +83,11 @@ namespace detail static GLM_RELAXED_CONSTEXPR precision prec = defaultp; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + GLM_FUNC_DECL length_t length() const; fvec4SIMD Data[4]; diff --git a/glm/gtx/simd_mat4.inl b/glm/gtx/simd_mat4.inl index 13dcb20f..c436ab1f 100644 --- a/glm/gtx/simd_mat4.inl +++ b/glm/gtx/simd_mat4.inl @@ -61,6 +61,11 @@ GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[] return this->Data[i]; } +#ifdef GLM_STATIC_CONST_MEMBERS + const fmat4x4SIMD fmat4x4SIMD::ZERO(static_cast(0)); + const fmat4x4SIMD fmat4x4SIMD::IDENTITY(static_cast(1)); +#endif + ////////////////////////////////////////////////////////////// // Constructors diff --git a/glm/gtx/simd_quat.hpp b/glm/gtx/simd_quat.hpp index 97075ba6..16782081 100644 --- a/glm/gtx/simd_quat.hpp +++ b/glm/gtx/simd_quat.hpp @@ -91,6 +91,26 @@ namespace detail __m128 Data; #endif +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; + static const type X; + static const type Y; + static const type Z; + static const type W; + static const type XY; + static const type XZ; + static const type XW; + static const type YZ; + static const type YW; + static const type ZW; + static const type XYZ; + static const type XYW; + static const type XZW; + static const type YZW; + static const type XYZW; +# endif + ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/gtx/simd_quat.inl b/glm/gtx/simd_quat.inl index 2fcc7fe4..c301988a 100644 --- a/glm/gtx/simd_quat.inl +++ b/glm/gtx/simd_quat.inl @@ -51,6 +51,25 @@ void print(const fvec4SIMD &v) } #endif +# ifdef GLM_STATIC_CONST_MEMBERS + const fquatSIMD fquatSIMD::ZERO(0, 0, 0, 0); + const fquatSIMD fquatSIMD::IDENTITY(1, 0, 0, 0); + const fquatSIMD fquatSIMD::X(0, 1, 0, 0); + const fquatSIMD fquatSIMD::Y(0, 0, 1, 0); + const fquatSIMD fquatSIMD::Z(0, 0, 0, 1); + const fquatSIMD fquatSIMD::W(1, 0, 0, 0); + const fquatSIMD fquatSIMD::XY(0, 1, 1, 0); + const fquatSIMD fquatSIMD::XZ(0, 1, 0, 1); + const fquatSIMD fquatSIMD::XW(1, 1, 0, 0); + const fquatSIMD fquatSIMD::YZ(0, 0, 1, 1); + const fquatSIMD fquatSIMD::YW(1, 0, 1, 0); + const fquatSIMD fquatSIMD::ZW(1, 0, 0, 1); + const fquatSIMD fquatSIMD::XYZ(0, 1, 1, 1); + const fquatSIMD fquatSIMD::XYW(1, 1, 1, 0); + const fquatSIMD fquatSIMD::XZW(1, 1, 0, 1); + const fquatSIMD fquatSIMD::YZW(1, 0, 1, 1); + const fquatSIMD fquatSIMD::XYZW(1, 1, 1, 1); +# endif ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index cb084852..3877f821 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -114,6 +114,25 @@ namespace detail __m128 Data; #endif +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type X; + static const type Y; + static const type Z; + static const type W; + static const type XY; + static const type XZ; + static const type XW; + static const type YZ; + static const type YW; + static const type ZW; + static const type XYZ; + static const type XYW; + static const type XZW; + static const type YZW; + static const type XYZW; +# endif + ////////////////////////////////////// // Implicit basic constructors @@ -167,15 +186,15 @@ namespace detail ////////////////////////////////////// // Swizzle operators - template + template fvec4SIMD& swizzle(); - template + template fvec4SIMD swizzle() const; - template + template fvec4SIMD swizzle() const; - template + template fvec4SIMD swizzle() const; - template + template fvec4SIMD swizzle() const; }; }//namespace detail diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index e375073f..b1413eea 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -16,6 +16,25 @@ struct shuffle_mask enum{value = Value}; }; +# ifdef GLM_STATIC_CONST_MEMBERS + const fvec4SIMD fvec4SIMD::ZERO(0, 0, 0, 0); + const fvec4SIMD fvec4SIMD::X(1, 0, 0, 0); + const fvec4SIMD fvec4SIMD::Y(0, 1, 0, 0); + const fvec4SIMD fvec4SIMD::Z(0, 0, 1, 0); + const fvec4SIMD fvec4SIMD::W(0, 0, 0, 1); + const fvec4SIMD fvec4SIMD::XY(1, 1, 0, 0); + const fvec4SIMD fvec4SIMD::XZ(1, 0, 1, 0); + const fvec4SIMD fvec4SIMD::XW(1, 0, 0, 1); + const fvec4SIMD fvec4SIMD::YZ(0, 1, 1, 0); + const fvec4SIMD fvec4SIMD::YW(0, 1, 0, 1); + const fvec4SIMD fvec4SIMD::ZW(0, 0, 1, 1); + const fvec4SIMD fvec4SIMD::XYZ(1, 1, 1, 0); + const fvec4SIMD fvec4SIMD::XYW(1, 1, 0, 1); + const fvec4SIMD fvec4SIMD::XZW(1, 0, 1, 1); + const fvec4SIMD fvec4SIMD::YZW(0, 1, 1, 1); + const fvec4SIMD fvec4SIMD::XYZW(1, 1, 1, 1); +# endif + ////////////////////////////////////// // Implicit basic constructors @@ -167,21 +186,21 @@ GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator--() ////////////////////////////////////// // Swizzle operators -template +template GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const { __m128 Data = _mm_shuffle_ps( this->Data, this->Data, - shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + shuffle_mask<(W_ << 6) | (Z_ << 4) | (Y_ << 2) | (X_ << 0)>::value); return fvec4SIMD(Data); } -template +template GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle() { this->Data = _mm_shuffle_ps( this->Data, this->Data, - shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + shuffle_mask<(W_ << 6) | (Z_ << 4) | (Y_ << 2) | (X_ << 0)>::value); return *this; } diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index e04320c0..c292efd1 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -48,6 +48,8 @@ // Dependency: #include "../glm.hpp" #include "../gtc/type_precision.hpp" +#include "../gtc/quaternion.hpp" +#include "../gtx/dual_quaternion.hpp" #include #if(GLM_COMPILER & GLM_COMPILER_CUDA) diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index fb70ebc0..c21fa75f 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -444,6 +444,38 @@ namespace detail x[3][0], x[3][1], x[3][2], x[3][3]); } }; + + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tquat const & x) + { + char const * PrefixStr = prefix::value(); + char const * LiteralStr = literal::is_iec559>::value(); + std::string FormatStr(detail::format("%squat(%s, %s, %s, %s)", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); + } + }; + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tdualquat const & x) + { + char const * PrefixStr = prefix::value(); + char const * LiteralStr = literal::is_iec559>::value(); + std::string FormatStr(detail::format("%sdualquat((%s, %s, %s, %s), (%s, %s, %s, %s))", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x.real[0], x.real[1], x.real[2], x.real[3], x.dual[0], x.dual[1], x.dual[2], x.dual[3]); + } + }; + }//namespace detail template