mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Fixed merge
This commit is contained in:
commit
10778448ef
@ -1,82 +1,190 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
/// OpenGL Mathematics (glm.g-truc.net)
|
/// OpenGL Mathematics (glm.g-truc.net)
|
||||||
///
|
///
|
||||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
/// of this software and associated documentation files (the "Software"), to deal
|
/// of this software and associated documentation files (the "Software"), to deal
|
||||||
/// in the Software without restriction, including without limitation the rights
|
/// in the Software without restriction, including without limitation the rights
|
||||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
/// copies of the Software, and to permit persons to whom the Software is
|
/// copies of the Software, and to permit persons to whom the Software is
|
||||||
/// furnished to do so, subject to the following conditions:
|
/// furnished to do so, subject to the following conditions:
|
||||||
///
|
///
|
||||||
/// The above copyright notice and this permission notice shall be included in
|
/// The above copyright notice and this permission notice shall be included in
|
||||||
/// all copies or substantial portions of the Software.
|
/// all copies or substantial portions of the Software.
|
||||||
///
|
///
|
||||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
/// 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
|
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
/// THE SOFTWARE.
|
/// THE SOFTWARE.
|
||||||
///
|
///
|
||||||
/// @ref core
|
/// @ref core
|
||||||
/// @file glm/core/dummy.cpp
|
/// @file glm/core/dummy.cpp
|
||||||
/// @date 2011-01-19 / 2011-06-15
|
/// @date 2011-01-19 / 2011-06-15
|
||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///
|
///
|
||||||
/// GLM is a header only library. There is nothing to compile.
|
/// GLM is a header only library. There is nothing to compile.
|
||||||
/// dummy.cpp exist only a wordaround for CMake file.
|
/// dummy.cpp exist only a wordaround for CMake file.
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
#define GLM_MESSAGES
|
#define GLM_MESSAGES
|
||||||
#include "../glm.hpp"
|
#include "../glm.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
/*
|
|
||||||
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
struct material
|
||||||
struct float4
|
{
|
||||||
{
|
glm::vec4 emission; // Ecm
|
||||||
union
|
glm::vec4 ambient; // Acm
|
||||||
{
|
glm::vec4 diffuse; // Dcm
|
||||||
struct {float r, g, b, a;};
|
glm::vec4 specular; // Scm
|
||||||
struct {float s, t, p, q;};
|
float shininess; // Srm
|
||||||
struct {float x, y, z, w;};
|
};
|
||||||
__m128 data;
|
struct light
|
||||||
};
|
{
|
||||||
};
|
glm::vec4 ambient; // Acli
|
||||||
|
glm::vec4 diffuse; // Dcli
|
||||||
int test_simd()
|
glm::vec4 specular; // Scli
|
||||||
{
|
glm::vec4 position; // Ppli
|
||||||
float4 f;
|
glm::vec4 halfVector; // Derived: Hi
|
||||||
|
glm::vec3 spotDirection; // Sdli
|
||||||
|
float spotExponent; // Srli
|
||||||
|
float spotCutoff; // Crli
|
||||||
return 0;
|
// (range: [0.0,90.0], 180.0)
|
||||||
}
|
float spotCosCutoff; // Derived: cos(Crli)
|
||||||
|
// (range: [1.0,0.0],-1.0)
|
||||||
#endif//GLM_ARCH
|
float constantAttenuation; // K0
|
||||||
*/
|
float linearAttenuation; // K1
|
||||||
|
float quadraticAttenuation;// K2
|
||||||
template <class T = int>
|
};
|
||||||
class C;
|
|
||||||
|
// Sample 1
|
||||||
template <class T>
|
#include <glm/vec3.hpp>// glm::vec3
|
||||||
class C
|
#include <glm/geometric.hpp>// glm::cross, glm::normalize
|
||||||
{
|
|
||||||
public:
|
glm::vec3 computeNormal
|
||||||
T value;
|
(
|
||||||
};
|
glm::vec3 const & a,
|
||||||
|
glm::vec3 const & b,
|
||||||
int main()
|
glm::vec3 const & c
|
||||||
{
|
)
|
||||||
/*
|
{
|
||||||
# if(GLM_ARCH & GLM_ARCH_SSE2)
|
return glm::normalize(glm::cross(c - a, b - a));
|
||||||
test_simd();
|
}
|
||||||
# endif
|
|
||||||
*/
|
typedef unsigned int GLuint;
|
||||||
|
#define GL_FALSE 0
|
||||||
C<> c;
|
void glUniformMatrix4fv(GLuint, int, int, float*){}
|
||||||
|
|
||||||
return 0;
|
// 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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -197,12 +197,22 @@ namespace detail
|
|||||||
// sqrt
|
// sqrt
|
||||||
GLM_FUNC_QUALIFIER float sqrt(float x)
|
GLM_FUNC_QUALIFIER float sqrt(float x)
|
||||||
{
|
{
|
||||||
return detail::compute_sqrt<detail::tvec1, float, highp>::call(x).x;
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
|
detail::tvec1<float, highp> tmp(detail::compute_sqrt<detail::tvec1, float, highp>::call(x));
|
||||||
|
return tmp.x;
|
||||||
|
# else
|
||||||
|
return detail::compute_sqrt<detail::tvec1, float, highp>::call(x).x;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER double sqrt(double x)
|
GLM_FUNC_QUALIFIER double sqrt(double x)
|
||||||
{
|
{
|
||||||
return detail::compute_sqrt<detail::tvec1, double, highp>::call(x).x;
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
|
detail::tvec1<double, highp> tmp(detail::compute_sqrt<detail::tvec1, double, highp>::call(x));
|
||||||
|
return tmp.x;
|
||||||
|
# else
|
||||||
|
return detail::compute_sqrt<detail::tvec1, double, highp>::call(x).x;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
@ -43,7 +43,12 @@ namespace detail
|
|||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static T call(detail::tvec1<T, P> const & x, detail::tvec1<T, P> const & y)
|
GLM_FUNC_QUALIFIER static T call(detail::tvec1<T, P> const & x, detail::tvec1<T, P> const & y)
|
||||||
{
|
{
|
||||||
return detail::tvec1<T, P>(x * y).x;
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
|
detail::tvec1<T, P> tmp(x * y);
|
||||||
|
return tmp.x;
|
||||||
|
# else
|
||||||
|
return detail::tvec1<T, P>(x * y).x;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ namespace glm
|
|||||||
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
|
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
|
||||||
|
|
||||||
Borrow = x >= y ? static_cast<uint32>(0) : static_cast<uint32>(1);
|
Borrow = x >= y ? static_cast<uint32>(0) : static_cast<uint32>(1);
|
||||||
if(x > y)
|
if(y >= x)
|
||||||
return static_cast<uint32>(static_cast<int64>(x) -static_cast<int64>(y));
|
return y - x;
|
||||||
else
|
else
|
||||||
return static_cast<uint32>((static_cast<int64>(1) << static_cast<int64>(32)) + static_cast<int64>(x) - static_cast<int64>(y));
|
return static_cast<uint32>((static_cast<int64>(1) << static_cast<int64>(32)) + (static_cast<int64>(y) - static_cast<int64>(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -171,8 +171,10 @@ namespace glm
|
|||||||
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
|
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
|
||||||
|
|
||||||
uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y);
|
uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y);
|
||||||
msb = *(reinterpret_cast<uint32*>(&Value64) + 1);
|
uint32* PointerMSB = (reinterpret_cast<uint32*>(&Value64) + 1);
|
||||||
lsb = reinterpret_cast<uint32&>(Value64);
|
msb = *PointerMSB;
|
||||||
|
uint32* PointerLSB = (reinterpret_cast<uint32*>(&Value64) + 0);
|
||||||
|
lsb = *PointerLSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -230,8 +232,10 @@ namespace glm
|
|||||||
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch");
|
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch");
|
||||||
|
|
||||||
int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y);
|
int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y);
|
||||||
msb = *(reinterpret_cast<int32*>(&Value64) + 1);
|
int32* PointerMSB = (reinterpret_cast<int32*>(&Value64) + 1);
|
||||||
lsb = reinterpret_cast<int32&>(Value64);
|
msb = *PointerMSB;
|
||||||
|
int32* PointerLSB = (reinterpret_cast<int32*>(&Value64));
|
||||||
|
lsb = *PointerLSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -214,7 +214,7 @@ namespace glm
|
|||||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
||||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||||
return detail::nextafterf(x, std::numeric_limits<double>::max());
|
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||||
# else
|
# else
|
||||||
return nextafter(x, DBL_MAX);
|
return nextafter(x, DBL_MAX);
|
||||||
# endif
|
# endif
|
||||||
|
@ -420,6 +420,62 @@ namespace glm
|
|||||||
return REG1 | (REG2 << 1);
|
return REG1 | (REG2 << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint8 x, glm::uint8 y, glm::uint8 z)
|
||||||
|
{
|
||||||
|
glm::uint32 REG1(x);
|
||||||
|
glm::uint32 REG2(y);
|
||||||
|
glm::uint32 REG3(z);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 16) | REG1) & glm::uint32(0x00FF0000FF0000FF);
|
||||||
|
REG2 = ((REG2 << 16) | REG2) & glm::uint32(0x00FF0000FF0000FF);
|
||||||
|
REG3 = ((REG3 << 16) | REG3) & glm::uint32(0x00FF0000FF0000FF);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 8) | REG1) & glm::uint32(0xF00F00F00F00F00F);
|
||||||
|
REG2 = ((REG2 << 8) | REG2) & glm::uint32(0xF00F00F00F00F00F);
|
||||||
|
REG3 = ((REG3 << 8) | REG3) & glm::uint32(0xF00F00F00F00F00F);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 4) | REG1) & glm::uint32(0x30C30C30C30C30C3);
|
||||||
|
REG2 = ((REG2 << 4) | REG2) & glm::uint32(0x30C30C30C30C30C3);
|
||||||
|
REG3 = ((REG3 << 4) | REG3) & glm::uint32(0x30C30C30C30C30C3);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 2) | REG1) & glm::uint32(0x9249249249249249);
|
||||||
|
REG2 = ((REG2 << 2) | REG2) & glm::uint32(0x9249249249249249);
|
||||||
|
REG3 = ((REG3 << 2) | REG3) & glm::uint32(0x9249249249249249);
|
||||||
|
|
||||||
|
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z)
|
||||||
|
{
|
||||||
|
glm::uint64 REG1(x);
|
||||||
|
glm::uint64 REG2(y);
|
||||||
|
glm::uint64 REG3(z);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 32) | REG1) & glm::uint64(0xFFFF00000000FFFF);
|
||||||
|
REG2 = ((REG2 << 32) | REG2) & glm::uint64(0xFFFF00000000FFFF);
|
||||||
|
REG3 = ((REG3 << 32) | REG3) & glm::uint64(0xFFFF00000000FFFF);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FF);
|
||||||
|
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FF);
|
||||||
|
REG3 = ((REG3 << 16) | REG3) & glm::uint64(0x00FF0000FF0000FF);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0xF00F00F00F00F00F);
|
||||||
|
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0xF00F00F00F00F00F);
|
||||||
|
REG3 = ((REG3 << 8) | REG3) & glm::uint64(0xF00F00F00F00F00F);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3);
|
||||||
|
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3);
|
||||||
|
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249);
|
||||||
|
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249);
|
||||||
|
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249);
|
||||||
|
|
||||||
|
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y, glm::uint32 z)
|
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y, glm::uint32 z)
|
||||||
{
|
{
|
||||||
@ -450,6 +506,32 @@ namespace glm
|
|||||||
return REG1 | (REG2 << 1) | (REG3 << 2);
|
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint8 x, glm::uint8 y, glm::uint8 z, glm::uint8 w)
|
||||||
|
{
|
||||||
|
glm::uint32 REG1(x);
|
||||||
|
glm::uint32 REG2(y);
|
||||||
|
glm::uint32 REG3(z);
|
||||||
|
glm::uint32 REG4(w);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 12) | REG1) & glm::uint32(0x000F000F000F000F);
|
||||||
|
REG2 = ((REG2 << 12) | REG2) & glm::uint32(0x000F000F000F000F);
|
||||||
|
REG3 = ((REG3 << 12) | REG3) & glm::uint32(0x000F000F000F000F);
|
||||||
|
REG4 = ((REG4 << 12) | REG4) & glm::uint32(0x000F000F000F000F);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 6) | REG1) & glm::uint32(0x0303030303030303);
|
||||||
|
REG2 = ((REG2 << 6) | REG2) & glm::uint32(0x0303030303030303);
|
||||||
|
REG3 = ((REG3 << 6) | REG3) & glm::uint32(0x0303030303030303);
|
||||||
|
REG4 = ((REG4 << 6) | REG4) & glm::uint32(0x0303030303030303);
|
||||||
|
|
||||||
|
REG1 = ((REG1 << 3) | REG1) & glm::uint32(0x1111111111111111);
|
||||||
|
REG2 = ((REG2 << 3) | REG2) & glm::uint32(0x1111111111111111);
|
||||||
|
REG3 = ((REG3 << 3) | REG3) & glm::uint32(0x1111111111111111);
|
||||||
|
REG4 = ((REG4 << 3) | REG4) & glm::uint32(0x1111111111111111);
|
||||||
|
|
||||||
|
return REG1 | (REG2 << 1) | (REG3 << 2) | (REG4 << 3);
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w)
|
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w)
|
||||||
{
|
{
|
||||||
|
@ -70,10 +70,10 @@ namespace glm
|
|||||||
T sinY = glm::sin(angleY);
|
T sinY = glm::sin(angleY);
|
||||||
|
|
||||||
return detail::tmat4x4<T, defaultp>(
|
return detail::tmat4x4<T, defaultp>(
|
||||||
cosY, -sinX * sinY, cosX * sinY, T(0),
|
cosY, -sinX * -sinY, cosX * -sinY, T(0),
|
||||||
T(0), cosX, sinX, T(0),
|
T(0), cosX, sinX, T(0),
|
||||||
-sinY, -sinX * cosY, cosX * cosY, T(0),
|
sinY, -sinX * cosY, cosX * cosY, T(0),
|
||||||
T(0), T(0), T(0), T(1));
|
T(0), T(0), T(0), T(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -89,10 +89,10 @@ namespace glm
|
|||||||
T sinY = glm::sin(angleY);
|
T sinY = glm::sin(angleY);
|
||||||
|
|
||||||
return detail::tmat4x4<T, defaultp>(
|
return detail::tmat4x4<T, defaultp>(
|
||||||
cosY, T(0), sinY, T(0),
|
cosY, 0, -sinY, T(0),
|
||||||
-sinX * sinY, cosX, sinX * cosY, T(0),
|
sinY * sinX, cosX, cosY * sinX, T(0),
|
||||||
-cosX * sinY, -sinX, cosX * cosY, T(0),
|
sinY * cosX, -sinX, cosY * cosX, T(0),
|
||||||
T(0), T(0), T(0), T(1));
|
T(0), T(0), T(0), T(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -115,6 +115,26 @@ namespace glm
|
|||||||
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> eulerAngleYZ
|
||||||
|
(
|
||||||
|
T const & angleY,
|
||||||
|
T const & angleZ
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return eulerAngleY(angleY) * eulerAngleZ(angleZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> eulerAngleZY
|
||||||
|
(
|
||||||
|
T const & angleZ,
|
||||||
|
T const & angleY
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return eulerAngleZ(angleZ) * eulerAngleY(angleY);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> eulerAngleYXZ
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> eulerAngleYXZ
|
||||||
(
|
(
|
||||||
|
@ -27,13 +27,23 @@ namespace glm
|
|||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER float fastInverseSqrt<float>(float const & x)
|
GLM_FUNC_QUALIFIER float fastInverseSqrt<float>(float const & x)
|
||||||
{
|
{
|
||||||
return detail::compute_inversesqrt<detail::tvec1, float, lowp>::call(detail::tvec1<float, lowp>(x)).x;
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
|
detail::tvec1<T, P> tmp(detail::compute_inversesqrt<detail::tvec1, float, lowp>::call(detail::tvec1<float, lowp>(x)));
|
||||||
|
return tmp.x;
|
||||||
|
# else
|
||||||
|
return detail::compute_inversesqrt<detail::tvec1, float, lowp>::call(detail::tvec1<float, lowp>(x)).x;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER double fastInverseSqrt<double>(double const & x)
|
GLM_FUNC_QUALIFIER double fastInverseSqrt<double>(double const & x)
|
||||||
{
|
{
|
||||||
return detail::compute_inversesqrt<detail::tvec1, double, lowp>::call(detail::tvec1<double, lowp>(x)).x;
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
|
detail::tvec1<T, P> tmp(detail::compute_inversesqrt<detail::tvec1, double, lowp>::call(detail::tvec1<double, lowp>(x)));
|
||||||
|
return tmp.x;
|
||||||
|
# else
|
||||||
|
return detail::compute_inversesqrt<detail::tvec1, double, lowp>::call(detail::tvec1<double, lowp>(x)).x;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template <class, precision> class vecType, typename T, precision P>
|
template <template <class, precision> class vecType, typename T, precision P>
|
||||||
|
@ -46,8 +46,6 @@
|
|||||||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||||
|
|
||||||
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
||||||
# include "../core/intrinsic_common.hpp"
|
|
||||||
# include "../core/intrinsic_geometric.hpp"
|
|
||||||
# include "../gtx/simd_mat4.hpp"
|
# include "../gtx/simd_mat4.hpp"
|
||||||
#else
|
#else
|
||||||
# error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
|
# error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
|
||||||
|
@ -194,7 +194,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD operator* (fquatSIMD const & q, fvec4SIMD const & v
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v, fquatSIMD const & q)
|
GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v, fquatSIMD const & q)
|
||||||
{
|
{
|
||||||
return inverse(q) * v;
|
return glm::inverse(q) * v;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER fquatSIMD operator* (fquatSIMD const & q, float s)
|
GLM_FUNC_QUALIFIER fquatSIMD operator* (fquatSIMD const & q, float s)
|
||||||
|
@ -45,7 +45,7 @@ GLM 0.9.6.0: 2014-XX-XX
|
|||||||
- Added move contructors and assignment operators (#141)
|
- Added move contructors and assignment operators (#141)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.5.3: 2014-0X-XX
|
GLM 0.9.5.3: 2014-04-02
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
- Added instruction set auto detection with Visual C++ using _M_IX86_FP - /arch
|
- Added instruction set auto detection with Visual C++ using _M_IX86_FP - /arch
|
||||||
compiler argument
|
compiler argument
|
||||||
@ -54,6 +54,12 @@ GLM 0.9.5.3: 2014-0X-XX
|
|||||||
- Added GLM_GTX_matrix_transform_2d extension (#178, #176)
|
- Added GLM_GTX_matrix_transform_2d extension (#178, #176)
|
||||||
- Fixed CUDA issues (#169, #168, #183, #182)
|
- Fixed CUDA issues (#169, #168, #183, #182)
|
||||||
- Added support for all extensions but GTX_string_cast to CUDA
|
- Added support for all extensions but GTX_string_cast to CUDA
|
||||||
|
- Fixed strict aliasing warnings in GCC 4.8.1 / Android NDK 9c (#152)
|
||||||
|
- Fixed missing bitfieldInterleave definisions
|
||||||
|
- Fixed usubBorrow (#171)
|
||||||
|
- Fixed eulerAngle*** not consistent for right-handed coordinate system (#173)
|
||||||
|
- Added full tests for eulerAngle*** functions (#173)
|
||||||
|
- Added workaround for a CUDA compiler bug (#186, #185)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.5.2: 2014-02-08
|
GLM 0.9.5.2: 2014-02-08
|
||||||
|
@ -197,14 +197,14 @@ namespace findLSB
|
|||||||
genType Value;
|
genType Value;
|
||||||
genType Return;
|
genType Return;
|
||||||
};
|
};
|
||||||
|
|
||||||
type<int> const DataI32[] =
|
type<int> const DataI32[] =
|
||||||
{
|
{
|
||||||
{0x00000001, 0},
|
{0x00000001, 0},
|
||||||
{0x00000003, 0},
|
{0x00000003, 0},
|
||||||
{0x00000002, 1}
|
{0x00000002, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
int test()
|
int test()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
@ -215,11 +215,27 @@ namespace findLSB
|
|||||||
Error += DataI32[i].Return == Result ? 0 : 1;
|
Error += DataI32[i].Return == Result ? 0 : 1;
|
||||||
assert(!Error);
|
assert(!Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
}//findLSB
|
}//findLSB
|
||||||
|
|
||||||
|
namespace usubBorrow
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
glm::uint x = 16;
|
||||||
|
glm::uint y = 17;
|
||||||
|
glm::uint Borrow = 0;
|
||||||
|
glm::uint Result = glm::usubBorrow(x, y, Borrow);
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//namespace usubBorrow
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
@ -11,33 +11,328 @@
|
|||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
#include <glm/gtc/epsilon.hpp>
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
#include <glm/gtx/euler_angles.hpp>
|
#include <glm/gtx/euler_angles.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace glm;
|
namespace test_eulerAngleX
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
float const Angle(glm::pi<float>() * 0.5f);
|
||||||
|
glm::vec3 const X(1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::vec4 const Y(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec4 const Y1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Y;
|
||||||
|
glm::vec4 const Y2 = glm::eulerAngleX(Angle) * Y;
|
||||||
|
glm::vec4 const Y3 = glm::eulerAngleXY(Angle, 0.0f) * Y;
|
||||||
|
glm::vec4 const Y4 = glm::eulerAngleYX(0.0f, Angle) * Y;
|
||||||
|
glm::vec4 const Y5 = glm::eulerAngleXZ(Angle, 0.0f) * Y;
|
||||||
|
glm::vec4 const Y6 = glm::eulerAngleZX(0.0f, Angle) * Y;
|
||||||
|
glm::vec4 const Y7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Y;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Y1, Y7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Z;
|
||||||
|
glm::vec4 const Z2 = glm::eulerAngleX(Angle) * Z;
|
||||||
|
glm::vec4 const Z3 = glm::eulerAngleXY(Angle, 0.0f) * Z;
|
||||||
|
glm::vec4 const Z4 = glm::eulerAngleYX(0.0f, Angle) * Z;
|
||||||
|
glm::vec4 const Z5 = glm::eulerAngleXZ(Angle, 0.0f) * Z;
|
||||||
|
glm::vec4 const Z6 = glm::eulerAngleZX(0.0f, Angle) * Z;
|
||||||
|
glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Z;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleX
|
||||||
|
|
||||||
|
namespace test_eulerAngleY
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
float const Angle(glm::pi<float>() * 0.5f);
|
||||||
|
glm::vec3 const Y(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Y) * X;
|
||||||
|
glm::vec4 const X2 = glm::eulerAngleY(Angle) * X;
|
||||||
|
glm::vec4 const X3 = glm::eulerAngleYX(Angle, 0.0f) * X;
|
||||||
|
glm::vec4 const X4 = glm::eulerAngleXY(0.0f, Angle) * X;
|
||||||
|
glm::vec4 const X5 = glm::eulerAngleYZ(Angle, 0.0f) * X;
|
||||||
|
glm::vec4 const X6 = glm::eulerAngleZY(0.0f, Angle) * X;
|
||||||
|
glm::vec4 const X7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * X;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
glm::vec4 const Z1 = glm::eulerAngleY(Angle) * Z;
|
||||||
|
glm::vec4 const Z2 = glm::rotate(glm::mat4(1.0f), Angle, Y) * Z;
|
||||||
|
glm::vec4 const Z3 = glm::eulerAngleYX(Angle, 0.0f) * Z;
|
||||||
|
glm::vec4 const Z4 = glm::eulerAngleXY(0.0f, Angle) * Z;
|
||||||
|
glm::vec4 const Z5 = glm::eulerAngleYZ(Angle, 0.0f) * Z;
|
||||||
|
glm::vec4 const Z6 = glm::eulerAngleZY(0.0f, Angle) * Z;
|
||||||
|
glm::vec4 const Z7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * Z;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleY
|
||||||
|
|
||||||
|
namespace test_eulerAngleZ
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
float const Angle(glm::pi<float>() * 0.5f);
|
||||||
|
glm::vec3 const Z(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * X;
|
||||||
|
glm::vec4 const X2 = glm::eulerAngleZ(Angle) * X;
|
||||||
|
glm::vec4 const X3 = glm::eulerAngleZX(Angle, 0.0f) * X;
|
||||||
|
glm::vec4 const X4 = glm::eulerAngleXZ(0.0f, Angle) * X;
|
||||||
|
glm::vec4 const X5 = glm::eulerAngleZY(Angle, 0.0f) * X;
|
||||||
|
glm::vec4 const X6 = glm::eulerAngleYZ(0.0f, Angle) * X;
|
||||||
|
glm::vec4 const X7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * X;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
glm::vec4 const Y(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * Y;
|
||||||
|
glm::vec4 const Z2 = glm::eulerAngleZ(Angle) * Y;
|
||||||
|
glm::vec4 const Z3 = glm::eulerAngleZX(Angle, 0.0f) * Y;
|
||||||
|
glm::vec4 const Z4 = glm::eulerAngleXZ(0.0f, Angle) * Y;
|
||||||
|
glm::vec4 const Z5 = glm::eulerAngleZY(Angle, 0.0f) * Y;
|
||||||
|
glm::vec4 const Z6 = glm::eulerAngleYZ(0.0f, Angle) * Y;
|
||||||
|
glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * Y;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleZ
|
||||||
|
|
||||||
|
namespace test_eulerAngleXY
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleX(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleY(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleXY(AngleX, AngleY) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleY(AngleY) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleXY
|
||||||
|
|
||||||
|
namespace test_eulerAngleYX
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleX(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleY(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleYX(AngleY, AngleX) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleX(AngleX) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleYX
|
||||||
|
|
||||||
|
namespace test_eulerAngleXZ
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleX(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleZ(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleXZ(AngleX, AngleZ) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleZ(AngleZ) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleXZ
|
||||||
|
|
||||||
|
namespace test_eulerAngleZX
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleX(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleZ(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleZX(AngleZ, AngleX) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleX(AngleX) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleZX
|
||||||
|
|
||||||
|
namespace test_eulerAngleYZ
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleY(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleZ(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
|
||||||
|
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleYZ(AngleY, AngleZ) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleZ(AngleZ) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleYZ
|
||||||
|
|
||||||
|
namespace test_eulerAngleZY
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec4 const V(1.0f);
|
||||||
|
|
||||||
|
float const AngleY(glm::pi<float>() * 0.5f);
|
||||||
|
float const AngleZ(glm::pi<float>() * 0.25f);
|
||||||
|
|
||||||
|
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
|
||||||
|
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
|
||||||
|
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V;
|
||||||
|
glm::vec4 const V2 = glm::eulerAngleZY(AngleZ, AngleY) * V;
|
||||||
|
glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleY(AngleY) * V;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace test_eulerAngleZY
|
||||||
|
|
||||||
|
namespace test_eulerAngleYXZ
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
glm::f32 first = 1.046f;
|
||||||
|
glm::f32 second = 0.52f;
|
||||||
|
glm::f32 third = -0.785f;
|
||||||
|
|
||||||
|
glm::fmat4 rotationEuler = glm::eulerAngleYXZ(first, second, third);
|
||||||
|
|
||||||
|
glm::fmat4 rotationInvertedY = glm::eulerAngleY(-1.f*first) * glm::eulerAngleX(second) * glm::eulerAngleZ(third);
|
||||||
|
glm::fmat4 rotationDumb = glm::fmat4();
|
||||||
|
rotationDumb = glm::rotate(rotationDumb, first, glm::fvec3(0,1,0));
|
||||||
|
rotationDumb = glm::rotate(rotationDumb, second, glm::fvec3(1,0,0));
|
||||||
|
rotationDumb = glm::rotate(rotationDumb, third, glm::fvec3(0,0,1));
|
||||||
|
|
||||||
|
std::cout << glm::to_string(glm::fmat3(rotationEuler)) << std::endl;
|
||||||
|
std::cout << glm::to_string(glm::fmat3(rotationDumb)) << std::endl;
|
||||||
|
std::cout << glm::to_string(glm::fmat3(rotationInvertedY )) << std::endl;
|
||||||
|
|
||||||
|
std::cout <<"\nRESIDUAL\n";
|
||||||
|
std::cout << glm::to_string(glm::fmat3(rotationEuler-(rotationDumb))) << std::endl;
|
||||||
|
std::cout << glm::to_string(glm::fmat3(rotationEuler-(rotationInvertedY ))) << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}//namespace eulerAngleYXZ
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
f32 first = 1.046f;
|
int Error = 0;
|
||||||
f32 second = 0.52f;
|
|
||||||
f32 third = -0.785f;
|
|
||||||
|
|
||||||
fmat4 rotationEuler = eulerAngleYXZ(first, second, third);
|
Error += test_eulerAngleX::test();
|
||||||
|
Error += test_eulerAngleY::test();
|
||||||
|
Error += test_eulerAngleZ::test();
|
||||||
|
Error += test_eulerAngleXY::test();
|
||||||
|
Error += test_eulerAngleYX::test();
|
||||||
|
Error += test_eulerAngleXZ::test();
|
||||||
|
Error += test_eulerAngleZX::test();
|
||||||
|
Error += test_eulerAngleYZ::test();
|
||||||
|
Error += test_eulerAngleZY::test();
|
||||||
|
Error += test_eulerAngleYXZ::test();
|
||||||
|
|
||||||
fmat4 rotationInvertedY = eulerAngleY(-1.f*first) * eulerAngleX(second) * eulerAngleZ(third);
|
return Error;
|
||||||
fmat4 rotationDumb = glm::fmat4();
|
|
||||||
rotationDumb = rotate(rotationDumb, first, glm::fvec3(0,1,0));
|
|
||||||
rotationDumb = rotate(rotationDumb, second, glm::fvec3(1,0,0));
|
|
||||||
rotationDumb = rotate(rotationDumb, third, glm::fvec3(0,0,1));
|
|
||||||
|
|
||||||
std::cout << glm::to_string(fmat3(rotationEuler)) << std::endl;
|
|
||||||
std::cout << glm::to_string(fmat3(rotationDumb)) << std::endl;
|
|
||||||
std::cout << glm::to_string(fmat3(rotationInvertedY )) << std::endl;
|
|
||||||
|
|
||||||
std::cout <<"\nRESIDUAL\n";
|
|
||||||
std::cout << glm::to_string(fmat3(rotationEuler-(rotationDumb))) << std::endl;
|
|
||||||
std::cout << glm::to_string(fmat3(rotationEuler-(rotationInvertedY ))) << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user