mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
5441bc7a93
@ -508,6 +508,22 @@
|
||||
# define GLM_HAS_OPENMP 0
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// nullptr
|
||||
|
||||
//
|
||||
#if GLM_LANG & GLM_LANG_CXX0X_FLAG
|
||||
# define GLM_HAS_NULLPTR 1
|
||||
#else
|
||||
# define GLM_HAS_NULLPTR 0
|
||||
#endif
|
||||
|
||||
#if GLM_HAS_NULLPTR
|
||||
# define GLM_NULLPTR nullptr
|
||||
#else
|
||||
# define GLM_NULLPTR 0
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Static assert
|
||||
|
||||
|
@ -142,6 +142,9 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> operator+(tquat<T, Q> const& q, tquat<T, Q> const& p);
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> operator-(tquat<T, Q> const& q, tquat<T, Q> const& p);
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> operator*(tquat<T, Q> const& q, tquat<T, Q> const& p);
|
||||
|
||||
|
@ -200,7 +200,7 @@ namespace detail
|
||||
return mat3_cast(*this);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, Q>::operator mat<4, 4, T, Q>()
|
||||
{
|
||||
return mat4_cast(*this);
|
||||
@ -308,6 +308,12 @@ namespace detail
|
||||
return tquat<T, Q>(q) += p;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, Q> operator-(tquat<T, Q> const& q, tquat<T, Q> const& p)
|
||||
{
|
||||
return tquat<T, Q>(q) -= p;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, Q> operator*(tquat<T, Q> const& q, tquat<T, Q> const& p)
|
||||
{
|
||||
|
@ -340,13 +340,12 @@ namespace detail
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, defaultp> sphericalRand(T Radius)
|
||||
{
|
||||
T z = linearRand(T(-1), T(1));
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
T theta = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
T phi = std::acos(linearRand(T(-1.0f), T(1.0f)));
|
||||
|
||||
T r = sqrt(T(1) - z * z);
|
||||
|
||||
T x = r * std::cos(a);
|
||||
T y = r * std::sin(a);
|
||||
T x = std::sin(phi) * std::cos(theta);
|
||||
T y = std::sin(phi) * std::sin(theta);
|
||||
T z = std::cos(phi);
|
||||
|
||||
return vec<3, T, defaultp>(x, y, z) * Radius;
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ namespace glm
|
||||
typename genType::value_type & intersectionDistance);
|
||||
|
||||
//! Compute the intersection of a ray and a triangle.
|
||||
/// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
|
||||
/// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
|
||||
//! From GLM_GTX_intersect extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL bool intersectRayTriangle(
|
||||
vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
|
||||
vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2,
|
||||
vec<3, T, Q>& baryPosition, T& distance);
|
||||
vec<2, T, Q>& baryPosition, T& distance);
|
||||
|
||||
//! Compute the intersection of a line and a triangle.
|
||||
//! From GLM_GTX_intersect extension.
|
||||
|
@ -9,7 +9,7 @@
|
||||
///
|
||||
/// Include <glm/gtx/matrix_interpolation.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Allows to directly interpolate two exiciting matrices.
|
||||
/// Allows to directly interpolate two matrices.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace detail
|
||||
char text[STRING_BUFFER];
|
||||
va_list list;
|
||||
|
||||
if(msg == 0)
|
||||
if(msg == GLM_NULLPTR)
|
||||
return std::string();
|
||||
|
||||
va_start(list, msg);
|
||||
|
@ -227,7 +227,8 @@ int test_ctr()
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 1} };
|
||||
|
||||
Error += glm::equal(m4[0][3], 1.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::equal(m4[0][0], 1.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::equal(m4[3][3], 1.0f, 0.0001f) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat4> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
|
@ -525,17 +525,17 @@ static int test_inheritance()
|
||||
{
|
||||
my_vec4()
|
||||
: glm::vec4(76.f, 75.f, 74.f, 73.f)
|
||||
, data(82)
|
||||
, member(82)
|
||||
{}
|
||||
|
||||
int data;
|
||||
int member;
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
my_vec4 v;
|
||||
|
||||
Error += v.data == 82 ? 0 : 1;
|
||||
Error += v.member == 82 ? 0 : 1;
|
||||
Error += glm::epsilonEqual(v.x, 76.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(v.y, 75.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(v.z, 74.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
@ -24,7 +24,7 @@ int test_axisAngle()
|
||||
float dltAngle = 0.0f;
|
||||
glm::axisAngle(dltRotation, dltAxis, dltAngle);
|
||||
|
||||
std::cout << "dltAngle: (" << dltAxis.x << ", " << dltAxis.y << ", " << dltAxis.z << "), dltAngle: " << dltAngle << std::endl;
|
||||
std::cout << "dltAxis: (" << dltAxis.x << ", " << dltAxis.y << ", " << dltAxis.z << "), dltAngle: " << dltAngle << std::endl;
|
||||
|
||||
glm::fquat q = glm::quat_cast(dltRotation);
|
||||
std::cout << "q: (" << q.x << ", " << q.y << ", " << q.z << ", " << q.w << ")" << std::endl;
|
||||
|
@ -107,6 +107,18 @@ int test_quat_lookAt()
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quat) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quat + (-test_mat)), glm::length(test_quat + test_mat)) > glm::epsilon<float>());
|
||||
|
||||
// Test left-handed implementation
|
||||
glm::quat test_quatLH = glm::quatLookAtLH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matLH = glm::conjugate(glm::quat_cast(glm::lookAtLH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatLH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatLH - test_matLH), glm::length(test_quatLH + test_matLH)) > glm::epsilon<float>());
|
||||
|
||||
// Test right-handed implementation
|
||||
glm::quat test_quatRH = glm::quatLookAtRH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matRH = glm::conjugate(glm::quat_cast(glm::lookAtRH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatRH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatRH - test_matRH), glm::length(test_quatRH + test_matRH)) > glm::epsilon<float>());
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user