merge upstream/master

This commit is contained in:
jan p springer
2015-10-29 13:44:26 +00:00
546 changed files with 65986 additions and 67295 deletions

View File

@@ -4,6 +4,7 @@ file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)
file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
@@ -18,7 +19,7 @@ file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
source_group("Text Files" FILES ${ROOT_TEXT})
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
@@ -32,7 +33,7 @@ source_group("GTX Files" FILES ${GTX_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
if(GLM_TEST_ENABLE)
add_executable(${NAME} ${ROOT_TEXT} ${ROOT_NAT}
add_executable(${NAME} ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}

View File

@@ -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 <glm/glm.hpp>
#include <glm/ext.hpp>
#include <limits>
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.hpp>// glm::vec3
#include <glm/geometric.hpp>// 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.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4, glm::ivec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
#include <glm/gtc/type_ptr.hpp> // 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.hpp>// glm::vec2
#include <glm/packing.hpp>// glm::packUnorm2x16
#include <glm/integer.hpp>// glm::uint
#include <glm/gtc/type_precision.hpp>// 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.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
#include <glm/exponential.hpp>// glm::pow
#include <glm/gtc/random.hpp>// 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 <typename T, glm::precision P, template<typename, glm::precision> class vecType>
T normalizeDotA(vecType<T, P> const & x, vecType<T, P> 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<typename, glm::precision> class
template <GLM_TEMPLATE_GENTYPE vecType>
T normalizeDotB(vecType<T, P> const & x, vecType<T, P> const & y)
{
return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
}
template <typename vecType>
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 <glm/glm.hpp>
#include <glm/ext.hpp>
#include <limits>
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.hpp>// glm::vec3
#include <glm/geometric.hpp>// 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.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4, glm::ivec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
#include <glm/gtc/type_ptr.hpp> // 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.hpp>// glm::vec2
#include <glm/packing.hpp>// glm::packUnorm2x16
#include <glm/integer.hpp>// glm::uint
#include <glm/gtc/type_precision.hpp>// 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.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
#include <glm/exponential.hpp>// glm::pow
#include <glm/gtc/random.hpp>// 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 <typename T, glm::precision P, template<typename, glm::precision> class vecType>
T normalizeDotA(vecType<T, P> const & x, vecType<T, P> 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<typename, glm::precision> class
template <GLM_TEMPLATE_GENTYPE vecType>
T normalizeDotB(vecType<T, P> const & x, vecType<T, P> const & y)
{
return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
}
template <typename vecType>
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;
}

View File

@@ -86,7 +86,7 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType length(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' accepts only floating-point inputs");
return abs(x);
}
@@ -94,7 +94,7 @@ namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER T length(vecType<T, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' accepts only floating-point inputs");
return sqrt(dot(v, v));
}
@@ -103,7 +103,7 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType distance(genType const & p0, genType const & p1)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' accepts only floating-point inputs");
return length(p1 - p0);
}
@@ -118,14 +118,14 @@ namespace detail
template <typename T>
GLM_FUNC_QUALIFIER T dot(T x, T y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return x * y;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER T dot(vecType<T, P> const & x, vecType<T, P> const & y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<vecType, T, P>::call(x, y);
}
@@ -133,7 +133,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> cross(tvec3<T, P> const & x, tvec3<T, P> const & y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cross' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cross' accepts only floating-point inputs");
return tvec3<T, P>(
x.y * y.z - y.y * x.z,
@@ -145,7 +145,7 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType normalize(genType const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'normalize' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'normalize' accepts only floating-point inputs");
return x < genType(0) ? genType(-1) : genType(1);
}
@@ -153,7 +153,7 @@ namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> normalize(vecType<T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
return x * inversesqrt(dot(x, x));
}
@@ -182,7 +182,7 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType refract(genType const & I, genType const & N, genType const & eta)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'refract' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'refract' accepts only floating-point inputs");
genType const dotValue(dot(N, I));
genType const k(static_cast<genType>(1) - eta * eta * (static_cast<genType>(1) - dotValue * dotValue));
@@ -192,7 +192,7 @@ namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> refract(vecType<T, P> const & I, vecType<T, P> const & N, T eta)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'refract' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'refract' accepts only floating-point inputs");
T const dotValue(dot(N, I));
T const k(static_cast<T>(1) - eta * eta * (static_cast<T>(1) - dotValue * dotValue));

View File

@@ -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 <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.13 Noise Functions</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise1.xml">GLSL noise1 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.13 Noise Functions</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise2.xml">GLSL noise2 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.13 Noise Functions</a>
template <typename genType>
GLM_FUNC_DECL tvec2<typename genType::value_type, defaultp> noise2(genType const & x);
/// Returns a 3D noise value based on the input value x.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise3.xml">GLSL noise3 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.13 Noise Functions</a>
template <typename genType>
GLM_FUNC_DECL tvec3<typename genType::value_type, defaultp> noise3(genType const & x);
/// Returns a 4D noise value based on the input value x.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise4.xml">GLSL noise4 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.13 Noise Functions</a>
template <typename genType>
GLM_FUNC_DECL tvec4<typename genType::value_type, defaultp> noise4(genType const & x);
/// @}
}//namespace glm
#include "func_noise.inl"

View File

@@ -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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> grad4(T const & j, tvec4<T, P> const & ip)
{
tvec3<T, P> pXYZ = floor(fract(tvec3<T, P>(j) * tvec3<T, P>(ip)) * T(7)) * ip[2] - T(1);
T pW = static_cast<T>(1.5) - dot(abs(pXYZ), tvec3<T, P>(1));
tvec4<T, P> s = tvec4<T, P>(lessThan(tvec4<T, P>(pXYZ, pW), tvec4<T, P>(0.0)));
pXYZ = pXYZ + (tvec3<T, P>(s) * T(2) - T(1)) * s.w;
return tvec4<T, P>(pXYZ, pW);
}
}//namespace detail
template <typename T>
GLM_FUNC_QUALIFIER T noise1(T const & x)
{
return noise1(tvec2<T, defaultp>(x, T(0)));
}
template <typename T>
GLM_FUNC_QUALIFIER tvec2<T, defaultp> noise2(T const & x)
{
return tvec2<T, defaultp>(
noise1(x + T(0.0)),
noise1(x + T(1.0)));
}
template <typename T>
GLM_FUNC_QUALIFIER tvec3<T, defaultp> noise3(T const & x)
{
return tvec3<T, defaultp>(
noise1(x - T(1.0)),
noise1(x + T(0.0)),
noise1(x + T(1.0)));
}
template <typename T>
GLM_FUNC_QUALIFIER tvec4<T, defaultp> noise4(T const & x)
{
return tvec4<T, defaultp>(
noise1(x - T(1.0)),
noise1(x + T(0.0)),
noise1(x + T(1.0)),
noise1(x + T(2.0)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T noise1(tvec2<T, P> const & v)
{
tvec4<T, P> const C = tvec4<T, P>(
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<T, P> i = floor(v + dot(v, tvec2<T, P>(C[1])));
tvec2<T, P> x0 = v - i + dot(i, tvec2<T, P>(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<T, P> i1 = (x0.x > x0.y) ? tvec2<T, P>(1, 0) : tvec2<T, P>(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<T, P> x12 = tvec4<T, P>(x0.x, x0.y, x0.x, x0.y) + tvec4<T, P>(C.x, C.x, C.z, C.z);
x12 = tvec4<T, P>(tvec2<T, P>(x12) - i1, x12.z, x12.w);
// Permutations
i = mod(i, T(289)); // Avoid truncation effects in permutation
tvec3<T, P> p = detail::permute(
detail::permute(i.y + tvec3<T, P>(T(0), i1.y, T(1))) + i.x + tvec3<T, P>(T(0), i1.x, T(1)));
tvec3<T, P> m = max(T(0.5) - tvec3<T, P>(
dot(x0, x0),
dot(tvec2<T, P>(x12.x, x12.y), tvec2<T, P>(x12.x, x12.y)),
dot(tvec2<T, P>(x12.z, x12.w), tvec2<T, P>(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<T, P> x = static_cast<T>(2) * fract(p * C.w) - T(1);
tvec3<T, P> h = abs(x) - T(0.5);
tvec3<T, P> ox = floor(x + T(0.5));
tvec3<T, P> a0 = x - ox;
// Normalise gradients implicitly by scaling m
// Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h );
m *= static_cast<T>(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h);
// Compute final noise value at P
tvec3<T, P> 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 <typename T, precision P>
GLM_FUNC_QUALIFIER T noise1(tvec3<T, P> const & v)
{
tvec2<T, P> const C(1.0 / 6.0, 1.0 / 3.0);
tvec4<T, P> const D(0.0, 0.5, 1.0, 2.0);
// First corner
tvec3<T, P> i(floor(v + dot(v, tvec3<T, P>(C.y))));
tvec3<T, P> x0(v - i + dot(i, tvec3<T, P>(C.x)));
// Other corners
tvec3<T, P> g(step(tvec3<T, P>(x0.y, x0.z, x0.x), x0));
tvec3<T, P> l(T(1) - g);
tvec3<T, P> i1(min(g, tvec3<T, P>(l.z, l.x, l.y)));
tvec3<T, P> i2(max(g, tvec3<T, P>(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<T, P> x1(x0 - i1 + C.x);
tvec3<T, P> x2(x0 - i2 + C.y); // 2.0*C.x = 1/3 = C.y
tvec3<T, P> x3(x0 - D.y); // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
tvec4<T, P> p(detail::permute(detail::permute(detail::permute(
i.z + tvec4<T, P>(T(0), i1.z, i2.z, T(1))) +
i.y + tvec4<T, P>(T(0), i1.y, i2.y, T(1))) +
i.x + tvec4<T, P>(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<T>(0.142857142857); // 1.0/7.0
tvec3<T, P> ns(n_ * tvec3<T, P>(D.w, D.y, D.z) - tvec3<T, P>(D.x, D.z, D.x));
tvec4<T, P> j(p - T(49) * floor(p * ns.z * ns.z)); // mod(p,7*7)
tvec4<T, P> x_(floor(j * ns.z));
tvec4<T, P> y_(floor(j - T(7) * x_)); // mod(j,N)
tvec4<T, P> x(x_ * ns.x + ns.y);
tvec4<T, P> y(y_ * ns.x + ns.y);
tvec4<T, P> h(T(1) - abs(x) - abs(y));
tvec4<T, P> b0(x.x, x.y, y.x, y.y);
tvec4<T, P> 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<T, P> s0(floor(b0) * T(2) + T(1));
tvec4<T, P> s1(floor(b1) * T(2) + T(1));
tvec4<T, P> sh(-step(h, tvec4<T, P>(0.0)));
tvec4<T, P> a0 = tvec4<T, P>(b0.x, b0.z, b0.y, b0.w) + tvec4<T, P>(s0.x, s0.z, s0.y, s0.w) * tvec4<T, P>(sh.x, sh.x, sh.y, sh.y);
tvec4<T, P> a1 = tvec4<T, P>(b1.x, b1.z, b1.y, b1.w) + tvec4<T, P>(s1.x, s1.z, s1.y, s1.w) * tvec4<T, P>(sh.z, sh.z, sh.w, sh.w);
tvec3<T, P> p0(a0.x, a0.y, h.x);
tvec3<T, P> p1(a0.z, a0.w, h.y);
tvec3<T, P> p2(a1.x, a1.y, h.z);
tvec3<T, P> p3(a1.z, a1.w, h.w);
// Normalise gradients
tvec4<T, P> norm = taylorInvSqrt(tvec4<T, P>(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<T, P> m = max(T(0.6) - tvec4<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), T(0));
m = m * m;
return T(42) * dot(m * m, tvec4<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T noise1(tvec4<T, P> const & v)
{
tvec4<T, P> 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<T>(0.309016994374947451);
// First corner
tvec4<T, P> i = floor(v + dot(v, tvec4<T, P>(F4)));
tvec4<T, P> x0 = v - i + dot(i, tvec4<T, P>(C.x));
// Other corners
// Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)
tvec4<T, P> i0;
tvec3<T, P> isX = step(tvec3<T, P>(x0.y, x0.z, x0.w), tvec3<T, P>(x0.x));
tvec3<T, P> isYZ = step(tvec3<T, P>(x0.z, x0.w, x0.w), tvec3<T, P>(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<T>(1) - isX;
i0 = tvec4<T, P>(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<T, P>(isYZ.x, isYZ.y);
i0.z += static_cast<T>(1) - isYZ.x;
i0.w += static_cast<T>(1) - isYZ.y;
i0.z += isYZ.z;
i0.w += static_cast<T>(1) - isYZ.z;
// i0 now contains the unique values 0,1,2,3 in each channel
tvec4<T, P> i3 = clamp(i0, T(0), T(1));
tvec4<T, P> i2 = clamp(i0 - T(1), T(0), T(1));
tvec4<T, P> 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<T, P> x1 = x0 - i1 + C.x;
tvec4<T, P> x2 = x0 - i2 + C.y;
tvec4<T, P> x3 = x0 - i3 + C.z;
tvec4<T, P> 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<T, P> j1 = detail::permute(detail::permute(detail::permute(detail::permute(
i.w + tvec4<T, P>(i1.w, i2.w, i3.w, T(1))) +
i.z + tvec4<T, P>(i1.z, i2.z, i3.z, T(1))) +
i.y + tvec4<T, P>(i1.y, i2.y, i3.y, T(1))) +
i.x + tvec4<T, P>(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<T, P> ip = tvec4<T, P>(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0));
tvec4<T, P> p0 = detail::grad4(j0, ip);
tvec4<T, P> p1 = detail::grad4(j1.x, ip);
tvec4<T, P> p2 = detail::grad4(j1.y, ip);
tvec4<T, P> p3 = detail::grad4(j1.z, ip);
tvec4<T, P> p4 = detail::grad4(j1.w, ip);
// Normalise gradients
tvec4<T, P> norm = detail::taylorInvSqrt(tvec4<T, P>(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<T, P> m0 = max(T(0.6) - tvec3<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0));
tvec2<T, P> m1 = max(T(0.6) - tvec2<T, P>(dot(x3, x3), dot(x4, x4) ), T(0));
m0 = m0 * m0;
m1 = m1 * m1;
return T(49) * (
dot(m0 * m0, tvec3<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2))) +
dot(m1 * m1, tvec2<T, P>(dot(p3, x3), dot(p4, x4))));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> noise2(tvec2<T, P> const & x)
{
return tvec2<T, P>(
noise1(x + tvec2<T, P>(0.0)),
noise1(tvec2<T, P>(0.0) - x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> noise2(tvec3<T, P> const & x)
{
return tvec2<T, P>(
noise1(x + tvec3<T, P>(0.0)),
noise1(tvec3<T, P>(0.0) - x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> noise2(tvec4<T, P> const & x)
{
return tvec2<T, P>(
noise1(x + tvec4<T, P>(0)),
noise1(tvec4<T, P>(0) - x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> noise3(tvec2<T, P> const & x)
{
return tvec3<T, P>(
noise1(x - tvec2<T, P>(1.0)),
noise1(x + tvec2<T, P>(0.0)),
noise1(x + tvec2<T, P>(1.0)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> noise3(tvec3<T, P> const & x)
{
return tvec3<T, P>(
noise1(x - tvec3<T, P>(1.0)),
noise1(x + tvec3<T, P>(0.0)),
noise1(x + tvec3<T, P>(1.0)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> noise3(tvec4<T, P> const & x)
{
return tvec3<T, P>(
noise1(x - tvec4<T, P>(1)),
noise1(x + tvec4<T, P>(0)),
noise1(x + tvec4<T, P>(1)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> noise4(tvec2<T, P> const & x)
{
return tvec4<T, P>(
noise1(x - tvec2<T, P>(1)),
noise1(x + tvec2<T, P>(0)),
noise1(x + tvec2<T, P>(1)),
noise1(x + tvec2<T, P>(2)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> noise4(tvec3<T, P> const & x)
{
return tvec4<T, P>(
noise1(x - tvec3<T, P>(1)),
noise1(x + tvec3<T, P>(0)),
noise1(x + tvec3<T, P>(1)),
noise1(x + tvec3<T, P>(2)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> noise4(tvec4<T, P> const & x)
{
return tvec4<T, P>(
noise1(x - tvec4<T, P>(1)),
noise1(x + tvec4<T, P>(0)),
noise1(x + tvec4<T, P>(1)),
noise1(x + tvec4<T, P>(2)));
}
}//namespace glm

View File

@@ -38,82 +38,178 @@ namespace glm
{
GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v)
{
u16vec2 const Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
return reinterpret_cast<uint const &>(Topack);
union
{
u16 in[2];
uint out;
} u;
u16vec2 result(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
u.in[0] = result[0];
u.in[1] = result[1];
return u.out;
}
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint p)
{
vec2 Unpack(reinterpret_cast<u16vec2 const &>(p));
return Unpack * float(1.5259021896696421759365224689097e-5); // 1.0 / 65535.0
union
{
uint in;
u16 out[2];
} u;
u.in = p;
return vec2(u.out[0], u.out[1]) * 1.5259021896696421759365224689097e-5f;
}
GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v)
{
i16vec2 const Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
return reinterpret_cast<uint const &>(Topack);
union
{
i16 in[2];
uint out;
} u;
i16vec2 result(round(clamp(v, -1.0f, 1.0f) * 32767.0f));
u.in[0] = result[0];
u.in[1] = result[1];
return u.out;
}
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint p)
{
vec2 const Unpack(reinterpret_cast<i16vec2 const &>(p));
return clamp(
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
-1.0f, 1.0f);
union
{
uint in;
i16 out[2];
} u;
u.in = p;
return clamp(vec2(u.out[0], u.out[1]) * 3.0518509475997192297128208258309e-5f, -1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v)
{
u8vec4 const Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
return reinterpret_cast<uint const &>(Topack);
union
{
u8 in[4];
uint out;
} u;
u8vec4 result(round(clamp(v, 0.0f, 1.0f) * 255.0f));
u.in[0] = result[0];
u.in[1] = result[1];
u.in[2] = result[2];
u.in[3] = result[3];
return u.out;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint p)
{
vec4 const Unpack(reinterpret_cast<u8vec4 const&>(p));
return Unpack * float(0.0039215686274509803921568627451); // 1 / 255
union
{
uint in;
u8 out[4];
} u;
u.in = p;
return vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0039215686274509803921568627451f;
}
GLM_FUNC_QUALIFIER uint packSnorm4x8(vec4 const & v)
{
i8vec4 const Topack(round(clamp(v ,-1.0f, 1.0f) * 127.0f));
return reinterpret_cast<uint const &>(Topack);
union
{
i8 in[4];
uint out;
} u;
i8vec4 result(round(clamp(v, -1.0f, 1.0f) * 127.0f));
u.in[0] = result[0];
u.in[1] = result[1];
u.in[2] = result[2];
u.in[3] = result[3];
return u.out;
}
GLM_FUNC_QUALIFIER glm::vec4 unpackSnorm4x8(uint p)
{
vec4 const Unpack(reinterpret_cast<i8vec4 const &>(p));
return clamp(
Unpack * 0.0078740157480315f, // 1.0f / 127.0f
-1.0f, 1.0f);
union
{
uint in;
i8 out[4];
} u;
u.in = p;
return clamp(vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0078740157480315f, -1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER double packDouble2x32(uvec2 const & v)
{
return reinterpret_cast<double const &>(v);
union
{
uint in[2];
double out;
} u;
u.in[0] = v[0];
u.in[1] = v[1];
return u.out;
}
GLM_FUNC_QUALIFIER uvec2 unpackDouble2x32(double v)
{
return reinterpret_cast<uvec2 const &>(v);
union
{
double in;
uint out[2];
} u;
u.in = v;
return uvec2(u.out[0], u.out[1]);
}
GLM_FUNC_QUALIFIER uint packHalf2x16(vec2 const & v)
{
i16vec2 const Unpack(
detail::toFloat16(v.x),
detail::toFloat16(v.y));
union
{
i16 in[2];
uint out;
} u;
return reinterpret_cast<uint const &>(Unpack);
u.in[0] = detail::toFloat16(v.x);
u.in[1] = detail::toFloat16(v.y);
return u.out;
}
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint v)
{
i16vec2 const Unpack(reinterpret_cast<i16vec2 const &>(v));
union
{
uint in;
i16 out[2];
} u;
u.in = v;
return vec2(
detail::toFloat32(Unpack.x),
detail::toFloat32(Unpack.y));
detail::toFloat32(u.out[0]),
detail::toFloat32(u.out[1]));
}
}//namespace glm

View File

@@ -58,7 +58,7 @@ namespace glm
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> radians(vecType<T, P> const & degrees);
GLM_FUNC_DECL GLM_CONSTEXPR vecType<T, P> radians(vecType<T, P> const & degrees);
/// Converts radians to degrees and returns the result.
///
@@ -67,7 +67,7 @@ namespace glm
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> degrees(vecType<T, P> const & radians);
GLM_FUNC_DECL GLM_CONSTEXPR vecType<T, P> degrees(vecType<T, P> const & radians);
/// The standard trigonometric sine function.
/// The values returned by this function will range from [-1, 1].

View File

@@ -38,7 +38,7 @@ namespace glm
{
// radians
template <typename genType>
GLM_FUNC_QUALIFIER genType radians(genType degrees)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType radians(genType degrees)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'radians' only accept floating-point input");
@@ -46,14 +46,14 @@ namespace glm
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> radians(vecType<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType<T, P> radians(vecType<T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(radians, v);
}
// degrees
template <typename genType>
GLM_FUNC_QUALIFIER genType degrees(genType radians)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType degrees(genType radians)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'degrees' only accept floating-point input");
@@ -61,7 +61,7 @@ namespace glm
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> degrees(vecType<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType<T, P> degrees(vecType<T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(degrees, v);
}

View File

@@ -39,6 +39,15 @@ namespace glm
highp,
mediump,
lowp,
simd,
defaultp = highp
};
template <typename T, precision P, template <typename, precision> class genType>
struct type
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = false;
};
}//namespace glm

View File

@@ -8,14 +8,14 @@
/// 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
@@ -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")
# pragma message ("GLM: version 0.9.8.0")
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////
@@ -65,6 +65,8 @@
#ifdef GLM_FORCE_PLATFORM_UNKNOWN
# define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
#elif defined(__CYGWIN__)
# define GLM_PLATFORM GLM_PLATFORM_CYGWIN
#elif defined(__QNXNTO__)
# define GLM_PLATFORM GLM_PLATFORM_QNXNTO
#elif defined(__APPLE__)
@@ -117,7 +119,7 @@
// Compiler
// User defines: GLM_FORCE_COMPILER_UNKNOWN
// TODO ? __llvm__
// TODO ? __llvm__
#define GLM_COMPILER_UNKNOWN 0x00000000
@@ -128,6 +130,7 @@
#define GLM_COMPILER_INTEL13 0x00100030
#define GLM_COMPILER_INTEL14 0x00100040
#define GLM_COMPILER_INTEL15 0x00100050
#define GLM_COMPILER_INTEL16 0x00100060
// Visual C++ defines
#define GLM_COMPILER_VC 0x01000000
@@ -145,6 +148,9 @@
#define GLM_COMPILER_GCC48 0x020000F0
#define GLM_COMPILER_GCC49 0x02000100
#define GLM_COMPILER_GCC50 0x02000200
#define GLM_COMPILER_GCC51 0x02000300
#define GLM_COMPILER_GCC52 0x02000400
#define GLM_COMPILER_GCC53 0x02000500
// CUDA
#define GLM_COMPILER_CUDA 0x10000000
@@ -154,6 +160,8 @@
#define GLM_COMPILER_CUDA50 0x10000070
#define GLM_COMPILER_CUDA60 0x10000080
#define GLM_COMPILER_CUDA65 0x10000090
#define GLM_COMPILER_CUDA70 0x100000A0
#define GLM_COMPILER_CUDA75 0x100000B0
// LLVM
#define GLM_COMPILER_LLVM 0x20000000
@@ -161,6 +169,10 @@
#define GLM_COMPILER_LLVM33 0x20000040
#define GLM_COMPILER_LLVM34 0x20000050
#define GLM_COMPILER_LLVM35 0x20000060
#define GLM_COMPILER_LLVM36 0x20000070
#define GLM_COMPILER_LLVM37 0x20000080
#define GLM_COMPILER_LLVM38 0x20000090
#define GLM_COMPILER_LLVM39 0x200000A0
// Apple Clang
#define GLM_COMPILER_APPLE_CLANG 0x40000000
@@ -170,6 +182,7 @@
#define GLM_COMPILER_APPLE_CLANG50 0x40000040
#define GLM_COMPILER_APPLE_CLANG51 0x40000050
#define GLM_COMPILER_APPLE_CLANG60 0x40000060
#define GLM_COMPILER_APPLE_CLANG61 0x40000070
// Build model
#define GLM_MODEL_32 0x00000010
@@ -190,6 +203,8 @@
# define GLM_COMPILER GLM_COMPILER_INTEL14
# elif __INTEL_COMPILER >= 1500
# define GLM_COMPILER GLM_COMPILER_INTEL15
# elif __INTEL_COMPILER >= 1600
# define GLM_COMPILER GLM_COMPILER_INTEL16
# else
# define GLM_COMPILER GLM_COMPILER_INTEL
# endif
@@ -197,7 +212,7 @@
// CUDA
#elif defined(__CUDACC__)
# if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA)
# include <cuda.h> // make sure version is defined since nvcc does not define it itself!
# include <cuda.h> // make sure version is defined since nvcc does not define it itself!
# endif
# if CUDA_VERSION < 3000
# error "GLM requires CUDA 3.0 or higher"
@@ -234,8 +249,14 @@
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG50
# elif __clang_major__ == 5 && __clang_minor__ == 1
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG51
# elif __clang_major__ >= 6
# elif __clang_major__ == 6 && __clang_minor__ == 0
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG60
# elif __clang_major__ == 6 && __clang_minor__ >= 1
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG61
# elif __clang_major__ >= 7
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG61
# else
# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG
# endif
# else
# if __clang_major__ == 3 && __clang_minor__ == 0
@@ -250,12 +271,22 @@
# define GLM_COMPILER GLM_COMPILER_LLVM34
# elif __clang_major__ == 3 && __clang_minor__ == 5
# define GLM_COMPILER GLM_COMPILER_LLVM35
# elif __clang_major__ == 3 && __clang_minor__ == 6
# define GLM_COMPILER GLM_COMPILER_LLVM36
# elif __clang_major__ == 3 && __clang_minor__ == 7
# define GLM_COMPILER GLM_COMPILER_LLVM37
# elif __clang_major__ == 3 && __clang_minor__ == 8
# define GLM_COMPILER GLM_COMPILER_LLVM38
# elif __clang_major__ == 3 && __clang_minor__ >= 9
# define GLM_COMPILER GLM_COMPILER_LLVM39
# elif __clang_major__ >= 4
# define GLM_COMPILER GLM_COMPILER_LLVM39
# else
# define GLM_COMPILER GLM_COMPILER_LLVM35
# define GLM_COMPILER GLM_COMPILER_LLVM
# endif
# endif
// G++
// G++
#elif defined(__GNUC__) || defined(__MINGW32__)
# if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC42)
@@ -273,8 +304,14 @@
# define GLM_COMPILER (GLM_COMPILER_GCC48)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
# define GLM_COMPILER (GLM_COMPILER_GCC49)
# elif (__GNUC__ > 4 )
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0)
# define GLM_COMPILER (GLM_COMPILER_GCC50)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 1)
# define GLM_COMPILER (GLM_COMPILER_GCC51)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC52)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ >= 3)
# define GLM_COMPILER (GLM_COMPILER_GCC53)
# else
# define GLM_COMPILER (GLM_COMPILER_GCC)
# endif
@@ -331,6 +368,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 <intrin.h>
#endif
#if GLM_ARCH & GLM_ARCH_AVX2
# include <immintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_AVX
# include <immintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE4
# include <smmintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE3
# include <pmmintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE2
# include <emmintrin.h>
# 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
@@ -500,14 +652,24 @@
// http://gcc.gnu.org/projects/cxx0x.html
// http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
#if GLM_PLATFORM == GLM_PLATFORM_ANDROID
#if GLM_PLATFORM == GLM_PLATFORM_ANDROID || GLM_PLATFORM == GLM_PLATFORM_CYGWIN
# define GLM_HAS_CXX11_STL 0
#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_INTEL)
# define GLM_HAS_CXX11_STL __has_include("__config")
#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG)
# if __has_include(<__config>) // libc++
# include <__config>
//# else // libstdc++
//# include <bits/c++config.h>
# endif
# if defined(_LIBCPP_VERSION)// || defined(__GLIBCXX__)
# define GLM_HAS_CXX11_STL 1
# else
# define GLM_HAS_CXX11_STL 0
# endif
#else
# define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && \
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)))
#endif
// N1720
@@ -516,9 +678,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
@@ -540,9 +702,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
@@ -551,9 +713,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
@@ -572,9 +734,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_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12))))
#endif
// N2118
@@ -583,9 +746,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
@@ -594,10 +757,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
@@ -606,10 +769,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
@@ -618,41 +781,40 @@
#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
//
//
#define GLM_HAS_TRIVIAL_QUERIES 0
//
//
#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
#ifdef _OPENMP
#ifdef _OPENMP
# if GLM_COMPILER & GLM_COMPILER_GCC
# if GLM_COMPILER >= GLM_COMPILER_GCC47
# define GLM_HAS_OPENMP 31
@@ -673,121 +835,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 <intrin.h>
#endif
#if GLM_ARCH & GLM_ARCH_AVX2
# include <immintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_AVX
# include <immintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE4
# include <smmintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE3
# include <pmmintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE2
# include <emmintrin.h>
# 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
@@ -878,10 +925,30 @@
# define GLM_RESTRICT_VAR
#endif//GLM_COMPILER
#if GLM_HAS_DEFAULTED_FUNCTIONS
# define GLM_DEFAULT = default
# ifdef GLM_FORCE_NO_CTOR_INIT
# define GLM_DEFAULT_CTOR = default
# else
# define GLM_DEFAULT_CTOR
# endif
#else
# define GLM_DEFAULT
# define GLM_DEFAULT_CTOR
#endif
#if GLM_HAS_CONSTEXPR
# define GLM_CONSTEXPR constexpr
# define GLM_RELAXED_CONSTEXPR constexpr
#else
# define GLM_CONSTEXPR
# define GLM_RELAXED_CONSTEXPR const
#endif
#ifdef GLM_FORCE_EXPLICIT_CTOR
# define GLM_EXPLICIT explicit
#else
# define GLM_EXPLICIT
#endif
///////////////////////////////////////////////////////////////////////////////////

View File

@@ -8,14 +8,14 @@
/// 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
@@ -54,16 +54,25 @@ namespace glm
template <typename U, precision Q>
friend tvec2<U, Q> operator/(tvec2<U, Q> const & v, tmat2x2<U, Q> const & m);
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 2;
static GLM_RELAXED_CONSTEXPR length_t cols = 2;
static GLM_RELAXED_CONSTEXPR length_t rows = 2;
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:
/// @cond DETAIL
col_type value[2];
/// @endcond
public:
//////////////////////////////////////
// Constructors
GLM_FUNC_DECL tmat2x2();
GLM_FUNC_DECL tmat2x2(tmat2x2<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat2x2() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat2x2(tmat2x2<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat2x2(tmat2x2<T, Q> const & m);
@@ -76,8 +85,8 @@ namespace glm
col_type const & v1,
col_type const & v2);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <typename U, typename V, typename M, typename N>
GLM_FUNC_DECL tmat2x2(
U const & x1, V const & y1,
@@ -88,16 +97,10 @@ namespace glm
tvec2<U, P> const & v1,
tvec2<V, P> const & v2);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat2x2(tmat2x2<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat2x2(tmat2x2<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat2x2<U, Q> const & m);
GLM_FUNC_DECL explicit tmat2x2(tmat3x3<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x2(tmat4x4<T, P> const & x);
@@ -108,8 +111,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat2x2(tmat3x4<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x2(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -125,32 +127,30 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<T, P> const & v);
GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<T, P> const & v) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator+=(tmat2x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator-=(tmat2x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator*=(tmat2x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator/=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator/=(tmat2x2<U, P> const & m);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat2x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x2<T, P> & operator-- ();
@@ -158,7 +158,16 @@ namespace glm
GLM_FUNC_DECL tmat2x2<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator-(tmat2x2<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m, T const & s);
@@ -191,10 +200,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat3x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat4x2<T, P> const & m2);
@@ -213,9 +222,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator/(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2);
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> const operator-(tmat2x2<T, P> const & m);
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat2x2>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
} //namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -50,24 +50,34 @@ namespace detail
}
}//namespace detail
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat2x2<T, P> tmat2x2<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
# endif
}
template<typename T, precision P>
const tmat2x2<T, P> tmat2x2<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(tmat2x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(tmat2x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -106,8 +116,8 @@ namespace detail
this->value[1] = v1;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <typename X1, typename Y1, typename X2, typename Y2>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2
@@ -128,8 +138,7 @@ namespace detail
this->value[1] = col_type(v2);
}
//////////////////////////////////////////////////////////////
// mat2x2 matrix conversions
// -- mat2x2 matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -195,8 +204,7 @@ namespace detail
this->value[1] = col_type(m[1]);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -240,16 +248,17 @@ namespace detail
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator=(tmat2x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator=(tmat2x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -328,6 +337,8 @@ namespace detail
return (*this = *this * detail::compute_inverse<T, P>(m));
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator++()
{
@@ -360,8 +371,23 @@ namespace detail
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+(tmat2x2<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> operator-(tmat2x2<T, P> const & m)
{
return tmat2x2<T, P>(
-m[0],
-m[1]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+(tmat2x2<T, P> const & m, T const & s)
@@ -522,17 +548,7 @@ namespace detail
return m1_copy /= m2;
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> const operator-(tmat2x2<T, P> const & m)
{
return tmat2x2<T, P>(
-m[0],
-m[1]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,15 +50,26 @@ namespace glm
typedef tmat3x2<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 2;
static GLM_RELAXED_CONSTEXPR length_t cols = 2;
static GLM_RELAXED_CONSTEXPR length_t rows = 3;
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:
/// @cond DETAIL
col_type value[2];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat2x3();
GLM_FUNC_DECL tmat2x3(tmat2x3<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat2x3() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat2x3(tmat2x3<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat2x3(tmat2x3<T, Q> const & m);
@@ -71,29 +82,22 @@ namespace glm
col_type const & v0,
col_type const & v1);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <typename X1, typename Y1, typename Z1, typename X2, typename Y2, typename Z2>
GLM_FUNC_DECL tmat2x3(
X1 const & x1, Y1 const & y1, Z1 const & z1,
X2 const & x2, Y2 const & y2, Z2 const & z2);
template <typename U, typename V>
GLM_FUNC_DECL tmat2x3(
tvec3<U, P> const & v1,
tvec3<V, P> const & v2);
//////////////////////////////////////
// Matrix conversion
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat2x3(tmat2x3<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat2x3(tmat2x3<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat2x3(tmat2x3<U, Q> const & m);
GLM_FUNC_DECL explicit tmat2x3(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x3(tmat3x3<T, P> const & x);
@@ -104,8 +108,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat2x3(tmat4x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x3(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -121,28 +124,26 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat2x3<T, P> & operator=(tmat2x3<T, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> & operator=(tmat2x3<T, P> const & m) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator=(tmat2x3<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator+=(tmat2x3<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator-=(tmat2x3<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat2x3<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x3<T, P> & operator-- ();
@@ -150,7 +151,15 @@ namespace glm
GLM_FUNC_DECL tmat2x3<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator+(tmat2x3<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator-(tmat2x3<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator+(tmat2x3<T, P> const & m, T const & s);
@@ -181,7 +190,7 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat3x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat4x2<T, P> const & m2);
@@ -191,9 +200,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator/(T const & s, tmat2x3<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> const operator-(tmat2x3<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat2x3>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,24 +32,34 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat2x3<T, P> tmat2x3<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
# endif
}
template<typename T, precision P>
const tmat2x3<T, P> tmat2x3<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -88,8 +98,8 @@ namespace glm
this->value[1] = v1;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
typename X1, typename Y1, typename Z1,
@@ -112,8 +122,7 @@ namespace glm
this->value[1] = col_type(v2);
}
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -179,8 +188,7 @@ namespace glm
this->value[1] = m[1];
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -224,16 +232,17 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -298,6 +307,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator++()
{
@@ -330,8 +341,23 @@ namespace glm
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> operator-(tmat2x3<T, P> const & m)
{
return tmat2x3<T, P>(
-m[0],
-m[1]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m, T const & s)
@@ -480,17 +506,7 @@ namespace glm
s / m[1]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> const operator-(tmat2x3<T, P> const & m)
{
return tmat2x3<T, P>(
-m[0],
-m[1]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,15 +50,26 @@ namespace glm
typedef tmat4x2<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 2;
static GLM_RELAXED_CONSTEXPR length_t cols = 2;
static GLM_RELAXED_CONSTEXPR length_t rows = 4;
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:
/// @cond DETAIL
col_type value[2];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat2x4();
GLM_FUNC_DECL tmat2x4(tmat2x4<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat2x4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat2x4(tmat2x4<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat2x4(tmat2x4<T, Q> const & m);
@@ -68,11 +79,11 @@ namespace glm
T const & x0, T const & y0, T const & z0, T const & w0,
T const & x1, T const & y1, T const & z1, T const & w1);
GLM_FUNC_DECL tmat2x4(
col_type const & v0,
col_type const & v0,
col_type const & v1);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <
typename X1, typename Y1, typename Z1, typename W1,
typename X2, typename Y2, typename Z2, typename W2>
@@ -85,16 +96,10 @@ namespace glm
tvec4<U, P> const & v1,
tvec4<V, P> const & v2);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat2x4(tmat2x4<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat2x4(tmat2x4<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat2x4(tmat2x4<U, Q> const & m);
GLM_FUNC_DECL explicit tmat2x4(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x4(tmat3x3<T, P> const & x);
@@ -105,8 +110,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat2x4(tmat4x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat2x4(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -122,28 +126,26 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat2x4<T, P> & operator=(tmat2x4<T, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> & operator=(tmat2x4<T, P> const & m) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator=(tmat2x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator+=(tmat2x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator-=(tmat2x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat2x4<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x4<T, P> & operator-- ();
@@ -151,7 +153,15 @@ namespace glm
GLM_FUNC_DECL tmat2x4<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator+(tmat2x4<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator-(tmat2x4<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator+(tmat2x4<T, P> const & m, T const & s);
@@ -179,7 +189,7 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator*(tmat2x4<T, P> const & m1, tmat4x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator*(tmat2x4<T, P> const & m1, tmat2x2<T, P> const & m2);
@@ -189,12 +199,26 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator/(tmat2x4<T, P> const & m, T s);
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator/(T s, tmat2x4<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> const operator-(tmat2x4<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat2x4<T, P> const & m1, tmat2x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat2x4<T, P> const & m1, tmat2x4<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat2x4>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,24 +32,34 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat2x4<T, P> tmat2x4<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
# endif
}
template<typename T, precision P>
const tmat2x4<T, P> tmat2x4<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(tmat2x4<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(tmat2x4<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -89,8 +99,8 @@ namespace glm
this->value[1] = v1;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
typename X1, typename Y1, typename Z1, typename W1,
@@ -113,8 +123,7 @@ namespace glm
this->value[1] = col_type(v2);
}
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -180,8 +189,7 @@ namespace glm
this->value[1] = col_type(m[1], 0);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -225,16 +233,17 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator=(tmat2x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator=(tmat2x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -299,6 +308,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator++()
{
@@ -331,8 +342,23 @@ namespace glm
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> operator+(tmat2x4<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> operator-(tmat2x4<T, P> const & m)
{
return tmat2x4<T, P>(
-m[0],
-m[1]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> operator+(tmat2x4<T, P> const & m, T const & s)
@@ -489,17 +515,7 @@ namespace glm
s / m[1]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> const operator-(tmat2x4<T, P> const & m)
{
return tmat2x4<T, P>(
-m[0],
-m[1]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat2x4<T, P> const & m1, tmat2x4<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,15 +50,26 @@ namespace glm
typedef tmat2x3<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 3;
static GLM_RELAXED_CONSTEXPR length_t cols = 3;
static GLM_RELAXED_CONSTEXPR length_t rows = 2;
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:
/// @cond DETAIL
col_type value[3];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat3x2();
GLM_FUNC_DECL tmat3x2(tmat3x2<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat3x2() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat3x2(tmat3x2<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat3x2(tmat3x2<T, Q> const & m);
@@ -73,8 +84,7 @@ namespace glm
col_type const & v1,
col_type const & v2);
//////////////////////////////////////
// Conversions
// -- Conversions --
template<
typename X1, typename Y1,
@@ -84,23 +94,17 @@ namespace glm
X1 const & x1, Y1 const & y1,
X2 const & x2, Y2 const & y2,
X3 const & x3, Y3 const & y3);
template <typename V1, typename V2, typename V3>
GLM_FUNC_DECL tmat3x2(
tvec2<V1, P> const & v1,
tvec2<V2, P> const & v2,
tvec2<V3, P> const & v3);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat3x2(tmat3x2<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat3x2(tmat3x2<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat3x2(tmat3x2<U, Q> const & m);
GLM_FUNC_DECL explicit tmat3x2(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x2(tmat3x3<T, P> const & x);
@@ -111,8 +115,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat3x2(tmat4x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x2(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -128,28 +131,26 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat3x2<T, P> & operator=(tmat3x2<T, P> const & m);
GLM_FUNC_DECL tmat3x2<T, P> & operator=(tmat3x2<T, P> const & m) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator=(tmat3x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator+=(tmat3x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator-=(tmat3x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat3x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat3x2<T, P> & operator-- ();
@@ -157,7 +158,16 @@ namespace glm
GLM_FUNC_DECL tmat3x2<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator+(tmat3x2<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator-(tmat3x2<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator+(tmat3x2<T, P> const & m, T const & s);
@@ -184,10 +194,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat2x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat3x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat4x3<T, P> const & m2);
@@ -197,9 +207,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator/(T const & s, tmat3x2<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> const operator-(tmat3x2<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat3x2>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,26 +32,36 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat3x2<T, P> tmat3x2<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0);
# endif
}
template<typename T, precision P>
const tmat3x2<T, P> tmat3x2<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -100,8 +110,8 @@ namespace glm
this->value[2] = v2;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
typename X1, typename Y1,
@@ -133,8 +143,7 @@ namespace glm
this->value[2] = col_type(v3);
}
//////////////////////////////////////////////////////////////
// mat3x2 matrix conversions
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -209,8 +218,7 @@ namespace glm
this->value[2] = col_type(m[2]);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -254,17 +262,18 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator=(tmat3x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator=(tmat3x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -336,6 +345,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator++()
{
@@ -370,8 +381,24 @@ namespace glm
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> operator-(tmat3x2<T, P> const & m)
{
return tmat3x2<T, P>(
-m[0],
-m[1],
-m[2]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m, T const & s)
@@ -513,18 +540,7 @@ namespace glm
s / m[2]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> const operator-(tmat3x2<T, P> const & m)
{
return tmat3x2<T, P>(
-m[0],
-m[1],
-m[2]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -49,20 +49,31 @@ namespace glm
typedef tmat3x3<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 3;
static GLM_RELAXED_CONSTEXPR length_t cols = 3;
static GLM_RELAXED_CONSTEXPR length_t rows = 3;
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 <typename U, precision Q>
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
template <typename U, precision Q>
friend tvec3<U, Q> operator/(tvec3<U, Q> const & v, tmat3x3<U, Q> const & m);
private:
/// @cond DETAIL
col_type value[3];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat3x3();
GLM_FUNC_DECL tmat3x3(tmat3x3<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat3x3() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat3x3(tmat3x3<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat3x3(tmat3x3<T, Q> const & m);
@@ -77,8 +88,7 @@ namespace glm
col_type const & v1,
col_type const & v2);
//////////////////////////////////////
// Conversions
// -- Conversions --
template<
typename X1, typename Y1, typename Z1,
@@ -88,23 +98,17 @@ namespace glm
X1 const & x1, Y1 const & y1, Z1 const & z1,
X2 const & x2, Y2 const & y2, Z2 const & z2,
X3 const & x3, Y3 const & y3, Z3 const & z3);
template <typename V1, typename V2, typename V3>
GLM_FUNC_DECL tmat3x3(
tvec3<V1, P> const & v1,
tvec3<V2, P> const & v2,
tvec3<V3, P> const & v3);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat3x3(tmat3x3<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat3x3(tmat3x3<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat3x3(tmat3x3<U, Q> const & m);
GLM_FUNC_DECL explicit tmat3x3(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x3(tmat4x4<T, P> const & x);
@@ -115,8 +119,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat3x3(tmat3x4<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x3(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -132,10 +135,9 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat3x3<T, P> & operator=(tmat3x3<T, P> const & m);
GLM_FUNC_DECL tmat3x3<T, P> & operator=(tmat3x3<T, P> const & m) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tmat3x3<T, P> & operator=(tmat3x3<U, P> const & m);
@@ -156,8 +158,7 @@ namespace glm
template <typename U>
GLM_FUNC_DECL tmat3x3<T, P> & operator/=(tmat3x3<U, P> const & m);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat3x3<T, P> & operator++();
GLM_FUNC_DECL tmat3x3<T, P> & operator--();
@@ -165,7 +166,16 @@ namespace glm
GLM_FUNC_DECL tmat3x3<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator+(tmat3x3<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator-(tmat3x3<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator+(tmat3x3<T, P> const & m, T const & s);
@@ -198,10 +208,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator*(tmat3x3<T, P> const & m1, tmat3x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator*(tmat3x3<T, P> const & m1, tmat2x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator*(tmat3x3<T, P> const & m1, tmat4x3<T, P> const & m2);
@@ -220,9 +230,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator/(tmat3x3<T, P> const & m1, tmat3x3<T, P> const & m2);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> const operator-(tmat3x3<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat3x3<T, P> const & m1, tmat3x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat3x3<T, P> const & m1, tmat3x3<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat3x3>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -56,30 +56,37 @@ namespace detail
}
}//namespace detail
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat3x3<T, P> tmat3x3<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1);
# endif
}
template<typename T, precision P>
const tmat3x3<T, P> tmat3x3<T, P>::IDENTITY(static_cast<T>(1));
# endif
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(ctor)
{}
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(tmat3x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(tmat3x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -90,6 +97,10 @@ namespace detail
this->value[2] = m.value[2];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(T const & s)
{
@@ -124,8 +135,8 @@ namespace detail
this->value[2] = v2;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
typename X1, typename Y1, typename Z1,
@@ -157,8 +168,7 @@ namespace detail
this->value[2] = col_type(v3);
}
//////////////////////////////////////////////////////////////
// Conversions
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -233,8 +243,7 @@ namespace detail
this->value[2] = m[2];
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -278,17 +287,18 @@ namespace detail
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator=(tmat3x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator=(tmat3x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -374,6 +384,8 @@ namespace detail
return (*this = *this * detail::compute_inverse<T, P>(m));
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator++()
{
@@ -408,8 +420,24 @@ namespace detail
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> operator+(tmat3x3<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> operator-(tmat3x3<T, P> const & m)
{
return tmat3x3<T, P>(
-m[0],
-m[1],
-m[2]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> operator+(tmat3x3<T, P> const & m, T const & s)
@@ -604,18 +632,7 @@ namespace detail
return m1_copy /= m2;
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> const operator-(tmat3x3<T, P> const & m)
{
return tmat3x3<T, P>(
-m[0],
-m[1],
-m[2]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat3x3<T, P> const & m1, tmat3x3<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,15 +50,26 @@ namespace glm
typedef tmat4x3<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 3;
static GLM_RELAXED_CONSTEXPR length_t cols = 3;
static GLM_RELAXED_CONSTEXPR length_t rows = 4;
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:
/// @cond DETAIL
col_type value[3];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat3x4();
GLM_FUNC_DECL tmat3x4(tmat3x4<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat3x4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat3x4(tmat3x4<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat3x4(tmat3x4<T, Q> const & m);
@@ -73,8 +84,8 @@ namespace glm
col_type const & v1,
col_type const & v2);
//////////////////////////////////////
// Conversions
// -- Conversions --
template<
typename X1, typename Y1, typename Z1, typename W1,
typename X2, typename Y2, typename Z2, typename W2,
@@ -83,23 +94,17 @@ namespace glm
X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1,
X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2,
X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3);
template <typename V1, typename V2, typename V3>
GLM_FUNC_DECL tmat3x4(
tvec4<V1, P> const & v1,
tvec4<V2, P> const & v2,
tvec4<V3, P> const & v3);
//////////////////////////////////////
// Matrix conversion
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat3x4(tmat3x4<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat3x4(tmat3x4<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat3x4(tmat3x4<U, Q> const & m);
GLM_FUNC_DECL explicit tmat3x4(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x4(tmat3x3<T, P> const & x);
@@ -110,8 +115,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat3x4(tmat4x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat3x4(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -127,28 +131,26 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat3x4<T, P> & operator=(tmat3x4<T, P> const & m);
GLM_FUNC_DECL tmat3x4<T, P> & operator=(tmat3x4<T, P> const & m) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator=(tmat3x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator+=(tmat3x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator-=(tmat3x4<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat3x4<T, P> & operator++();
GLM_FUNC_DECL tmat3x4<T, P> & operator--();
@@ -156,7 +158,16 @@ namespace glm
GLM_FUNC_DECL tmat3x4<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator+(tmat3x4<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator-(tmat3x4<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator+(tmat3x4<T, P> const & m, T const & s);
@@ -178,15 +189,15 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL typename tmat3x4<T, P>::col_type operator*(tmat3x4<T, P> const & m, typename tmat3x4<T, P>::row_type const & v);
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL typename tmat3x4<T, P>::row_type operator*(typename tmat3x4<T, P>::col_type const & v, tmat3x4<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator*(tmat3x4<T, P> const & m1, tmat4x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator*(tmat3x4<T, P> const & m1, tmat2x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator*(tmat3x4<T, P> const & m1, tmat3x3<T, P> const & m2);
@@ -196,9 +207,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator/(T const & s, tmat3x4<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> const operator-(tmat3x4<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat3x4<T, P> const & m1, tmat3x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat3x4<T, P> const & m1, tmat3x4<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat3x4>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,26 +32,36 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat3x4<T, P> tmat3x4<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0);
# endif
}
template<typename T, precision P>
const tmat3x4<T, P> tmat3x4<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(tmat3x4<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(tmat3x4<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -69,10 +79,9 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(T const & s)
{
value_type const Zero(0);
this->value[0] = col_type(s, Zero, Zero, Zero);
this->value[1] = col_type(Zero, s, Zero, Zero);
this->value[2] = col_type(Zero, Zero, s, Zero);
this->value[0] = col_type(s, 0, 0, 0);
this->value[1] = col_type(0, s, 0, 0);
this->value[2] = col_type(0, 0, s, 0);
}
template <typename T, precision P>
@@ -101,8 +110,8 @@ namespace glm
this->value[2] = v2;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
typename X1, typename Y1, typename Z1, typename W1,
@@ -134,7 +143,8 @@ namespace glm
this->value[2] = col_type(v3);
}
// Conversion
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(tmat3x4<U, Q> const & m)
@@ -181,7 +191,7 @@ namespace glm
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(m[2], 0, 1);
this->value[2] = col_type(m[2], 1, 0);
}
template <typename T, precision P>
@@ -208,8 +218,7 @@ namespace glm
this->value[2] = col_type(m[2], 0);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -253,17 +262,18 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>& tmat3x4<T, P>::operator=(tmat3x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>& tmat3x4<T, P>::operator=(tmat3x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -335,6 +345,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>& tmat3x4<T, P>::operator++()
{
@@ -369,8 +381,24 @@ namespace glm
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> operator+(tmat3x4<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> operator-(tmat3x4<T, P> const & m)
{
return tmat3x4<T, P>(
-m[0],
-m[1],
-m[2]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> operator+(tmat3x4<T, P> const & m, T const & s)
@@ -552,18 +580,7 @@ namespace glm
s / m[2]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> const operator-(tmat3x4<T, P> const & m)
{
return tmat3x4<T, P>(
-m[0],
-m[1],
-m[2]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat3x4<T, P> const & m1, tmat3x4<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,15 +50,26 @@ namespace glm
typedef tmat2x4<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR length_t cols = 4;
static GLM_RELAXED_CONSTEXPR length_t rows = 2;
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:
/// @cond DETAIL
col_type value[4];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat4x2();
GLM_FUNC_DECL tmat4x2(tmat4x2<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat4x2() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat4x2(tmat4x2<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat4x2(tmat4x2<T, Q> const & m);
@@ -70,13 +81,12 @@ namespace glm
T const & x2, T const & y2,
T const & x3, T const & y3);
GLM_FUNC_DECL tmat4x2(
col_type const & v0,
col_type const & v0,
col_type const & v1,
col_type const & v2,
col_type const & v3);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <
typename X1, typename Y1,
@@ -96,16 +106,10 @@ namespace glm
tvec2<V3, P> const & v3,
tvec2<V4, P> const & v4);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat4x2(tmat4x2<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat4x2(tmat4x2<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat4x2(tmat4x2<U, Q> const & m);
GLM_FUNC_DECL explicit tmat4x2(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x2(tmat3x3<T, P> const & x);
@@ -116,8 +120,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat4x2(tmat4x3<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x2(tmat3x4<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -133,28 +136,26 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat4x2<T, P> & operator=(tmat4x2<T, P> const & m);
GLM_FUNC_DECL tmat4x2<T, P> & operator=(tmat4x2<T, P> const & m) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator=(tmat4x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator+=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator+=(tmat4x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator-=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator-=(tmat4x2<U, P> const & m);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator*=(U s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat4x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat4x2<T, P> & operator-- ();
@@ -162,7 +163,16 @@ namespace glm
GLM_FUNC_DECL tmat4x2<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator+(tmat4x2<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator-(tmat4x2<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator+(tmat4x2<T, P> const & m, T const & s);
@@ -189,10 +199,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> operator*(tmat4x2<T, P> const & m1, tmat3x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat4x2<T, P> const & m1, tmat4x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator*(tmat4x3<T, P> const & m1, tmat2x4<T, P> const & m2);
@@ -202,9 +212,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> operator/(T const & s, tmat4x2<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> const operator-(tmat4x2<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat4x2<T, P> const & m1, tmat4x2<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat4x2<T, P> const & m1, tmat4x2<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat4x2>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,28 +32,38 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat4x2<T, P> tmat4x2<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0);
this->value[3] = col_type(0, 0);
# endif
}
template<typename T, precision P>
const tmat4x2<T, P> tmat4x2<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(tmat4x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0);
this->value[3] = col_type(0, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(tmat4x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -72,11 +82,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(T const & s)
{
value_type const Zero(0);
this->value[0] = col_type(s, Zero);
this->value[1] = col_type(Zero, s);
this->value[2] = col_type(Zero, Zero);
this->value[3] = col_type(Zero, Zero);
this->value[0] = col_type(s, 0);
this->value[1] = col_type(0, s);
this->value[2] = col_type(0, 0);
this->value[3] = col_type(0, 0);
}
template <typename T, precision P>
@@ -109,8 +118,7 @@ namespace glm
this->value[3] = v3;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
@@ -148,8 +156,8 @@ namespace glm
this->value[3] = col_type(v4);
}
//////////////////////////////////////
// Conversion
// -- Conversion --
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(tmat4x2<U, Q> const & m)
@@ -232,8 +240,7 @@ namespace glm
this->value[3] = col_type(0);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -277,18 +284,19 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>& tmat4x2<T, P>::operator=(tmat4x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>& tmat4x2<T, P>::operator=(tmat4x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -367,6 +375,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> & tmat4x2<T, P>::operator++()
{
@@ -403,8 +413,25 @@ namespace glm
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> operator+(tmat4x2<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> operator-(tmat4x2<T, P> const & m)
{
return tmat4x2<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> operator+(tmat4x2<T, P> const & m, T const & s)
@@ -559,19 +586,7 @@ namespace glm
s / m[3]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> const operator-(tmat4x2<T, P> const & m)
{
return tmat4x2<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat4x2<T, P> const & m1, tmat4x2<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -50,14 +50,26 @@ namespace glm
typedef tmat3x4<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR length_t cols = 4;
static GLM_RELAXED_CONSTEXPR length_t rows = 3;
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:
// Data
col_type value[4];
public:
// Constructors
GLM_FUNC_DECL tmat4x3();
GLM_FUNC_DECL tmat4x3(tmat4x3<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat4x3() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat4x3(tmat4x3<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat4x3(tmat4x3<T, Q> const & m);
@@ -74,8 +86,7 @@ namespace glm
col_type const & v2,
col_type const & v3);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <
typename X1, typename Y1, typename Z1,
@@ -87,7 +98,7 @@ namespace glm
X2 const & x2, Y2 const & y2, Z2 const & z2,
X3 const & x3, Y3 const & y3, Z3 const & z3,
X4 const & x4, Y4 const & y4, Z4 const & z4);
template <typename V1, typename V2, typename V3, typename V4>
GLM_FUNC_DECL tmat4x3(
tvec3<V1, P> const & v1,
@@ -95,16 +106,10 @@ namespace glm
tvec3<V3, P> const & v3,
tvec3<V4, P> const & v4);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat4x3(tmat4x3<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat4x3(tmat4x3<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat4x3(tmat4x3<U, Q> const & m);
GLM_FUNC_DECL explicit tmat4x3(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x3(tmat3x3<T, P> const & x);
@@ -115,8 +120,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat4x3(tmat4x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x3(tmat3x4<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -132,10 +136,9 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat4x3<T, P> & operator=(tmat4x3<T, P> const & m);
GLM_FUNC_DECL tmat4x3<T, P> & operator=(tmat4x3<T, P> const & m) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tmat4x3<T, P> & operator=(tmat4x3<U, P> const & m);
@@ -152,8 +155,7 @@ namespace glm
template <typename U>
GLM_FUNC_DECL tmat4x3<T, P> & operator/=(U s);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat4x3<T, P> & operator++();
GLM_FUNC_DECL tmat4x3<T, P> & operator--();
@@ -161,7 +163,16 @@ namespace glm
GLM_FUNC_DECL tmat4x3<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator+(tmat4x3<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator-(tmat4x3<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator+(tmat4x3<T, P> const & m, T const & s);
@@ -191,7 +202,7 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator*(tmat4x3<T, P> const & m1, tmat3x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator*(tmat4x3<T, P> const & m1, tmat4x4<T, P> const & m2);
@@ -201,9 +212,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator/(T const & s, tmat4x3<T, P> const & m);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> const operator-(tmat4x3<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat4x3<T, P> const & m1, tmat4x3<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat4x3<T, P> const & m1, tmat4x3<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat4x3>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,28 +32,38 @@
namespace glm
{
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat4x3<T, P> tmat4x3<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1);
this->value[3] = col_type(0, 0, 0);
# endif
}
template<typename T, precision P>
const tmat4x3<T, P> tmat4x3<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(tmat4x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1);
this->value[3] = col_type(0, 0, 0);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(tmat4x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -108,8 +118,7 @@ namespace glm
this->value[3] = v3;
}
//////////////////////////////////////
// Conversion constructors
// -- Conversion constructors --
template <typename T, precision P>
template <
@@ -147,8 +156,7 @@ namespace glm
this->value[3] = col_type(v4);
}
//////////////////////////////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
template <typename T, precision P>
template <typename U, precision Q>
@@ -165,7 +173,7 @@ namespace glm
{
this->value[0] = col_type(m[0], 0);
this->value[1] = col_type(m[1], 0);
this->value[2] = col_type(m[2], 1);
this->value[2] = col_type(0, 0, 1);
this->value[3] = col_type(0);
}
@@ -232,8 +240,7 @@ namespace glm
this->value[3] = col_type(0);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -277,18 +284,19 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Unary updatable operators
// -- Unary updatable operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>& tmat4x3<T, P>::operator=(tmat4x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>& tmat4x3<T, P>::operator=(tmat4x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -367,6 +375,8 @@ namespace glm
return *this;
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> & tmat4x3<T, P>::operator++()
{
@@ -387,8 +397,41 @@ namespace glm
return *this;
}
//////////////////////////////////////////////////////////////
// Binary operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator++(int)
{
tmat4x3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator--(int)
{
tmat4x3<T, P> Result(*this);
--*this;
return Result;
}
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> operator+(tmat4x3<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> operator-(tmat4x3<T, P> const & m)
{
return tmat4x3<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> operator+(tmat4x3<T, P> const & m, T const & s)
@@ -567,55 +610,7 @@ namespace glm
s / m[3]);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> const operator-(tmat4x3<T, P> const & m)
{
return tmat4x3<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> const operator++(tmat4x3<T, P> const & m, int)
{
return tmat4x3<T, P>(
m[0] + T(1),
m[1] + T(1),
m[2] + T(1),
m[3] + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> const operator--(tmat4x3<T, P> const & m, int)
{
return tmat4x3<T, P>(
m[0] - T(1),
m[1] - T(1),
m[2] - T(1),
m[3] - T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator++(int)
{
tmat4x3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator--(int)
{
tmat4x3<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat4x3<T, P> const & m1, tmat4x3<T, P> const & m2)

View File

@@ -8,14 +8,14 @@
/// 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
@@ -49,20 +49,31 @@ namespace glm
typedef tmat4x4<T, P> transpose_type;
typedef T value_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR length_t cols = 4;
static GLM_RELAXED_CONSTEXPR length_t rows = 4;
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 <typename U, precision Q>
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
template <typename U, precision Q>
friend tvec4<U, Q> operator/(tvec4<U, Q> const & v, tmat4x4<U, Q> const & m);
private:
/// @cond DETAIL
col_type value[4];
/// @endcond
public:
// Constructors
GLM_FUNC_DECL tmat4x4();
GLM_FUNC_DECL tmat4x4(tmat4x4<T, P> const & m);
// -- Constructors --
GLM_FUNC_DECL tmat4x4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tmat4x4(tmat4x4<T, P> const & m) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tmat4x4(tmat4x4<T, Q> const & m);
@@ -79,8 +90,7 @@ namespace glm
col_type const & v2,
col_type const & v3);
//////////////////////////////////////
// Conversions
// -- Conversions --
template <
typename X1, typename Y1, typename Z1, typename W1,
@@ -100,16 +110,10 @@ namespace glm
tvec4<V3, P> const & v3,
tvec4<V4, P> const & v4);
//////////////////////////////////////
// Matrix conversions
// -- Matrix conversions --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tmat4x4(tmat4x4<U, Q> const & m);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tmat4x4(tmat4x4<U, Q> const & m);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tmat4x4(tmat4x4<U, Q> const & m);
GLM_FUNC_DECL explicit tmat4x4(tmat2x2<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x4(tmat3x3<T, P> const & x);
@@ -120,8 +124,7 @@ namespace glm
GLM_FUNC_DECL explicit tmat4x4(tmat3x4<T, P> const & x);
GLM_FUNC_DECL explicit tmat4x4(tmat4x3<T, P> const & x);
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -137,10 +140,9 @@ namespace glm
GLM_FUNC_DECL col_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tmat4x4<T, P> & operator=(tmat4x4<T, P> const & m);
GLM_FUNC_DECL tmat4x4<T, P> & operator=(tmat4x4<T, P> const & m) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tmat4x4<T, P> & operator=(tmat4x4<U, P> const & m);
@@ -161,8 +163,7 @@ namespace glm
template <typename U>
GLM_FUNC_DECL tmat4x4<T, P> & operator/=(tmat4x4<U, P> const & m);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tmat4x4<T, P> & operator++();
GLM_FUNC_DECL tmat4x4<T, P> & operator--();
@@ -170,20 +171,29 @@ namespace glm
GLM_FUNC_DECL tmat4x4<T, P> operator--(int);
};
// Binary operators
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator+(tmat4x4<T, P> const & m);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator-(tmat4x4<T, P> const & m);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator+(tmat4x4<T, P> const & m, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator+(T const & s, tmat4x4<T, P> const & m);
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator+(tmat4x4<T, P> const & m1, tmat4x4<T, P> const & m2);
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator-(tmat4x4<T, P> const & m, T const & s);
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator-(T const & s, tmat4x4<T, P> const & m);
template <typename T, precision P>
@@ -225,9 +235,23 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator/(tmat4x4<T, P> const & m1, tmat4x4<T, P> const & m2);
// Unary constant operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> const operator-(tmat4x4<T, P> const & m);
GLM_FUNC_DECL bool operator==(tmat4x4<T, P> const & m1, tmat4x4<T, P> const & m2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tmat4x4<T, P> const & m1, tmat4x4<T, P> const & m2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tmat4x4>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -92,28 +92,38 @@ namespace detail
}
}//namespace detail
//////////////////////////////////////////////////////////////
// Constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tmat4x4<T, P> tmat4x4<T, P>::ZERO(static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
# endif
}
template<typename T, precision P>
const tmat4x4<T, P> tmat4x4<T, P>::IDENTITY(static_cast<T>(1));
# endif
// -- Constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(tmat4x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
# endif
}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(tmat4x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -181,8 +191,8 @@ namespace detail
this->value[3] = col_type(m[3]);
}
//////////////////////////////////////
// Conversion constructors
// -- Conversions --
template <typename T, precision P>
template <
typename X1, typename Y1, typename Z1, typename W1,
@@ -244,14 +254,14 @@ namespace detail
this->value[3] = col_type(v4);
}
//////////////////////////////////////
// Matrix convertion constructors
// -- Matrix conversions --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(tmat2x2<T, P> const & m)
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@@ -269,7 +279,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0);
this->value[1] = col_type(m[1], 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@@ -278,7 +288,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(m[2], 0, 0);
this->value[2] = col_type(m[2], 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@@ -287,7 +297,7 @@ namespace detail
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@@ -296,7 +306,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@@ -318,8 +328,7 @@ namespace detail
this->value[3] = col_type(m[3], 1);
}
//////////////////////////////////////
// Accesses
// -- Accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -363,20 +372,21 @@ namespace detail
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////////////////////////////
// Operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>& tmat4x4<T, P>::operator=(tmat4x4<T, P> const & m)
{
//memcpy could be faster
//memcpy(&this->value, &m.value, 16 * sizeof(valType));
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>& tmat4x4<T, P>::operator=(tmat4x4<T, P> const & m)
{
//memcpy could be faster
//memcpy(&this->value, &m.value, 16 * sizeof(valType));
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -471,6 +481,8 @@ namespace detail
return (*this = *this * detail::compute_inverse<T, P>(m));
}
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> & tmat4x4<T, P>::operator++()
{
@@ -507,7 +519,26 @@ namespace detail
return Result;
}
// Binary operators
// -- Unary constant operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> operator+(tmat4x4<T, P> const & m)
{
return m;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> operator-(tmat4x4<T, P> const & m)
{
return tmat4x4<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> operator+(tmat4x4<T, P> const & m, T const & s)
{
@@ -742,39 +773,7 @@ namespace detail
return m1_copy /= m2;
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> const operator-(tmat4x4<T, P> const & m)
{
return tmat4x4<T, P>(
-m[0],
-m[1],
-m[2],
-m[3]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> const operator++(tmat4x4<T, P> const & m, int)
{
return tmat4x4<T, P>(
m[0] + static_cast<T>(1),
m[1] + static_cast<T>(1),
m[2] + static_cast<T>(1),
m[3] + static_cast<T>(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> const operator--(tmat4x4<T, P> const & m, int)
{
return tmat4x4<T, P>(
m[0] - static_cast<T>(1),
m[1] - static_cast<T>(1),
m[2] - static_cast<T>(1),
m[3] - static_cast<T>(1));
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tmat4x4<T, P> const & m1, tmat4x4<T, P> const & m2)

View File

@@ -168,7 +168,6 @@ namespace glm
/// @}
/// @addtogroup core_precision
/// @{
@@ -374,8 +373,7 @@ namespace glm
/// @addtogroup core_types
/// @{
//////////////////////////
// Default float definition
// -- Default float definition --
#if(defined(GLM_PRECISION_LOWP_FLOAT))
typedef lowp_vec2 vec2;
@@ -402,8 +400,7 @@ namespace glm
typedef highp_vec4 vec4;
#endif//GLM_PRECISION
//////////////////////////
// Default double definition
// -- Default double definition --
#if(defined(GLM_PRECISION_LOWP_DOUBLE))
typedef lowp_dvec2 dvec2;
@@ -418,21 +415,20 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_dvec2 dvec2;
//! 3 components vector of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_dvec3 dvec3;
//! 4 components vector of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_dvec4 dvec4;
#endif//GLM_PRECISION
//////////////////////////
// Signed integer definition
// -- Signed integer definition --
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_ivec2 ivec2;
typedef lowp_ivec3 ivec3;
@@ -442,25 +438,24 @@ namespace glm
typedef mediump_ivec3 ivec3;
typedef mediump_ivec4 ivec4;
#else //defined(GLM_PRECISION_HIGHP_INT)
//! 2 components vector of signed integer numbers.
/// 2 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_ivec2 ivec2;
//! 3 components vector of signed integer numbers.
/// 3 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_ivec3 ivec3;
//! 4 components vector of signed integer numbers.
/// 4 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_ivec4 ivec4;
#endif//GLM_PRECISION
//////////////////////////
// Unsigned integer definition
// -- Unsigned integer definition --
#if(defined(GLM_PRECISION_LOWP_UINT))
typedef lowp_uvec2 uvec2;
typedef lowp_uvec3 uvec3;
@@ -474,20 +469,19 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_uvec2 uvec2;
/// 3 components vector of unsigned integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_uvec3 uvec3;
/// 4 components vector of unsigned integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_uvec4 uvec4;
#endif//GLM_PRECISION
//////////////////////////
// Boolean definition
// -- Boolean definition --
#if(defined(GLM_PRECISION_LOWP_BOOL))
typedef lowp_bvec2 bvec2;
@@ -498,21 +492,21 @@ namespace glm
typedef mediump_bvec3 bvec3;
typedef mediump_bvec4 bvec4;
#else //defined(GLM_PRECISION_HIGHP_BOOL)
//! 2 components vector of boolean.
/// 2 components vector of boolean.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_bvec2 bvec2;
//! 3 components vector of boolean.
/// 3 components vector of boolean.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_bvec3 bvec3;
//! 4 components vector of boolean.
/// 4 components vector of boolean.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef highp_bvec4 bvec4;
#endif//GLM_PRECISION
/// @}
}//namespace glm

View File

@@ -8,14 +8,14 @@
/// 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
@@ -48,15 +48,22 @@ namespace glm
template <typename T, precision P = defaultp>
struct tvec1
{
//////////////////////////////////////
// Implementation detail
// -- Implementation detail --
typedef tvec1<T, P> type;
typedef tvec1<bool, P> bool_type;
typedef T value_type;
//////////////////////////////////////
// Data
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 1;
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
union
@@ -85,8 +92,7 @@ namespace glm
# endif//GLM_SWIZZLE*/
# endif
//////////////////////////////////////
// Accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
@@ -104,45 +110,35 @@ namespace glm
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tvec1();
GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tvec1(tvec1<T, P> const & v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
//////////////////////////////////////
// Explicit basic constructors
// -- 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
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
// -- Conversion vector constructors --
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);
# ifdef GLM_FORCE_EXPLICIT_CTOR
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
# else
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL tvec1(tvec1<U, Q> const & v);
# endif
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec1(tvec1<U, Q> const & v);
//////////////////////////////////////
// Swizzle constructors
// -- Swizzle constructors --
# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
template <int E0>
@@ -152,106 +148,168 @@ namespace glm
}
# endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v) GLM_DEFAULT;
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tvec1<T, P> & operator++();
GLM_FUNC_DECL tvec1<T, P> & operator--();
GLM_FUNC_DECL tvec1<T, P> operator++(int);
GLM_FUNC_DECL tvec1<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
template <typename U>
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & scalar);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
};
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> operator-(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> operator*(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> operator/(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(T const & scalar, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
@@ -259,62 +317,21 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
template <precision P>
GLM_FUNC_DECL tvec1<bool, P> operator&&(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec1<bool, P> operator||(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
struct type<T, P, tvec1>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,20 +32,30 @@
namespace glm
{
//////////////////////////////////////
// Implicit basic constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P>
const tvec1<T, P> tvec1<T, P>::X(static_cast<T>(1));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0)
# endif
{}
template<typename T, precision P>
const tvec1<T, P> tvec1<T, P>::ZERO(static_cast<T>(0));
# endif
// -- Implicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(tvec1<T, P> const & v)
: x(v.x)
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(tvec1<T, P> const & v)
: x(v.x)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -53,20 +63,18 @@ namespace glm
: x(v.x)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(T const & s)
: x(s)
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(T const & scalar)
: x(scalar)
{}
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
template <typename T, precision P>
template <typename U, precision Q>
@@ -92,8 +100,7 @@ namespace glm
: x(static_cast<T>(v.x))
{}
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -137,15 +144,16 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v)
{
this->x = v.x;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v)
{
this->x = v.x;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -157,9 +165,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator+=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator+=(U const & scalar)
{
this->x += static_cast<T>(s);
this->x += static_cast<T>(scalar);
return *this;
}
@@ -173,9 +181,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator-=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator-=(U const & scalar)
{
this->x -= static_cast<T>(s);
this->x -= static_cast<T>(scalar);
return *this;
}
@@ -189,9 +197,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator*=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator*=(U const & scalar)
{
this->x *= static_cast<T>(s);
this->x *= static_cast<T>(scalar);
return *this;
}
@@ -205,9 +213,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator/=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator/=(U const & scalar)
{
this->x /= static_cast<T>(s);
this->x /= static_cast<T>(scalar);
return *this;
}
@@ -219,8 +227,7 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator++()
@@ -252,29 +259,13 @@ namespace glm
return Result;
}
//////////////////////////////////////
// Boolean operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2)
{
return (v1.x == v2.x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2)
{
return (v1.x != v2.x);
}
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator%=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator%=(U const & scalar)
{
this->x %= static_cast<T>(s);
this->x %= static_cast<T>(scalar);
return *this;
}
@@ -288,9 +279,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator&=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator&=(U const & scalar)
{
this->x &= static_cast<T>(s);
this->x &= static_cast<T>(scalar);
return *this;
}
@@ -304,9 +295,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator|=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator|=(U const & scalar)
{
this->x |= static_cast<T>(s);
this->x |= static_cast<T>(scalar);
return *this;
}
@@ -320,9 +311,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator^=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator^=(U const & scalar)
{
this->x ^= static_cast<T>(s);
this->x ^= static_cast<T>(scalar);
return *this;
}
@@ -336,9 +327,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator<<=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator<<=(U const & scalar)
{
this->x <<= static_cast<T>(s);
this->x <<= static_cast<T>(scalar);
return *this;
}
@@ -352,9 +343,9 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator>>=(U const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator>>=(U const & scalar)
{
this->x >>= static_cast<T>(s);
this->x >>= static_cast<T>(scalar);
return *this;
}
@@ -366,21 +357,35 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Binary arithmetic operators
// -- Unary constant operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator+(tvec1<T, P> const & v)
{
return v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v)
{
return tvec1<T, P>(
v.x + s);
-v.x);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator+(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x + scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator+(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s + v.x);
scalar + v.x);
}
template <typename T, precision P>
@@ -392,17 +397,17 @@ namespace glm
//operator-
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x - s);
v.x - scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s - v.x);
scalar - v.x);
}
template <typename T, precision P>
@@ -412,19 +417,18 @@ namespace glm
v1.x - v2.x);
}
//operator*
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator*(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x * s);
v.x * scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator*(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s * v.x);
scalar * v.x);
}
template <typename T, precision P>
@@ -434,19 +438,18 @@ namespace glm
v1.x * v2.x);
}
//operator/
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator/(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x / s);
v.x / scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator/(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s / v.x);
scalar / v.x);
}
template <typename T, precision P>
@@ -456,43 +459,20 @@ namespace glm
v1.x / v2.x);
}
// Unary constant operators
// -- Binary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator%(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
-v.x);
v.x % scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator++(tvec1<T, P> const & v, int)
GLM_FUNC_QUALIFIER tvec1<T, P> operator%(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
v.x + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator--(tvec1<T, P> const & v, int)
{
return tvec1<T, P>(
v.x - T(1));
}
//////////////////////////////////////
// Binary bit operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s)
{
return tvec1<T, P>(
v.x % s);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s % v.x);
scalar % v.x);
}
template <typename T, precision P>
@@ -503,17 +483,17 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator&(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x & s);
v.x & scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator&(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s & v.x);
scalar & v.x);
}
template <typename T, precision P>
@@ -524,17 +504,17 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator|(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x | s);
v.x | scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator|(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s | v.x);
scalar | v.x);
}
template <typename T, precision P>
@@ -545,17 +525,17 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator^(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x ^ s);
v.x ^ scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator^(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s ^ v.x);
scalar ^ v.x);
}
template <typename T, precision P>
@@ -566,17 +546,17 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x << s);
v.x << scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s << v.x);
scalar << v.x);
}
template <typename T, precision P>
@@ -587,17 +567,17 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & scalar)
{
return tvec1<T, P>(
v.x >> s);
v.x >> scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>(T const & scalar, tvec1<T, P> const & v)
{
return tvec1<T, P>(
s >> v.x);
scalar >> v.x);
}
template <typename T, precision P>
@@ -613,4 +593,30 @@ namespace glm
return tvec1<T, P>(
~v.x);
}
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2)
{
return (v1.x == v2.x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2)
{
return (v1.x != v2.x);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec1<bool, P> operator&&(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2)
{
return tvec1<bool, P>(v1.x && v2.x);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec1<bool, P> operator||(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2)
{
return tvec1<bool, P>(v1.x || v2.x);
}
}//namespace glm

View File

@@ -32,7 +32,6 @@
#pragma once
//#include "../fwd.hpp"
#include "type_vec.hpp"
#ifdef GLM_SWIZZLE
# if GLM_HAS_ANONYMOUS_UNION
@@ -48,15 +47,25 @@ namespace glm
template <typename T, precision P = defaultp>
struct tvec2
{
//////////////////////////////////////
// Implementation detail
// -- Implementation detail --
typedef tvec2<T, P> type;
typedef tvec2<bool, P> bool_type;
typedef T value_type;
//////////////////////////////////////
// Data
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 2;
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
union
@@ -86,8 +95,7 @@ namespace glm
# endif//GLM_SWIZZLE
# endif
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
@@ -105,23 +113,20 @@ namespace glm
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tvec2();
GLM_FUNC_DECL tvec2(tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tvec2(tvec2<T, P> const & v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tvec2(tvec2<T, Q> const & v);
//////////////////////////////////////
// Explicit basic constructors
// -- 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
// -- Conversion constructors --
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
@@ -129,28 +134,20 @@ namespace glm
template <typename A, typename B>
GLM_FUNC_DECL tvec2(tvec1<A, P> const & v1, tvec1<B, P> const & v2);
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec2(tvec3<U, Q> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec2(tvec4<U, Q> const & v);
# ifdef GLM_FORCE_EXPLICIT_CTOR
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec2(tvec2<U, Q> const & v);
# else
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL tvec2(tvec2<U, Q> const & v);
# endif
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec2(tvec2<U, Q> const & v);
//////////////////////////////////////
// Swizzle constructors
// -- Swizzle constructors --
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
template <int E0, int E1>
@@ -160,95 +157,102 @@ namespace glm
}
# endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<T, P> const & v) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator+=(U s);
GLM_FUNC_DECL tvec2<T, P>& operator+=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator+=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator+=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator-=(U s);
GLM_FUNC_DECL tvec2<T, P>& operator-=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator-=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator-=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator*=(U s);
GLM_FUNC_DECL tvec2<T, P>& operator*=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator*=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator*=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator/=(U s);
GLM_FUNC_DECL tvec2<T, P>& operator/=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator/=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator/=(tvec2<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tvec2<T, P> & operator++();
GLM_FUNC_DECL tvec2<T, P> & operator--();
GLM_FUNC_DECL tvec2<T, P> operator++(int);
GLM_FUNC_DECL tvec2<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator%=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator%=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator%=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator%=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator&=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator&=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator&=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator&=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator|=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator|=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator|=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator|=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator^=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator^=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator^=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator^=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator<<=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator<<=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator<<=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator<<=(tvec2<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator>>=(U s);
GLM_FUNC_DECL tvec2<T, P> & operator>>=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator>>=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator>>=(tvec2<U, P> const & v);
};
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator+(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -257,13 +261,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator-(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator-(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator-(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -272,13 +276,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator*(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator*(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator*(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator*(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator*(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator*(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -287,13 +291,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator*(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator/(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator/(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator/(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator/(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator/(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator/(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -305,13 +309,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator%(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator%(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator%(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator%(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator%(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator%(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -320,13 +324,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator%(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator&(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator&(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator&(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator&(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator&(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator&(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -335,13 +339,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator&(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator|(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator|(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator|(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator|(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator|(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator|(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -350,13 +354,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator|(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator^(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator^(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator^(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator^(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator^(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator^(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -365,13 +369,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator^(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator<<(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator<<(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator<<(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator<<(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator<<(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator<<(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -380,13 +384,13 @@ namespace glm
GLM_FUNC_DECL tvec2<T, P> operator<<(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator>>(tvec2<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec2<T, P> operator>>(tvec2<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator>>(tvec2<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator>>(T const & s, tvec2<T, P> const & v);
GLM_FUNC_DECL tvec2<T, P> operator>>(T const & scalar, tvec2<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator>>(tvec1<T, P> const & v1, tvec2<T, P> const & v2);
@@ -396,6 +400,30 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator~(tvec2<T, P> const & v);
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec2<bool, P> operator&&(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec2<bool, P> operator||(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tvec2>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -28,51 +28,36 @@
namespace glm
{
#ifdef GLM_FORCE_SIZE_FUNC
# ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2<T, P>::size() const
{
return 2;
}
#else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec2<T, P>::length() const
{
return 2;
}
#endif
//////////////////////////////////////
// Accesses
const tvec2<T, P> tvec2<T, P>::ZERO(static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
const tvec2<T, P> tvec2<T, P>::X(static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
//////////////////////////////////////
// Implicit basic constructors
const tvec2<T, P> tvec2<T, P>::Y(static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0)
# endif
{}
const tvec2<T, P> tvec2<T, P>::XY(static_cast<T>(1), static_cast<T>(1));
# endif
// -- Implicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(tvec2<T, P> const & v)
: x(v.x), y(v.y)
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(tvec2<T, P> const & v)
: x(v.x), y(v.y)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -80,16 +65,15 @@ namespace glm
: x(v.x), y(v.y)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(T const & s)
: x(s), y(s)
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(T const & scalar)
: x(scalar), y(scalar)
{}
template <typename T, precision P>
@@ -97,8 +81,7 @@ namespace glm
: x(s1), y(s2)
{}
//////////////////////////////////////
// Conversion scalar constructors
// -- Conversion scalar constructors --
template <typename T, precision P>
template <typename A, typename B>
@@ -114,8 +97,7 @@ namespace glm
, y(static_cast<T>(b.x))
{}
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
template <typename T, precision P>
template <typename U, precision Q>
@@ -138,16 +120,61 @@ namespace glm
, y(static_cast<T>(v.y))
{}
//////////////////////////////////////
// Unary arithmetic operators
// -- Component accesses --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T, P>::size_type tvec2<T, P>::size() const
{
return 2;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](typename tvec2<T, P>::size_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](typename tvec2<T, P>::size_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T, P>::length_type tvec2<T, P>::length() const
{
return 2;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](typename tvec2<T, P>::length_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](typename tvec2<T, P>::length_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# endif//GLM_FORCE_SIZE_FUNC
// -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -160,10 +187,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator+=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator+=(U scalar)
{
this->x += static_cast<T>(s);
this->y += static_cast<T>(s);
this->x += static_cast<T>(scalar);
this->y += static_cast<T>(scalar);
return *this;
}
@@ -187,10 +214,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator-=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator-=(U scalar)
{
this->x -= static_cast<T>(s);
this->y -= static_cast<T>(s);
this->x -= static_cast<T>(scalar);
this->y -= static_cast<T>(scalar);
return *this;
}
@@ -214,10 +241,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator*=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator*=(U scalar)
{
this->x *= static_cast<T>(s);
this->y *= static_cast<T>(s);
this->x *= static_cast<T>(scalar);
this->y *= static_cast<T>(scalar);
return *this;
}
@@ -241,10 +268,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator/=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator/=(U scalar)
{
this->x /= static_cast<T>(s);
this->y /= static_cast<T>(s);
this->x /= static_cast<T>(scalar);
this->y /= static_cast<T>(scalar);
return *this;
}
@@ -266,8 +293,7 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator++()
@@ -301,30 +327,14 @@ namespace glm
return Result;
}
//////////////////////////////////////
// Boolean operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec2<T, P> const & v1, tvec2<T, P> const & v2)
{
return (v1.x == v2.x) && (v1.y == v2.y);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec2<T, P> const & v1, tvec2<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y);
}
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator%=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator%=(U scalar)
{
this->x %= static_cast<T>(s);
this->y %= static_cast<T>(s);
this->x %= static_cast<T>(scalar);
this->y %= static_cast<T>(scalar);
return *this;
}
@@ -348,10 +358,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator&=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator&=(U scalar)
{
this->x &= static_cast<T>(s);
this->y &= static_cast<T>(s);
this->x &= static_cast<T>(scalar);
this->y &= static_cast<T>(scalar);
return *this;
}
@@ -375,10 +385,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator|=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator|=(U scalar)
{
this->x |= static_cast<T>(s);
this->y |= static_cast<T>(s);
this->x |= static_cast<T>(scalar);
this->y |= static_cast<T>(scalar);
return *this;
}
@@ -402,10 +412,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator^=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator^=(U scalar)
{
this->x ^= static_cast<T>(s);
this->y ^= static_cast<T>(s);
this->x ^= static_cast<T>(scalar);
this->y ^= static_cast<T>(scalar);
return *this;
}
@@ -429,10 +439,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator<<=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator<<=(U scalar)
{
this->x <<= static_cast<T>(s);
this->y <<= static_cast<T>(s);
this->x <<= static_cast<T>(scalar);
this->y <<= static_cast<T>(scalar);
return *this;
}
@@ -456,10 +466,10 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator>>=(U s)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator>>=(U scalar)
{
this->x >>= static_cast<T>(s);
this->y >>= static_cast<T>(s);
this->x >>= static_cast<T>(scalar);
this->y >>= static_cast<T>(scalar);
return *this;
}
@@ -481,15 +491,30 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Binary arithmetic operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator+(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator+(tvec2<T, P> const & v)
{
return v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v)
{
return tvec2<T, P>(
v.x + s,
v.y + s);
-v.x,
-v.y);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator+(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x + scalar,
v.y + scalar);
}
template <typename T, precision P>
@@ -501,11 +526,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator+(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator+(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s + v.x,
s + v.y);
scalar + v.x,
scalar + v.y);
}
template <typename T, precision P>
@@ -524,13 +549,12 @@ namespace glm
v1.y + v2.y);
}
//operator-
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x - s,
v.y - s);
v.x - scalar,
v.y - scalar);
}
template <typename T, precision P>
@@ -542,11 +566,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s - v.x,
s - v.y);
scalar - v.x,
scalar - v.y);
}
template <typename T, precision P>
@@ -565,7 +589,6 @@ namespace glm
v1.y - v2.y);
}
//operator*
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator*(tvec2<T, P> const & v1, T const & v2)
{
@@ -583,11 +606,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator*(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator*(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s * v.x,
s * v.y);
scalar * v.x,
scalar * v.y);
}
template <typename T, precision P>
@@ -606,13 +629,12 @@ namespace glm
v1.y * v2.y);
}
//operator/
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator/(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator/(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x / s,
v.y / s);
v.x / scalar,
v.y / scalar);
}
template <typename T, precision P>
@@ -624,11 +646,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator/(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator/(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s / v.x,
s / v.y);
scalar / v.x,
scalar / v.y);
}
template <typename T, precision P>
@@ -647,24 +669,14 @@ namespace glm
v1.y / v2.y);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v)
{
return tvec2<T, P>(
-v.x,
-v.y);
}
//////////////////////////////////////
// Binary bit operators
// -- Binary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator%(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator%(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x % s,
v.y % s);
v.x % scalar,
v.y % scalar);
}
template <typename T, precision P>
@@ -676,11 +688,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator%(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator%(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s % v.x,
s % v.y);
scalar % v.x,
scalar % v.y);
}
template <typename T, precision P>
@@ -700,11 +712,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator&(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator&(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x & s,
v.y & s);
v.x & scalar,
v.y & scalar);
}
template <typename T, precision P>
@@ -716,11 +728,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator&(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator&(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s & v.x,
s & v.y);
scalar & v.x,
scalar & v.y);
}
template <typename T, precision P>
@@ -740,11 +752,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator|(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator|(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x | s,
v.y | s);
v.x | scalar,
v.y | scalar);
}
template <typename T, precision P>
@@ -756,11 +768,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator|(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator|(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s | v.x,
s | v.y);
scalar | v.x,
scalar | v.y);
}
template <typename T, precision P>
@@ -780,11 +792,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator^(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator^(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x ^ s,
v.y ^ s);
v.x ^ scalar,
v.y ^ scalar);
}
template <typename T, precision P>
@@ -796,11 +808,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator^(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator^(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s ^ v.x,
s ^ v.y);
scalar ^ v.x,
scalar ^ v.y);
}
template <typename T, precision P>
@@ -820,11 +832,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator<<(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator<<(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x << s,
v.y << s);
v.x << scalar,
v.y << scalar);
}
template <typename T, precision P>
@@ -836,11 +848,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator<<(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator<<(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s << v.x,
s << v.y);
scalar << v.x,
scalar << v.y);
}
template <typename T, precision P>
@@ -860,11 +872,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator>>(tvec2<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec2<T, P> operator>>(tvec2<T, P> const & v, T const & scalar)
{
return tvec2<T, P>(
v.x >> s,
v.y >> s);
v.x >> scalar,
v.y >> scalar);
}
template <typename T, precision P>
@@ -876,11 +888,11 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator>>(T const & s, tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> operator>>(T const & scalar, tvec2<T, P> const & v)
{
return tvec2<T, P>(
s >> v.x,
s >> v.y);
scalar >> v.x,
scalar >> v.y);
}
template <typename T, precision P>
@@ -906,4 +918,30 @@ namespace glm
~v.x,
~v.y);
}
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec2<T, P> const & v1, tvec2<T, P> const & v2)
{
return (v1.x == v2.x) && (v1.y == v2.y);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec2<T, P> const & v1, tvec2<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec2<bool, P> operator&&(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2)
{
return tvec2<bool, P>(v1.x && v2.x, v1.y && v2.y);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec2<bool, P> operator||(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2)
{
return tvec2<bool, P>(v1.x || v2.x, v1.y || v2.y);
}
}//namespace glm

View File

@@ -32,7 +32,6 @@
#pragma once
//#include "../fwd.hpp"
#include "type_vec.hpp"
#ifdef GLM_SWIZZLE
# if GLM_HAS_ANONYMOUS_UNION
@@ -47,16 +46,30 @@ namespace glm
{
template <typename T, precision P = defaultp>
struct tvec3
{
//////////////////////////////////////
// Implementation detail
{
// -- Implementation detail --
typedef tvec3<T, P> type;
typedef tvec3<bool, P> bool_type;
typedef T value_type;
//////////////////////////////////////
// Data
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 3;
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
union
@@ -87,8 +100,7 @@ namespace glm
# endif//GLM_SWIZZLE
# endif//GLM_LANG
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
@@ -106,23 +118,20 @@ namespace glm
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tvec3();
GLM_FUNC_DECL tvec3(tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tvec3(tvec3<T, P> const & v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tvec3(tvec3<T, Q> const & v);
//////////////////////////////////////
// Explicit basic constructors
// -- 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
// -- Conversion scalar constructors --
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
@@ -130,37 +139,29 @@ namespace glm
template <typename A, typename B, typename C>
GLM_FUNC_DECL tvec3(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c);
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec3(tvec2<A, Q> const & a, B const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec3(tvec2<A, Q> const & a, tvec1<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec3(A const & a, tvec2<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec3(tvec1<A, Q> const & a, tvec2<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec3(tvec4<U, Q> const & v);
# ifdef GLM_FORCE_EXPLICIT_CTOR
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec3(tvec3<U, Q> const & v);
# else
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL tvec3(tvec3<U, Q> const & v);
# endif
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec3<U, Q> const & v);
//////////////////////////////////////
// Swizzle constructors
// -- Swizzle constructors --
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
template <int E0, int E1, int E2>
@@ -170,254 +171,282 @@ namespace glm
}
template <int E0, int E1>
GLM_FUNC_DECL tvec3(detail::_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & s)
GLM_FUNC_DECL tvec3(detail::_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & scalar)
{
*this = tvec3<T, P>(v(), s);
*this = tvec3<T, P>(v(), scalar);
}
template <int E0, int E1>
GLM_FUNC_DECL tvec3(T const & s, detail::_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
GLM_FUNC_DECL tvec3(T const & scalar, detail::_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
{
*this = tvec3<T, P>(s, v());
*this = tvec3<T, P>(scalar, v());
}
# endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<T, P> const & v) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator+=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator+=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator-=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator-=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator-=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator-=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator*=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator*=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator*=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator*=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator/=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator/=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec3<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tvec3<T, P> & operator++();
GLM_FUNC_DECL tvec3<T, P> & operator--();
GLM_FUNC_DECL tvec3<T, P> operator++(int);
GLM_FUNC_DECL tvec3<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator%=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator%=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator%=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator%=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator&=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator&=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator&=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator&=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator|=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator|=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator|=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator|=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator^=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator^=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator^=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator^=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator<<=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator<<=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator<<=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator<<=(tvec3<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator>>=(U s);
GLM_FUNC_DECL tvec3<T, P> & operator>>=(U scalar);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec1<U, P> const & v);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec3<U, P> const & v);
};
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T const & s);
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator-(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator-(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator*(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator*(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator*(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator*(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator/(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator/(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator/(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator/(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator%(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator%(T const & s, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator%(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator%(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator&(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator&(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator&(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator&(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator|(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator|(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator|(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator|(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator^(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator^(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator^(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator^(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator<<(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator<<(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & s);
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator>>(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator>>(T const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec1<T, P> const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec1<T, P> const & scalar, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator~(tvec3<T, P> const & v);
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec3<bool, P> operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec3<bool, P> operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tvec3>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,20 +32,49 @@
namespace glm
{
//////////////////////////////////////
// Implicit basic constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::ZERO(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0)
# endif
{}
const tvec3<T, P> tvec3<T, P>::X(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(tvec3<T, P> const & v)
: x(v.x), y(v.y), z(v.z)
{}
const tvec3<T, P> tvec3<T, P>::Y(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::Z(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XY(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XZ(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::YZ(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XYZ(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(tvec3<T, P> const & v)
: x(v.x), y(v.y), z(v.z)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -53,16 +82,15 @@ namespace glm
: x(v.x), y(v.y), z(v.z)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(T const & s)
: x(s), y(s), z(s)
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(T const & scalar)
: x(scalar), y(scalar), z(scalar)
{}
template <typename T, precision P>
@@ -70,8 +98,7 @@ namespace glm
: x(a), y(b), z(c)
{}
//////////////////////////////////////
// Conversion scalar constructors
// -- Conversion scalar constructors --
template <typename T, precision P>
template <typename A, typename B, typename C>
@@ -89,8 +116,7 @@ namespace glm
z(static_cast<T>(c))
{}
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
template <typename T, precision P>
template <typename A, typename B, precision Q>
@@ -140,8 +166,7 @@ namespace glm
z(static_cast<T>(v.z))
{}
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -185,17 +210,18 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -209,11 +235,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator+=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator+=(U scalar)
{
this->x += static_cast<T>(s);
this->y += static_cast<T>(s);
this->z += static_cast<T>(s);
this->x += static_cast<T>(scalar);
this->y += static_cast<T>(scalar);
this->z += static_cast<T>(scalar);
return *this;
}
@@ -239,11 +265,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator-=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator-=(U scalar)
{
this->x -= static_cast<T>(s);
this->y -= static_cast<T>(s);
this->z -= static_cast<T>(s);
this->x -= static_cast<T>(scalar);
this->y -= static_cast<T>(scalar);
this->z -= static_cast<T>(scalar);
return *this;
}
@@ -269,11 +295,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator*=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator*=(U scalar)
{
this->x *= static_cast<T>(s);
this->y *= static_cast<T>(s);
this->z *= static_cast<T>(s);
this->x *= static_cast<T>(scalar);
this->y *= static_cast<T>(scalar);
this->z *= static_cast<T>(scalar);
return *this;
}
@@ -299,11 +325,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=(U v)
{
this->x /= static_cast<T>(s);
this->y /= static_cast<T>(s);
this->z /= static_cast<T>(s);
this->x /= static_cast<T>(v);
this->y /= static_cast<T>(v);
this->z /= static_cast<T>(v);
return *this;
}
@@ -327,8 +353,7 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator++()
@@ -364,16 +389,15 @@ namespace glm
return Result;
}
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator%=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator%=(U scalar)
{
this->x %= s;
this->y %= s;
this->z %= s;
this->x %= scalar;
this->y %= scalar;
this->z %= scalar;
return *this;
}
@@ -399,11 +423,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator&=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator&=(U scalar)
{
this->x &= s;
this->y &= s;
this->z &= s;
this->x &= scalar;
this->y &= scalar;
this->z &= scalar;
return *this;
}
@@ -429,11 +453,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator|=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator|=(U scalar)
{
this->x |= s;
this->y |= s;
this->z |= s;
this->x |= scalar;
this->y |= scalar;
this->z |= scalar;
return *this;
}
@@ -459,11 +483,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator^=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator^=(U scalar)
{
this->x ^= s;
this->y ^= s;
this->z ^= s;
this->x ^= scalar;
this->y ^= scalar;
this->z ^= scalar;
return *this;
}
@@ -489,11 +513,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator<<=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator<<=(U scalar)
{
this->x <<= s;
this->y <<= s;
this->z <<= s;
this->x <<= scalar;
this->y <<= scalar;
this->z <<= scalar;
return *this;
}
@@ -519,11 +543,11 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator>>=(U s)
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator>>=(U scalar)
{
this->x >>= static_cast<T>(s);
this->y >>= static_cast<T>(s);
this->z >>= static_cast<T>(s);
this->x >>= static_cast<T>(scalar);
this->y >>= static_cast<T>(scalar);
this->z >>= static_cast<T>(scalar);
return *this;
}
@@ -547,58 +571,59 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Boolean operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec3<T, P> const & v1, tvec3<T, P> const & v2)
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v)
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
return v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z);
}
//////////////////////////////////////
// Binary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v)
{
return tvec3<T, P>(
v.x + s,
v.y + s,
v.z + s);
-v.x,
-v.y,
-v.z);
}
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x + scalar,
v.y + scalar,
v.z + scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s + v.x,
s + v.y,
s + v.z);
scalar + v.x,
scalar + v.y,
scalar + v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -610,41 +635,40 @@ namespace glm
v1.z + v2.z);
}
//operator-
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x - s,
v.y - s,
v.z - s);
v.x - scalar,
v.y - scalar,
v.z - scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s - v.x,
s - v.y,
s - v.z);
scalar - v.x,
scalar - v.y,
scalar - v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -656,41 +680,40 @@ namespace glm
v1.z - v2.z);
}
//operator*
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x * s,
v.y * s,
v.z * s);
v.x * scalar,
v.y * scalar,
v.z * scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s * v.x,
s * v.y,
s * v.z);
scalar * v.x,
scalar * v.y,
scalar * v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -702,41 +725,40 @@ namespace glm
v1.z * v2.z);
}
//operator/
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x / s,
v.y / s,
v.z / s);
v.x / scalar,
v.y / scalar,
v.z / scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s / v.x,
s / v.y,
s / v.z);
scalar / v.x,
scalar / v.y,
scalar / v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -748,53 +770,42 @@ namespace glm
v1.z / v2.z);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v)
{
return tvec3<T, P>(
-v.x,
-v.y,
-v.z);
}
//////////////////////////////////////
// Binary bit operators
// -- Binary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x % s,
v.y % s,
v.z % s);
v.x % scalar,
v.y % scalar,
v.z % scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s % v.x,
s % v.y,
s % v.z);
scalar % v.x,
scalar % v.y,
scalar % v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -807,39 +818,39 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x & s,
v.y & s,
v.z & s);
v.x & scalar,
v.y & scalar,
v.z & scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s & v.x,
s & v.y,
s & v.z);
scalar & v.x,
scalar & v.y,
scalar & v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -852,39 +863,39 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x | s,
v.y | s,
v.z | s);
v.x | scalar,
v.y | scalar,
v.z | scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s | v.x,
s | v.y,
s | v.z);
scalar | v.x,
scalar | v.y,
scalar | v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -897,39 +908,39 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x ^ s,
v.y ^ s,
v.z ^ s);
v.x ^ scalar,
v.y ^ scalar,
v.z ^ scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s ^ v.x,
s ^ v.y,
s ^ v.z);
scalar ^ v.x,
scalar ^ v.y,
scalar ^ v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -942,39 +953,39 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x << s,
v.y << s,
v.z << s);
v.x << scalar,
v.y << scalar,
v.z << scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s << v.x,
s << v.y,
s << v.z);
scalar << v.x,
scalar << v.y,
scalar << v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -987,39 +998,39 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & scalar)
{
return tvec3<T, P>(
v.x >> s,
v.y >> s,
v.z >> s);
v.x >> scalar,
v.y >> scalar,
v.z >> scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec3<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(T const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(T const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
s >> v.x,
s >> v.y,
s >> v.z);
scalar >> v.x,
scalar >> v.y,
scalar >> v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec1<T, P> const & s, tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec1<T, P> const & scalar, tvec3<T, P> const & v)
{
return tvec3<T, P>(
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 <typename T, precision P>
@@ -1039,4 +1050,30 @@ namespace glm
~v.y,
~v.z);
}
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec3<T, P> const & v1, tvec3<T, P> const & v2)
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec3<bool, P> operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2)
{
return tvec3<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec3<bool, P> operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2)
{
return tvec3<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z);
}
}//namespace glm

View File

@@ -32,7 +32,6 @@
#pragma once
//#include "../fwd.hpp"
#include "setup.hpp"
#include "type_vec.hpp"
#ifdef GLM_SWIZZLE
@@ -47,51 +46,51 @@
namespace glm{
namespace detail
{
template <typename T>
struct simd
template <typename T, precision P = defaultp>
struct simd_data
{
typedef T type[4];
};
# define GLM_NOT_BUGGY_VC32BITS !(GLM_MODEL == GLM_MODEL_32 && GLM_COMPILER & GLM_COMPILER_VC && GLM_COMPILER < GLM_COMPILER_VC2013)
# define GLM_NOT_BUGGY_VC32BITS !(GLM_MODEL == GLM_MODEL_32 && (GLM_COMPILER & GLM_COMPILER_VC) && GLM_COMPILER < GLM_COMPILER_VC2013)
# if GLM_ARCH & GLM_ARCH_SSE2 && GLM_NOT_BUGGY_VC32BITS
# if (GLM_ARCH & GLM_ARCH_SSE2) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<float>
struct simd_data<float, simd>
{
typedef __m128 type;
};
template <>
struct simd<int>
struct simd_data<int, simd>
{
typedef __m128i type;
};
template <>
struct simd<unsigned int>
struct simd_data<unsigned int, simd>
{
typedef __m128i type;
};
# endif
# if GLM_ARCH & GLM_ARCH_AVX && GLM_NOT_BUGGY_VC32BITS
# if (GLM_ARCH & GLM_ARCH_AVX) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<double>
struct simd_data<double, simd>
{
typedef __m256d type;
};
# endif
# if GLM_ARCH & GLM_ARCH_AVX2 && GLM_NOT_BUGGY_VC32BITS
# if (GLM_ARCH & GLM_ARCH_AVX2) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<int64>
struct simd_data<int64, simd>
{
typedef __m256i type;
};
template <>
struct simd<uint64>
struct simd_data<uint64, simd>
{
typedef __m256i type;
};
@@ -102,24 +101,46 @@ namespace detail
template <typename T, precision P = defaultp>
struct tvec4
{
//////////////////////////////////////
// Implementation detail
// -- Implementation detail --
typedef tvec4<T, P> type;
typedef tvec4<bool, P> bool_type;
typedef T value_type;
//////////////////////////////////////
// Data
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR precision prec = P;
# endif//GLM_META_PROG_HELPERS
# if GLM_HAS_ANONYMOUS_UNION
# 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 && 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<T>::type data;
typename detail::simd_data<T, P>::type data;
# ifdef GLM_SWIZZLE
_GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w)
@@ -144,8 +165,7 @@ namespace detail
# endif//GLM_SWIZZLE
# endif//GLM_LANG
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
@@ -163,24 +183,20 @@ namespace detail
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tvec4();
GLM_FUNC_DECL tvec4(tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tvec4(tvec4<T, P> const & v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tvec4(tvec4<T, Q> const & v);
//////////////////////////////////////
// Explicit basic constructors
// -- 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);
GLM_FUNC_DECL ~tvec4(){}
//////////////////////////////////////
// Conversion scalar constructors
// -- Conversion scalar constructors --
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, typename D>
@@ -188,55 +204,47 @@ namespace detail
template <typename A, typename B, typename C, typename D>
GLM_FUNC_DECL tvec4(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c, tvec1<D, P> const & d);
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & a, B b, C c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & a, tvec1<B, Q> const & b, tvec1<C, Q> const & c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(A a, tvec2<B, Q> const & b, C c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec1<A, Q> const & a, tvec2<B, Q> const & b, tvec1<C, Q> const & c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(A a, B b, tvec2<C, Q> const & c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec1<A, Q> const & a, tvec1<B, Q> const & b, tvec2<C, Q> const & c);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec3<A, Q> const & a, B b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec3<A, Q> const & a, tvec1<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec4(A a, tvec3<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec1<A, Q> const & a, tvec3<B, Q> const & b);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & a, tvec2<B, Q> const & b);
# ifdef GLM_FORCE_EXPLICIT_CTOR
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL explicit tvec4(tvec4<U, Q> const & v);
# else
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL tvec4(tvec4<U, Q> const & v);
# endif
//////////////////////////////////////
// Swizzle constructors
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec4<U, Q> const & v);
// -- Swizzle constructors --
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
template <int E0, int E1, int E2, int E3>
@@ -282,10 +290,9 @@ namespace detail
}
# endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<U, P> const & v);
@@ -314,16 +321,14 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
GLM_FUNC_DECL tvec4<T, P> & operator++();
GLM_FUNC_DECL tvec4<T, P> & operator--();
GLM_FUNC_DECL tvec4<T, P> operator++(int);
GLM_FUNC_DECL tvec4<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator%=(U scalar);
@@ -363,17 +368,27 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec4<U, P> const & v);
};
// -- Unary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator+(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -382,13 +397,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator-(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -397,13 +412,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator*(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator*(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator*(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -412,20 +427,17 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator/(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator/(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator/(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -436,13 +448,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator%(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator%(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator%(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -451,13 +463,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator&(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator&(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator&(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -466,13 +478,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator|(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator|(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator|(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -481,13 +493,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator^(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator^(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator^(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -496,13 +508,13 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator<<(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
@@ -511,19 +523,43 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, T scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, tvec1<T, P> const & s);
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator>>(T scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec1<T, P> const & s, tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator~(tvec4<T, P> const & v);
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec4<bool, P> operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL tvec4<bool, P> operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>
struct type<T, P, tvec4>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
}//namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE

View File

@@ -32,20 +32,89 @@
namespace glm
{
//////////////////////////////////////
// Implicit basic constructors
# ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::ZERO
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
{}
const tvec4<T, P> tvec4<T, P>::X
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec4<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
const tvec4<T, P> tvec4<T, P>::Y
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::Z
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::W
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XY
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XZ
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XW
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YZ
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YW
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::ZW
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYZ
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XZW
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YZW
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYZW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec4<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -53,16 +122,15 @@ namespace glm
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(T s)
: x(s), y(s), z(s), w(s)
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(T scalar)
: x(scalar), y(scalar), z(scalar), w(scalar)
{}
template <typename T, precision P>
@@ -70,8 +138,7 @@ namespace glm
: x(a), y(b), z(c), w(d)
{}
//////////////////////////////////////
// Conversion scalar constructors
// -- Conversion scalar constructors --
template <typename T, precision P>
template <typename A, typename B, typename C, typename D>
@@ -91,8 +158,7 @@ namespace glm
w(static_cast<T>(d.x))
{}
//////////////////////////////////////
// Conversion vector constructors
// -- Conversion vector constructors --
template <typename T, precision P>
template <typename A, typename B, typename C, precision Q>
@@ -202,8 +268,7 @@ namespace glm
w(static_cast<T>(v.w))
{}
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -247,18 +312,19 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator=(tvec4<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator=(tvec4<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -341,12 +407,12 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(U s)
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(U v)
{
this->x *= static_cast<T>(s);
this->y *= static_cast<T>(s);
this->z *= static_cast<T>(s);
this->w *= static_cast<T>(s);
this->x *= static_cast<T>(v);
this->y *= static_cast<T>(v);
this->z *= static_cast<T>(v);
this->w *= static_cast<T>(v);
return *this;
}
@@ -374,12 +440,12 @@ namespace glm
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(U s)
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(U v)
{
this->x /= static_cast<T>(s);
this->y /= static_cast<T>(s);
this->z /= static_cast<T>(s);
this->w /= static_cast<T>(s);
this->x /= static_cast<T>(v);
this->y /= static_cast<T>(v);
this->z /= static_cast<T>(v);
this->w /= static_cast<T>(v);
return *this;
}
@@ -405,8 +471,7 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator++()
@@ -444,8 +509,7 @@ namespace glm
return Result;
}
//////////////////////////////////////
// Unary bit operators
// -- Unary bit operators --
template <typename T, precision P>
template <typename U>
@@ -645,149 +709,15 @@ namespace glm
return *this;
}
//////////////////////////////////////
// Boolean operators
// -- Unary constant operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v)
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
return v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w);
}
//////////////////////////////////////
// Binary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x + scalar,
v.y + scalar,
v.z + scalar,
v.w + scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar + v.x,
scalar + v.y,
scalar + v.z,
scalar + v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x + v2.x,
v1.y + v2.y,
v1.z + v2.z,
v1.w + v2.w);
}
//operator-
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x - scalar,
v.y - scalar,
v.z - scalar,
v.w - scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar - v.x,
scalar - v.y,
scalar - v.z,
scalar - v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x - v2.x,
v1.y - v2.y,
v1.z - v2.z,
v1.w - v2.w);
}
//operator*
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x * scalar,
v.y * scalar,
v.z * scalar,
v.w * scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar * v.x,
scalar * v.y,
scalar * v.z,
scalar * v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x * v2.x,
v1.y * v2.y,
v1.z * v2.z,
v1.w * v2.w);
}
//operator/
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x / scalar,
v.y / scalar,
v.z / scalar,
v.w / scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar / v.x,
scalar / v.y,
scalar / v.z,
scalar / v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x / v2.x,
v1.y / v2.y,
v1.z / v2.z,
v1.w / v2.w);
}
// Unary constant operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v)
{
return tvec4<T, P>(
@@ -797,47 +727,168 @@ namespace glm
-v.w);
}
//////////////////////////////////////
// Binary bit operators
// -- Binary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v, T s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
v.x % s.x,
v.y % s.x,
v.z % s.x,
v.w % s.x);
scalar + v.x,
scalar + v.y,
scalar + v.z,
scalar + v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(T s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
s % v.x,
s % v.y,
s % v.z,
s % v.w);
v1.x + v2.x,
v1.y + v2.y,
v1.z + v2.z,
v1.w + v2.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
s.x % v.x,
s.x % v.y,
s.x % v.z,
s.x % v.w);
v.x - scalar,
v.y - scalar,
v.z - scalar,
v.w - scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar - v.x,
scalar - v.y,
scalar - v.z,
scalar - v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x - v2.x,
v1.y - v2.y,
v1.z - v2.z,
v1.w - v2.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x * scalar,
v.y * scalar,
v.z * scalar,
v.w * scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar * v.x,
scalar * v.y,
scalar * v.z,
scalar * v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x * v2.x,
v1.y * v2.y,
v1.z * v2.z,
v1.w * v2.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x / scalar,
v.y / scalar,
v.z / scalar,
v.w / scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar / v.x,
scalar / v.y,
scalar / v.z,
scalar / v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return tvec4<T, P>(
v1.x / v2.x,
v1.y / v2.y,
v1.z / v2.z,
v1.w / v2.w);
}
// -- Binary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
v.x % scalar,
v.y % scalar,
v.z % scalar,
v.w % scalar);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
v.x % scalar.x,
v.y % scalar.x,
v.z % scalar.x,
v.w % scalar.x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar % v.x,
scalar % v.y,
scalar % v.z,
scalar % v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
scalar.x % v.x,
scalar.x % v.y,
scalar.x % v.z,
scalar.x % v.w);
}
template <typename T, precision P>
@@ -851,43 +902,43 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, T s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(T s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -901,43 +952,43 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v, T s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(T s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(T scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -951,23 +1002,23 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v, T s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v, T scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -981,13 +1032,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -1011,13 +1062,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -1031,13 +1082,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -1061,13 +1112,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec4<T, P> const & v, tvec1<T, P> const & s)
GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec4<T, P> const & v, tvec1<T, P> const & scalar)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -1081,13 +1132,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec1<T, P> const & s, tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec1<T, P> const & scalar, tvec4<T, P> const & v)
{
return tvec4<T, P>(
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 <typename T, precision P>
@@ -1109,6 +1160,32 @@ namespace glm
~v.z,
~v.w);
}
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2)
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2)
{
return tvec4<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2)
{
return tvec4<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w);
}
}//namespace glm
#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS

View File

@@ -31,48 +31,29 @@
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace detail
{
}//namespace detail
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4(float s) :
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4(float a, float b, float c, float d) :
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(U scalar)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=(U scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(scalar)));
return *this;
@@ -80,7 +61,7 @@ namespace detail
template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=<float>(float scalar)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=<float>(float scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar));
return *this;
@@ -88,31 +69,7 @@ namespace detail
template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(U scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(scalar)));
return *this;
}
template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=<float>(float scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar));
return *this;
}
template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(tvec1<U, lowp> const & v)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(v.x)));
return *this;
}
template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(tvec1<U, mediump> const & v)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=(tvec1<U, simd> const & v)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(v.x)));
return *this;

View File

@@ -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"

View File

@@ -124,9 +124,6 @@ namespace glm
// GLM_GTC_precision
namespace glm
{
/// @addtogroup gtc_type_precision
/// @{
/// Low precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_int8;
@@ -1547,15 +1544,15 @@ namespace glm
typedef tvec1<float, lowp> lowp_vec1;
/// Low single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<float, lowp> lowp_vec2;
/// Low single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<float, lowp> lowp_vec3;
/// Low single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<float, lowp> lowp_vec4;
/// Low single-precision floating-point vector of 1 component.
@@ -1580,15 +1577,15 @@ namespace glm
typedef tvec1<float, mediump> mediump_vec1;
/// Medium Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<float, mediump> mediump_vec2;
/// Medium Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<float, mediump> mediump_vec3;
/// Medium Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<float, mediump> mediump_vec4;
/// Medium single-precision floating-point vector of 1 component.
@@ -1613,15 +1610,15 @@ namespace glm
typedef tvec1<float, highp> highp_vec1;
/// High Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<float, highp> highp_vec2;
/// High Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<float, highp> highp_vec3;
/// High Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<float, highp> highp_vec4;
/// High single-precision floating-point vector of 1 component.
@@ -1629,15 +1626,15 @@ namespace glm
typedef tvec1<float, highp> highp_fvec1;
/// High Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<float, highp> highp_fvec2;
/// High Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<float, highp> highp_fvec3;
/// High Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<float, highp> highp_fvec4;
@@ -1646,15 +1643,15 @@ namespace glm
typedef tvec1<f32, lowp> lowp_f32vec1;
/// Low single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<f32, lowp> lowp_f32vec2;
/// Low single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<f32, lowp> lowp_f32vec3;
/// Low single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<f32, lowp> lowp_f32vec4;
/// Medium single-precision floating-point vector of 1 component.
@@ -1662,15 +1659,15 @@ namespace glm
typedef tvec1<f32, mediump> mediump_f32vec1;
/// Medium single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec2<f32, mediump> mediump_f32vec2;
/// Medium single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec3<f32, mediump> mediump_f32vec3;
/// Medium single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
/// @see core_precision
typedef tvec4<f32, mediump> mediump_f32vec4;
/// High single-precision floating-point vector of 1 component.
@@ -2598,4 +2595,5 @@ namespace glm
/// @see gtc_type_precision
typedef highp_f64quat f64quat;
#endif
}//namespace glm

View File

@@ -24,15 +24,15 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtc_color
/// @file glm/gtc/color.hpp
/// @date 2015-02-10 / 2015-02-10
/// @ref gtc_color_space
/// @file glm/gtc/color_space.hpp
/// @date 2015-02-10 / 2015-08-02
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_color (dependence)
/// @see gtc_color_space (dependence)
///
/// @defgroup gtc_color GLM_GTC_color
/// @defgroup gtc_color_space GLM_GTC_color_space
/// @ingroup gtc
///
/// @brief Allow to perform bit operations on integer values
@@ -51,31 +51,31 @@
#include <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_color extension included")
# pragma message("GLM: GLM_GTC_color_space extension included")
#endif
namespace glm
{
/// @addtogroup gtc_color
/// @addtogroup gtc_color_space
/// @{
/// Convert a RGB color to sRGB color using a standard gamma correction
/// Convert a linear color to sRGB color using a standard gamma correction
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertRgbToSrgb(vecType<T, P> const & ColorRGB);
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear);
/// Convert a RGB color to sRGB color using a custom gamma correction
/// Convert a linear color to sRGB color using a custom gamma correction
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertRgbToSrgb(vecType<T, P> const & ColorRGB, T Gamma);
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear, T Gamma);
/// Convert a sRGB color to RGB color using a standard gamma correction
/// Convert a sRGB color to linear color using a standard gamma correction
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSrgbToRgb(vecType<T, P> const & ColorSRGB);
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB);
/// Convert a sRGB color to RGB color using a custom gamma correction
/// Convert a sRGB color to linear color using a custom gamma correction
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSrgbToRgb(vecType<T, P> const & ColorSRGB, T Gamma);
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma);
/// @}
} //namespace glm
#include "color.inl"
#include "color_space.inl"

View File

@@ -24,9 +24,9 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtc_color
/// @file glm/gtc/color.inl
/// @date 2015-02-10 / 2015-02-10
/// @ref gtc_color_space
/// @file glm/gtc/color_space.inl
/// @date 2015-02-10 / 2015-08-02
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -79,25 +79,25 @@ namespace detail
}//namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertRgbToSrgb(vecType<T, P> const & ColorRGB)
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorRGB, static_cast<T>(0.41666));
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertRgbToSrgb(vecType<T, P> const & ColorRGB, T Gamma)
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear, T Gamma)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorRGB, static_cast<T>(1) / Gamma);
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSrgbToRgb(vecType<T, P> const & ColorSRGB)
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSrgbToRgb(vecType<T, P> const & ColorSRGB, T Gamma)
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
}

View File

@@ -57,147 +57,147 @@ namespace glm
/// Return the epsilon constant for floating point types.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType epsilon();
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon();
/// Return 0.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType zero();
GLM_FUNC_DECL GLM_CONSTEXPR genType zero();
/// Return 1.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType one();
GLM_FUNC_DECL GLM_CONSTEXPR genType one();
/// Return the pi constant.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType pi();
/// Return pi * 2.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType two_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_pi();
/// Return square root of pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_pi();
/// Return pi / 2.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType half_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType half_pi();
/// Return pi / 2 * 3.
/// @see gtc_constants
template <typename genType>
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 <typename genType>
GLM_FUNC_DECL genType quarter_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType quarter_pi();
/// Return 1 / pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType one_over_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_pi();
/// Return 1 / (pi * 2).
/// @see gtc_constants
template <typename genType>
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 <typename genType>
GLM_FUNC_DECL genType two_over_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_pi();
/// Return 4 / pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType four_over_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType four_over_pi();
/// Return 2 / sqrt(pi).
/// @see gtc_constants
template <typename genType>
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 <typename genType>
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 <typename genType>
GLM_FUNC_DECL genType root_half_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_half_pi();
/// Return sqrt(2 * pi).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_two_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two_pi();
/// Return sqrt(ln(4)).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_ln_four();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_ln_four();
/// Return e constant.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType e();
GLM_FUNC_DECL GLM_CONSTEXPR genType e();
/// Return Euler's constant.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType euler();
GLM_FUNC_DECL GLM_CONSTEXPR genType euler();
/// Return sqrt(2).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two();
/// Return sqrt(3).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_three();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_three();
/// Return sqrt(5).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType root_five();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_five();
/// Return ln(2).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType ln_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_two();
/// Return ln(10).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType ln_ten();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ten();
/// Return ln(ln(2)).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType ln_ln_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ln_two();
/// Return 1 / 3.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType third();
GLM_FUNC_DECL GLM_CONSTEXPR genType third();
/// Return 2 / 3.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType two_thirds();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_thirds();
/// Return the golden ratio constant.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType golden_ratio();
GLM_FUNC_DECL GLM_CONSTEXPR genType golden_ratio();
/// @}
} //namespace glm

View File

@@ -35,175 +35,175 @@
namespace glm
{
template <typename genType>
GLM_FUNC_QUALIFIER genType epsilon()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon()
{
return std::numeric_limits<genType>::epsilon();
}
template <typename genType>
GLM_FUNC_QUALIFIER genType zero()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType zero()
{
return genType(0);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one()
{
return genType(1);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi()
{
return genType(3.14159265358979323846264338327950288);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_pi()
{
return genType(6.28318530717958647692528676655900576);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_pi()
{
return genType(1.772453850905516027);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType half_pi()
{
return genType(1.57079632679489661923132169163975144);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType three_over_two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType three_over_two_pi()
{
return genType(4.71238898038468985769396507491925432);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType quarter_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType quarter_pi()
{
return genType(0.785398163397448309615660845819875721);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_pi()
{
return genType(0.318309886183790671537767526745028724);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_two_pi()
{
return genType(0.159154943091895335768883763372514362);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_pi()
{
return genType(0.636619772367581343075535053490057448);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType four_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType four_over_pi()
{
return genType(1.273239544735162686151070106980114898);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_root_pi()
{
return genType(1.12837916709551257389615890312154517);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_root_two()
{
return genType(0.707106781186547524400844362104849039);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_half_pi()
{
return genType(1.253314137315500251);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two_pi()
{
return genType(2.506628274631000502);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_ln_four()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_ln_four()
{
return genType(1.17741002251547469);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType e()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType e()
{
return genType(2.71828182845904523536);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType euler()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType euler()
{
return genType(0.577215664901532860606);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two()
{
return genType(1.41421356237309504880168872420969808);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_three()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_three()
{
return genType(1.73205080756887729352744634150587236);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_five()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_five()
{
return genType(2.23606797749978969640917366873127623);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_two()
{
return genType(0.693147180559945309417232121458176568);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_ten()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ten()
{
return genType(2.30258509299404568401799145468436421);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ln_two()
{
return genType(-0.3665129205816643);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType third()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType third()
{
return genType(0.3333333333333333333333333333333333333333);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_thirds()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_thirds()
{
return genType(0.666666666666666666666666666666666666667);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType golden_ratio()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType golden_ratio()
{
return genType(1.61803398874989484820458683436563811);
}

View File

@@ -35,23 +35,24 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> affineInverse(tmat3x3<T, P> const & m)
{
tmat3x3<T, P> Result(m);
Result[2] = tvec3<T, P>(0, 0, 1);
Result = transpose(Result);
tvec3<T, P> Translation = Result * tvec3<T, P>(-tvec2<T, P>(m[2]), m[2][2]);
Result[2] = Translation;
return Result;
tmat2x2<T, P> const Inv(inverse(tmat2x2<T, P>(m)));
return tmat3x3<T, P>(
tvec3<T, P>(Inv[0], static_cast<T>(0)),
tvec3<T, P>(Inv[1], static_cast<T>(0)),
tvec3<T, P>(-Inv * tvec2<T, P>(m[2]), static_cast<T>(1)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> affineInverse(tmat4x4<T, P> const & m)
{
tmat4x4<T, P> Result(m);
Result[3] = tvec4<T, P>(0, 0, 0, 1);
Result = transpose(Result);
tvec4<T, P> Translation = Result * tvec4<T, P>(-tvec3<T, P>(m[3]), m[3][3]);
Result[3] = Translation;
return Result;
tmat3x3<T, P> const Inv(inverse(tmat3x3<T, P>(m)));
return tmat4x4<T, P>(
tvec4<T, P>(Inv[0], static_cast<T>(0)),
tvec4<T, P>(Inv[1], static_cast<T>(0)),
tvec4<T, P>(Inv[2], static_cast<T>(0)),
tvec4<T, P>(-Inv * tvec3<T, P>(m[3]), static_cast<T>(1)));
}
template <typename T, precision P>

View File

@@ -92,7 +92,7 @@ namespace glm
///
/// @param m Input matrix multiplied by this rotation matrix.
/// @param angle Rotation angle expressed in radians.
/// @param axis Rotation axis, recommanded to be normalized.
/// @param axis Rotation axis, recommended to be normalized.
/// @tparam T Value type used to build the matrix. Supported: half, float or double.
/// @see gtc_matrix_transform
/// @see - rotate(tmat4x4<T, P> const & m, T angle, T x, T y, T z)
@@ -173,7 +173,7 @@ namespace glm
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
///
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
@@ -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.

View File

@@ -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<float, P> unpackHalf(vecType<uint16, P> const & p)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<uint16, P> packHalf(vecType<float, P> 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<uint16, P> packHalf(vecType<float, P> const & v)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<float, P> unpackHalf(vecType<uint16, P> const & p);
/// Convert each component of the normalized floating-point vector into unsigned integer values.
///
/// @see gtc_packing
/// @see vecType<floatType, P> unpackUnorm(vecType<intType, P> const & p);
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<uintType, P> packUnorm(vecType<floatType, P> const & v);
/// Convert each unsigned integer components of a vector to normalized floating-point values.
///
/// @see gtc_packing
/// @see vecType<intType, P> packUnorm(vecType<floatType, P> const & v)
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<floatType, P> unpackUnorm(vecType<uintType, P> const & v);
/// Convert each component of the normalized floating-point vector into signed integer values.
///
/// @see gtc_packing
/// @see vecType<floatType, P> unpackSnorm(vecType<intType, P> const & p);
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<intType, P> packSnorm(vecType<floatType, P> const & v);
/// Convert each signed integer components of a vector to normalized floating-point values.
///
/// @see gtc_packing
/// @see vecType<intType, P> packSnorm(vecType<floatType, P> const & v)
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<floatType, P> unpackSnorm(vecType<intType, P> 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

View File

@@ -36,6 +36,7 @@
#include "../vec4.hpp"
#include "../detail/type_half.hpp"
#include <cstring>
#include <limits>
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 <precision P, template <typename, precision> class vecType>
struct compute_half
{};
template <precision P>
struct compute_half<P, tvec1>
{
GLM_FUNC_QUALIFIER static tvec1<uint16, P> pack(tvec1<float, P> const & v)
{
int16 const Unpacked(detail::toFloat16(v.x));
return tvec1<uint16, P>(reinterpret_cast<uint16 const &>(Unpacked));
}
GLM_FUNC_QUALIFIER static tvec1<float, P> unpack(tvec1<uint16, P> const & v)
{
return tvec1<float, P>(detail::toFloat32(reinterpret_cast<int16 const &>(v.x)));
}
};
template <precision P>
struct compute_half<P, tvec2>
{
GLM_FUNC_QUALIFIER static tvec2<uint16, P> pack(tvec2<float, P> const & v)
{
tvec2<int16, P> const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y));
return tvec2<uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y));
}
GLM_FUNC_QUALIFIER static tvec2<float, P> unpack(tvec2<uint16, P> const & v)
{
return tvec2<float, P>(
detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
detail::toFloat32(reinterpret_cast<int16 const &>(v.y)));
}
};
template <precision P>
struct compute_half<P, tvec3>
{
GLM_FUNC_QUALIFIER static tvec3<uint16, P> pack(tvec3<float, P> const & v)
{
tvec3<int16, P> const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z));
return tvec3<uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y),
reinterpret_cast<uint16 const &>(Unpacked.z));
}
GLM_FUNC_QUALIFIER static tvec3<float, P> unpack(tvec3<uint16, P> const & v)
{
return tvec3<float, P>(
detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
detail::toFloat32(reinterpret_cast<int16 const &>(v.y)),
detail::toFloat32(reinterpret_cast<int16 const &>(v.z)));
}
};
template <precision P>
struct compute_half<P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<uint16, P> pack(tvec4<float, P> const & v)
{
tvec4<int16, P> const Unpacked(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w));
return tvec4<uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y),
reinterpret_cast<uint16 const &>(Unpacked.z),
reinterpret_cast<uint16 const &>(Unpacked.w));
}
GLM_FUNC_QUALIFIER static tvec4<float, P> unpack(tvec4<uint16, P> const & v)
{
return tvec4<float, P>(
detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
detail::toFloat32(reinterpret_cast<int16 const &>(v.y)),
detail::toFloat32(reinterpret_cast<int16 const &>(v.z)),
detail::toFloat32(reinterpret_cast<int16 const &>(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<uint16>(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 <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint16, P> packHalf(vecType<float, P> const & v)
{
return detail::compute_half<P, vecType>::pack(v);
}
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<float, P> unpackHalf(vecType<uint16, P> const & v)
{
return detail::compute_half<P, vecType>::unpack(v);
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uintType, P> packUnorm(vecType<floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<uintType, P>(round(clamp(v, static_cast<floatType>(0), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<uintType>::max())));
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> unpackUnorm(vecType<uintType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<float, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<uintType>::max()));
}
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<intType, P> packSnorm(vecType<floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<intType, P>(round(clamp(v , static_cast<floatType>(-1), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<intType>::max())));
}
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> unpackSnorm(vecType<intType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return clamp(vecType<floatType, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<intType>::max())), static_cast<floatType>(-1), static_cast<floatType>(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

View File

@@ -62,14 +62,41 @@ namespace glm
template <typename T, precision P = defaultp>
struct tquat
{
// -- Implementation detail --
typedef tquat<T, P> type;
typedef T value_type;
public:
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR precision prec = P;
# endif//GLM_META_PROG_HELPERS
// -- Data --
T x, y, z, w;
//////////////////////////////////////
// Component accesses
# 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
typedef size_t size_type;
@@ -87,40 +114,32 @@ namespace glm
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tquat();
GLM_FUNC_DECL tquat(tquat<T, P> const & q);
GLM_FUNC_DECL tquat() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tquat(tquat<T, P> const & q) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tquat(tquat<T, Q> const & q);
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
GLM_FUNC_DECL explicit tquat(ctor);
GLM_FUNC_DECL explicit tquat(T const & s, tvec3<T, P> const & v);
GLM_FUNC_DECL tquat(T const & w, T const & x, T const & y, T const & z);
//////////////////////////////////////
// Convertions
// -- Conversion constructors --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tquat(tquat<U, Q> const & q);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tquat(tquat<U, Q> const & q);
# endif
// explicit conversion operators
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tquat(tquat<U, Q> const & q);
/// Explicit conversion operators
# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
GLM_FUNC_DECL explicit operator tmat3x3<T, P>();
GLM_FUNC_DECL explicit operator tmat4x4<T, P>();
# endif
/// Create a quaternion from two normalized axis
///
///
/// @param u A first normalized axis
/// @param v A second normalized axis
/// @see gtc_quaternion
@@ -132,10 +151,9 @@ namespace glm
GLM_FUNC_DECL explicit tquat(tmat3x3<T, P> const & m);
GLM_FUNC_DECL explicit tquat(tmat4x4<T, P> const & m);
//////////////////////////////////////
// Operators
// -- Unary arithmetic operators --
GLM_FUNC_DECL tquat<T, P> & operator=(tquat<T, P> const & m);
GLM_FUNC_DECL tquat<T, P> & operator=(tquat<T, P> const & m) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tquat<T, P> & operator=(tquat<U, P> const & m);
@@ -149,9 +167,16 @@ namespace glm
GLM_FUNC_DECL tquat<T, P> & operator/=(U s);
};
// -- Unary bit operators --
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p);
@@ -372,6 +397,16 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y);
/// @}
// -- Is type --
template <typename T, precision P>
struct type<T, P, tquat>
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
};
} //namespace glm
#include "quaternion.inl"

View File

@@ -49,8 +49,74 @@ namespace detail
};
}//namespace detail
//////////////////////////////////////
// Component accesses
# ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::ZERO
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> const tquat<T, P> tquat<T, P>::IDENTITY;
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::X
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::Y
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::Z
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::W
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XY
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XZ
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YZ
(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YW
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::ZW
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYZ
(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XZW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YZW
(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYZW
(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -94,20 +160,23 @@ namespace detail
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(1)
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(1)
# endif
{}
# endif
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q)
: x(q.x), y(q.y), z(q.z), w(q.w)
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q)
: x(q.x), y(q.y), z(q.z), w(q.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -115,8 +184,7 @@ namespace detail
: x(q.x), y(q.y), z(q.z), w(q.w)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor)
@@ -132,8 +200,7 @@ namespace detail
: x(x), y(y), z(z), w(w)
{}
//////////////////////////////////////////////////////////////
// Conversions
// -- Conversion constructors --
template <typename T, precision P>
template <typename U, precision Q>
@@ -222,18 +289,19 @@ namespace detail
return conjugate(q) / dot(q, q);
}
//////////////////////////////////////////////////////////////
// tquat<valType> operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator=(tquat<T, P> const & q)
{
this->w = q.w;
this->x = q.x;
this->y = q.y;
this->z = q.z;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator=(tquat<T, P> const & q)
{
this->w = q.w;
this->x = q.x;
this->y = q.y;
this->z = q.z;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -293,8 +361,13 @@ namespace detail
return *this;
}
//////////////////////////////////////////////////////////////
// tquat<T, P> external operators
// -- Unary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q)
{
return q;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
@@ -302,6 +375,8 @@ namespace detail
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
}
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
{
@@ -314,7 +389,6 @@ namespace detail
return tquat<T, P>(q) *= p;
}
// Transformation
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v)
{
@@ -363,8 +437,7 @@ namespace detail
q.w / s, q.x / s, q.y / s, q.z / s);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tquat<T, P> const & q1, tquat<T, P> const & q2)
@@ -378,7 +451,8 @@ namespace detail
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w);
}
////////////////////////////////////////////////////////
// -- Operations --
template <typename T, precision P>
GLM_FUNC_QUALIFIER T length(tquat<T, P> const & q)
{

View File

@@ -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 <typename genTYpe>
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 <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> linearRand(
vecType<T, P> const & Min,

View File

@@ -51,7 +51,7 @@ namespace detail
GLM_FUNC_QUALIFIER static tvec1<uint8, P> call()
{
return tvec1<uint8, P>(
std::rand()) % std::numeric_limits<uint8>::max();
std::rand() % std::numeric_limits<uint8>::max());
}
};
@@ -61,8 +61,8 @@ namespace detail
GLM_FUNC_QUALIFIER static tvec2<uint8, P> call()
{
return tvec2<uint8, P>(
std::rand(),
std::rand()) % std::numeric_limits<uint8>::max();
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max());
}
};
@@ -72,9 +72,9 @@ namespace detail
GLM_FUNC_QUALIFIER static tvec3<uint8, P> call()
{
return tvec3<uint8, P>(
std::rand(),
std::rand(),
std::rand()) % std::numeric_limits<uint8>::max();
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max());
}
};
@@ -84,10 +84,10 @@ namespace detail
GLM_FUNC_QUALIFIER static tvec4<uint8, P> call()
{
return tvec4<uint8, P>(
std::rand(),
std::rand(),
std::rand(),
std::rand()) % std::numeric_limits<uint8>::max();
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max());
}
};

View File

@@ -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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
GLM_FUNC_DECL genType asech(genType const & x);
GLM_FUNC_DECL genType asech(genType x);
/// Inverse cosecant hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
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 <typename genType>
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 <typename genType>
GLM_FUNC_DECL genType acoth(genType x);
/// @}
}//namespace glm

View File

@@ -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;
}
};

View File

@@ -84,6 +84,7 @@ namespace glm
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec4<T, P> atan2(const tvec4<T, P>& x, const tvec4<T, P>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
template <typename genType> GLM_FUNC_DECL bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename T, precision P> GLM_FUNC_DECL tvec1<bool, P> isfinite(const tvec1<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename T, precision P> GLM_FUNC_DECL tvec2<bool, P> isfinite(const tvec2<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename T, precision P> GLM_FUNC_DECL tvec3<bool, P> isfinite(const tvec3<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename T, precision P> GLM_FUNC_DECL tvec4<bool, P> isfinite(const tvec4<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)

View File

@@ -46,10 +46,21 @@ namespace glm
# elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID
return _isfinite(x) != 0;
# else
return x >= std::numeric_limits<genType>::min() && x <= std::numeric_limits<genType>::max();
if (std::numeric_limits<genType>::is_integer || std::denorm_absent == std::numeric_limits<genType>::has_denorm)
return std::numeric_limits<genType>::min() <= x && std::numeric_limits<genType>::max() >= x;
else
return -std::numeric_limits<genType>::max() <= x && std::numeric_limits<genType>::max() >= x;
# endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<bool, P> isfinite(
tvec1<T, P> const & x)
{
return tvec1<bool, P>(
isfinite(x.x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<bool, P> isfinite(
tvec2<T, P> const & x)

View File

@@ -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 <typename floatType, typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<floatType, P> compNormalize(vecType<T, P> 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 <typename T, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> compScale(vecType<floatType, P> const & v);
/// Add all vector components together.
/// @see gtx_component_wise
template <typename genType>
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 <typename genType>
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 <typename genType>
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 <typename genType>
GLM_FUNC_DECL typename genType::value_type compMax(
genType const & v);
GLM_FUNC_DECL typename genType::value_type compMax(genType const & v);
/// @}
}//namespace glm

View File

@@ -30,8 +30,95 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm
#include <limits>
namespace glm{
namespace detail
{
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
struct compute_compNormalize
{};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, true, true>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
floatType const Min = static_cast<floatType>(std::numeric_limits<T>::min());
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max());
return (vecType<floatType, P>(v) - Min) / (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1);
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, true, false>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
return vecType<floatType, P>(v) / static_cast<floatType>(std::numeric_limits<T>::max());
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, false, true>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
return v;
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
struct compute_compScale
{};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, true, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max()) + static_cast<floatType>(0.5);
vecType<floatType, P> const Scaled(v * Max);
vecType<T, P> const Result(Scaled - static_cast<floatType>(0.5));
return Result;
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, true, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
return vecType<T, P>(vecType<floatType, P>(v) * static_cast<floatType>(std::numeric_limits<T>::max()));
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, false, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
return v;
}
};
}//namespace detail
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> compNormalize(vecType<T, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compNormalize' accepts only floating-point types for 'floatType' template parameter");
return detail::compute_compNormalize<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
}
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> compScale(vecType<floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compScale' accepts only floating-point types for 'floatType' template parameter");
return detail::compute_compScale<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER T compAdd(vecType<T, P> const & v)
{

View File

@@ -15,7 +15,7 @@
/// 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
@@ -61,14 +61,21 @@ namespace glm
template <typename T, precision P = defaultp>
struct tdualquat
{
// -- Implementation detail --
typedef T value_type;
typedef glm::tquat<T, P> part_type;
public:
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 2;
static GLM_RELAXED_CONSTEXPR precision prec = P;
# endif//GLM_META_PROG_HELPERS
// -- Data --
glm::tquat<T, P> real, dual;
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
@@ -86,38 +93,31 @@ namespace glm
GLM_FUNC_DECL part_type const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
GLM_FUNC_DECL tdualquat();
GLM_FUNC_DECL tdualquat(tdualquat<T, P> const & d);
GLM_FUNC_DECL tdualquat() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tdualquat(tdualquat<T, Q> const & d);
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
GLM_FUNC_DECL explicit tdualquat(ctor);
GLM_FUNC_DECL explicit tdualquat(tquat<T, P> const & real);
GLM_FUNC_DECL tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
GLM_FUNC_DECL tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
//////////////////////////////////////////////////////////////
// tdualquat conversions
// -- Conversion constructors --
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tdualquat(tdualquat<U, Q> const & q);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tdualquat(tdualquat<U, Q> const & q);
# endif
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
GLM_FUNC_DECL explicit tdualquat(tmat2x4<T, P> const & holder_mat);
GLM_FUNC_DECL explicit tdualquat(tmat3x4<T, P> const & aug_mat);
// Operators
GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m);
// -- Unary arithmetic operators --
GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<U, P> const & m);
@@ -126,118 +126,97 @@ namespace glm
template <typename U>
GLM_FUNC_DECL tdualquat<T, P> & operator/=(U s);
};
// -- Unary bit operators --
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> operator- (
tquat<T, P> const & q);
GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator+ (
tdualquat<T, P> const & q,
tdualquat<T, P> const & p);
GLM_FUNC_DECL tdualquat<T, P> operator-(tdualquat<T, P> const & q);
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator* (
tdualquat<T, P> const & q,
tdualquat<T, P> const & p);
GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator* (
tquat<T, P> const & q,
tvec3<T, P> const & v);
GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator* (
tvec3<T, P> const & v,
tquat<T, P> const & q);
GLM_FUNC_DECL tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator* (
tquat<T, P> const & q,
tvec4<T, P> const & v);
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator* (
tvec4<T, P> const & v,
tquat<T, P> const & q);
GLM_FUNC_DECL tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator* (
tdualquat<T, P> const & q,
T const & s);
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator* (
T const & s,
tdualquat<T, P> const & q);
GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator/ (
tdualquat<T, P> const & q,
T const & s);
GLM_FUNC_DECL tdualquat<T, P> operator*(T const & s, tdualquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> operator/(tdualquat<T, P> const & q, T const & s);
/// Returns the normalized quaternion.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> normalize(
tdualquat<T, P> const & q);
GLM_FUNC_DECL tdualquat<T, P> normalize(tdualquat<T, P> const & q);
/// Returns the linear interpolation of two dual quaternion.
///
/// @see gtc_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> lerp(
tdualquat<T, P> const & x,
tdualquat<T, P> const & y,
T const & a);
GLM_FUNC_DECL tdualquat<T, P> lerp(tdualquat<T, P> const & x, tdualquat<T, P> const & y, T const & a);
/// Returns the q inverse.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> inverse(
tdualquat<T, P> const & q);
GLM_FUNC_DECL tdualquat<T, P> inverse(tdualquat<T, P> const & q);
/// Converts a quaternion to a 2 * 4 matrix.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(
tdualquat<T, P> const & x);
GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(tdualquat<T, P> const & x);
/// Converts a quaternion to a 3 * 4 matrix.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(
tdualquat<T, P> const & x);
GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(tdualquat<T, P> const & x);
/// Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
tmat2x4<T, P> const & x);
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat2x4<T, P> const & x);
/// Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(
tmat3x4<T, P> const & x);
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat3x4<T, P> const & x);
/// Dual-quaternion of low single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, lowp> lowp_dualquat;
/// Dual-quaternion of medium single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, mediump> mediump_dualquat;
/// Dual-quaternion of high single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
@@ -248,40 +227,40 @@ namespace glm
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, lowp> lowp_fdualquat;
/// Dual-quaternion of medium single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, mediump> mediump_fdualquat;
/// Dual-quaternion of high single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, highp> highp_fdualquat;
/// Dual-quaternion of low double-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, lowp> lowp_ddualquat;
/// Dual-quaternion of medium double-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, mediump> mediump_ddualquat;
/// Dual-quaternion of high double-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, highp> highp_ddualquat;
#if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
/// Dual-quaternion of floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef highp_fdualquat dualquat;
/// Dual-quaternion of single-precision floating-point numbers.
///
/// @see gtx_dual_quaternion
@@ -298,7 +277,7 @@ namespace glm
#else
# error "GLM error: multiple default precision requested for single-precision floating-point types"
#endif
#if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
/// Dual-quaternion of default double-precision floating-point numbers.
@@ -316,6 +295,16 @@ namespace glm
#endif
/// @}
// -- Is type --
template <typename T, precision P>
struct type<T, P, tdualquat>
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
};
} //namespace glm
#include "dual_quaternion.inl"

View File

@@ -35,8 +35,7 @@
namespace glm
{
//////////////////////////////////////
// Component accesses
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
@@ -80,22 +79,25 @@ namespace glm
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
// -- Implicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
: real(tquat<T, P>())
, dual(tquat<T, P>(0, 0, 0, 0))
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
: real(tquat<T, P>())
, dual(tquat<T, P>(0, 0, 0, 0))
# endif
{}
# endif
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tdualquat<T, P> const & d)
: real(d.real)
, dual(d.dual)
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tdualquat<T, P> const & d)
: real(d.real)
, dual(d.dual)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -104,8 +106,7 @@ namespace glm
, dual(d.dual)
{}
//////////////////////////////////////
// Explicit basic constructors
// -- Explicit basic constructors --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(ctor)
@@ -130,8 +131,7 @@ namespace glm
: real(r), dual(d)
{}
//////////////////////////////////////////////////////////////
// tdualquat conversions
// -- Conversion constructors --
template <typename T, precision P>
template <typename U, precision Q>
@@ -152,16 +152,17 @@ namespace glm
*this = dualquat_cast(m);
}
//////////////////////////////////////////////////////////////
// tdualquat operators
// -- Unary arithmetic operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> & tdualquat<T, P>::operator=(tdualquat<T, P> const & q)
{
this->real = q.real;
this->dual = q.dual;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> & tdualquat<T, P>::operator=(tdualquat<T, P> const & q)
{
this->real = q.real;
this->dual = q.dual;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>
@@ -190,15 +191,16 @@ namespace glm
return *this;
}
//////////////////////////////////////////////////////////////
// tquat<valType> external operators
// -- Unary bit operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> operator-(tdualquat<T, P> const & q)
{
return tdualquat<T, P>(-q.real,-q.dual);
return q;
}
// -- Binary operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p)
{
@@ -211,7 +213,6 @@ namespace glm
return tdualquat<T, P>(p.real * o.real,p.real * o.dual + p.dual * o.real);
}
// Transformation
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tdualquat<T, P> const & q, tvec3<T, P> const & v)
{
@@ -256,8 +257,8 @@ namespace glm
return tdualquat<T, P>(q.real / s, q.dual / s);
}
//////////////////////////////////////
// Boolean operators
// -- Boolean operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2)
{
@@ -270,7 +271,8 @@ namespace glm
return (q1.real != q2.dual) || (q1.real != q2.dual);
}
////////////////////////////////////////////////////////
// -- Operations --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> normalize(tdualquat<T, P> const & q)
{

View File

@@ -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"

View File

@@ -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
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -33,6 +33,16 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> taylorCos(vecType<T, P> const & x)
{
return static_cast<T>(1)
- (x * x) / 2.f
+ (x * x * x * x) / 24.f
- (x * x * x * x * x * x) / 720.f
+ (x * x * x * x * x * x * x * x) / 40320.f;
}
template <typename T>
GLM_FUNC_QUALIFIER T cos_52s(T x)
{
@@ -66,11 +76,11 @@ namespace detail
{
T const angle(wrapAngle<T>(x));
if(angle<half_pi<T>())
if(angle < half_pi<T>())
return detail::cos_52s(angle);
if(angle<pi<T>())
if(angle < pi<T>())
return -detail::cos_52s(pi<T>() - angle);
if(angle<(T(3) * half_pi<T>()))
if(angle < (T(3) * half_pi<T>()))
return -detail::cos_52s(angle - pi<T>());
return detail::cos_52s(two_pi<T>() - angle);

View File

@@ -24,41 +24,20 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_multiple
/// @file glm/gtx/multiple.inl
/// @date 2009-10-26 / 2011-06-07
/// @ref gtx_float_normalize
/// @file glm/gtx/float_normalize.inl
/// @date 2015-09-25 / 2015-09-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <limits>
namespace glm
{
//////////////////////
// higherMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType higherMultiple(genType Source, genType Multiple)
{
return detail::compute_ceilMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> higherMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
GLM_FUNC_QUALIFIER vecType<float, P> floatNormalize(vecType<T, P> const & v)
{
return detail::functor2<T, P, vecType>::call(higherMultiple, Source, Multiple);
return vecType<float, P>(v) / static_cast<float>(std::numeric_limits<T>::max());
}
//////////////////////
// lowerMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType lowerMultiple(genType Source, genType Multiple)
{
return detail::compute_floorMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> lowerMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(lowerMultiple, Source, Multiple);
}
}//namespace glm

View File

@@ -41,10 +41,6 @@
#pragma once
#if !GLM_HAS_CXX11_STL
# error "GLM_GTX_hash requires C++11 standard library support"
#endif
#include <functional>
#include "../vec2.hpp"
@@ -53,6 +49,7 @@
#include "../gtc/vec1.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#include "../mat2x2.hpp"
#include "../mat2x3.hpp"
@@ -66,90 +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 <typename T, glm::precision P>
struct hash<glm::tvec1<T,P>>
struct hash<glm::tvec1<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tvec1<T,P> &v) const;
GLM_FUNC_DECL size_t operator()(glm::tvec1<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec2<T,P>>
struct hash<glm::tvec2<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tvec2<T,P> &v) const;
GLM_FUNC_DECL size_t operator()(glm::tvec2<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec3<T,P>>
struct hash<glm::tvec3<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tvec3<T,P> &v) const;
GLM_FUNC_DECL size_t operator()(glm::tvec3<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec4<T,P>>
struct hash<glm::tvec4<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tvec4<T,P> &v) const;
GLM_FUNC_DECL size_t operator()(glm::tvec4<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tquat<T,P>>
{
GLM_FUNC_DECL size_t operator()(const glm::tquat<T,P> &q) const;
GLM_FUNC_DECL size_t operator()(glm::tquat<T, P> const & q) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x2<T,P>>
struct hash<glm::tdualquat<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat2x2<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,P> const & q) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x3<T,P>>
struct hash<glm::tmat2x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat2x3<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat2x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x4<T,P>>
struct hash<glm::tmat2x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat2x4<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat2x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x2<T,P>>
struct hash<glm::tmat2x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat3x2<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat2x4<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x3<T,P>>
struct hash<glm::tmat3x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat3x3<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat3x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x4<T,P>>
struct hash<glm::tmat3x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat3x4<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat3x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x2<T,P>>
struct hash<glm::tmat3x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat4x2<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat3x4<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat4x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x3<T,P>>
struct hash<glm::tmat4x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat4x3<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat4x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x4<T,P>>
struct hash<glm::tmat4x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(const glm::tmat4x4<T,P> &m) const;
GLM_FUNC_DECL size_t operator()(glm::tmat4x4<T,P> const & m) const;
};
} // namespace std

View File

@@ -52,16 +52,14 @@ namespace detail
namespace std
{
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tvec1<T,P>>::operator()(const glm::tvec1<T,P> &v) const
GLM_FUNC_QUALIFIER size_t hash<glm::tvec1<T, P>>::operator()(glm::tvec1<T, P> const & v) const
{
hash<T> hasher;
return hasher(v.x);
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tvec2<T,P>>::operator()(const glm::tvec2<T,P> &v) const
GLM_FUNC_QUALIFIER size_t hash<glm::tvec2<T, P>>::operator()(glm::tvec2<T, P> const & v) const
{
size_t seed = 0;
hash<T> hasher;
@@ -71,8 +69,7 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tvec3<T,P>>::operator()(const glm::tvec3<T,P> &v) const
GLM_FUNC_QUALIFIER size_t hash<glm::tvec3<T, P>>::operator()(glm::tvec3<T, P> const & v) const
{
size_t seed = 0;
hash<T> hasher;
@@ -83,8 +80,7 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tvec4<T,P>>::operator()(const glm::tvec4<T,P> &v) const
GLM_FUNC_QUALIFIER size_t hash<glm::tvec4<T, P>>::operator()(glm::tvec4<T, P> const & v) const
{
size_t seed = 0;
hash<T> hasher;
@@ -96,8 +92,7 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tquat<T,P>>::operator()(const glm::tquat<T,P> &q) const
GLM_FUNC_QUALIFIER size_t hash<glm::tquat<T, P>>::operator()(glm::tquat<T,P> const & q) const
{
size_t seed = 0;
hash<T> hasher;
@@ -109,44 +104,50 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat2x2<T,P>>::operator()(const glm::tmat2x2<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tdualquat<T, P>>::operator()(glm::tdualquat<T, P> const & q) const
{
size_t seed = 0;
hash<glm::tvec2<T,P>> hasher;
hash<glm::tquat<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(q.real));
glm::detail::hash_combine(seed, hasher(q.dual));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x2<T, P>>::operator()(glm::tmat2x2<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat2x3<T,P>>::operator()(const glm::tmat2x3<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x3<T, P>>::operator()(glm::tmat2x3<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T,P>> hasher;
hash<glm::tvec3<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat2x4<T,P>>::operator()(const glm::tmat2x4<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x4<T, P>>::operator()(glm::tmat2x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T,P>> hasher;
hash<glm::tvec4<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat3x2<T,P>>::operator()(const glm::tmat3x2<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x2<T, P>>::operator()(glm::tmat3x2<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T,P>> hasher;
hash<glm::tvec2<T, P>> 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]));
@@ -154,11 +155,10 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat3x3<T,P>>::operator()(const glm::tmat3x3<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x3<T, P>>::operator()(glm::tmat3x3<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T,P>> hasher;
hash<glm::tvec3<T, P>> 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]));
@@ -166,11 +166,10 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat3x4<T,P>>::operator()(const glm::tmat3x4<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x4<T, P>>::operator()(glm::tmat3x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T,P>> hasher;
hash<glm::tvec4<T, P>> 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]));
@@ -178,11 +177,10 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat4x2<T,P>>::operator()(const glm::tmat4x2<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x2<T,P>>::operator()(glm::tmat4x2<T,P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T,P>> hasher;
hash<glm::tvec2<T, P>> 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]));
@@ -191,11 +189,10 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat4x3<T,P>>::operator()(const glm::tmat4x3<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x3<T,P>>::operator()(glm::tmat4x3<T,P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T,P>> hasher;
hash<glm::tvec3<T, P>> 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]));
@@ -204,11 +201,10 @@ namespace std
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t
hash<glm::tmat4x4<T,P>>::operator()(const glm::tmat4x4<T,P> &m) const
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x4<T,P>>::operator()(glm::tmat4x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T,P>> hasher;
hash<glm::tvec4<T, P>> 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]));

View File

@@ -55,7 +55,7 @@ namespace glm
/// @addtogroup gtx_intersect
/// @{
//! Compute the intersection of a ray and a triangle.
//! Compute the intersection of a ray and a plane.
//! Ray direction and plane normal must be unit length.
//! From GLM_GTX_intersect extension.
template <typename genType>

View File

@@ -220,12 +220,12 @@ namespace glm
std::pair<tmat4x4<T,P> const,
tmat4x4<T,P> const> const &);
template <typename CTy, typename CTr, typename T, precision P>
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(
std::basic_ostream<CTy,CTr> &,
std::pair<tmat4x4<T,P>,
tmat4x4<T,P>> const &);
tmat4x4<T,P> > const &);
/// @}
}//namespace glm

View File

@@ -646,12 +646,11 @@ namespace io
return os;
}
template <typename CTy, typename CTr, typename T, precision P>
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(
std::basic_ostream<CTy,CTr> & os,
std::pair<tmat4x4<T,P>, tmat4x4<T,P>> const& a)
std::pair<tmat4x4<T,P>, tmat4x4<T,P> > const& a)
{
return operator<<(os, static_cast<std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const&>(a));
}
return operator<<(os, static_cast<std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const&>(a));
}
}//namespace glm

View File

@@ -36,7 +36,7 @@
///
/// @brief Decomposes a model matrix to translations, rotation and scale components
///
/// <glm/gtx/decomposition.hpp> need to be included to use these functionalities.
/// <glm/gtx/matrix_decompose.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once

View File

@@ -81,15 +81,15 @@ namespace glm
tmat4x4<T, P> PerspectiveMatrix(LocalMatrix);
for(length_t i = 0; i < 3; i++)
PerspectiveMatrix[i][3] = 0;
PerspectiveMatrix[3][3] = 1;
PerspectiveMatrix[i][3] = static_cast<T>(0);
PerspectiveMatrix[3][3] = static_cast<T>(1);
/// TODO: Fixme!
if(determinant(PerspectiveMatrix) == static_cast<T>(0))
return false;
// First, isolate perspective. This is the messiest.
if(LocalMatrix[0][3] != 0 || LocalMatrix[1][3] != 0 || LocalMatrix[2][3] != 0)
if(LocalMatrix[0][3] != static_cast<T>(0) || LocalMatrix[1][3] != static_cast<T>(0) || LocalMatrix[2][3] != static_cast<T>(0))
{
// rightHandSide is the right hand side of the equation.
tvec4<T, P> RightHandSide;
@@ -108,8 +108,8 @@ namespace glm
// v4MulPointByMatrix(rightHandSide, transposedInversePerspectiveMatrix, perspectivePoint);
// Clear the perspective partition
LocalMatrix[0][3] = LocalMatrix[1][3] = LocalMatrix[2][3] = 0;
LocalMatrix[3][3] = 1;
LocalMatrix[0][3] = LocalMatrix[1][3] = LocalMatrix[2][3] = static_cast<T>(0);
LocalMatrix[3][3] = static_cast<T>(1);
}
else
{
@@ -186,38 +186,38 @@ namespace glm
T s, t, x, y, z, w;
t = Row[0][0] + Row[1][1] + Row[2][2] + 1.0;
t = Row[0][0] + Row[1][1] + Row[2][2] + static_cast<T>(1);
if(t > 1e-4)
if(t > static_cast<T>(1e-4))
{
s = 0.5 / sqrt(t);
w = 0.25 / s;
s = static_cast<T>(0.5) / sqrt(t);
w = static_cast<T>(0.25) / s;
x = (Row[2][1] - Row[1][2]) * s;
y = (Row[0][2] - Row[2][0]) * s;
z = (Row[1][0] - Row[0][1]) * s;
}
else if(Row[0][0] > Row[1][1] && Row[0][0] > Row[2][2])
{
s = sqrt (1.0 + Row[0][0] - Row[1][1] - Row[2][2]) * 2.0; // S=4*qx
x = 0.25 * s;
s = sqrt (static_cast<T>(1) + Row[0][0] - Row[1][1] - Row[2][2]) * static_cast<T>(2); // S=4*qx
x = static_cast<T>(0.25) * s;
y = (Row[0][1] + Row[1][0]) / s;
z = (Row[0][2] + Row[2][0]) / s;
w = (Row[2][1] - Row[1][2]) / s;
}
else if(Row[1][1] > Row[2][2])
{
s = sqrt (1.0 + Row[1][1] - Row[0][0] - Row[2][2]) * 2.0; // S=4*qy
s = sqrt (static_cast<T>(1) + Row[1][1] - Row[0][0] - Row[2][2]) * static_cast<T>(2); // S=4*qy
x = (Row[0][1] + Row[1][0]) / s;
y = 0.25 * s;
y = static_cast<T>(0.25) * s;
z = (Row[1][2] + Row[2][1]) / s;
w = (Row[0][2] - Row[2][0]) / s;
}
else
{
s = sqrt(1.0 + Row[2][2] - Row[0][0] - Row[1][1]) * 2.0; // S=4*qz
s = sqrt(static_cast<T>(1) + Row[2][2] - Row[0][0] - Row[1][1]) * static_cast<T>(2); // S=4*qz
x = (Row[0][2] + Row[2][0]) / s;
y = (Row[1][2] + Row[2][1]) / s;
z = 0.25 * s;
z = static_cast<T>(0.25) * s;
w = (Row[1][0] - Row[0][1]) / s;
}

View File

@@ -1,106 +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 gtx_multiple
/// @file glm/gtx/multiple.hpp
/// @date 2009-10-26 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_multiple GLM_GTX_multiple
/// @ingroup gtx
///
/// @brief Find the closest number of a number multiple of other number.
///
/// <glm/gtx/multiple.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../gtc/round.hpp"
#pragma message("GLM: GLM_GTX_multiple extension is deprecated, use GLM_GTC_round instead.")
namespace glm
{
/// @addtogroup gtx_multiple
/// @{
/// Higher multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename genType>
GLM_DEPRECATED GLM_FUNC_DECL genType higherMultiple(
genType Source,
genType Multiple);
/// Higher multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename T, precision P, template <typename, precision> class vecType>
GLM_DEPRECATED GLM_FUNC_DECL vecType<T, P> higherMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
/// Lower multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename genType>
GLM_DEPRECATED GLM_FUNC_DECL genType lowerMultiple(
genType Source,
genType Multiple);
/// Lower multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename T, precision P, template <typename, precision> class vecType>
GLM_DEPRECATED GLM_FUNC_DECL vecType<T, P> lowerMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
/// @}
}//namespace glm
#include "multiple.inl"

View File

@@ -67,14 +67,14 @@ namespace glm
GLM_FUNC_DECL typename genType::value_type length2(
genType const & x);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! Returns the squared distance between p0 and p1, i.e., length2(p0 - p1).
//! From GLM_GTX_norm extension.
template <typename T>
GLM_FUNC_DECL T distance2(
T const & p0,
T const & p1);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! Returns the squared distance between p0 and p1, i.e., length2(p0 - p1).
//! From GLM_GTX_norm extension.
template <typename genType>
GLM_FUNC_DECL typename genType::value_type distance2(

View File

@@ -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<typename T, precision P>

View File

@@ -121,33 +121,28 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> pow
(
tquat<T, P> const & x,
T const & y
)
GLM_FUNC_QUALIFIER tquat<T, P> pow(tquat<T, P> const & x, T const & y)
{
if(abs(x.w) > (static_cast<T>(1) - epsilon<T>()))
return x;
T Angle = acos(y);
//Raising to the power of 0 should yield 1
//Needed to prevent a division by 0 error later on
if(y > -epsilon<T>() && y < epsilon<T>())
return tquat<T, P>(1,0,0,0);
//To deal with non-unit quaternions
T magnitude = sqrt(x.x * x.x + x.y * x.y + x.z * x.z + x.w *x.w);
//Equivalent to raising a real number to a power
//Needed to prevent a division by 0 error later on
if(abs(x.w / magnitude) > static_cast<T>(1) - epsilon<T>() && abs(x.w / magnitude) < static_cast<T>(1) + epsilon<T>())
return tquat<T, P>(pow(x.w, y),0,0,0);
T Angle = acos(x.w / magnitude);
T NewAngle = Angle * y;
T Div = sin(NewAngle) / sin(Angle);
return tquat<T, P>(
cos(NewAngle),
x.x * Div,
x.y * Div,
x.z * Div);
}
T Mag = pow(magnitude, y-1);
//template <typename T, precision P>
//GLM_FUNC_QUALIFIER tquat<T, P> sqrt
//(
// tquat<T, P> const & q
//)
//{
// T q0 = static_cast<T>(1) - dot(q, q);
// return T(2) * (T(1) + q0) * q;
//}
return tquat<T, P>(cos(NewAngle) * magnitude * Mag, x.x * Div * Mag, x.y * Div * Mag, x.z * Div * Mag);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> rotate
@@ -254,6 +249,9 @@ namespace glm
T cosTheta = dot(orig, dest);
tvec3<T, P> rotationAxis;
if(cosTheta >= static_cast<T>(1) - epsilon<T>())
return quat();
if(cosTheta < static_cast<T>(-1) + epsilon<T>())
{
// special case when vectors in opposite directions :

View File

@@ -8,14 +8,14 @@
/// 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
@@ -33,9 +33,9 @@
///
/// @defgroup gtx_simd_mat4 GLM_GTX_simd_mat4
/// @ingroup gtx
///
///
/// @brief SIMD implementation of mat4 type.
///
///
/// <glm/gtx/simd_mat4.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
@@ -71,6 +71,23 @@ namespace detail
typedef fmat4x4SIMD type;
typedef fmat4x4SIMD transpose_type;
typedef tmat4x4<float, defaultp> pure_type;
typedef tvec4<float, defaultp> pure_row_type;
typedef tvec4<float, defaultp> pure_col_type;
typedef tmat4x4<float, defaultp> pure_transpose_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR length_t cols = 4;
static GLM_RELAXED_CONSTEXPR length_t rows = 4;
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];
@@ -78,7 +95,7 @@ namespace detail
//////////////////////////////////////
// Constructors
fmat4x4SIMD();
fmat4x4SIMD() GLM_DEFAULT_CTOR;
explicit fmat4x4SIMD(float const & s);
explicit fmat4x4SIMD(
float const & x0, float const & y0, float const & z0, float const & w0,
@@ -96,7 +113,7 @@ namespace detail
__m128 const in[4]);
// Conversions
//template <typename U>
//template <typename U>
//explicit tmat4x4(tmat4x4<U> const & m);
//explicit tmat4x4(tmat2x2<T> const & x);
@@ -113,7 +130,7 @@ namespace detail
fvec4SIMD const & operator[](length_t i) const;
// Unary updatable operators
fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator= (fmat4x4SIMD const & m) GLM_DEFAULT;
fmat4x4SIMD & operator+= (float const & s);
fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
fmat4x4SIMD & operator-= (float const & s);

View File

@@ -61,18 +61,25 @@ GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[]
return this->Data[i];
}
#ifdef GLM_STATIC_CONST_MEMBERS
const fmat4x4SIMD fmat4x4SIMD::ZERO(static_cast<float>(0));
const fmat4x4SIMD fmat4x4SIMD::IDENTITY(static_cast<float>(1));
#endif
//////////////////////////////////////////////////////////////
// Constructors
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->Data[0] = fvec4SIMD(1, 0, 0, 0);
this->Data[1] = fvec4SIMD(0, 1, 0, 0);
this->Data[2] = fvec4SIMD(0, 0, 1, 0);
this->Data[3] = fvec4SIMD(0, 0, 0, 1);
# endif
}
#if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD()
{
# ifndef GLM_FORCE_NO_CTOR_INIT
this->Data[0] = fvec4SIMD(1, 0, 0, 0);
this->Data[1] = fvec4SIMD(0, 1, 0, 0);
this->Data[2] = fvec4SIMD(0, 0, 1, 0);
this->Data[3] = fvec4SIMD(0, 0, 0, 1);
# endif
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD(float const & s)
{
@@ -135,17 +142,19 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD
//////////////////////////////////////////////////////////////
// mat4 operators
GLM_FUNC_QUALIFIER fmat4x4SIMD& fmat4x4SIMD::operator=
(
fmat4x4SIMD const & m
)
{
this->Data[0] = m[0];
this->Data[1] = m[1];
this->Data[2] = m[2];
this->Data[3] = m[3];
return *this;
}
#if !GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fmat4x4SIMD& fmat4x4SIMD::operator=
(
fmat4x4SIMD const & m
)
{
this->Data[0] = m[0];
this->Data[1] = m[1];
this->Data[2] = m[2];
this->Data[3] = m[3];
return *this;
}
#endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+=
(

View File

@@ -8,14 +8,14 @@
/// 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
@@ -33,9 +33,9 @@
///
/// @defgroup gtx_simd_quat GLM_GTX_simd_quat
/// @ingroup gtx
///
///
/// @brief SIMD implementation of quat type.
///
///
/// <glm/gtx/simd_quat.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
@@ -69,12 +69,17 @@ namespace detail
{
GLM_ALIGNED_STRUCT(16) fquatSIMD
{
typedef __m128 value_type;
typedef float value_type;
typedef std::size_t size_type;
static size_type value_size();
typedef fquatSIMD type;
typedef tquat<bool, defaultp> bool_type;
typedef tquat<float, defaultp> pure_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR precision prec = defaultp;
# endif//GLM_META_PROG_HELPERS
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
union
@@ -86,12 +91,32 @@ 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
fquatSIMD();
fquatSIMD() GLM_DEFAULT_CTOR;
fquatSIMD(fquatSIMD const & q) GLM_DEFAULT;
fquatSIMD(__m128 const & Data);
fquatSIMD(fquatSIMD const & q);
//////////////////////////////////////
// Explicit basic constructors
@@ -99,20 +124,20 @@ namespace detail
explicit fquatSIMD(
ctor);
explicit fquatSIMD(
float const & w,
float const & x,
float const & y,
float const & w,
float const & x,
float const & y,
float const & z);
explicit fquatSIMD(
quat const & v);
explicit fquatSIMD(
vec3 const & eulerAngles);
//////////////////////////////////////
// Unary arithmetic operators
fquatSIMD& operator =(fquatSIMD const & q);
fquatSIMD& operator= (fquatSIMD const & q) GLM_DEFAULT;
fquatSIMD& operator*=(float const & s);
fquatSIMD& operator/=(float const & s);
};
@@ -124,16 +149,16 @@ namespace detail
detail::fquatSIMD operator- (
detail::fquatSIMD const & q);
detail::fquatSIMD operator+ (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fquatSIMD operator+ (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fquatSIMD operator* (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fquatSIMD operator* (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fvec4SIMD operator* (
detail::fquatSIMD const & q,
detail::fquatSIMD const & q,
detail::fvec4SIMD const & v);
detail::fvec4SIMD operator* (
@@ -141,7 +166,7 @@ namespace detail
detail::fquatSIMD const & q);
detail::fquatSIMD operator* (
detail::fquatSIMD const & q,
detail::fquatSIMD const & q,
float s);
detail::fquatSIMD operator* (
@@ -149,7 +174,7 @@ namespace detail
detail::fquatSIMD const & q);
detail::fquatSIMD operator/ (
detail::fquatSIMD const & q,
detail::fquatSIMD const & q,
float s);
}//namespace detail
@@ -192,64 +217,64 @@ namespace detail
detail::fquatSIMD const & q);
/// Returns the length of the quaternion.
///
/// Returns the length of the quaternion.
///
/// @see gtx_simd_quat
float length(
detail::fquatSIMD const & x);
/// Returns the normalized quaternion.
///
/// Returns the normalized quaternion.
///
/// @see gtx_simd_quat
detail::fquatSIMD normalize(
detail::fquatSIMD const & x);
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
///
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
///
/// @see gtx_simd_quat
float dot(
detail::fquatSIMD const & q1,
detail::fquatSIMD const & q1,
detail::fquatSIMD const & q2);
/// Spherical linear interpolation of two quaternions.
/// The interpolation is oriented and the rotation is performed at constant speed.
/// For short path spherical linear interpolation, use the slerp function.
///
///
/// @param x A quaternion
/// @param y A quaternion
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
/// @see gtx_simd_quat
/// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
/// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
detail::fquatSIMD mix(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
/// Linear interpolation of two quaternions.
/// Linear interpolation of two quaternions.
/// The interpolation is oriented.
///
///
/// @param x A quaternion
/// @param y A quaternion
/// @param a Interpolation factor. The interpolation is defined in the range [0, 1].
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
/// @see gtx_simd_quat
detail::fquatSIMD lerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
/// Spherical linear interpolation of two quaternions.
/// The interpolation always take the short path and the rotation is performed at constant speed.
///
///
/// @param x A quaternion
/// @param y A quaternion
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
/// @see gtx_simd_quat
detail::fquatSIMD slerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
@@ -262,10 +287,10 @@ namespace detail
/// This will use the equivalent to fastAcos() and fastSin().
///
/// @see gtx_simd_quat
/// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
/// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
detail::fquatSIMD fastMix(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
/// Identical to fastMix() except takes the shortest path.
@@ -273,22 +298,22 @@ namespace detail
/// The same rules apply here as those in fastMix(). Both quaternions must be unit length and 'a' must be
/// in the range [0, 1].
///
/// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
/// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
/// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
/// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a)
detail::fquatSIMD fastSlerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
/// Returns the q conjugate.
///
/// Returns the q conjugate.
///
/// @see gtx_simd_quat
detail::fquatSIMD conjugate(
detail::fquatSIMD const & q);
/// Returns the q inverse.
///
/// Returns the q inverse.
///
/// @see gtx_simd_quat
detail::fquatSIMD inverse(
detail::fquatSIMD const & q);
@@ -296,14 +321,14 @@ namespace detail
/// Build a quaternion from an angle and a normalized axis.
///
/// @param angle Angle expressed in radians.
/// @param axis Axis of the quaternion, must be normalized.
/// @param axis Axis of the quaternion, must be normalized.
///
/// @see gtx_simd_quat
detail::fquatSIMD angleAxisSIMD(
float const & angle,
float const & angle,
vec3 const & axis);
/// Build a quaternion from an angle and a normalized axis.
/// Build a quaternion from an angle and a normalized axis.
///
/// @param angle Angle expressed in radians.
/// @param x x component of the x-axis, x, y, z must be a normalized axis
@@ -312,9 +337,9 @@ namespace detail
///
/// @see gtx_simd_quat
detail::fquatSIMD angleAxisSIMD(
float const & angle,
float const & x,
float const & y,
float const & angle,
float const & x,
float const & y,
float const & z);
// TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp().

View File

@@ -51,25 +51,47 @@ 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
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD()
# ifdef GLM_FORCE_NO_CTOR_INIT
: Data(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f))
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD()
# ifdef GLM_FORCE_NO_CTOR_INIT
: Data(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f))
# endif
{}
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD(fquatSIMD const & q) :
Data(q.Data)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD(__m128 const & Data) :
Data(Data)
{}
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD(fquatSIMD const & q) :
Data(q.Data)
{}
//////////////////////////////////////
// Explicit basic constructors
@@ -83,25 +105,27 @@ GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD(quat const & q) :
GLM_FUNC_QUALIFIER fquatSIMD::fquatSIMD(vec3 const & eulerAngles)
{
vec3 c = glm::cos(eulerAngles * 0.5f);
vec3 c = glm::cos(eulerAngles * 0.5f);
vec3 s = glm::sin(eulerAngles * 0.5f);
Data = _mm_set_ps(
(c.x * c.y * c.z) + (s.x * s.y * s.z),
(c.x * c.y * s.z) - (s.x * s.y * c.z),
(c.x * s.y * c.z) + (s.x * c.y * s.z),
(s.x * c.y * c.z) - (c.x * s.y * s.z));
Data = _mm_set_ps(
(c.x * c.y * c.z) + (s.x * s.y * s.z),
(c.x * c.y * s.z) - (s.x * s.y * c.z),
(c.x * s.y * c.z) + (s.x * c.y * s.z),
(s.x * c.y * c.z) - (c.x * s.y * s.z));
}
//////////////////////////////////////
// Unary arithmetic operators
GLM_FUNC_QUALIFIER fquatSIMD& fquatSIMD::operator=(fquatSIMD const & q)
{
this->Data = q.Data;
return *this;
}
#if !GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fquatSIMD& fquatSIMD::operator=(fquatSIMD const & q)
{
this->Data = q.Data;
return *this;
}
#endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fquatSIMD& fquatSIMD::operator*=(float const & s)
{

View File

@@ -8,14 +8,14 @@
/// 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
@@ -33,9 +33,9 @@
///
/// @defgroup gtx_simd_vec4 GLM_GTX_simd_vec4
/// @ingroup gtx
///
///
/// @brief SIMD implementation of vec4 type.
///
///
/// <glm/gtx/simd_vec4.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
@@ -92,13 +92,18 @@ namespace detail
/// \ingroup gtx_simd_vec4
GLM_ALIGNED_STRUCT(16) fvec4SIMD
{
typedef __m128 value_type;
typedef float value_type;
typedef std::size_t size_type;
static size_type value_size();
typedef fvec4SIMD type;
typedef tvec4<float, defaultp> pure_type;
typedef tvec4<bool, highp> bool_type;
# ifdef GLM_META_PROG_HELPERS
static GLM_RELAXED_CONSTEXPR length_t components = 4;
static GLM_RELAXED_CONSTEXPR precision prec = defaultp;
# endif//GLM_META_PROG_HELPERS
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
union
{
@@ -109,12 +114,31 @@ 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
fvec4SIMD();
fvec4SIMD() GLM_DEFAULT_CTOR;
fvec4SIMD(fvec4SIMD const & v) GLM_DEFAULT;
fvec4SIMD(__m128 const & Data);
fvec4SIMD(fvec4SIMD const & v);
//////////////////////////////////////
// Explicit basic constructors
@@ -124,9 +148,9 @@ namespace detail
explicit fvec4SIMD(
float const & s);
explicit fvec4SIMD(
float const & x,
float const & y,
float const & z,
float const & x,
float const & y,
float const & z,
float const & w);
explicit fvec4SIMD(
vec4 const & v);
@@ -145,7 +169,7 @@ namespace detail
//////////////////////////////////////
// Unary arithmetic operators
fvec4SIMD& operator= (fvec4SIMD const & v);
fvec4SIMD& operator= (fvec4SIMD const & v) GLM_DEFAULT;
fvec4SIMD& operator+=(fvec4SIMD const & v);
fvec4SIMD& operator-=(fvec4SIMD const & v);
fvec4SIMD& operator*=(fvec4SIMD const & v);
@@ -162,15 +186,15 @@ namespace detail
//////////////////////////////////////
// Swizzle operators
template <comp X, comp Y, comp Z, comp W>
template <comp X_, comp Y_, comp Z_, comp W_>
fvec4SIMD& swizzle();
template <comp X, comp Y, comp Z, comp W>
template <comp X_, comp Y_, comp Z_, comp W_>
fvec4SIMD swizzle() const;
template <comp X, comp Y, comp Z>
template <comp X_, comp Y_, comp Z_>
fvec4SIMD swizzle() const;
template <comp X, comp Y>
template <comp X_, comp Y_>
fvec4SIMD swizzle() const;
template <comp X>
template <comp X_>
fvec4SIMD swizzle() const;
};
}//namespace detail
@@ -213,13 +237,13 @@ namespace detail
//! Returns a value equal to the nearest integer to x.
//! A fractional part of 0.5 will round toward the nearest even
//! integer. (Both 3.5 and 4.5 for x will return 4.0.)
//! integer. (Both 3.5 and 4.5 for x will return 4.0.)
///
/// @see gtx_simd_vec4
//detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x);
//! Returns a value equal to the nearest integer
//! that is greater than or equal to x.
//! Returns a value equal to the nearest integer
//! that is greater than or equal to x.
/// @see gtx_simd_vec4
detail::fvec4SIMD ceil(detail::fvec4SIMD const & x);
@@ -233,7 +257,7 @@ namespace detail
///
/// @see gtx_simd_vec4
detail::fvec4SIMD mod(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & y);
//! Modulus. Returns x - y * floor(x / y)
@@ -241,7 +265,7 @@ namespace detail
///
/// @see gtx_simd_vec4
detail::fvec4SIMD mod(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
float const & y);
//! Returns the fractional part of x and sets i to the integer
@@ -250,51 +274,51 @@ namespace detail
//! sign as x.
//! (From GLM_GTX_simd_vec4 extension, common function)
//detail::fvec4SIMD modf(
// detail::fvec4SIMD const & x,
// detail::fvec4SIMD const & x,
// detail::fvec4SIMD & i);
//! Returns y if y < x; otherwise, it returns x.
///
///
/// @see gtx_simd_vec4
detail::fvec4SIMD min(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & y);
detail::fvec4SIMD min(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
float const & y);
//! Returns y if x < y; otherwise, it returns x.
///
/// @see gtx_simd_vec4
detail::fvec4SIMD max(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & y);
detail::fvec4SIMD max(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & x,
float const & y);
//! Returns min(max(x, minVal), maxVal) for each component in x
//! Returns min(max(x, minVal), maxVal) for each component in x
//! using the floating-point values minVal and maxVal.
///
/// @see gtx_simd_vec4
detail::fvec4SIMD clamp(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & minVal,
detail::fvec4SIMD const & maxVal);
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & minVal,
detail::fvec4SIMD const & maxVal);
detail::fvec4SIMD clamp(
detail::fvec4SIMD const & x,
float const & minVal,
float const & maxVal);
detail::fvec4SIMD const & x,
float const & minVal,
float const & maxVal);
//! \return If genTypeU is a floating scalar or vector:
//! Returns x * (1.0 - a) + y * a, i.e., the linear blend of
//! x and y using the floating-point value a.
//! \return If genTypeU is a floating scalar or vector:
//! Returns x * (1.0 - a) + y * a, i.e., the linear blend of
//! x and y using the floating-point value a.
//! The value for a is not restricted to the range [0, 1].
//!
//! \return If genTypeU is a boolean scalar or vector:
//! \return If genTypeU is a boolean scalar or vector:
//! Selects which vector each returned component comes
//! from. For a component of a that is false, the
//! corresponding component of x is returned. For a
@@ -305,9 +329,9 @@ namespace detail
//! provides different functionality than
//! genType mix(genType x, genType y, genType(a))
//! where a is a Boolean vector.
//!
//!
//! From GLSL 1.30.08 specification, section 8.3
//!
//!
//! \param[in] x Floating point scalar or vector.
//! \param[in] y Floating point scalar or vector.
//! \param[in] a Floating point or boolean scalar or vector.
@@ -316,19 +340,19 @@ namespace detail
///
/// @see gtx_simd_vec4
detail::fvec4SIMD mix(
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & y,
detail::fvec4SIMD const & x,
detail::fvec4SIMD const & y,
detail::fvec4SIMD const & a);
//! Returns 0.0 if x < edge, otherwise it returns 1.0.
///
/// @see gtx_simd_vec4
detail::fvec4SIMD step(
detail::fvec4SIMD const & edge,
detail::fvec4SIMD const & edge,
detail::fvec4SIMD const & x);
detail::fvec4SIMD step(
float const & edge,
float const & edge,
detail::fvec4SIMD const & x);
//! Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
@@ -343,13 +367,13 @@ namespace detail
///
/// @see gtx_simd_vec4
detail::fvec4SIMD smoothstep(
detail::fvec4SIMD const & edge0,
detail::fvec4SIMD const & edge1,
detail::fvec4SIMD const & edge0,
detail::fvec4SIMD const & edge1,
detail::fvec4SIMD const & x);
detail::fvec4SIMD smoothstep(
float const & edge0,
float const & edge1,
float const & edge0,
float const & edge1,
detail::fvec4SIMD const & x);
//! Returns true if x holds a NaN (not a number)
@@ -390,8 +414,8 @@ namespace detail
///
/// @see gtx_simd_vec4
detail::fvec4SIMD fma(
detail::fvec4SIMD const & a,
detail::fvec4SIMD const & b,
detail::fvec4SIMD const & a,
detail::fvec4SIMD const & b,
detail::fvec4SIMD const & c);
//! Splits x into a floating-point significand in the range

View File

@@ -16,23 +16,46 @@ 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
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD()
# ifdef GLM_FORCE_NO_CTOR_INIT
: Data(_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f))
# endif
{}
#if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD()
# ifdef GLM_FORCE_NO_CTOR_INIT
: Data(_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f))
# endif
{}
#endif//!GLM_HAS_DEFAULTED_FUNCTIONS
#if !GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) :
Data(v.Data)
{}
#endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(__m128 const & Data) :
Data(Data)
{}
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) :
Data(v.Data)
{}
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec4 const & v) :
Data(_mm_set_ps(v.w, v.z, v.y, v.x))
{}
@@ -92,11 +115,13 @@ GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) :
//////////////////////////////////////
// Unary arithmetic operators
GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v)
{
this->Data = v.Data;
return *this;
}
#if !GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v)
{
this->Data = v.Data;
return *this;
}
#endif//!GLM_HAS_DEFAULTED_FUNCTIONS
GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(float const & s)
{
@@ -161,21 +186,21 @@ GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator--()
//////////////////////////////////////
// Swizzle operators
template <comp X, comp Y, comp Z, comp W>
template <comp X_, comp Y_, comp Z_, comp W_>
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 <comp X, comp Y, comp Z, comp W>
template <comp X_, comp Y_, comp Z_, comp W_>
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;
}

View File

@@ -48,6 +48,8 @@
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#include <string>
#if(GLM_COMPILER & GLM_COMPILER_CUDA)

View File

@@ -444,6 +444,38 @@ namespace detail
x[3][0], x[3][1], x[3][2], x[3][3]);
}
};
template <typename T, precision P>
struct compute_to_string<tquat, T, P>
{
GLM_FUNC_QUALIFIER static std::string call(tquat<T, P> const & x)
{
char const * PrefixStr = prefix<T>::value();
char const * LiteralStr = literal<T, std::numeric_limits<T>::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 <typename T, precision P>
struct compute_to_string<tdualquat, T, P>
{
GLM_FUNC_QUALIFIER static std::string call(tdualquat<T, P> const & x)
{
char const * PrefixStr = prefix<T>::value();
char const * LiteralStr = literal<T, std::numeric_limits<T>::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 <template <typename, precision> class matType, typename T, precision P>

View File

@@ -63,6 +63,11 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL genType repeat(genType const & Texcoord);
/// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template <typename genType>
GLM_FUNC_DECL genType mirrorClamp(genType const & Texcoord);
/// Simulate GL_MIRROR_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template <typename genType>

View File

@@ -33,67 +33,46 @@
namespace glm
{
template <typename genType>
GLM_FUNC_QUALIFIER genType clamp
(
genType const & Texcoord
)
GLM_FUNC_QUALIFIER genType clamp(genType const & Texcoord)
{
return glm::clamp(Texcoord, genType(0), genType(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> clamp
(
tvec2<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec2<T, P> clamp(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> clamp
(
tvec3<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec3<T, P> clamp(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> clamp
(
tvec4<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec4<T, P> clamp(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
////////////////////////
// repeat
template <typename genType>
GLM_FUNC_QUALIFIER genType repeat
(
genType const & Texcoord
)
template <typename genType>
GLM_FUNC_QUALIFIER genType repeat(genType const & Texcoord)
{
return glm::fract(Texcoord);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> repeat
(
tvec2<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> repeat(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
@@ -101,11 +80,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> repeat
(
tvec3<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> repeat(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
@@ -113,11 +89,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> repeat
(
tvec4<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> repeat(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
@@ -125,18 +98,47 @@ namespace glm
return Result;
}
////////////////////////
// mirrorRepeat
template <typename genType, precision P>
GLM_FUNC_QUALIFIER genType mirrorRepeat
(
genType const & Texcoord
)
template <typename genType>
GLM_FUNC_QUALIFIER genType mirrorClamp(genType const & Texcoord)
{
genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
genType const Floor = glm::floor(Texcoord);
genType const Rest = Texcoord - Floor;
return glm::fract(glm::abs(Texcoord));
//return glm::mod(glm::abs(Texcoord), 1.0f);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorClamp(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorClamp(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorClamp(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename genType>
GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const & Texcoord)
{
genType const Abs = glm::abs(Texcoord);
genType const Clamp = genType(int(glm::floor(Abs)) % 2);
genType const Floor = glm::floor(Abs);
genType const Rest = Abs - Floor;
genType const Mirror = Clamp + Rest;
genType Out;
@@ -147,11 +149,8 @@ namespace glm
return Out;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorRepeat
(
tvec2<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorRepeat(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
@@ -159,11 +158,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorRepeat
(
tvec3<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorRepeat(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
@@ -171,11 +167,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorRepeat
(
tvec4<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorRepeat(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)