mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-07 09:13:22 +08:00
Updated GLM version w/ now standard radians as angles.
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2005-12-24
|
||||
// Updated : 2011-10-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/integer.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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_integer
|
||||
/// @file glm/gtx/integer.inl
|
||||
/// @date 2005-12-24 / 2011-10-13
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
@@ -38,7 +61,7 @@ namespace glm
|
||||
}
|
||||
|
||||
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
|
||||
namespace _detail
|
||||
namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x)
|
||||
{
|
||||
@@ -53,22 +76,7 @@ namespace _detail
|
||||
x += (x >> 16);
|
||||
return(x & 0x0000003f);
|
||||
}
|
||||
|
||||
template <>
|
||||
struct _compute_log2<detail::float_or_int_value::GLM_INT>
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
|
||||
{
|
||||
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
|
||||
return Value <= T(1) ? T(0) : T(32) - nlz(Value - T(1));
|
||||
#else
|
||||
return T(32) - nlz(Value - T(1));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
}//namespace _detail
|
||||
}//namespace detail
|
||||
|
||||
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
|
||||
/*
|
||||
@@ -100,30 +108,30 @@ namespace _detail
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
|
||||
detail::tvec2<valType> const & x)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec2<T, P> factorial(
|
||||
tvec2<T, P> const & x)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
return tvec2<T, P>(
|
||||
factorial(x.x),
|
||||
factorial(x.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
|
||||
detail::tvec3<valType> const & x)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> factorial(
|
||||
tvec3<T, P> const & x)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
return tvec3<T, P>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
|
||||
detail::tvec4<valType> const & x)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> factorial(
|
||||
tvec4<T, P> const & x)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
return tvec4<T, P>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z),
|
||||
@@ -171,31 +179,31 @@ namespace _detail
|
||||
// Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt
|
||||
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
|
||||
{
|
||||
int y, m, n;
|
||||
int y, m, n;
|
||||
|
||||
y = -int(x >> 16); // If left half of x is 0,
|
||||
m = (y >> 16) & 16; // set n = 16. If left half
|
||||
n = 16 - m; // is nonzero, set n = 0 and
|
||||
x = x >> m; // shift x right 16.
|
||||
y = -int(x >> 16); // If left half of x is 0,
|
||||
m = (y >> 16) & 16; // set n = 16. If left half
|
||||
n = 16 - m; // is nonzero, set n = 0 and
|
||||
x = x >> m; // shift x right 16.
|
||||
// Now x is of the form 0000xxxx.
|
||||
y = x - 0x100; // If positions 8-15 are 0,
|
||||
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = x - 0x100; // If positions 8-15 are 0,
|
||||
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x1000; // If positions 12-15 are 0,
|
||||
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = x - 0x1000; // If positions 12-15 are 0,
|
||||
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x4000; // If positions 14-15 are 0,
|
||||
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = x - 0x4000; // If positions 14-15 are 0,
|
||||
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x >> 14; // Set y = 0, 1, 2, or 3.
|
||||
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
|
||||
return unsigned(n + 2 - m);
|
||||
y = x >> 14; // Set y = 0, 1, 2, or 3.
|
||||
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
|
||||
return unsigned(n + 2 - m);
|
||||
}
|
||||
|
||||
#endif//(GLM_COMPILER)
|
||||
|
||||
Reference in New Issue
Block a user