Reduced dependencies

This commit is contained in:
Christophe Riccio 2018-08-19 19:33:11 +02:00
parent 0ceb2b755f
commit 6543cc9ad1
6 changed files with 65 additions and 64 deletions

View File

@ -19,10 +19,9 @@
#pragma once #pragma once
// Dependencies // Dependencies
#include "../gtc/constants.hpp" #include "../ext/scalar_constants.hpp"
#include "../geometric.hpp" #include "../geometric.hpp"
#include "../trigonometric.hpp" #include "../trigonometric.hpp"
#include "../matrix.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_EXT_matrix_clip_space extension included") # pragma message("GLM: GLM_EXT_matrix_clip_space extension included")

View File

@ -38,33 +38,6 @@ namespace glm
/// @see ext_quaternion_transform /// @see ext_quaternion_transform
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> rotate(qua<T, Q> const& q, T const& angle, vec<3, T, Q> const& axis); GLM_FUNC_DECL qua<T, Q> rotate(qua<T, Q> const& q, T const& angle, vec<3, T, Q> const& axis);
/// Build a look at quaternion based on the default handedness.
///
/// @param direction Desired forward direction. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAt(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// Build a right-handed look at quaternion.
///
/// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAtRH(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// Build a left-handed look at quaternion.
///
/// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAtLH(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// @} /// @}
} //namespace glm } //namespace glm

View File

@ -20,39 +20,5 @@ namespace glm
return q * qua<T, Q>(cos(AngleRad * static_cast<T>(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin); return q * qua<T, Q>(cos(AngleRad * static_cast<T>(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
} }
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAt(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
return quatLookAtLH(direction, up);
# else
return quatLookAtRH(direction, up);
# endif
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAtRH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
mat<3, 3, T, Q> Result;
Result[2] = -direction;
Result[0] = normalize(cross(up, Result[2]));
Result[1] = cross(Result[2], Result[0]);
return quat_cast(Result);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAtLH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
mat<3, 3, T, Q> Result;
Result[2] = direction;
Result[0] = normalize(cross(up, Result[2]));
Result[1] = cross(Result[2], Result[0]);
return quat_cast(Result);
}
}//namespace glm }//namespace glm

View File

@ -152,6 +152,32 @@ namespace glm
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y); GLM_FUNC_DECL vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
/// Build a look at quaternion based on the default handedness.
///
/// @param direction Desired forward direction. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAt(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// Build a right-handed look at quaternion.
///
/// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAtRH(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// Build a left-handed look at quaternion.
///
/// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized.
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quatLookAtLH(
vec<3, T, Q> const& direction,
vec<3, T, Q> const& up);
/// @} /// @}
} //namespace glm } //namespace glm

View File

@ -157,6 +157,41 @@ namespace glm
Result[i] = x[i] >= y[i]; Result[i] = x[i] >= y[i];
return Result; return Result;
} }
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAt(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
return quatLookAtLH(direction, up);
# else
return quatLookAtRH(direction, up);
# endif
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAtRH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
mat<3, 3, T, Q> Result;
Result[2] = -direction;
Result[0] = normalize(cross(up, Result[2]));
Result[1] = cross(Result[2], Result[0]);
return quat_cast(Result);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAtLH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
{
mat<3, 3, T, Q> Result;
Result[2] = direction;
Result[0] = normalize(cross(up, Result[2]));
Result[1] = cross(Result[2], Result[0]);
return quat_cast(Result);
}
}//namespace glm }//namespace glm
#if GLM_CONFIG_SIMD == GLM_ENABLE #if GLM_CONFIG_SIMD == GLM_ENABLE

View File

@ -65,9 +65,11 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
- Redesigned constexpr support which excludes both SIMD and constexpr #783 - Redesigned constexpr support which excludes both SIMD and constexpr #783
- Added detection of Visual C++ 2017 toolsets - Added detection of Visual C++ 2017 toolsets
- Added identity functions #765 - Added identity functions #765
- Split headers to improve compilation time #670 - Splitted headers into EXT extensions to improve compilation time #670
- Added separated performance tests
#### Fixes: #### Fixes:
- Fixed SIMD detection on Clang and GCC
- Fixed build problems due to printf and std::clock_t #778 - Fixed build problems due to printf and std::clock_t #778
- Fixed int mod - Fixed int mod
- Anonymous unions require C++ language extensions - Anonymous unions require C++ language extensions