mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-07 01:03: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,46 +1,17 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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_dual_quaternion
|
||||
/// @file glm/gtx/dual_quaternion.hpp
|
||||
/// @date 2013-02-10 / 2013-02-20
|
||||
/// @author Maksim Vorobiev (msomeone@gmail.com)
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_constants (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtx_dual_quaternion GLM_GTX_dual_quaternion
|
||||
/// @ingroup gtx
|
||||
///
|
||||
/// @brief Defines a templated dual-quaternion type and several dual-quaternion operations.
|
||||
/// Include <glm/gtx/dual_quaternion.hpp> to use the features of this extension.
|
||||
///
|
||||
/// <glm/gtx/dual_quaternion.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// Defines a templated dual-quaternion type and several dual-quaternion operations.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -49,7 +20,11 @@
|
||||
#include "../gtc/constants.hpp"
|
||||
#include "../gtc/quaternion.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#ifndef GLM_ENABLE_EXPERIMENTAL
|
||||
# error "GLM: GLM_GTX_dual_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTX_dual_quaternion extension included")
|
||||
#endif
|
||||
|
||||
@@ -58,206 +33,197 @@ namespace glm
|
||||
/// @addtogroup gtx_dual_quaternion
|
||||
/// @{
|
||||
|
||||
template <typename T, precision P = defaultp>
|
||||
template<typename T, qualifier Q = defaultp>
|
||||
struct tdualquat
|
||||
{
|
||||
// -- Implementation detail --
|
||||
|
||||
typedef T value_type;
|
||||
typedef glm::tquat<T, P> part_type;
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
static GLM_RELAXED_CONSTEXPR length_t components = 2;
|
||||
static GLM_RELAXED_CONSTEXPR precision prec = P;
|
||||
# endif//GLM_META_PROG_HELPERS
|
||||
typedef qua<T, Q> part_type;
|
||||
|
||||
// -- Data --
|
||||
|
||||
glm::tquat<T, P> real, dual;
|
||||
qua<T, Q> real, dual;
|
||||
|
||||
// -- Component accesses --
|
||||
|
||||
# ifdef GLM_FORCE_SIZE_FUNC
|
||||
typedef size_t size_type;
|
||||
/// Return the count of components of a dual quaternion
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
|
||||
typedef length_t length_type;
|
||||
/// Return the count of components of a dual quaternion
|
||||
GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
|
||||
|
||||
GLM_FUNC_DECL part_type & operator[](size_type i);
|
||||
GLM_FUNC_DECL part_type const & operator[](size_type i) const;
|
||||
# else
|
||||
typedef length_t length_type;
|
||||
/// Return the count of components of a dual quaternion
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
|
||||
|
||||
GLM_FUNC_DECL part_type & operator[](length_type i);
|
||||
GLM_FUNC_DECL part_type const & operator[](length_type i) const;
|
||||
# endif//GLM_FORCE_SIZE_FUNC
|
||||
GLM_FUNC_DECL part_type & operator[](length_type i);
|
||||
GLM_FUNC_DECL part_type const& operator[](length_type i) const;
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL tdualquat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
|
||||
template <precision Q>
|
||||
GLM_FUNC_DECL tdualquat(tdualquat<T, Q> const & d);
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const& d) GLM_DEFAULT;
|
||||
template<qualifier P>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const& d);
|
||||
|
||||
// -- Explicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL explicit tdualquat(ctor);
|
||||
GLM_FUNC_DECL explicit tdualquat(tquat<T, P> const & real);
|
||||
GLM_FUNC_DECL tdualquat(tquat<T, P> const & orientation, tvec3<T, P> const & translation);
|
||||
GLM_FUNC_DECL tdualquat(tquat<T, P> const & real, tquat<T, P> const & dual);
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real);
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& orientation, vec<3, T, Q> const& translation);
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real, qua<T, Q> const& dual);
|
||||
|
||||
// -- Conversion constructors --
|
||||
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
|
||||
template<typename U, qualifier P>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, P> const& q);
|
||||
|
||||
GLM_FUNC_DECL explicit tdualquat(tmat2x4<T, P> const & holder_mat);
|
||||
GLM_FUNC_DECL explicit tdualquat(tmat3x4<T, P> const & aug_mat);
|
||||
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<2, 4, T, Q> const& holder_mat);
|
||||
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<3, 4, T, Q> const& aug_mat);
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<T, P> const & m) GLM_DEFAULT;
|
||||
GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<T, Q> const& m) GLM_DEFAULT;
|
||||
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, P> & operator=(tdualquat<U, P> const & m);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, P> & operator*=(U s);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, P> & operator/=(U s);
|
||||
template<typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<U, Q> const& m);
|
||||
template<typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> & operator*=(U s);
|
||||
template<typename U>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> & operator/=(U s);
|
||||
};
|
||||
|
||||
// -- Unary bit operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator-(tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator-(tdualquat<T, Q> const& q);
|
||||
|
||||
// -- Binary operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, tdualquat<T, P> const & p);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tdualquat<T, P> const & q, tvec3<T, P> const & v);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> operator*(tdualquat<T, Q> const& q, vec<3, T, Q> const& v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, tdualquat<T, Q> const& q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tdualquat<T, P> const & q, tvec4<T, P> const & v);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> operator*(tdualquat<T, Q> const& q, vec<4, T, Q> const& v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q> const& v, tdualquat<T, Q> const& q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator*(tdualquat<T, P> const & q, T const & s);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, T const& s);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator*(T const & s, tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator*(T const& s, tdualquat<T, Q> const& q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> operator/(tdualquat<T, P> const & q, T const & s);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> operator/(tdualquat<T, Q> const& q, T const& s);
|
||||
|
||||
// -- Boolean operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL bool operator==(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL bool operator==(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL bool operator!=(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL bool operator!=(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
|
||||
|
||||
/// Creates an identity dual quaternion.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> dual_quat_identity();
|
||||
|
||||
/// Returns the normalized quaternion.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> normalize(tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> normalize(tdualquat<T, Q> const& q);
|
||||
|
||||
/// Returns the linear interpolation of two dual quaternion.
|
||||
///
|
||||
/// @see gtc_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> lerp(tdualquat<T, P> const & x, tdualquat<T, P> const & y, T const & a);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> lerp(tdualquat<T, Q> const& x, tdualquat<T, Q> const& y, T const& a);
|
||||
|
||||
/// Returns the q inverse.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> inverse(tdualquat<T, P> const & q);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> inverse(tdualquat<T, Q> const& q);
|
||||
|
||||
/// Converts a quaternion to a 2 * 4 matrix.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat2x4<T, P> mat2x4_cast(tdualquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<2, 4, T, Q> mat2x4_cast(tdualquat<T, Q> const& x);
|
||||
|
||||
/// Converts a quaternion to a 3 * 4 matrix.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat3x4<T, P> mat3x4_cast(tdualquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<3, 4, T, Q> mat3x4_cast(tdualquat<T, Q> const& x);
|
||||
|
||||
/// Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat2x4<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<2, 4, T, Q> const& x);
|
||||
|
||||
/// Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tdualquat<T, P> dualquat_cast(tmat3x4<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<3, 4, T, Q> const& x);
|
||||
|
||||
|
||||
/// Dual-quaternion of low single-precision floating-point numbers.
|
||||
/// Dual-quaternion of low single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, lowp> lowp_dualquat;
|
||||
|
||||
/// Dual-quaternion of medium single-precision floating-point numbers.
|
||||
/// Dual-quaternion of medium single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, mediump> mediump_dualquat;
|
||||
|
||||
/// Dual-quaternion of high single-precision floating-point numbers.
|
||||
/// Dual-quaternion of high single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, highp> highp_dualquat;
|
||||
|
||||
|
||||
/// Dual-quaternion of low single-precision floating-point numbers.
|
||||
/// Dual-quaternion of low single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, lowp> lowp_fdualquat;
|
||||
|
||||
/// Dual-quaternion of medium single-precision floating-point numbers.
|
||||
/// Dual-quaternion of medium single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, mediump> mediump_fdualquat;
|
||||
|
||||
/// Dual-quaternion of high single-precision floating-point numbers.
|
||||
/// Dual-quaternion of high single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<float, highp> highp_fdualquat;
|
||||
|
||||
|
||||
/// Dual-quaternion of low double-precision floating-point numbers.
|
||||
/// Dual-quaternion of low double-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<double, lowp> lowp_ddualquat;
|
||||
|
||||
/// Dual-quaternion of medium double-precision floating-point numbers.
|
||||
/// Dual-quaternion of medium double-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<double, mediump> mediump_ddualquat;
|
||||
|
||||
/// Dual-quaternion of high double-precision floating-point numbers.
|
||||
/// Dual-quaternion of high double-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef tdualquat<double, highp> highp_ddualquat;
|
||||
@@ -269,7 +235,7 @@ namespace glm
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef highp_fdualquat dualquat;
|
||||
|
||||
/// Dual-quaternion of single-precision floating-point numbers.
|
||||
/// Dual-quaternion of single-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef highp_fdualquat fdualquat;
|
||||
@@ -288,7 +254,7 @@ namespace glm
|
||||
|
||||
|
||||
#if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
|
||||
/// Dual-quaternion of default double-precision floating-point numbers.
|
||||
/// Dual-quaternion of default double-qualifier floating-point numbers.
|
||||
///
|
||||
/// @see gtx_dual_quaternion
|
||||
typedef highp_ddualquat ddualquat;
|
||||
|
||||
Reference in New Issue
Block a user