mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-07 09:13:22 +08:00
Update GLM to latest version (0.9.9.3). This includes GLM's change of matrices no longer default initializing to the identity matrix. This commit thus also includes the update of all of LearnOpenGL's code to reflect this: all matrices are now constructor-initialized to the identity matrix where relevant.
This commit is contained in:
@@ -1,51 +1,21 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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_fast_exponential
|
||||
/// @file glm/gtx/fast_exponential.inl
|
||||
/// @date 2006-01-09 / 2011-06-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
// fastPow:
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastPow(genType x, genType y)
|
||||
{
|
||||
return exp(y * log(x));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastPow(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastPow(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
|
||||
{
|
||||
return exp(y * log(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fastPow(T x, int y)
|
||||
{
|
||||
T f = static_cast<T>(1);
|
||||
@@ -54,18 +24,18 @@ namespace glm
|
||||
return f;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastPow(vecType<T, P> const & x, vecType<int, P> const & y)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastPow(vec<L, T, Q> const& x, vec<L, int, Q> const& y)
|
||||
{
|
||||
vecType<T, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = x.length(); i < n; ++i)
|
||||
Result[i] = fastPow(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
// fastExp
|
||||
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fastExp(T x)
|
||||
{
|
||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||
@@ -110,14 +80,14 @@ namespace glm
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastExp(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastExp(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(fastExp, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(fastExp, x);
|
||||
}
|
||||
|
||||
// fastLog
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLog(genType x)
|
||||
{
|
||||
return std::log(x);
|
||||
@@ -132,35 +102,35 @@ namespace glm
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastLog(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastLog(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(fastLog, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(fastLog, x);
|
||||
}
|
||||
|
||||
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastExp2(genType x)
|
||||
{
|
||||
return fastExp(0.69314718055994530941723212145818f * x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastExp2(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastExp2(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(fastExp2, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(fastExp2, x);
|
||||
}
|
||||
|
||||
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLog2(genType x)
|
||||
{
|
||||
return fastLog(x) / 0.69314718055994530941723212145818f;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> fastLog2(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastLog2(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(fastLog2, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(fastLog2, x);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
Reference in New Issue
Block a user