mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-02 04:37:54 +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,55 +1,29 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_bitfield
|
||||
/// @file glm/gtc/bitfield.hpp
|
||||
/// @date 2014-10-25 / 2014-10-25
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_bitfield (dependence)
|
||||
///
|
||||
/// @defgroup gtc_bitfield GLM_GTC_bitfield
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Allow to perform bit operations on integer values
|
||||
///
|
||||
/// <glm/gtc/bitfield.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/bitfield.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Allow to perform bit operations on integer values
|
||||
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/type_int.hpp"
|
||||
#include "../ext/scalar_int_sized.hpp"
|
||||
#include "../ext/scalar_uint_sized.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/_vectorize.hpp"
|
||||
#include "type_precision.hpp"
|
||||
#include <limits>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_bitfield extension included")
|
||||
#endif
|
||||
|
||||
@@ -61,172 +35,228 @@ namespace glm
|
||||
/// Build a mask of 'count' bits
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType mask(genIUType Bits);
|
||||
|
||||
|
||||
/// Build a mask of 'count' bits
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Signed and unsigned integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename T, precision P, template <typename, precision> class vecIUType>
|
||||
GLM_FUNC_DECL vecIUType<T, P> mask(vecIUType<T, P> const & v);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> mask(vec<L, T, Q> const& v);
|
||||
|
||||
/// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType bitfieldRotateRight(genIUType In, int Shift);
|
||||
|
||||
/// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Signed and unsigned integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateRight(vec<L, T, Q> const& In, int Shift);
|
||||
|
||||
/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType bitfieldRotateLeft(genIUType In, int Shift);
|
||||
|
||||
/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Signed and unsigned integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> bitfieldRotateLeft(vecType<T, P> const & In, int Shift);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateLeft(vec<L, T, Q> const& In, int Shift);
|
||||
|
||||
/// Set to 1 a range of bits.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount);
|
||||
|
||||
/// Set to 1 a range of bits.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Signed and unsigned integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> bitfieldFillOne(vecType<T, P> const & Value, int FirstBit, int BitCount);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> bitfieldFillOne(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
|
||||
|
||||
/// Set to 0 a range of bits.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount);
|
||||
|
||||
/// Set to 0 a range of bits.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Signed and unsigned integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> bitfieldFillZero(vecType<T, P> const & Value, int FirstBit, int BitCount);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> bitfieldFillZero(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int16 bitfieldInterleave(int8 x, int8 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint16 bitfieldInterleave(uint8 x, uint8 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of v.x followed by the first bit of v.y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint16 bitfieldInterleave(u8vec2 const& v);
|
||||
|
||||
/// Deinterleaves the bits of x.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL glm::u8vec2 bitfieldDeinterleave(glm::uint16 x);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int16 x, int16 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint16 x, uint16 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of v.x followed by the first bit of v.y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(u16vec2 const& v);
|
||||
|
||||
/// Deinterleaves the bits of x.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL glm::u16vec2 bitfieldDeinterleave(glm::uint32 x);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of v.x followed by the first bit of v.y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(u32vec2 const& v);
|
||||
|
||||
/// Deinterleaves the bits of x.
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL glm::u32vec2 bitfieldDeinterleave(glm::uint64 x);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y, int32 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
///
|
||||
/// @see gtc_bitfield
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
|
||||
|
||||
|
||||
@@ -1,197 +1,169 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_bitfield
|
||||
/// @file glm/gtc/bitfield.inl
|
||||
/// @date 2011-10-14 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../simd/integer.h"
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename PARAM, typename RET>
|
||||
template<typename PARAM, typename RET>
|
||||
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y);
|
||||
|
||||
template <typename PARAM, typename RET>
|
||||
template<typename PARAM, typename RET>
|
||||
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z);
|
||||
|
||||
template <typename PARAM, typename RET>
|
||||
template<typename PARAM, typename RET>
|
||||
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w);
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint16 bitfieldInterleave(glm::uint8 x, glm::uint8 y)
|
||||
{
|
||||
glm::uint16 REG1(x);
|
||||
glm::uint16 REG2(y);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint16(0x0F0F);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint16(0x0F0F);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint16>(0x0F0F);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint16>(0x0F0F);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint16(0x3333);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint16(0x3333);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint16>(0x3333);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint16>(0x3333);
|
||||
|
||||
REG1 = ((REG1 << 1) | REG1) & glm::uint16(0x5555);
|
||||
REG2 = ((REG2 << 1) | REG2) & glm::uint16(0x5555);
|
||||
REG1 = ((REG1 << 1) | REG1) & static_cast<glm::uint16>(0x5555);
|
||||
REG2 = ((REG2 << 1) | REG2) & static_cast<glm::uint16>(0x5555);
|
||||
|
||||
return REG1 | (REG2 << 1);
|
||||
return REG1 | static_cast<glm::uint16>(REG2 << 1);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint16 x, glm::uint16 y)
|
||||
{
|
||||
glm::uint32 REG1(x);
|
||||
glm::uint32 REG2(y);
|
||||
|
||||
REG1 = ((REG1 << 8) | REG1) & glm::uint32(0x00FF00FF);
|
||||
REG2 = ((REG2 << 8) | REG2) & glm::uint32(0x00FF00FF);
|
||||
REG1 = ((REG1 << 8) | REG1) & static_cast<glm::uint32>(0x00FF00FF);
|
||||
REG2 = ((REG2 << 8) | REG2) & static_cast<glm::uint32>(0x00FF00FF);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint32(0x0F0F0F0F);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint32(0x0F0F0F0F);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint32>(0x0F0F0F0F);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint32>(0x0F0F0F0F);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint32(0x33333333);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint32(0x33333333);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint32>(0x33333333);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint32>(0x33333333);
|
||||
|
||||
REG1 = ((REG1 << 1) | REG1) & glm::uint32(0x55555555);
|
||||
REG2 = ((REG2 << 1) | REG2) & glm::uint32(0x55555555);
|
||||
REG1 = ((REG1 << 1) | REG1) & static_cast<glm::uint32>(0x55555555);
|
||||
REG2 = ((REG2 << 1) | REG2) & static_cast<glm::uint32>(0x55555555);
|
||||
|
||||
return REG1 | (REG2 << 1);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y)
|
||||
{
|
||||
glm::uint64 REG1(x);
|
||||
glm::uint64 REG2(y);
|
||||
|
||||
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
|
||||
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
|
||||
REG1 = ((REG1 << 16) | REG1) & static_cast<glm::uint64>(0x0000FFFF0000FFFFull);
|
||||
REG2 = ((REG2 << 16) | REG2) & static_cast<glm::uint64>(0x0000FFFF0000FFFFull);
|
||||
|
||||
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
|
||||
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
|
||||
REG1 = ((REG1 << 8) | REG1) & static_cast<glm::uint64>(0x00FF00FF00FF00FFull);
|
||||
REG2 = ((REG2 << 8) | REG2) & static_cast<glm::uint64>(0x00FF00FF00FF00FFull);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint64>(0x0F0F0F0F0F0F0F0Full);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint64>(0x0F0F0F0F0F0F0F0Full);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint64>(0x3333333333333333ull);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint64>(0x3333333333333333ull);
|
||||
|
||||
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
|
||||
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
|
||||
REG1 = ((REG1 << 1) | REG1) & static_cast<glm::uint64>(0x5555555555555555ull);
|
||||
REG2 = ((REG2 << 1) | REG2) & static_cast<glm::uint64>(0x5555555555555555ull);
|
||||
|
||||
return REG1 | (REG2 << 1);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint8 x, glm::uint8 y, glm::uint8 z)
|
||||
{
|
||||
glm::uint32 REG1(x);
|
||||
glm::uint32 REG2(y);
|
||||
glm::uint32 REG3(z);
|
||||
|
||||
REG1 = ((REG1 << 16) | REG1) & glm::uint32(0x00FF0000FF0000FF);
|
||||
REG2 = ((REG2 << 16) | REG2) & glm::uint32(0x00FF0000FF0000FF);
|
||||
REG3 = ((REG3 << 16) | REG3) & glm::uint32(0x00FF0000FF0000FF);
|
||||
REG1 = ((REG1 << 16) | REG1) & static_cast<glm::uint32>(0xFF0000FFu);
|
||||
REG2 = ((REG2 << 16) | REG2) & static_cast<glm::uint32>(0xFF0000FFu);
|
||||
REG3 = ((REG3 << 16) | REG3) & static_cast<glm::uint32>(0xFF0000FFu);
|
||||
|
||||
REG1 = ((REG1 << 8) | REG1) & glm::uint32(0xF00F00F00F00F00F);
|
||||
REG2 = ((REG2 << 8) | REG2) & glm::uint32(0xF00F00F00F00F00F);
|
||||
REG3 = ((REG3 << 8) | REG3) & glm::uint32(0xF00F00F00F00F00F);
|
||||
REG1 = ((REG1 << 8) | REG1) & static_cast<glm::uint32>(0x0F00F00Fu);
|
||||
REG2 = ((REG2 << 8) | REG2) & static_cast<glm::uint32>(0x0F00F00Fu);
|
||||
REG3 = ((REG3 << 8) | REG3) & static_cast<glm::uint32>(0x0F00F00Fu);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint32(0x30C30C30C30C30C3);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint32(0x30C30C30C30C30C3);
|
||||
REG3 = ((REG3 << 4) | REG3) & glm::uint32(0x30C30C30C30C30C3);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint32>(0xC30C30C3u);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint32>(0xC30C30C3u);
|
||||
REG3 = ((REG3 << 4) | REG3) & static_cast<glm::uint32>(0xC30C30C3u);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint32(0x9249249249249249);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint32(0x9249249249249249);
|
||||
REG3 = ((REG3 << 2) | REG3) & glm::uint32(0x9249249249249249);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint32>(0x49249249u);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint32>(0x49249249u);
|
||||
REG3 = ((REG3 << 2) | REG3) & static_cast<glm::uint32>(0x49249249u);
|
||||
|
||||
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z)
|
||||
{
|
||||
glm::uint64 REG1(x);
|
||||
glm::uint64 REG2(y);
|
||||
glm::uint64 REG3(z);
|
||||
|
||||
REG1 = ((REG1 << 32) | REG1) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG2 = ((REG2 << 32) | REG2) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG3 = ((REG3 << 32) | REG3) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG1 = ((REG1 << 32) | REG1) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
REG2 = ((REG2 << 32) | REG2) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
REG3 = ((REG3 << 32) | REG3) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
|
||||
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG3 = ((REG3 << 16) | REG3) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG1 = ((REG1 << 16) | REG1) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
REG2 = ((REG2 << 16) | REG2) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
REG3 = ((REG3 << 16) | REG3) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
|
||||
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG3 = ((REG3 << 8) | REG3) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG1 = ((REG1 << 8) | REG1) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
REG2 = ((REG2 << 8) | REG2) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
REG3 = ((REG3 << 8) | REG3) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
REG3 = ((REG3 << 4) | REG3) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249ull);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249ull);
|
||||
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249ull);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
REG3 = ((REG3 << 2) | REG3) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
|
||||
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y, glm::uint32 z)
|
||||
{
|
||||
glm::uint64 REG1(x);
|
||||
glm::uint64 REG2(y);
|
||||
glm::uint64 REG3(z);
|
||||
|
||||
REG1 = ((REG1 << 32) | REG1) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG2 = ((REG2 << 32) | REG2) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG3 = ((REG3 << 32) | REG3) & glm::uint64(0xFFFF00000000FFFFull);
|
||||
REG1 = ((REG1 << 32) | REG1) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
REG2 = ((REG2 << 32) | REG2) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
REG3 = ((REG3 << 32) | REG3) & static_cast<glm::uint64>(0xFFFF00000000FFFFull);
|
||||
|
||||
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG3 = ((REG3 << 16) | REG3) & glm::uint64(0x00FF0000FF0000FFull);
|
||||
REG1 = ((REG1 << 16) | REG1) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
REG2 = ((REG2 << 16) | REG2) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
REG3 = ((REG3 << 16) | REG3) & static_cast<glm::uint64>(0x00FF0000FF0000FFull);
|
||||
|
||||
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG3 = ((REG3 << 8) | REG3) & glm::uint64(0xF00F00F00F00F00Full);
|
||||
REG1 = ((REG1 << 8) | REG1) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
REG2 = ((REG2 << 8) | REG2) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
REG3 = ((REG3 << 8) | REG3) & static_cast<glm::uint64>(0xF00F00F00F00F00Full);
|
||||
|
||||
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3ull);
|
||||
REG1 = ((REG1 << 4) | REG1) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
REG2 = ((REG2 << 4) | REG2) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
REG3 = ((REG3 << 4) | REG3) & static_cast<glm::uint64>(0x30C30C30C30C30C3ull);
|
||||
|
||||
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249ull);
|
||||
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249ull);
|
||||
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249ull);
|
||||
REG1 = ((REG1 << 2) | REG1) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
REG2 = ((REG2 << 2) | REG2) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
REG3 = ((REG3 << 2) | REG3) & static_cast<glm::uint64>(0x9249249249249249ull);
|
||||
|
||||
return REG1 | (REG2 << 1) | (REG3 << 2);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint8 x, glm::uint8 y, glm::uint8 z, glm::uint8 w)
|
||||
{
|
||||
glm::uint32 REG1(x);
|
||||
@@ -199,25 +171,25 @@ namespace detail
|
||||
glm::uint32 REG3(z);
|
||||
glm::uint32 REG4(w);
|
||||
|
||||
REG1 = ((REG1 << 12) | REG1) & glm::uint32(0x000F000F000F000F);
|
||||
REG2 = ((REG2 << 12) | REG2) & glm::uint32(0x000F000F000F000F);
|
||||
REG3 = ((REG3 << 12) | REG3) & glm::uint32(0x000F000F000F000F);
|
||||
REG4 = ((REG4 << 12) | REG4) & glm::uint32(0x000F000F000F000F);
|
||||
REG1 = ((REG1 << 12) | REG1) & static_cast<glm::uint32>(0x000F000Fu);
|
||||
REG2 = ((REG2 << 12) | REG2) & static_cast<glm::uint32>(0x000F000Fu);
|
||||
REG3 = ((REG3 << 12) | REG3) & static_cast<glm::uint32>(0x000F000Fu);
|
||||
REG4 = ((REG4 << 12) | REG4) & static_cast<glm::uint32>(0x000F000Fu);
|
||||
|
||||
REG1 = ((REG1 << 6) | REG1) & glm::uint32(0x0303030303030303);
|
||||
REG2 = ((REG2 << 6) | REG2) & glm::uint32(0x0303030303030303);
|
||||
REG3 = ((REG3 << 6) | REG3) & glm::uint32(0x0303030303030303);
|
||||
REG4 = ((REG4 << 6) | REG4) & glm::uint32(0x0303030303030303);
|
||||
REG1 = ((REG1 << 6) | REG1) & static_cast<glm::uint32>(0x03030303u);
|
||||
REG2 = ((REG2 << 6) | REG2) & static_cast<glm::uint32>(0x03030303u);
|
||||
REG3 = ((REG3 << 6) | REG3) & static_cast<glm::uint32>(0x03030303u);
|
||||
REG4 = ((REG4 << 6) | REG4) & static_cast<glm::uint32>(0x03030303u);
|
||||
|
||||
REG1 = ((REG1 << 3) | REG1) & glm::uint32(0x1111111111111111);
|
||||
REG2 = ((REG2 << 3) | REG2) & glm::uint32(0x1111111111111111);
|
||||
REG3 = ((REG3 << 3) | REG3) & glm::uint32(0x1111111111111111);
|
||||
REG4 = ((REG4 << 3) | REG4) & glm::uint32(0x1111111111111111);
|
||||
REG1 = ((REG1 << 3) | REG1) & static_cast<glm::uint32>(0x11111111u);
|
||||
REG2 = ((REG2 << 3) | REG2) & static_cast<glm::uint32>(0x11111111u);
|
||||
REG3 = ((REG3 << 3) | REG3) & static_cast<glm::uint32>(0x11111111u);
|
||||
REG4 = ((REG4 << 3) | REG4) & static_cast<glm::uint32>(0x11111111u);
|
||||
|
||||
return REG1 | (REG2 << 1) | (REG3 << 2) | (REG4 << 3);
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w)
|
||||
{
|
||||
glm::uint64 REG1(x);
|
||||
@@ -225,31 +197,31 @@ namespace detail
|
||||
glm::uint64 REG3(z);
|
||||
glm::uint64 REG4(w);
|
||||
|
||||
REG1 = ((REG1 << 24) | REG1) & glm::uint64(0x000000FF000000FFull);
|
||||
REG2 = ((REG2 << 24) | REG2) & glm::uint64(0x000000FF000000FFull);
|
||||
REG3 = ((REG3 << 24) | REG3) & glm::uint64(0x000000FF000000FFull);
|
||||
REG4 = ((REG4 << 24) | REG4) & glm::uint64(0x000000FF000000FFull);
|
||||
REG1 = ((REG1 << 24) | REG1) & static_cast<glm::uint64>(0x000000FF000000FFull);
|
||||
REG2 = ((REG2 << 24) | REG2) & static_cast<glm::uint64>(0x000000FF000000FFull);
|
||||
REG3 = ((REG3 << 24) | REG3) & static_cast<glm::uint64>(0x000000FF000000FFull);
|
||||
REG4 = ((REG4 << 24) | REG4) & static_cast<glm::uint64>(0x000000FF000000FFull);
|
||||
|
||||
REG1 = ((REG1 << 12) | REG1) & glm::uint64(0x000F000F000F000Full);
|
||||
REG2 = ((REG2 << 12) | REG2) & glm::uint64(0x000F000F000F000Full);
|
||||
REG3 = ((REG3 << 12) | REG3) & glm::uint64(0x000F000F000F000Full);
|
||||
REG4 = ((REG4 << 12) | REG4) & glm::uint64(0x000F000F000F000Full);
|
||||
REG1 = ((REG1 << 12) | REG1) & static_cast<glm::uint64>(0x000F000F000F000Full);
|
||||
REG2 = ((REG2 << 12) | REG2) & static_cast<glm::uint64>(0x000F000F000F000Full);
|
||||
REG3 = ((REG3 << 12) | REG3) & static_cast<glm::uint64>(0x000F000F000F000Full);
|
||||
REG4 = ((REG4 << 12) | REG4) & static_cast<glm::uint64>(0x000F000F000F000Full);
|
||||
|
||||
REG1 = ((REG1 << 6) | REG1) & glm::uint64(0x0303030303030303ull);
|
||||
REG2 = ((REG2 << 6) | REG2) & glm::uint64(0x0303030303030303ull);
|
||||
REG3 = ((REG3 << 6) | REG3) & glm::uint64(0x0303030303030303ull);
|
||||
REG4 = ((REG4 << 6) | REG4) & glm::uint64(0x0303030303030303ull);
|
||||
REG1 = ((REG1 << 6) | REG1) & static_cast<glm::uint64>(0x0303030303030303ull);
|
||||
REG2 = ((REG2 << 6) | REG2) & static_cast<glm::uint64>(0x0303030303030303ull);
|
||||
REG3 = ((REG3 << 6) | REG3) & static_cast<glm::uint64>(0x0303030303030303ull);
|
||||
REG4 = ((REG4 << 6) | REG4) & static_cast<glm::uint64>(0x0303030303030303ull);
|
||||
|
||||
REG1 = ((REG1 << 3) | REG1) & glm::uint64(0x1111111111111111ull);
|
||||
REG2 = ((REG2 << 3) | REG2) & glm::uint64(0x1111111111111111ull);
|
||||
REG3 = ((REG3 << 3) | REG3) & glm::uint64(0x1111111111111111ull);
|
||||
REG4 = ((REG4 << 3) | REG4) & glm::uint64(0x1111111111111111ull);
|
||||
REG1 = ((REG1 << 3) | REG1) & static_cast<glm::uint64>(0x1111111111111111ull);
|
||||
REG2 = ((REG2 << 3) | REG2) & static_cast<glm::uint64>(0x1111111111111111ull);
|
||||
REG3 = ((REG3 << 3) | REG3) & static_cast<glm::uint64>(0x1111111111111111ull);
|
||||
REG4 = ((REG4 << 3) | REG4) & static_cast<glm::uint64>(0x1111111111111111ull);
|
||||
|
||||
return REG1 | (REG2 << 1) | (REG3 << 2) | (REG4 << 3);
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType mask(genIUType Bits)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'mask' accepts only integer values");
|
||||
@@ -257,15 +229,15 @@ namespace detail
|
||||
return Bits >= sizeof(genIUType) * 8 ? ~static_cast<genIUType>(0) : (static_cast<genIUType>(1) << Bits) - static_cast<genIUType>(1);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecIUType>
|
||||
GLM_FUNC_QUALIFIER vecIUType<T, P> mask(vecIUType<T, P> const & v)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> mask(vec<L, T, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'mask' accepts only integer values");
|
||||
|
||||
return detail::functor1<T, T, P, vecIUType>::call(mask, v);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(mask, v);
|
||||
}
|
||||
|
||||
template <typename genIType>
|
||||
template<typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType bitfieldRotateRight(genIType In, int Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateRight' accepts only integer values");
|
||||
@@ -274,8 +246,8 @@ namespace detail
|
||||
return (In << static_cast<genIType>(Shift)) | (In >> static_cast<genIType>(BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldRotateRight(vec<L, T, Q> const& In, int Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateRight' accepts only integer values");
|
||||
|
||||
@@ -283,7 +255,7 @@ namespace detail
|
||||
return (In << static_cast<T>(Shift)) | (In >> static_cast<T>(BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename genIType>
|
||||
template<typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType bitfieldRotateLeft(genIType In, int Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateLeft' accepts only integer values");
|
||||
@@ -292,8 +264,8 @@ namespace detail
|
||||
return (In >> static_cast<genIType>(Shift)) | (In << static_cast<genIType>(BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateLeft(vecType<T, P> const & In, int Shift)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldRotateLeft(vec<L, T, Q> const& In, int Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateLeft' accepts only integer values");
|
||||
|
||||
@@ -301,26 +273,26 @@ namespace detail
|
||||
return (In >> static_cast<T>(Shift)) | (In << static_cast<T>(BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount)
|
||||
{
|
||||
return Value | static_cast<genIUType>(mask(BitCount) << FirstBit);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldFillOne(vecType<T, P> const & Value, int FirstBit, int BitCount)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldFillOne(vec<L, T, Q> const& Value, int FirstBit, int BitCount)
|
||||
{
|
||||
return Value | static_cast<T>(mask(BitCount) << FirstBit);
|
||||
}
|
||||
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount)
|
||||
{
|
||||
return Value & static_cast<genIUType>(~(mask(BitCount) << FirstBit));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldFillZero(vecType<T, P> const & Value, int FirstBit, int BitCount)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldFillZero(vec<L, T, Q> const& Value, int FirstBit, int BitCount)
|
||||
{
|
||||
return Value & static_cast<T>(~(mask(BitCount) << FirstBit));
|
||||
}
|
||||
@@ -351,6 +323,34 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint8, uint16>(x, y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 bitfieldInterleave(u8vec2 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint8, uint16>(v.x, v.y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u8vec2 bitfieldDeinterleave(glm::uint16 x)
|
||||
{
|
||||
uint16 REG1(x);
|
||||
uint16 REG2(x >>= 1);
|
||||
|
||||
REG1 = REG1 & static_cast<uint16>(0x5555);
|
||||
REG2 = REG2 & static_cast<uint16>(0x5555);
|
||||
|
||||
REG1 = ((REG1 >> 1) | REG1) & static_cast<uint16>(0x3333);
|
||||
REG2 = ((REG2 >> 1) | REG2) & static_cast<uint16>(0x3333);
|
||||
|
||||
REG1 = ((REG1 >> 2) | REG1) & static_cast<uint16>(0x0F0F);
|
||||
REG2 = ((REG2 >> 2) | REG2) & static_cast<uint16>(0x0F0F);
|
||||
|
||||
REG1 = ((REG1 >> 4) | REG1) & static_cast<uint16>(0x00FF);
|
||||
REG2 = ((REG2 >> 4) | REG2) & static_cast<uint16>(0x00FF);
|
||||
|
||||
REG1 = ((REG1 >> 8) | REG1) & static_cast<uint16>(0xFFFF);
|
||||
REG2 = ((REG2 >> 8) | REG2) & static_cast<uint16>(0xFFFF);
|
||||
|
||||
return glm::u8vec2(REG1, REG2);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int16 x, int16 y)
|
||||
{
|
||||
union sign16
|
||||
@@ -377,6 +377,34 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint16, uint32>(x, y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(u16vec2 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint16, uint32>(v.x, v.y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::u16vec2 bitfieldDeinterleave(glm::uint32 x)
|
||||
{
|
||||
glm::uint32 REG1(x);
|
||||
glm::uint32 REG2(x >>= 1);
|
||||
|
||||
REG1 = REG1 & static_cast<glm::uint32>(0x55555555);
|
||||
REG2 = REG2 & static_cast<glm::uint32>(0x55555555);
|
||||
|
||||
REG1 = ((REG1 >> 1) | REG1) & static_cast<glm::uint32>(0x33333333);
|
||||
REG2 = ((REG2 >> 1) | REG2) & static_cast<glm::uint32>(0x33333333);
|
||||
|
||||
REG1 = ((REG1 >> 2) | REG1) & static_cast<glm::uint32>(0x0F0F0F0F);
|
||||
REG2 = ((REG2 >> 2) | REG2) & static_cast<glm::uint32>(0x0F0F0F0F);
|
||||
|
||||
REG1 = ((REG1 >> 4) | REG1) & static_cast<glm::uint32>(0x00FF00FF);
|
||||
REG2 = ((REG2 >> 4) | REG2) & static_cast<glm::uint32>(0x00FF00FF);
|
||||
|
||||
REG1 = ((REG1 >> 8) | REG1) & static_cast<glm::uint32>(0x0000FFFF);
|
||||
REG2 = ((REG2 >> 8) | REG2) & static_cast<glm::uint32>(0x0000FFFF);
|
||||
|
||||
return glm::u16vec2(REG1, REG2);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y)
|
||||
{
|
||||
union sign32
|
||||
@@ -403,6 +431,37 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint32, uint64>(x, y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(u32vec2 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint32, uint64>(v.x, v.y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::u32vec2 bitfieldDeinterleave(glm::uint64 x)
|
||||
{
|
||||
glm::uint64 REG1(x);
|
||||
glm::uint64 REG2(x >>= 1);
|
||||
|
||||
REG1 = REG1 & static_cast<glm::uint64>(0x5555555555555555ull);
|
||||
REG2 = REG2 & static_cast<glm::uint64>(0x5555555555555555ull);
|
||||
|
||||
REG1 = ((REG1 >> 1) | REG1) & static_cast<glm::uint64>(0x3333333333333333ull);
|
||||
REG2 = ((REG2 >> 1) | REG2) & static_cast<glm::uint64>(0x3333333333333333ull);
|
||||
|
||||
REG1 = ((REG1 >> 2) | REG1) & static_cast<glm::uint64>(0x0F0F0F0F0F0F0F0Full);
|
||||
REG2 = ((REG2 >> 2) | REG2) & static_cast<glm::uint64>(0x0F0F0F0F0F0F0F0Full);
|
||||
|
||||
REG1 = ((REG1 >> 4) | REG1) & static_cast<glm::uint64>(0x00FF00FF00FF00FFull);
|
||||
REG2 = ((REG2 >> 4) | REG2) & static_cast<glm::uint64>(0x00FF00FF00FF00FFull);
|
||||
|
||||
REG1 = ((REG1 >> 8) | REG1) & static_cast<glm::uint64>(0x0000FFFF0000FFFFull);
|
||||
REG2 = ((REG2 >> 8) | REG2) & static_cast<glm::uint64>(0x0000FFFF0000FFFFull);
|
||||
|
||||
REG1 = ((REG1 >> 16) | REG1) & static_cast<glm::uint64>(0x00000000FFFFFFFFull);
|
||||
REG2 = ((REG2 >> 16) | REG2) & static_cast<glm::uint64>(0x00000000FFFFFFFFull);
|
||||
|
||||
return glm::u32vec2(REG1, REG2);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z)
|
||||
{
|
||||
union sign8
|
||||
@@ -430,6 +489,11 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint8, uint32>(x, y, z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(u8vec3 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint8, uint32>(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z)
|
||||
{
|
||||
union sign16
|
||||
@@ -457,6 +521,11 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint32, uint64>(x, y, z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(u16vec3 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint32, uint64>(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y, int32 z)
|
||||
{
|
||||
union sign16
|
||||
@@ -484,6 +553,11 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint32, uint64>(x, y, z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(u32vec3 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint32, uint64>(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w)
|
||||
{
|
||||
union sign8
|
||||
@@ -512,6 +586,11 @@ namespace detail
|
||||
return detail::bitfieldInterleave<uint8, uint32>(x, y, z, w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(u8vec4 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint8, uint32>(v.x, v.y, v.z, v.w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w)
|
||||
{
|
||||
union sign16
|
||||
@@ -539,4 +618,9 @@ namespace detail
|
||||
{
|
||||
return detail::bitfieldInterleave<uint16, uint64>(x, y, z, w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(u16vec4 const& v)
|
||||
{
|
||||
return detail::bitfieldInterleave<uint16, uint64>(v.x, v.y, v.z, v.w);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,56 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_color_space
|
||||
/// @file glm/gtc/color_space.hpp
|
||||
/// @date 2015-02-10 / 2015-08-02
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_color_space (dependence)
|
||||
///
|
||||
/// @defgroup gtc_color_space GLM_GTC_color_space
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Allow to perform bit operations on integer values
|
||||
///
|
||||
/// <glm/gtc/color.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/color_space.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Allow to perform bit operations on integer values
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include <limits>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_color_space extension included")
|
||||
#endif
|
||||
|
||||
@@ -59,21 +30,25 @@ namespace glm
|
||||
/// @addtogroup gtc_color_space
|
||||
/// @{
|
||||
|
||||
/// Convert a linear color to sRGB color using a standard gamma correction
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear);
|
||||
/// Convert a linear color to sRGB color using a standard gamma correction.
|
||||
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> convertLinearToSRGB(vec<L, T, Q> const& ColorLinear);
|
||||
|
||||
/// Convert a linear color to sRGB color using a custom gamma correction
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear, T Gamma);
|
||||
/// Convert a linear color to sRGB color using a custom gamma correction.
|
||||
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> convertLinearToSRGB(vec<L, T, Q> const& ColorLinear, T Gamma);
|
||||
|
||||
/// Convert a sRGB color to linear color using a standard gamma correction
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB);
|
||||
/// Convert a sRGB color to linear color using a standard gamma correction.
|
||||
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> convertSRGBToLinear(vec<L, T, Q> const& ColorSRGB);
|
||||
|
||||
/// Convert a sRGB color to linear color using a custom gamma correction
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma);
|
||||
/// Convert a sRGB color to linear color using a custom gamma correction.
|
||||
// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> convertSRGBToLinear(vec<L, T, Q> const& ColorSRGB, T Gamma);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
@@ -1,104 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_color_space
|
||||
/// @file glm/gtc/color_space.inl
|
||||
/// @date 2015-02-10 / 2015-08-02
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_rgbToSrgb
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & ColorRGB, T GammaCorrection)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& ColorRGB, T GammaCorrection)
|
||||
{
|
||||
vecType<T, P> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
|
||||
vec<L, T, Q> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
|
||||
|
||||
return mix(
|
||||
pow(ClampedColor, vecType<T, P>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
|
||||
pow(ClampedColor, vec<L, T, Q>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
|
||||
ClampedColor * static_cast<T>(12.92),
|
||||
lessThan(ClampedColor, vecType<T, P>(static_cast<T>(0.0031308))));
|
||||
lessThan(ClampedColor, vec<L, T, Q>(static_cast<T>(0.0031308))));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_rgbToSrgb<T, P, tvec4>
|
||||
template<typename T, qualifier Q>
|
||||
struct compute_rgbToSrgb<4, T, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & ColorRGB, T GammaCorrection)
|
||||
GLM_FUNC_QUALIFIER static vec<4, T, Q> call(vec<4, T, Q> const& ColorRGB, T GammaCorrection)
|
||||
{
|
||||
return tvec4<T, P>(compute_rgbToSrgb<T, P, tvec3>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.a);
|
||||
return vec<4, T, Q>(compute_rgbToSrgb<3, T, Q>::call(vec<3, T, Q>(ColorRGB), GammaCorrection), ColorRGB.w);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_srgbToRgb
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & ColorSRGB, T Gamma)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& ColorSRGB, T Gamma)
|
||||
{
|
||||
return mix(
|
||||
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<T, P>(Gamma)),
|
||||
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vec<L, T, Q>(Gamma)),
|
||||
ColorSRGB * static_cast<T>(0.07739938080495356037151702786378),
|
||||
lessThanEqual(ColorSRGB, vecType<T, P>(static_cast<T>(0.04045))));
|
||||
lessThanEqual(ColorSRGB, vec<L, T, Q>(static_cast<T>(0.04045))));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_srgbToRgb<T, P, tvec4>
|
||||
template<typename T, qualifier Q>
|
||||
struct compute_srgbToRgb<4, T, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & ColorSRGB, T Gamma)
|
||||
GLM_FUNC_QUALIFIER static vec<4, T, Q> call(vec<4, T, Q> const& ColorSRGB, T Gamma)
|
||||
{
|
||||
return tvec4<T, P>(compute_srgbToRgb<T, P, tvec3>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.a);
|
||||
return vec<4, T, Q>(compute_srgbToRgb<3, T, Q>::call(vec<3, T, Q>(ColorSRGB), Gamma), ColorSRGB.w);
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> convertLinearToSRGB(vec<L, T, Q> const& ColorLinear)
|
||||
{
|
||||
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
|
||||
return detail::compute_rgbToSrgb<L, T, Q>::call(ColorLinear, static_cast<T>(0.41666));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear, T Gamma)
|
||||
// Based on Ian Taylor http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER vec<3, float, lowp> convertLinearToSRGB(vec<3, float, lowp> const& ColorLinear)
|
||||
{
|
||||
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
|
||||
vec<3, float, lowp> S1 = sqrt(ColorLinear);
|
||||
vec<3, float, lowp> S2 = sqrt(S1);
|
||||
vec<3, float, lowp> S3 = sqrt(S2);
|
||||
return 0.662002687f * S1 + 0.684122060f * S2 - 0.323583601f * S3 - 0.0225411470f * ColorLinear;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> convertLinearToSRGB(vec<L, T, Q> const& ColorLinear, T Gamma)
|
||||
{
|
||||
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
|
||||
return detail::compute_rgbToSrgb<L, T, Q>::call(ColorLinear, static_cast<T>(1) / Gamma);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma)
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> convertSRGBToLinear(vec<L, T, Q> const& ColorSRGB)
|
||||
{
|
||||
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
|
||||
return detail::compute_srgbToRgb<L, T, Q>::call(ColorSRGB, static_cast<T>(2.4));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> convertSRGBToLinear(vec<L, T, Q> const& ColorSRGB, T Gamma)
|
||||
{
|
||||
return detail::compute_srgbToRgb<L, T, Q>::call(ColorSRGB, Gamma);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -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 gtc_constants
|
||||
/// @file glm/gtc/constants.hpp
|
||||
/// @date 2011-09-30 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
///
|
||||
/// @defgroup gtc_constants GLM_GTC_constants
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Provide a list of constants and precomputed useful values.
|
||||
///
|
||||
/// <glm/gtc/constants.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/constants.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Provide a list of constants and precomputed useful values.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../ext/scalar_constants.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_constants extension included")
|
||||
#endif
|
||||
|
||||
@@ -54,149 +24,139 @@ namespace glm
|
||||
/// @addtogroup gtc_constants
|
||||
/// @{
|
||||
|
||||
/// Return the epsilon constant for floating point types.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon();
|
||||
|
||||
/// Return 0.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType zero();
|
||||
|
||||
/// Return 1.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType one();
|
||||
|
||||
/// Return the pi constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType pi();
|
||||
|
||||
/// Return pi * 2.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType two_pi();
|
||||
|
||||
/// Return square root of pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_pi();
|
||||
|
||||
/// Return pi / 2.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType half_pi();
|
||||
|
||||
/// Return pi / 2 * 3.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType three_over_two_pi();
|
||||
|
||||
/// Return pi / 4.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType quarter_pi();
|
||||
|
||||
/// Return 1 / pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_pi();
|
||||
|
||||
/// Return 1 / (pi * 2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_two_pi();
|
||||
|
||||
/// Return 2 / pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_pi();
|
||||
|
||||
/// Return 4 / pi.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType four_over_pi();
|
||||
|
||||
/// Return 2 / sqrt(pi).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_root_pi();
|
||||
|
||||
/// Return 1 / sqrt(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_root_two();
|
||||
|
||||
/// Return sqrt(pi / 2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_half_pi();
|
||||
|
||||
/// Return sqrt(2 * pi).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two_pi();
|
||||
|
||||
/// Return sqrt(ln(4)).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_ln_four();
|
||||
|
||||
/// Return e constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType e();
|
||||
|
||||
/// Return Euler's constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType euler();
|
||||
|
||||
/// Return sqrt(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two();
|
||||
|
||||
/// Return sqrt(3).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_three();
|
||||
|
||||
/// Return sqrt(5).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType root_five();
|
||||
|
||||
/// Return ln(2).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_two();
|
||||
|
||||
/// Return ln(10).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ten();
|
||||
|
||||
/// Return ln(ln(2)).
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ln_two();
|
||||
|
||||
/// Return 1 / 3.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType third();
|
||||
|
||||
/// Return 2 / 3.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType two_thirds();
|
||||
|
||||
/// Return the golden ratio constant.
|
||||
/// @see gtc_constants
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR genType golden_ratio();
|
||||
|
||||
/// @}
|
||||
|
||||
@@ -1,208 +1,164 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_constants
|
||||
/// @file glm/gtc/constants.inl
|
||||
/// @date 2011-10-14 / 2014-10-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon()
|
||||
{
|
||||
return std::numeric_limits<genType>::epsilon();
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType zero()
|
||||
{
|
||||
return genType(0);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one()
|
||||
{
|
||||
return genType(1);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi()
|
||||
{
|
||||
return genType(3.14159265358979323846264338327950288);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_pi()
|
||||
{
|
||||
return genType(6.28318530717958647692528676655900576);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_pi()
|
||||
{
|
||||
return genType(1.772453850905516027);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType half_pi()
|
||||
{
|
||||
return genType(1.57079632679489661923132169163975144);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType three_over_two_pi()
|
||||
{
|
||||
return genType(4.71238898038468985769396507491925432);
|
||||
return genType(4.71238898038468985769396507491925432);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType quarter_pi()
|
||||
{
|
||||
return genType(0.785398163397448309615660845819875721);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_pi()
|
||||
{
|
||||
return genType(0.318309886183790671537767526745028724);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_two_pi()
|
||||
{
|
||||
return genType(0.159154943091895335768883763372514362);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_pi()
|
||||
{
|
||||
return genType(0.636619772367581343075535053490057448);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType four_over_pi()
|
||||
{
|
||||
return genType(1.273239544735162686151070106980114898);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_root_pi()
|
||||
{
|
||||
return genType(1.12837916709551257389615890312154517);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_root_two()
|
||||
{
|
||||
return genType(0.707106781186547524400844362104849039);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_half_pi()
|
||||
{
|
||||
return genType(1.253314137315500251);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two_pi()
|
||||
{
|
||||
return genType(2.506628274631000502);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_ln_four()
|
||||
{
|
||||
return genType(1.17741002251547469);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType e()
|
||||
{
|
||||
return genType(2.71828182845904523536);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType euler()
|
||||
{
|
||||
return genType(0.577215664901532860606);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two()
|
||||
{
|
||||
return genType(1.41421356237309504880168872420969808);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_three()
|
||||
{
|
||||
return genType(1.73205080756887729352744634150587236);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_five()
|
||||
{
|
||||
return genType(2.23606797749978969640917366873127623);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_two()
|
||||
{
|
||||
return genType(0.693147180559945309417232121458176568);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ten()
|
||||
{
|
||||
return genType(2.30258509299404568401799145468436421);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ln_two()
|
||||
{
|
||||
return genType(-0.3665129205816643);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType third()
|
||||
{
|
||||
return genType(0.3333333333333333333333333333333333333333);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_thirds()
|
||||
{
|
||||
return genType(0.666666666666666666666666666666666666667);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType golden_ratio()
|
||||
{
|
||||
return genType(1.61803398874989484820458683436563811);
|
||||
|
||||
@@ -1,53 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_epsilon
|
||||
/// @file glm/gtc/epsilon.hpp
|
||||
/// @date 2012-04-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtc_epsilon GLM_GTC_epsilon
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Comparison functions for a user defined epsilon values.
|
||||
///
|
||||
/// <glm/gtc/epsilon.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/epsilon.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Comparison functions for a user defined epsilon values.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_epsilon extension included")
|
||||
#endif
|
||||
|
||||
@@ -60,41 +30,29 @@ namespace glm
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> epsilonEqual(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, bool, Q> epsilonEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T const& epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL bool epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL bool epsilonEqual(genType const& x, genType const& y, genType const& epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is not satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::boolType epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, bool, Q> epsilonNotEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T const& epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| >= epsilon.
|
||||
/// True if this expression is not satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL bool epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL bool epsilonNotEqual(genType const& x, genType const& y, genType const& epsilon);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,154 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_epsilon
|
||||
/// @file glm/gtc/epsilon.inl
|
||||
/// @date 2012-04-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Dependency:
|
||||
#include "quaternion.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
float const & x,
|
||||
float const & y,
|
||||
float const & epsilon
|
||||
float const& x,
|
||||
float const& y,
|
||||
float const& epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
double const & x,
|
||||
double const & y,
|
||||
double const & epsilon
|
||||
double const& x,
|
||||
double const& y,
|
||||
double const& epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
float const & x,
|
||||
float const & y,
|
||||
float const & epsilon
|
||||
)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> epsilonEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T const& epsilon)
|
||||
{
|
||||
return lessThan(abs(x - y), vec<L, T, Q>(epsilon));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> epsilonEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& epsilon)
|
||||
{
|
||||
return lessThan(abs(x - y), vec<L, T, Q>(epsilon));
|
||||
}
|
||||
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual(float const& x, float const& y, float const& epsilon)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
double const & x,
|
||||
double const & y,
|
||||
double const & epsilon
|
||||
)
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual(double const& x, double const& y, double const& epsilon)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> epsilonNotEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T const& epsilon)
|
||||
{
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
return greaterThanEqual(abs(x - y), vec<L, T, Q>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> epsilonNotEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& epsilon)
|
||||
{
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
return greaterThanEqual(abs(x - y), vec<L, T, Q>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> epsilonEqual(qua<T, Q> const& x, qua<T, Q> const& y, T const& epsilon)
|
||||
{
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return lessThan(abs(v), vec<4, T, Q>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> epsilonNotEqual(qua<T, Q> const& x, qua<T, Q> const& y, T const& epsilon)
|
||||
{
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonEqual
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return lessThan(abs(v), tvec4<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonNotEqual
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return greaterThanEqual(abs(v), tvec4<T, P>(epsilon));
|
||||
vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return greaterThanEqual(abs(v), vec<4, T, Q>(epsilon));
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,56 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_integer
|
||||
/// @file glm/gtc/integer.hpp
|
||||
/// @date 2014-11-17 / 2014-11-17
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_integer (dependence)
|
||||
///
|
||||
/// @defgroup gtc_integer GLM_GTC_integer
|
||||
/// @ingroup gtc
|
||||
///
|
||||
///
|
||||
/// Include <glm/gtc/integer.hpp> to use the features of this extension.
|
||||
///
|
||||
/// @brief Allow to perform bit operations on integer values
|
||||
///
|
||||
/// <glm/gtc/integer.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/func_common.hpp"
|
||||
#include "../detail/func_integer.hpp"
|
||||
#include "../detail/func_exponential.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../integer.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include <limits>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_integer extension included")
|
||||
#endif
|
||||
|
||||
@@ -61,43 +32,32 @@ namespace glm
|
||||
|
||||
/// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size.
|
||||
/// @see gtc_integer
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType log2(genIUType x);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
/// Returns a value equal to the nearest integer to x.
|
||||
/// The fraction 0.5 will round in a direction chosen by the
|
||||
/// implementation, presumably the direction that is fastest.
|
||||
///
|
||||
/// @tparam genIUType Integer-point scalar or vector types.
|
||||
/// @param x The values of the argument must be greater or equal to zero.
|
||||
/// @tparam T floating point scalar types.
|
||||
///
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType mod(genIUType x, genIUType y);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, int, Q> iround(vec<L, T, Q> const& x);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
/// Returns a value equal to the nearest integer to x.
|
||||
/// The fraction 0.5 will round in a direction chosen by the
|
||||
/// implementation, presumably the direction that is fastest.
|
||||
///
|
||||
/// @tparam T Integer scalar types.
|
||||
/// @tparam vecType vector types.
|
||||
/// @param x The values of the argument must be greater or equal to zero.
|
||||
/// @tparam T floating point scalar types.
|
||||
///
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, T y);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
///
|
||||
/// @tparam T Integer scalar types.
|
||||
/// @tparam vecType vector types.
|
||||
///
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, vecType<T, P> const & y);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, uint, Q> uround(vec<L, T, Q> const& x);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
@@ -1,65 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_integer
|
||||
/// @file glm/gtc/integer.inl
|
||||
/// @date 2014-11-17 / 2014-11-17
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P, template <class, precision> class vecType>
|
||||
struct compute_log2<T, P, vecType, false>
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_log2<L, T, Q, false, Aligned>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & vec)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v)
|
||||
{
|
||||
//Equivalent to return findMSB(vec); but save one function call in ASM with VC
|
||||
//return findMSB(vec);
|
||||
return vecType<T, P>(detail::compute_findMSB_vec<T, P, vecType, sizeof(T) * 8>::call(vec));
|
||||
return vec<L, T, Q>(detail::compute_findMSB_vec<L, T, Q, sizeof(T) * 8>::call(v));
|
||||
}
|
||||
};
|
||||
|
||||
# if GLM_HAS_BITSCAN_WINDOWS
|
||||
template <precision P>
|
||||
struct compute_log2<int, P, tvec4, false>
|
||||
template<qualifier Q, bool Aligned>
|
||||
struct compute_log2<4, int, Q, false, Aligned>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<int, P> call(tvec4<int, P> const & vec)
|
||||
GLM_FUNC_QUALIFIER static vec<4, int, Q> call(vec<4, int, Q> const& v)
|
||||
{
|
||||
tvec4<int, P> Result(glm::uninitialize);
|
||||
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), vec.x);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), vec.y);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), vec.z);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), vec.w);
|
||||
|
||||
vec<4, int, Q> Result;
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), v.x);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), v.y);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), v.z);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), v.w);
|
||||
return Result;
|
||||
}
|
||||
};
|
||||
# endif//GLM_HAS_BITSCAN_WINDOWS
|
||||
}//namespace detail
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER int iround(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'iround' only accept floating-point inputs");
|
||||
assert(static_cast<genType>(0.0) <= x);
|
||||
|
||||
return static_cast<int>(x + static_cast<genType>(0.5));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, int, Q> iround(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'iround' only accept floating-point inputs");
|
||||
assert(all(lessThanEqual(vec<L, T, Q>(0), x)));
|
||||
|
||||
return vec<L, int, Q>(x + static_cast<T>(0.5));
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER uint uround(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'uround' only accept floating-point inputs");
|
||||
assert(static_cast<genType>(0.0) <= x);
|
||||
|
||||
return static_cast<uint>(x + static_cast<genType>(0.5));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, uint, Q> uround(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'uround' only accept floating-point inputs");
|
||||
assert(all(lessThanEqual(vec<L, T, Q>(0), x)));
|
||||
|
||||
return vec<L, uint, Q>(x + static_cast<T>(0.5));
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,49 +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 gtc_matrix_access
|
||||
/// @file glm/gtc/matrix_access.hpp
|
||||
/// @date 2005-12-27 / 2011-05-16
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
///
|
||||
/// @defgroup gtc_matrix_access GLM_GTC_matrix_access
|
||||
/// @ingroup gtc
|
||||
///
|
||||
///
|
||||
/// Include <glm/gtc/matrix_access.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines functions to access rows or columns of a matrix easily.
|
||||
/// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_matrix_access extension included")
|
||||
#endif
|
||||
|
||||
@@ -54,33 +26,33 @@ namespace glm
|
||||
|
||||
/// Get a specific row of a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL typename genType::row_type row(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index);
|
||||
|
||||
/// Set a specific row to a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType row(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index,
|
||||
typename genType::row_type const & x);
|
||||
typename genType::row_type const& x);
|
||||
|
||||
/// Get a specific column of a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL typename genType::col_type column(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index);
|
||||
|
||||
/// Set a specific column to a matrix.
|
||||
/// @see gtc_matrix_access
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType column(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index,
|
||||
typename genType::col_type const & x);
|
||||
typename genType::col_type const& x);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,91 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_access
|
||||
/// @file glm/gtc/matrix_access.inl
|
||||
/// @date 2005-12-27 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType row
|
||||
(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index,
|
||||
typename genType::row_type const & x
|
||||
typename genType::row_type const& x
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
|
||||
assert(index >= 0 && index < m[0].length());
|
||||
|
||||
genType Result = m;
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
|
||||
for(length_t i = 0; i < m.length(); ++i)
|
||||
Result[i][index] = x[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::row_type row
|
||||
(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
|
||||
assert(index >= 0 && index < m[0].length());
|
||||
|
||||
typename genType::row_type Result;
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
|
||||
typename genType::row_type Result(0);
|
||||
for(length_t i = 0; i < m.length(); ++i)
|
||||
Result[i] = m[i][index];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType column
|
||||
(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index,
|
||||
typename genType::col_type const & x
|
||||
typename genType::col_type const& x
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
|
||||
assert(index >= 0 && index < m.length());
|
||||
|
||||
genType Result = m;
|
||||
Result[index] = x;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::col_type column
|
||||
(
|
||||
genType const & m,
|
||||
genType const& m,
|
||||
length_t index
|
||||
)
|
||||
{
|
||||
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
|
||||
assert(index >= 0 && index < m.length());
|
||||
|
||||
return m[index];
|
||||
}
|
||||
|
||||
@@ -1,42 +1,14 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_integer
|
||||
/// @file glm/gtc/matrix_integer.hpp
|
||||
/// @date 2011-01-20 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_matrix_integer GLM_GTC_matrix_integer
|
||||
/// @ingroup gtc
|
||||
///
|
||||
///
|
||||
/// Include <glm/gtc/matrix_integer.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines a number of matrices with integer types.
|
||||
/// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -51,7 +23,7 @@
|
||||
#include "../mat4x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_matrix_integer extension included")
|
||||
#endif
|
||||
|
||||
@@ -60,302 +32,302 @@ namespace glm
|
||||
/// @addtogroup gtc_matrix_integer
|
||||
/// @{
|
||||
|
||||
/// High-precision signed integer 2x2 matrix.
|
||||
/// High-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, highp> highp_imat2;
|
||||
typedef mat<2, 2, int, highp> highp_imat2;
|
||||
|
||||
/// High-precision signed integer 3x3 matrix.
|
||||
/// High-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, highp> highp_imat3;
|
||||
typedef mat<3, 3, int, highp> highp_imat3;
|
||||
|
||||
/// High-precision signed integer 4x4 matrix.
|
||||
/// High-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, highp> highp_imat4;
|
||||
typedef mat<4, 4, int, highp> highp_imat4;
|
||||
|
||||
/// High-precision signed integer 2x2 matrix.
|
||||
/// High-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, highp> highp_imat2x2;
|
||||
typedef mat<2, 2, int, highp> highp_imat2x2;
|
||||
|
||||
/// High-precision signed integer 2x3 matrix.
|
||||
/// High-qualifier signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<int, highp> highp_imat2x3;
|
||||
typedef mat<2, 3, int, highp> highp_imat2x3;
|
||||
|
||||
/// High-precision signed integer 2x4 matrix.
|
||||
/// High-qualifier signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<int, highp> highp_imat2x4;
|
||||
typedef mat<2, 4, int, highp> highp_imat2x4;
|
||||
|
||||
/// High-precision signed integer 3x2 matrix.
|
||||
/// High-qualifier signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<int, highp> highp_imat3x2;
|
||||
typedef mat<3, 2, int, highp> highp_imat3x2;
|
||||
|
||||
/// High-precision signed integer 3x3 matrix.
|
||||
/// High-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, highp> highp_imat3x3;
|
||||
typedef mat<3, 3, int, highp> highp_imat3x3;
|
||||
|
||||
/// High-precision signed integer 3x4 matrix.
|
||||
/// High-qualifier signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<int, highp> highp_imat3x4;
|
||||
typedef mat<3, 4, int, highp> highp_imat3x4;
|
||||
|
||||
/// High-precision signed integer 4x2 matrix.
|
||||
/// High-qualifier signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<int, highp> highp_imat4x2;
|
||||
typedef mat<4, 2, int, highp> highp_imat4x2;
|
||||
|
||||
/// High-precision signed integer 4x3 matrix.
|
||||
/// High-qualifier signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<int, highp> highp_imat4x3;
|
||||
typedef mat<4, 3, int, highp> highp_imat4x3;
|
||||
|
||||
/// High-precision signed integer 4x4 matrix.
|
||||
/// High-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, highp> highp_imat4x4;
|
||||
typedef mat<4, 4, int, highp> highp_imat4x4;
|
||||
|
||||
|
||||
/// Medium-precision signed integer 2x2 matrix.
|
||||
/// Medium-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, mediump> mediump_imat2;
|
||||
typedef mat<2, 2, int, mediump> mediump_imat2;
|
||||
|
||||
/// Medium-precision signed integer 3x3 matrix.
|
||||
/// Medium-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, mediump> mediump_imat3;
|
||||
typedef mat<3, 3, int, mediump> mediump_imat3;
|
||||
|
||||
/// Medium-precision signed integer 4x4 matrix.
|
||||
/// Medium-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, mediump> mediump_imat4;
|
||||
typedef mat<4, 4, int, mediump> mediump_imat4;
|
||||
|
||||
|
||||
/// Medium-precision signed integer 2x2 matrix.
|
||||
/// Medium-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, mediump> mediump_imat2x2;
|
||||
typedef mat<2, 2, int, mediump> mediump_imat2x2;
|
||||
|
||||
/// Medium-precision signed integer 2x3 matrix.
|
||||
/// Medium-qualifier signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<int, mediump> mediump_imat2x3;
|
||||
typedef mat<2, 3, int, mediump> mediump_imat2x3;
|
||||
|
||||
/// Medium-precision signed integer 2x4 matrix.
|
||||
/// Medium-qualifier signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<int, mediump> mediump_imat2x4;
|
||||
typedef mat<2, 4, int, mediump> mediump_imat2x4;
|
||||
|
||||
/// Medium-precision signed integer 3x2 matrix.
|
||||
/// Medium-qualifier signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<int, mediump> mediump_imat3x2;
|
||||
typedef mat<3, 2, int, mediump> mediump_imat3x2;
|
||||
|
||||
/// Medium-precision signed integer 3x3 matrix.
|
||||
/// Medium-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, mediump> mediump_imat3x3;
|
||||
typedef mat<3, 3, int, mediump> mediump_imat3x3;
|
||||
|
||||
/// Medium-precision signed integer 3x4 matrix.
|
||||
/// Medium-qualifier signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<int, mediump> mediump_imat3x4;
|
||||
typedef mat<3, 4, int, mediump> mediump_imat3x4;
|
||||
|
||||
/// Medium-precision signed integer 4x2 matrix.
|
||||
/// Medium-qualifier signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<int, mediump> mediump_imat4x2;
|
||||
typedef mat<4, 2, int, mediump> mediump_imat4x2;
|
||||
|
||||
/// Medium-precision signed integer 4x3 matrix.
|
||||
/// Medium-qualifier signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<int, mediump> mediump_imat4x3;
|
||||
typedef mat<4, 3, int, mediump> mediump_imat4x3;
|
||||
|
||||
/// Medium-precision signed integer 4x4 matrix.
|
||||
/// Medium-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, mediump> mediump_imat4x4;
|
||||
typedef mat<4, 4, int, mediump> mediump_imat4x4;
|
||||
|
||||
|
||||
/// Low-precision signed integer 2x2 matrix.
|
||||
/// Low-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, lowp> lowp_imat2;
|
||||
|
||||
/// Low-precision signed integer 3x3 matrix.
|
||||
typedef mat<2, 2, int, lowp> lowp_imat2;
|
||||
|
||||
/// Low-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, lowp> lowp_imat3;
|
||||
typedef mat<3, 3, int, lowp> lowp_imat3;
|
||||
|
||||
/// Low-precision signed integer 4x4 matrix.
|
||||
/// Low-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, lowp> lowp_imat4;
|
||||
typedef mat<4, 4, int, lowp> lowp_imat4;
|
||||
|
||||
|
||||
/// Low-precision signed integer 2x2 matrix.
|
||||
/// Low-qualifier signed integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<int, lowp> lowp_imat2x2;
|
||||
typedef mat<2, 2, int, lowp> lowp_imat2x2;
|
||||
|
||||
/// Low-precision signed integer 2x3 matrix.
|
||||
/// Low-qualifier signed integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<int, lowp> lowp_imat2x3;
|
||||
typedef mat<2, 3, int, lowp> lowp_imat2x3;
|
||||
|
||||
/// Low-precision signed integer 2x4 matrix.
|
||||
/// Low-qualifier signed integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<int, lowp> lowp_imat2x4;
|
||||
typedef mat<2, 4, int, lowp> lowp_imat2x4;
|
||||
|
||||
/// Low-precision signed integer 3x2 matrix.
|
||||
/// Low-qualifier signed integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<int, lowp> lowp_imat3x2;
|
||||
typedef mat<3, 2, int, lowp> lowp_imat3x2;
|
||||
|
||||
/// Low-precision signed integer 3x3 matrix.
|
||||
/// Low-qualifier signed integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<int, lowp> lowp_imat3x3;
|
||||
typedef mat<3, 3, int, lowp> lowp_imat3x3;
|
||||
|
||||
/// Low-precision signed integer 3x4 matrix.
|
||||
/// Low-qualifier signed integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<int, lowp> lowp_imat3x4;
|
||||
typedef mat<3, 4, int, lowp> lowp_imat3x4;
|
||||
|
||||
/// Low-precision signed integer 4x2 matrix.
|
||||
/// Low-qualifier signed integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<int, lowp> lowp_imat4x2;
|
||||
typedef mat<4, 2, int, lowp> lowp_imat4x2;
|
||||
|
||||
/// Low-precision signed integer 4x3 matrix.
|
||||
/// Low-qualifier signed integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<int, lowp> lowp_imat4x3;
|
||||
typedef mat<4, 3, int, lowp> lowp_imat4x3;
|
||||
|
||||
/// Low-precision signed integer 4x4 matrix.
|
||||
/// Low-qualifier signed integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<int, lowp> lowp_imat4x4;
|
||||
typedef mat<4, 4, int, lowp> lowp_imat4x4;
|
||||
|
||||
|
||||
/// High-precision unsigned integer 2x2 matrix.
|
||||
/// High-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, highp> highp_umat2;
|
||||
typedef mat<2, 2, uint, highp> highp_umat2;
|
||||
|
||||
/// High-precision unsigned integer 3x3 matrix.
|
||||
/// High-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, highp> highp_umat3;
|
||||
typedef mat<3, 3, uint, highp> highp_umat3;
|
||||
|
||||
/// High-precision unsigned integer 4x4 matrix.
|
||||
/// High-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, highp> highp_umat4;
|
||||
typedef mat<4, 4, uint, highp> highp_umat4;
|
||||
|
||||
/// High-precision unsigned integer 2x2 matrix.
|
||||
/// High-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, highp> highp_umat2x2;
|
||||
typedef mat<2, 2, uint, highp> highp_umat2x2;
|
||||
|
||||
/// High-precision unsigned integer 2x3 matrix.
|
||||
/// High-qualifier unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<uint, highp> highp_umat2x3;
|
||||
typedef mat<2, 3, uint, highp> highp_umat2x3;
|
||||
|
||||
/// High-precision unsigned integer 2x4 matrix.
|
||||
/// High-qualifier unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<uint, highp> highp_umat2x4;
|
||||
typedef mat<2, 4, uint, highp> highp_umat2x4;
|
||||
|
||||
/// High-precision unsigned integer 3x2 matrix.
|
||||
/// High-qualifier unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<uint, highp> highp_umat3x2;
|
||||
typedef mat<3, 2, uint, highp> highp_umat3x2;
|
||||
|
||||
/// High-precision unsigned integer 3x3 matrix.
|
||||
/// High-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, highp> highp_umat3x3;
|
||||
typedef mat<3, 3, uint, highp> highp_umat3x3;
|
||||
|
||||
/// High-precision unsigned integer 3x4 matrix.
|
||||
/// High-qualifier unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<uint, highp> highp_umat3x4;
|
||||
typedef mat<3, 4, uint, highp> highp_umat3x4;
|
||||
|
||||
/// High-precision unsigned integer 4x2 matrix.
|
||||
/// High-qualifier unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<uint, highp> highp_umat4x2;
|
||||
typedef mat<4, 2, uint, highp> highp_umat4x2;
|
||||
|
||||
/// High-precision unsigned integer 4x3 matrix.
|
||||
/// High-qualifier unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<uint, highp> highp_umat4x3;
|
||||
typedef mat<4, 3, uint, highp> highp_umat4x3;
|
||||
|
||||
/// High-precision unsigned integer 4x4 matrix.
|
||||
/// High-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, highp> highp_umat4x4;
|
||||
typedef mat<4, 4, uint, highp> highp_umat4x4;
|
||||
|
||||
|
||||
/// Medium-precision unsigned integer 2x2 matrix.
|
||||
/// Medium-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, mediump> mediump_umat2;
|
||||
typedef mat<2, 2, uint, mediump> mediump_umat2;
|
||||
|
||||
/// Medium-precision unsigned integer 3x3 matrix.
|
||||
/// Medium-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, mediump> mediump_umat3;
|
||||
typedef mat<3, 3, uint, mediump> mediump_umat3;
|
||||
|
||||
/// Medium-precision unsigned integer 4x4 matrix.
|
||||
/// Medium-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, mediump> mediump_umat4;
|
||||
typedef mat<4, 4, uint, mediump> mediump_umat4;
|
||||
|
||||
|
||||
/// Medium-precision unsigned integer 2x2 matrix.
|
||||
/// Medium-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, mediump> mediump_umat2x2;
|
||||
typedef mat<2, 2, uint, mediump> mediump_umat2x2;
|
||||
|
||||
/// Medium-precision unsigned integer 2x3 matrix.
|
||||
/// Medium-qualifier unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<uint, mediump> mediump_umat2x3;
|
||||
typedef mat<2, 3, uint, mediump> mediump_umat2x3;
|
||||
|
||||
/// Medium-precision unsigned integer 2x4 matrix.
|
||||
/// Medium-qualifier unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<uint, mediump> mediump_umat2x4;
|
||||
typedef mat<2, 4, uint, mediump> mediump_umat2x4;
|
||||
|
||||
/// Medium-precision unsigned integer 3x2 matrix.
|
||||
/// Medium-qualifier unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<uint, mediump> mediump_umat3x2;
|
||||
typedef mat<3, 2, uint, mediump> mediump_umat3x2;
|
||||
|
||||
/// Medium-precision unsigned integer 3x3 matrix.
|
||||
/// Medium-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, mediump> mediump_umat3x3;
|
||||
typedef mat<3, 3, uint, mediump> mediump_umat3x3;
|
||||
|
||||
/// Medium-precision unsigned integer 3x4 matrix.
|
||||
/// Medium-qualifier unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<uint, mediump> mediump_umat3x4;
|
||||
typedef mat<3, 4, uint, mediump> mediump_umat3x4;
|
||||
|
||||
/// Medium-precision unsigned integer 4x2 matrix.
|
||||
/// Medium-qualifier unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<uint, mediump> mediump_umat4x2;
|
||||
typedef mat<4, 2, uint, mediump> mediump_umat4x2;
|
||||
|
||||
/// Medium-precision unsigned integer 4x3 matrix.
|
||||
/// Medium-qualifier unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<uint, mediump> mediump_umat4x3;
|
||||
typedef mat<4, 3, uint, mediump> mediump_umat4x3;
|
||||
|
||||
/// Medium-precision unsigned integer 4x4 matrix.
|
||||
/// Medium-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, mediump> mediump_umat4x4;
|
||||
typedef mat<4, 4, uint, mediump> mediump_umat4x4;
|
||||
|
||||
|
||||
/// Low-precision unsigned integer 2x2 matrix.
|
||||
/// Low-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, lowp> lowp_umat2;
|
||||
|
||||
/// Low-precision unsigned integer 3x3 matrix.
|
||||
typedef mat<2, 2, uint, lowp> lowp_umat2;
|
||||
|
||||
/// Low-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, lowp> lowp_umat3;
|
||||
typedef mat<3, 3, uint, lowp> lowp_umat3;
|
||||
|
||||
/// Low-precision unsigned integer 4x4 matrix.
|
||||
/// Low-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, lowp> lowp_umat4;
|
||||
typedef mat<4, 4, uint, lowp> lowp_umat4;
|
||||
|
||||
|
||||
/// Low-precision unsigned integer 2x2 matrix.
|
||||
/// Low-qualifier unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x2<uint, lowp> lowp_umat2x2;
|
||||
typedef mat<2, 2, uint, lowp> lowp_umat2x2;
|
||||
|
||||
/// Low-precision unsigned integer 2x3 matrix.
|
||||
/// Low-qualifier unsigned integer 2x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x3<uint, lowp> lowp_umat2x3;
|
||||
typedef mat<2, 3, uint, lowp> lowp_umat2x3;
|
||||
|
||||
/// Low-precision unsigned integer 2x4 matrix.
|
||||
/// Low-qualifier unsigned integer 2x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat2x4<uint, lowp> lowp_umat2x4;
|
||||
typedef mat<2, 4, uint, lowp> lowp_umat2x4;
|
||||
|
||||
/// Low-precision unsigned integer 3x2 matrix.
|
||||
/// Low-qualifier unsigned integer 3x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x2<uint, lowp> lowp_umat3x2;
|
||||
typedef mat<3, 2, uint, lowp> lowp_umat3x2;
|
||||
|
||||
/// Low-precision unsigned integer 3x3 matrix.
|
||||
/// Low-qualifier unsigned integer 3x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x3<uint, lowp> lowp_umat3x3;
|
||||
typedef mat<3, 3, uint, lowp> lowp_umat3x3;
|
||||
|
||||
/// Low-precision unsigned integer 3x4 matrix.
|
||||
/// Low-qualifier unsigned integer 3x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat3x4<uint, lowp> lowp_umat3x4;
|
||||
typedef mat<3, 4, uint, lowp> lowp_umat3x4;
|
||||
|
||||
/// Low-precision unsigned integer 4x2 matrix.
|
||||
/// Low-qualifier unsigned integer 4x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x2<uint, lowp> lowp_umat4x2;
|
||||
typedef mat<4, 2, uint, lowp> lowp_umat4x2;
|
||||
|
||||
/// Low-precision unsigned integer 4x3 matrix.
|
||||
/// Low-qualifier unsigned integer 4x3 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x3<uint, lowp> lowp_umat4x3;
|
||||
typedef mat<4, 3, uint, lowp> lowp_umat4x3;
|
||||
|
||||
/// Low-precision unsigned integer 4x4 matrix.
|
||||
/// Low-qualifier unsigned integer 4x4 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef tmat4x4<uint, lowp> lowp_umat4x4;
|
||||
typedef mat<4, 4, uint, lowp> lowp_umat4x4;
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_INT))
|
||||
typedef highp_imat2 imat2;
|
||||
@@ -461,7 +433,7 @@ namespace glm
|
||||
typedef lowp_umat4x3 umat4x3;
|
||||
typedef lowp_umat4x4 umat4x4;
|
||||
#else //if(defined(GLM_PRECISION_MEDIUMP_UINT))
|
||||
|
||||
|
||||
/// Unsigned integer 2x2 matrix.
|
||||
/// @see gtc_matrix_integer
|
||||
typedef mediump_umat2 umat2;
|
||||
|
||||
@@ -1,42 +1,14 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_inverse
|
||||
/// @file glm/gtc/matrix_inverse.hpp
|
||||
/// @date 2005-12-21 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
///
|
||||
/// @defgroup gtc_matrix_inverse GLM_GTC_matrix_inverse
|
||||
/// @ingroup gtc
|
||||
///
|
||||
///
|
||||
/// Include <glm/gtc/matrix_integer.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines additional matrix inverting functions.
|
||||
/// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -47,7 +19,7 @@
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_matrix_inverse extension included")
|
||||
#endif
|
||||
|
||||
@@ -57,20 +29,20 @@ namespace glm
|
||||
/// @{
|
||||
|
||||
/// Fast matrix inverse for affine matrix.
|
||||
///
|
||||
///
|
||||
/// @param m Input matrix to invert.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-qualifier floating point value is highly innacurate.
|
||||
/// @see gtc_matrix_inverse
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType affineInverse(genType const & m);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType affineInverse(genType const& m);
|
||||
|
||||
/// Compute the inverse transpose of a matrix.
|
||||
///
|
||||
///
|
||||
/// @param m Input matrix to invert transpose.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
|
||||
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-qualifier floating point value is highly innacurate.
|
||||
/// @see gtc_matrix_inverse
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType inverseTranspose(genType const & m);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType inverseTranspose(genType const& m);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,66 +1,36 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_inverse
|
||||
/// @file glm/gtc/matrix_inverse.inl
|
||||
/// @date 2005-12-21 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> affineInverse(tmat3x3<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> affineInverse(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
tmat2x2<T, P> const Inv(inverse(tmat2x2<T, P>(m)));
|
||||
mat<2, 2, T, Q> const Inv(inverse(mat<2, 2, T, Q>(m)));
|
||||
|
||||
return tmat3x3<T, P>(
|
||||
tvec3<T, P>(Inv[0], static_cast<T>(0)),
|
||||
tvec3<T, P>(Inv[1], static_cast<T>(0)),
|
||||
tvec3<T, P>(-Inv * tvec2<T, P>(m[2]), static_cast<T>(1)));
|
||||
return mat<3, 3, T, Q>(
|
||||
vec<3, T, Q>(Inv[0], static_cast<T>(0)),
|
||||
vec<3, T, Q>(Inv[1], static_cast<T>(0)),
|
||||
vec<3, T, Q>(-Inv * vec<2, T, Q>(m[2]), static_cast<T>(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> affineInverse(tmat4x4<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> affineInverse(mat<4, 4, T, Q> const& m)
|
||||
{
|
||||
tmat3x3<T, P> const Inv(inverse(tmat3x3<T, P>(m)));
|
||||
mat<3, 3, T, Q> const Inv(inverse(mat<3, 3, T, Q>(m)));
|
||||
|
||||
return tmat4x4<T, P>(
|
||||
tvec4<T, P>(Inv[0], static_cast<T>(0)),
|
||||
tvec4<T, P>(Inv[1], static_cast<T>(0)),
|
||||
tvec4<T, P>(Inv[2], static_cast<T>(0)),
|
||||
tvec4<T, P>(-Inv * tvec3<T, P>(m[3]), static_cast<T>(1)));
|
||||
return mat<4, 4, T, Q>(
|
||||
vec<4, T, Q>(Inv[0], static_cast<T>(0)),
|
||||
vec<4, T, Q>(Inv[1], static_cast<T>(0)),
|
||||
vec<4, T, Q>(Inv[2], static_cast<T>(0)),
|
||||
vec<4, T, Q>(-Inv * vec<3, T, Q>(m[3]), static_cast<T>(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat2x2<T, P> inverseTranspose(tmat2x2<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<2, 2, T, Q> inverseTranspose(mat<2, 2, T, Q> const& m)
|
||||
{
|
||||
T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
||||
|
||||
tmat2x2<T, P> Inverse(
|
||||
mat<2, 2, T, Q> Inverse(
|
||||
+ m[1][1] / Determinant,
|
||||
- m[0][1] / Determinant,
|
||||
- m[1][0] / Determinant,
|
||||
@@ -69,15 +39,15 @@ namespace glm
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> inverseTranspose(tmat3x3<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> inverseTranspose(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
T Determinant =
|
||||
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
|
||||
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
|
||||
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
||||
|
||||
tmat3x3<T, P> Inverse(uninitialize);
|
||||
mat<3, 3, T, Q> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
||||
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
||||
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
||||
@@ -92,8 +62,8 @@ namespace glm
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> inverseTranspose(tmat4x4<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> inverseTranspose(mat<4, 4, T, Q> const& m)
|
||||
{
|
||||
T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
|
||||
T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
|
||||
@@ -115,7 +85,7 @@ namespace glm
|
||||
T SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
||||
T SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
||||
|
||||
tmat4x4<T, P> Inverse(uninitialize);
|
||||
mat<4, 4, T, Q> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
||||
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
||||
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
||||
|
||||
@@ -1,51 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_transform
|
||||
/// @file glm/gtc/matrix_transform.hpp
|
||||
/// @date 2009-04-29 / 2011-05-16
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtx_transform
|
||||
/// @see gtx_transform2
|
||||
///
|
||||
///
|
||||
/// @defgroup gtc_matrix_transform GLM_GTC_matrix_transform
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Defines functions that generate common transformation matrices.
|
||||
///
|
||||
///
|
||||
/// Include <glm/gtc/matrix_transform.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines functions that generate common transformation matrices.
|
||||
///
|
||||
/// The matrices generated by this extension use standard OpenGL fixed-function
|
||||
/// conventions. For example, the lookAt function generates a transform from world
|
||||
/// space into the specific eye space that the projective matrix functions
|
||||
/// space into the specific eye space that the projective matrix functions
|
||||
/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
|
||||
/// specifications defines the particular layout of this eye space.
|
||||
///
|
||||
/// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -54,341 +25,12 @@
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
#include "../ext/matrix_projection.hpp"
|
||||
#include "../ext/matrix_clip_space.hpp"
|
||||
#include "../ext/matrix_transform.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_matrix_transform
|
||||
/// @{
|
||||
|
||||
/// Builds a translation 4 * 4 matrix created from a vector of 3 components.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this translation matrix.
|
||||
/// @param v Coordinates of a translation vector.
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @code
|
||||
/// #include <glm/glm.hpp>
|
||||
/// #include <glm/gtc/matrix_transform.hpp>
|
||||
/// ...
|
||||
/// glm::mat4 m = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));
|
||||
/// // m[0][0] == 1.0f, m[0][1] == 0.0f, m[0][2] == 0.0f, m[0][3] == 0.0f
|
||||
/// // m[1][0] == 0.0f, m[1][1] == 1.0f, m[1][2] == 0.0f, m[1][3] == 0.0f
|
||||
/// // m[2][0] == 0.0f, m[2][1] == 0.0f, m[2][2] == 1.0f, m[2][3] == 0.0f
|
||||
/// // m[3][0] == 1.0f, m[3][1] == 1.0f, m[3][2] == 1.0f, m[3][3] == 1.0f
|
||||
/// @endcode
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - translate(tmat4x4<T, P> const & m, T x, T y, T z)
|
||||
/// @see - translate(tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> translate(
|
||||
tmat4x4<T, P> const & m,
|
||||
tvec3<T, P> const & v);
|
||||
|
||||
/// Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this rotation matrix.
|
||||
/// @param angle Rotation angle expressed in radians.
|
||||
/// @param axis Rotation axis, recommended to be normalized.
|
||||
/// @tparam T Value type used to build the matrix. Supported: half, float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - rotate(tmat4x4<T, P> const & m, T angle, T x, T y, T z)
|
||||
/// @see - rotate(T angle, tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> rotate(
|
||||
tmat4x4<T, P> const & m,
|
||||
T angle,
|
||||
tvec3<T, P> const & axis);
|
||||
|
||||
/// Builds a scale 4 * 4 matrix created from 3 scalars.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this scale matrix.
|
||||
/// @param v Ratio of scaling for each axis.
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - scale(tmat4x4<T, P> const & m, T x, T y, T z)
|
||||
/// @see - scale(tvec3<T, P> const & v)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> scale(
|
||||
tmat4x4<T, P> const & m,
|
||||
tvec3<T, P> const & v);
|
||||
|
||||
/// Creates a matrix for an orthographic parallel viewing volume.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @param zNear
|
||||
/// @param zFar
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top)
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> ortho(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top,
|
||||
T zNear,
|
||||
T zFar);
|
||||
|
||||
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar)
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> ortho(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top);
|
||||
|
||||
/// Creates a frustum matrix.
|
||||
///
|
||||
/// @param left
|
||||
/// @param right
|
||||
/// @param bottom
|
||||
/// @param top
|
||||
/// @param near
|
||||
/// @param far
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> frustum(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspective(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveRH(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveLH(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Builds a perspective projection matrix based on a field of view and the default handedness.
|
||||
///
|
||||
/// @param fov Expressed in radians.
|
||||
/// @param width
|
||||
/// @param height
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveFov(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Builds a right handed perspective projection matrix based on a field of view.
|
||||
///
|
||||
/// @param fov Expressed in radians.
|
||||
/// @param width
|
||||
/// @param height
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveFovRH(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Builds a left handed perspective projection matrix based on a field of view.
|
||||
///
|
||||
/// @param fov Expressed in radians.
|
||||
/// @param width
|
||||
/// @param height
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveFovLH(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T near,
|
||||
T far);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||
///
|
||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||
/// @param ep
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near, T ep);
|
||||
|
||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
||||
///
|
||||
/// @param obj Specify the object coordinates.
|
||||
/// @param model Specifies the current modelview matrix
|
||||
/// @param proj Specifies the current projection matrix
|
||||
/// @param viewport Specifies the current viewport
|
||||
/// @return Return the computed window coordinates.
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> project(
|
||||
tvec3<T, P> const & obj,
|
||||
tmat4x4<T, P> const & model,
|
||||
tmat4x4<T, P> const & proj,
|
||||
tvec4<U, P> const & viewport);
|
||||
|
||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
||||
///
|
||||
/// @param win Specify the window coordinates to be mapped.
|
||||
/// @param model Specifies the modelview matrix
|
||||
/// @param proj Specifies the projection matrix
|
||||
/// @param viewport Specifies the viewport
|
||||
/// @return Returns the computed object coordinates.
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> unProject(
|
||||
tvec3<T, P> const & win,
|
||||
tmat4x4<T, P> const & model,
|
||||
tmat4x4<T, P> const & proj,
|
||||
tvec4<U, P> const & viewport);
|
||||
|
||||
/// Define a picking region
|
||||
///
|
||||
/// @param center
|
||||
/// @param delta
|
||||
/// @param viewport
|
||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double.
|
||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T, precision P, typename U>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> pickMatrix(
|
||||
tvec2<T, P> const & center,
|
||||
tvec2<T, P> const & delta,
|
||||
tvec4<U, P> const & viewport);
|
||||
|
||||
/// Build a look at view matrix based on the default handedness.
|
||||
///
|
||||
/// @param eye Position of the camera
|
||||
/// @param center Position where the camera is looking at
|
||||
/// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> lookAt(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up);
|
||||
|
||||
/// Build a right handed look at view matrix.
|
||||
///
|
||||
/// @param eye Position of the camera
|
||||
/// @param center Position where the camera is looking at
|
||||
/// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> lookAtRH(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up);
|
||||
|
||||
/// Build a left handed look at view matrix.
|
||||
///
|
||||
/// @param eye Position of the camera
|
||||
/// @param center Position where the camera is looking at
|
||||
/// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1)
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> lookAtLH(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "matrix_transform.inl"
|
||||
|
||||
@@ -1,538 +1,3 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_matrix_transform
|
||||
/// @file glm/gtc/matrix_transform.inl
|
||||
/// @date 2009-04-29 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../geometric.hpp"
|
||||
#include "../trigonometric.hpp"
|
||||
#include "../matrix.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> translate
|
||||
(
|
||||
tmat4x4<T, P> const & m,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
tmat4x4<T, P> Result(m);
|
||||
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate
|
||||
(
|
||||
tmat4x4<T, P> const & m,
|
||||
T angle,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
T const a = angle;
|
||||
T const c = cos(a);
|
||||
T const s = sin(a);
|
||||
|
||||
tvec3<T, P> axis(normalize(v));
|
||||
tvec3<T, P> temp((T(1) - c) * axis);
|
||||
|
||||
tmat4x4<T, P> Rotate(uninitialize);
|
||||
Rotate[0][0] = c + temp[0] * axis[0];
|
||||
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
|
||||
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
|
||||
|
||||
Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
|
||||
Rotate[1][1] = c + temp[1] * axis[1];
|
||||
Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
|
||||
|
||||
Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
|
||||
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
|
||||
Rotate[2][2] = c + temp[2] * axis[2];
|
||||
|
||||
tmat4x4<T, P> Result(uninitialize);
|
||||
Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
|
||||
Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
|
||||
Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
|
||||
Result[3] = m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate_slow
|
||||
(
|
||||
tmat4x4<T, P> const & m,
|
||||
T angle,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
T const a = angle;
|
||||
T const c = cos(a);
|
||||
T const s = sin(a);
|
||||
tmat4x4<T, P> Result;
|
||||
|
||||
tvec3<T, P> axis = normalize(v);
|
||||
|
||||
Result[0][0] = c + (1 - c) * axis.x * axis.x;
|
||||
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z;
|
||||
Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y;
|
||||
Result[0][3] = 0;
|
||||
|
||||
Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z;
|
||||
Result[1][1] = c + (1 - c) * axis.y * axis.y;
|
||||
Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x;
|
||||
Result[1][3] = 0;
|
||||
|
||||
Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y;
|
||||
Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x;
|
||||
Result[2][2] = c + (1 - c) * axis.z * axis.z;
|
||||
Result[2][3] = 0;
|
||||
|
||||
Result[3] = tvec4<T, P>(0, 0, 0, 1);
|
||||
return m * Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> scale
|
||||
(
|
||||
tmat4x4<T, P> const & m,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
tmat4x4<T, P> Result(uninitialize);
|
||||
Result[0] = m[0] * v[0];
|
||||
Result[1] = m[1] * v[1];
|
||||
Result[2] = m[2] * v[2];
|
||||
Result[3] = m[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> scale_slow
|
||||
(
|
||||
tmat4x4<T, P> const & m,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
tmat4x4<T, P> Result(T(1));
|
||||
Result[0][0] = v.x;
|
||||
Result[1][1] = v.y;
|
||||
Result[2][2] = v.z;
|
||||
return m * Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
|
||||
(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
tmat4x4<T, defaultp> Result(1);
|
||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||
Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
|
||||
(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top
|
||||
)
|
||||
{
|
||||
tmat4x4<T, defaultp> Result(1);
|
||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||
Result[2][2] = - static_cast<T>(1);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum
|
||||
(
|
||||
T left,
|
||||
T right,
|
||||
T bottom,
|
||||
T top,
|
||||
T nearVal,
|
||||
T farVal
|
||||
)
|
||||
{
|
||||
tmat4x4<T, defaultp> Result(0);
|
||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||
Result[2][0] = (right + left) / (right - left);
|
||||
Result[2][1] = (top + bottom) / (top - bottom);
|
||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||
Result[2][3] = static_cast<T>(-1);
|
||||
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
#ifdef GLM_LEFT_HANDED
|
||||
return perspectiveLH(fovy, aspect, zNear, zFar);
|
||||
#else
|
||||
return perspectiveRH(fovy, aspect, zNear, zFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveRH
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||
|
||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||
|
||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = - static_cast<T>(1);
|
||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveLH
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||
|
||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||
|
||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = static_cast<T>(1);
|
||||
Result[3][2] = -(static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFov
|
||||
(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
#ifdef GLM_LEFT_HANDED
|
||||
return perspectiveFovLH(fov, width, height, zNear, zFar);
|
||||
#else
|
||||
return perspectiveFovRH(fov, width, height, zNear, zFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFovRH
|
||||
(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
assert(width > static_cast<T>(0));
|
||||
assert(height > static_cast<T>(0));
|
||||
assert(fov > static_cast<T>(0));
|
||||
|
||||
T const rad = fov;
|
||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||
|
||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = w;
|
||||
Result[1][1] = h;
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = - static_cast<T>(1);
|
||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFovLH
|
||||
(
|
||||
T fov,
|
||||
T width,
|
||||
T height,
|
||||
T zNear,
|
||||
T zFar
|
||||
)
|
||||
{
|
||||
assert(width > static_cast<T>(0));
|
||||
assert(height > static_cast<T>(0));
|
||||
assert(fov > static_cast<T>(0));
|
||||
|
||||
T const rad = fov;
|
||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||
|
||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||
Result[0][0] = w;
|
||||
Result[1][1] = h;
|
||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = static_cast<T>(1);
|
||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear
|
||||
)
|
||||
{
|
||||
T const range = tan(fovy / T(2)) * zNear;
|
||||
T const left = -range * aspect;
|
||||
T const right = range * aspect;
|
||||
T const bottom = -range;
|
||||
T const top = range;
|
||||
|
||||
tmat4x4<T, defaultp> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - T(1);
|
||||
Result[2][3] = - T(1);
|
||||
Result[3][2] = - T(2) * zNear;
|
||||
return Result;
|
||||
}
|
||||
|
||||
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T ep
|
||||
)
|
||||
{
|
||||
T const range = tan(fovy / T(2)) * zNear;
|
||||
T const left = -range * aspect;
|
||||
T const right = range * aspect;
|
||||
T const bottom = -range;
|
||||
T const top = range;
|
||||
|
||||
tmat4x4<T, defaultp> Result(T(0));
|
||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = ep - static_cast<T>(1);
|
||||
Result[2][3] = static_cast<T>(-1);
|
||||
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear
|
||||
)
|
||||
{
|
||||
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
|
||||
}
|
||||
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> project
|
||||
(
|
||||
tvec3<T, P> const & obj,
|
||||
tmat4x4<T, P> const & model,
|
||||
tmat4x4<T, P> const & proj,
|
||||
tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
tvec4<T, P> tmp = tvec4<T, P>(obj, T(1));
|
||||
tmp = model * tmp;
|
||||
tmp = proj * tmp;
|
||||
|
||||
tmp /= tmp.w;
|
||||
tmp = tmp * T(0.5) + T(0.5);
|
||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||
|
||||
return tvec3<T, P>(tmp);
|
||||
}
|
||||
|
||||
template <typename T, typename U, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> unProject
|
||||
(
|
||||
tvec3<T, P> const & win,
|
||||
tmat4x4<T, P> const & model,
|
||||
tmat4x4<T, P> const & proj,
|
||||
tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
tmat4x4<T, P> Inverse = inverse(proj * model);
|
||||
|
||||
tvec4<T, P> tmp = tvec4<T, P>(win, T(1));
|
||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||
tmp = tmp * T(2) - T(1);
|
||||
|
||||
tvec4<T, P> obj = Inverse * tmp;
|
||||
obj /= obj.w;
|
||||
|
||||
return tvec3<T, P>(obj);
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename U>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> pickMatrix
|
||||
(
|
||||
tvec2<T, P> const & center,
|
||||
tvec2<T, P> const & delta,
|
||||
tvec4<U, P> const & viewport
|
||||
)
|
||||
{
|
||||
assert(delta.x > T(0) && delta.y > T(0));
|
||||
tmat4x4<T, P> Result(1.0f);
|
||||
|
||||
if(!(delta.x > T(0) && delta.y > T(0)))
|
||||
return Result; // Error
|
||||
|
||||
tvec3<T, P> Temp(
|
||||
(T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x,
|
||||
(T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y,
|
||||
T(0));
|
||||
|
||||
// Translate and scale the picked region to the entire window
|
||||
Result = translate(Result, Temp);
|
||||
return scale(Result, tvec3<T, P>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAt
|
||||
(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up
|
||||
)
|
||||
{
|
||||
#ifdef GLM_LEFT_HANDED
|
||||
return lookAtLH(eye, center, up);
|
||||
#else
|
||||
return lookAtRH(eye, center, up);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAtRH
|
||||
(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up
|
||||
)
|
||||
{
|
||||
tvec3<T, P> const f(normalize(center - eye));
|
||||
tvec3<T, P> const s(normalize(cross(f, up)));
|
||||
tvec3<T, P> const u(cross(s, f));
|
||||
|
||||
tmat4x4<T, P> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] =-f.x;
|
||||
Result[1][2] =-f.y;
|
||||
Result[2][2] =-f.z;
|
||||
Result[3][0] =-dot(s, eye);
|
||||
Result[3][1] =-dot(u, eye);
|
||||
Result[3][2] = dot(f, eye);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAtLH
|
||||
(
|
||||
tvec3<T, P> const & eye,
|
||||
tvec3<T, P> const & center,
|
||||
tvec3<T, P> const & up
|
||||
)
|
||||
{
|
||||
tvec3<T, P> const f(normalize(center - eye));
|
||||
tvec3<T, P> const s(normalize(cross(up, f)));
|
||||
tvec3<T, P> const u(cross(f, s));
|
||||
|
||||
tmat4x4<T, P> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] = f.x;
|
||||
Result[1][2] = f.y;
|
||||
Result[2][2] = f.z;
|
||||
Result[3][0] = -dot(s, eye);
|
||||
Result[3][1] = -dot(u, eye);
|
||||
Result[3][2] = -dot(f, eye);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,52 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_noise
|
||||
/// @file glm/gtc/noise.hpp
|
||||
/// @date 2011-04-21 / 2011-09-27
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_noise GLM_GTC_noise
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines 2D, 3D and 4D procedural noise functions
|
||||
/// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
|
||||
/// https://github.com/ashima/webgl-noise
|
||||
/// Following Stefan Gustavson's paper "Simplex noise demystified":
|
||||
///
|
||||
/// Include <glm/gtc/noise.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines 2D, 3D and 4D procedural noise functions
|
||||
/// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
|
||||
/// https://github.com/ashima/webgl-noise
|
||||
/// Following Stefan Gustavson's paper "Simplex noise demystified":
|
||||
/// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
|
||||
/// <glm/gtc/noise.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/_noise.hpp"
|
||||
#include "../geometric.hpp"
|
||||
#include "../common.hpp"
|
||||
@@ -55,7 +27,7 @@
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_noise extension included")
|
||||
#endif
|
||||
|
||||
@@ -66,22 +38,22 @@ namespace glm
|
||||
|
||||
/// Classic perlin noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T perlin(
|
||||
vecType<T, P> const & p);
|
||||
|
||||
vec<L, T, Q> const& p);
|
||||
|
||||
/// Periodic perlin noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T perlin(
|
||||
vecType<T, P> const & p,
|
||||
vecType<T, P> const & rep);
|
||||
vec<L, T, Q> const& p,
|
||||
vec<L, T, Q> const& rep);
|
||||
|
||||
/// Simplex noise.
|
||||
/// @see gtc_noise
|
||||
template <typename T, precision P, template<typename, precision> class vecType>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T simplex(
|
||||
vecType<T, P> const & p);
|
||||
vec<L, T, Q> const& p);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_packing
|
||||
/// @file glm/gtc/packing.hpp
|
||||
/// @date 2013-08-08 / 2013-08-08
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_packing GLM_GTC_packing
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief This extension provides a set of function to convert vertors to packed
|
||||
///
|
||||
/// Include <glm/gtc/packing.hpp> to use the features of this extension.
|
||||
///
|
||||
/// This extension provides a set of function to convert vertors to packed
|
||||
/// formats.
|
||||
///
|
||||
/// <glm/gtc/packing.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "type_precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_packing extension included")
|
||||
#endif
|
||||
|
||||
@@ -61,17 +32,17 @@ namespace glm
|
||||
/// packUnorm1x8: round(clamp(c, 0, +1) * 255.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm2x8(vec2 const & v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const & v)
|
||||
/// @see uint16 packUnorm2x8(vec2 const& v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint8 packUnorm1x8(float v);
|
||||
|
||||
/// Convert a single 8-bit integer to a normalized floating-point value.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm4x8: f / 255.0
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackUnorm2x8(uint16 p)
|
||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||
@@ -89,28 +60,28 @@ namespace glm
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packUnorm1x8(float const & v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const & v)
|
||||
/// @see uint8 packUnorm1x8(float const& v)
|
||||
/// @see uint32 packUnorm4x8(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const & v);
|
||||
GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const& v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit unsigned integers.
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit unsigned integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm4x8: f / 255.0
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackUnorm1x8(uint8 v)
|
||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 p);
|
||||
|
||||
|
||||
/// First, converts the normalized floating-point value v into 8-bit integer value.
|
||||
/// Then, the results are packed into the returned 8-bit unsigned integer.
|
||||
///
|
||||
@@ -118,25 +89,25 @@ namespace glm
|
||||
/// packSnorm1x8: round(clamp(s, -1, +1) * 127.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm2x8(vec2 const & v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const & v)
|
||||
/// @see uint16 packSnorm2x8(vec2 const& v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint8 packSnorm1x8(float s);
|
||||
|
||||
/// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
|
||||
/// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
|
||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm1x8: clamp(f / 127.0, -1, +1)
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackSnorm2x8(uint16 p)
|
||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackSnorm1x8(uint8 p);
|
||||
|
||||
|
||||
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
@@ -147,28 +118,28 @@ namespace glm
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packSnorm1x8(float const & v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const & v)
|
||||
/// @see uint8 packSnorm1x8(float const& v)
|
||||
/// @see uint32 packSnorm4x8(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const & v);
|
||||
GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const& v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit signed integers.
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm2x8: clamp(f / 127.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackSnorm1x8(uint8 p)
|
||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p);
|
||||
|
||||
|
||||
/// First, converts the normalized floating-point value v into a 16-bit integer value.
|
||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||
///
|
||||
@@ -176,18 +147,18 @@ namespace glm
|
||||
/// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm1x16(float const & v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||
/// @see uint16 packSnorm1x16(float const& v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packUnorm1x16(float v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
|
||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnorm1x16: f / 65535.0
|
||||
///
|
||||
/// unpackUnorm1x16: f / 65535.0
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackUnorm2x16(uint32 p)
|
||||
/// @see vec4 unpackUnorm4x16(uint64 p)
|
||||
@@ -205,21 +176,21 @@ namespace glm
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm1x16(float const & v)
|
||||
/// @see uint32 packUnorm2x16(vec2 const & v)
|
||||
/// @see uint16 packUnorm1x16(float const& v)
|
||||
/// @see uint32 packUnorm2x16(vec2 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const & v);
|
||||
GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const& v);
|
||||
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit unsigned integers.
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit unsigned integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackUnormx4x16: f / 65535.0
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// unpackUnormx4x16: f / 65535.0
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackUnorm1x16(uint16 p)
|
||||
/// @see vec2 unpackUnorm2x16(uint32 p)
|
||||
@@ -234,18 +205,18 @@ namespace glm
|
||||
/// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0)
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm2x16(vec2 const & v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||
/// @see uint32 packSnorm2x16(vec2 const& v)
|
||||
/// @see uint64 packSnorm4x16(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packSnorm1x16(float v);
|
||||
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
|
||||
/// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned scalar.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm1x16: clamp(f / 32767.0, -1, +1)
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackSnorm2x16(uint32 p)
|
||||
/// @see vec4 unpackSnorm4x16(uint64 p)
|
||||
@@ -263,122 +234,122 @@ namespace glm
|
||||
/// the last component will be written to the most significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packSnorm1x16(float const & v)
|
||||
/// @see uint32 packSnorm2x16(vec2 const & v)
|
||||
/// @see uint16 packSnorm1x16(float const& v)
|
||||
/// @see uint32 packSnorm2x16(vec2 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const & v);
|
||||
GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const& v);
|
||||
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// First, unpacks a single 64-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm4x16: clamp(f / 32767.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackSnorm1x16(uint16 p)
|
||||
/// @see vec2 unpackSnorm2x16(uint32 p)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm4x8 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 p);
|
||||
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a floating-point scalar
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||
/// and then packing this 16-bit value into a 16-bit unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packHalf2x16(vec2 const & v)
|
||||
/// @see uint64 packHalf4x16(vec4 const & v)
|
||||
/// @see uint32 packHalf2x16(vec2 const& v)
|
||||
/// @see uint64 packHalf4x16(vec4 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint16 packHalf1x16(float v);
|
||||
|
||||
|
||||
/// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value,
|
||||
/// interpreted as a 16-bit floating-point number according to the OpenGL Specification,
|
||||
/// and converting it to 32-bit floating-point values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
||||
/// @see vec4 unpackHalf4x16(uint64 const & v)
|
||||
/// @see vec2 unpackHalf2x16(uint32 const& v)
|
||||
/// @see vec4 unpackHalf4x16(uint64 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL float unpackHalf1x16(uint16 v);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||
/// and then packing these four 16-bit values into a 64-bit unsigned integer.
|
||||
/// The first vector component specifies the 16 least-significant bits of the result;
|
||||
/// The first vector component specifies the 16 least-significant bits of the result;
|
||||
/// the forth component specifies the 16 most-significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packHalf1x16(float const & v)
|
||||
/// @see uint32 packHalf2x16(vec2 const & v)
|
||||
/// @see uint16 packHalf1x16(float const& v)
|
||||
/// @see uint32 packHalf2x16(vec2 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL uint64 packHalf4x16(vec4 const & v);
|
||||
|
||||
GLM_FUNC_DECL uint64 packHalf4x16(vec4 const& v);
|
||||
|
||||
/// Returns a four-component floating-point vector with components obtained by unpacking a 64-bit unsigned integer into four 16-bit values,
|
||||
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
|
||||
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
|
||||
/// and converting them to 32-bit floating-point values.
|
||||
/// The first component of the vector is obtained from the 16 least-significant bits of v;
|
||||
/// The first component of the vector is obtained from the 16 least-significant bits of v;
|
||||
/// the forth component is obtained from the 16 most-significant bits of v.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see float unpackHalf1x16(uint16 const & v)
|
||||
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
||||
/// @see float unpackHalf1x16(uint16 const& v)
|
||||
/// @see vec2 unpackHalf2x16(uint32 const& v)
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 p);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
|
||||
/// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
|
||||
/// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
|
||||
/// and then packing these four values into a 32-bit unsigned integer.
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packI3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see ivec4 unpackI3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packI3x10_1x2(ivec4 const & v);
|
||||
/// @see uint32 packI3x10_1x2(uvec4 const& v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const& v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const& v)
|
||||
/// @see ivec4 unpackI3x10_1x2(uint32 const& p)
|
||||
GLM_FUNC_DECL uint32 packI3x10_1x2(ivec4 const& v);
|
||||
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit signed integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit signed integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const& v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const& p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const& p);
|
||||
GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 p);
|
||||
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
|
||||
/// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
|
||||
/// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
|
||||
/// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
|
||||
/// and then packing these four values into a 32-bit unsigned integer.
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see ivec4 unpackU3x10_1x2(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packU3x10_1x2(uvec4 const & v);
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const& v)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const& v)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const& v)
|
||||
/// @see ivec4 unpackU3x10_1x2(uint32 const& p)
|
||||
GLM_FUNC_DECL uint32 packU3x10_1x2(uvec4 const& v);
|
||||
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit unsigned integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit unsigned integers.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const& v)
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const& p);
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const& p);
|
||||
GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values.
|
||||
@@ -389,31 +360,31 @@ namespace glm
|
||||
/// packSnorm3x10_1x2(xyz): round(clamp(c, -1, +1) * 511.0)
|
||||
/// packSnorm3x10_1x2(w): round(clamp(c, -1, +1) * 1.0)
|
||||
///
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
GLM_FUNC_DECL uint32 packSnorm3x10_1x2(vec4 const & v);
|
||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const& p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const& v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const& v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const& v)
|
||||
GLM_FUNC_DECL uint32 packSnorm3x10_1x2(vec4 const& v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm3x10_1x2(xyz): clamp(f / 511.0, -1, +1)
|
||||
/// unpackSnorm3x10_1x2(w): clamp(f / 511.0, -1, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const& v)
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const& p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const& p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const& p)
|
||||
GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values.
|
||||
@@ -424,54 +395,333 @@ namespace glm
|
||||
/// packUnorm3x10_1x2(xyz): round(clamp(c, 0, +1) * 1023.0)
|
||||
/// packUnorm3x10_1x2(w): round(clamp(c, 0, +1) * 3.0)
|
||||
///
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// The first vector component specifies the 10 least-significant bits of the result;
|
||||
/// the forth component specifies the 2 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const & v)
|
||||
GLM_FUNC_DECL uint32 packUnorm3x10_1x2(vec4 const & v);
|
||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const& p)
|
||||
/// @see uint32 packUnorm3x10_1x2(vec4 const& v)
|
||||
/// @see uint32 packU3x10_1x2(uvec4 const& v)
|
||||
/// @see uint32 packI3x10_1x2(ivec4 const& v)
|
||||
GLM_FUNC_DECL uint32 packUnorm3x10_1x2(vec4 const& v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
|
||||
///
|
||||
///
|
||||
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
|
||||
/// unpackSnorm3x10_1x2(xyz): clamp(f / 1023.0, 0, +1)
|
||||
/// unpackSnorm3x10_1x2(w): clamp(f / 3.0, 0, +1)
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
/// @see vec4 unpackInorm3x10_1x2(uint32 const & p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||
/// @see uint32 packSnorm3x10_1x2(vec4 const& v)
|
||||
/// @see vec4 unpackInorm3x10_1x2(uint32 const& p))
|
||||
/// @see uvec4 unpackI3x10_1x2(uint32 const& p)
|
||||
/// @see uvec4 unpackU3x10_1x2(uint32 const& p)
|
||||
GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 p);
|
||||
|
||||
/// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
|
||||
/// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
|
||||
/// Then, the results are packed into the returned 32-bit unsigned integer.
|
||||
///
|
||||
/// The first vector component specifies the 11 least-significant bits of the result;
|
||||
/// The first vector component specifies the 11 least-significant bits of the result;
|
||||
/// the last component specifies the 10 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec3 unpackF2x11_1x10(uint32 const & p)
|
||||
GLM_FUNC_DECL uint32 packF2x11_1x10(vec3 const & v);
|
||||
/// @see vec3 unpackF2x11_1x10(uint32 const& p)
|
||||
GLM_FUNC_DECL uint32 packF2x11_1x10(vec3 const& v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
|
||||
/// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packF2x11_1x10(vec3 const & v)
|
||||
/// @see uint32 packF2x11_1x10(vec3 const& v)
|
||||
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
|
||||
|
||||
|
||||
/// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
|
||||
/// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
|
||||
/// Then, the results are packed into the returned 32-bit unsigned integer.
|
||||
///
|
||||
/// The first vector component specifies the 11 least-significant bits of the result;
|
||||
/// the last component specifies the 10 most-significant bits.
|
||||
///
|
||||
/// packF3x9_E1x5 allows encoding into RGBE / RGB9E5 format
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec3 unpackF3x9_E1x5(uint32 const& p)
|
||||
GLM_FUNC_DECL uint32 packF3x9_E1x5(vec3 const& v);
|
||||
|
||||
/// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
|
||||
/// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector.
|
||||
///
|
||||
/// The first component of the returned vector will be extracted from the least significant bits of the input;
|
||||
/// the last component will be extracted from the most significant bits.
|
||||
///
|
||||
/// unpackF3x9_E1x5 allows decoding RGBE / RGB9E5 data
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packF3x9_E1x5(vec3 const& v)
|
||||
GLM_FUNC_DECL vec3 unpackF3x9_E1x5(uint32 p);
|
||||
|
||||
/// Returns an unsigned integer vector obtained by converting the components of a floating-point vector
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification.
|
||||
/// The first vector component specifies the 16 least-significant bits of the result;
|
||||
/// the forth component specifies the 16 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<3, T, Q> unpackRGBM(vec<4, T, Q> const& p)
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> packRGBM(vec<3, T, Q> const& rgb);
|
||||
|
||||
/// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
|
||||
/// The first component of the vector is obtained from the 16 least-significant bits of v;
|
||||
/// the forth component is obtained from the 16 most-significant bits of v.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<4, T, Q> packRGBM(vec<3, float, Q> const& v)
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> unpackRGBM(vec<4, T, Q> const& rgbm);
|
||||
|
||||
/// Returns an unsigned integer vector obtained by converting the components of a floating-point vector
|
||||
/// to the 16-bit floating-point representation found in the OpenGL Specification.
|
||||
/// The first vector component specifies the 16 least-significant bits of the result;
|
||||
/// the forth component specifies the 16 most-significant bits.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, float, Q> unpackHalf(vec<L, uint16, Q> const& p)
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, uint16, Q> packHalf(vec<L, float, Q> const& v);
|
||||
|
||||
/// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
|
||||
/// The first component of the vector is obtained from the 16 least-significant bits of v;
|
||||
/// the forth component is obtained from the 16 most-significant bits of v.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, uint16, Q> packHalf(vec<L, float, Q> const& v)
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, float, Q> unpackHalf(vec<L, uint16, Q> const& p);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, floatType, Q> unpackUnorm(vec<L, intType, Q> const& p);
|
||||
template<typename uintType, length_t L, typename floatType, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, uintType, Q> packUnorm(vec<L, floatType, Q> const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, intType, Q> packUnorm(vec<L, floatType, Q> const& v)
|
||||
template<typename floatType, length_t L, typename uintType, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, floatType, Q> unpackUnorm(vec<L, uintType, Q> const& v);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into signed integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, floatType, Q> unpackSnorm(vec<L, intType, Q> const& p);
|
||||
template<typename intType, length_t L, typename floatType, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, intType, Q> packSnorm(vec<L, floatType, Q> const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec<L, intType, Q> packSnorm(vec<L, floatType, Q> const& v)
|
||||
template<typename floatType, length_t L, typename intType, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, floatType, Q> unpackSnorm(vec<L, intType, Q> const& v);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec2 unpackUnorm2x4(uint8 p)
|
||||
GLM_FUNC_DECL uint8 packUnorm2x4(vec2 const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packUnorm2x4(vec2 const& v)
|
||||
GLM_FUNC_DECL vec2 unpackUnorm2x4(uint8 p);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackUnorm4x4(uint16 p)
|
||||
GLM_FUNC_DECL uint16 packUnorm4x4(vec4 const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm4x4(vec4 const& v)
|
||||
GLM_FUNC_DECL vec4 unpackUnorm4x4(uint16 p);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec3 unpackUnorm1x5_1x6_1x5(uint16 p)
|
||||
GLM_FUNC_DECL uint16 packUnorm1x5_1x6_1x5(vec3 const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm1x5_1x6_1x5(vec3 const& v)
|
||||
GLM_FUNC_DECL vec3 unpackUnorm1x5_1x6_1x5(uint16 p);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec4 unpackUnorm3x5_1x1(uint16 p)
|
||||
GLM_FUNC_DECL uint16 packUnorm3x5_1x1(vec4 const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packUnorm3x5_1x1(vec4 const& v)
|
||||
GLM_FUNC_DECL vec4 unpackUnorm3x5_1x1(uint16 p);
|
||||
|
||||
/// Convert each component of the normalized floating-point vector into unsigned integer values.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see vec3 unpackUnorm2x3_1x2(uint8 p)
|
||||
GLM_FUNC_DECL uint8 packUnorm2x3_1x2(vec3 const& v);
|
||||
|
||||
/// Convert a packed integer to a normalized floating-point vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint8 packUnorm2x3_1x2(vec3 const& v)
|
||||
GLM_FUNC_DECL vec3 unpackUnorm2x3_1x2(uint8 p);
|
||||
|
||||
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see i8vec2 unpackInt2x8(int16 p)
|
||||
GLM_FUNC_DECL int16 packInt2x8(i8vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int16 packInt2x8(i8vec2 const& v)
|
||||
GLM_FUNC_DECL i8vec2 unpackInt2x8(int16 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see u8vec2 unpackInt2x8(uint16 p)
|
||||
GLM_FUNC_DECL uint16 packUint2x8(u8vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint16 packInt2x8(u8vec2 const& v)
|
||||
GLM_FUNC_DECL u8vec2 unpackUint2x8(uint16 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see i8vec4 unpackInt4x8(int32 p)
|
||||
GLM_FUNC_DECL int32 packInt4x8(i8vec4 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int32 packInt2x8(i8vec4 const& v)
|
||||
GLM_FUNC_DECL i8vec4 unpackInt4x8(int32 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see u8vec4 unpackUint4x8(uint32 p)
|
||||
GLM_FUNC_DECL uint32 packUint4x8(u8vec4 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint32 packUint4x8(u8vec2 const& v)
|
||||
GLM_FUNC_DECL u8vec4 unpackUint4x8(uint32 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see i16vec2 unpackInt2x16(int p)
|
||||
GLM_FUNC_DECL int packInt2x16(i16vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int packInt2x16(i16vec2 const& v)
|
||||
GLM_FUNC_DECL i16vec2 unpackInt2x16(int p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see i16vec4 unpackInt4x16(int64 p)
|
||||
GLM_FUNC_DECL int64 packInt4x16(i16vec4 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int64 packInt4x16(i16vec4 const& v)
|
||||
GLM_FUNC_DECL i16vec4 unpackInt4x16(int64 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see u16vec2 unpackUint2x16(uint p)
|
||||
GLM_FUNC_DECL uint packUint2x16(u16vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint packUint2x16(u16vec2 const& v)
|
||||
GLM_FUNC_DECL u16vec2 unpackUint2x16(uint p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see u16vec4 unpackUint4x16(uint64 p)
|
||||
GLM_FUNC_DECL uint64 packUint4x16(u16vec4 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see uint64 packUint4x16(u16vec4 const& v)
|
||||
GLM_FUNC_DECL u16vec4 unpackUint4x16(uint64 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see i32vec2 unpackInt2x32(int p)
|
||||
GLM_FUNC_DECL int64 packInt2x32(i32vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int packInt2x16(i32vec2 const& v)
|
||||
GLM_FUNC_DECL i32vec2 unpackInt2x32(int64 p);
|
||||
|
||||
/// Convert each component from an integer vector into a packed unsigned integer.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see u32vec2 unpackUint2x32(int p)
|
||||
GLM_FUNC_DECL uint64 packUint2x32(u32vec2 const& v);
|
||||
|
||||
/// Convert a packed integer into an integer vector.
|
||||
///
|
||||
/// @see gtc_packing
|
||||
/// @see int packUint2x16(u32vec2 const& v)
|
||||
GLM_FUNC_DECL u32vec2 unpackUint2x32(uint64 p);
|
||||
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
||||
|
||||
@@ -1,41 +1,14 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_packing
|
||||
/// @file glm/gtc/packing.inl
|
||||
/// @date 2013-08-08 / 2013-08-08
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../ext/scalar_relational.hpp"
|
||||
#include "../ext/vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../detail/type_half.hpp"
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
@@ -150,13 +123,8 @@ namespace detail
|
||||
else if(glm::isinf(x))
|
||||
return 0x1Fu << 6u;
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
|
||||
uint Pack = 0u;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
# else
|
||||
uint Pack = reinterpret_cast<uint&>(x);
|
||||
# endif
|
||||
|
||||
uint Pack = 0u;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
return float2packed11(Pack);
|
||||
}
|
||||
|
||||
@@ -171,13 +139,9 @@ namespace detail
|
||||
|
||||
uint Result = packed11ToFloat(x);
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
# else
|
||||
return reinterpret_cast<float&>(Result);
|
||||
# endif
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
|
||||
@@ -189,13 +153,8 @@ namespace detail
|
||||
else if(glm::isinf(x))
|
||||
return 0x1Fu << 5u;
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
|
||||
uint Pack = 0;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
# else
|
||||
uint Pack = reinterpret_cast<uint&>(x);
|
||||
# endif
|
||||
|
||||
uint Pack = 0;
|
||||
memcpy(&Pack, &x, sizeof(Pack));
|
||||
return float2packed10(Pack);
|
||||
}
|
||||
|
||||
@@ -210,13 +169,9 @@ namespace detail
|
||||
|
||||
uint Result = packed10ToFloat(x);
|
||||
|
||||
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
# else
|
||||
return reinterpret_cast<float&>(Result);
|
||||
# endif
|
||||
float Temp = 0;
|
||||
memcpy(&Temp, &Result, sizeof(Temp));
|
||||
return Temp;
|
||||
}
|
||||
|
||||
// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
|
||||
@@ -224,6 +179,62 @@ namespace detail
|
||||
// return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22);
|
||||
// }
|
||||
|
||||
union u3u3u2
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 3;
|
||||
uint y : 3;
|
||||
uint z : 2;
|
||||
} data;
|
||||
uint8 pack;
|
||||
};
|
||||
|
||||
union u4u4
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 4;
|
||||
uint y : 4;
|
||||
} data;
|
||||
uint8 pack;
|
||||
};
|
||||
|
||||
union u4u4u4u4
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 4;
|
||||
uint y : 4;
|
||||
uint z : 4;
|
||||
uint w : 4;
|
||||
} data;
|
||||
uint16 pack;
|
||||
};
|
||||
|
||||
union u5u6u5
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 5;
|
||||
uint y : 6;
|
||||
uint z : 5;
|
||||
} data;
|
||||
uint16 pack;
|
||||
};
|
||||
|
||||
union u5u5u5u1
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 5;
|
||||
uint y : 5;
|
||||
uint z : 5;
|
||||
uint w : 1;
|
||||
} data;
|
||||
uint16 pack;
|
||||
};
|
||||
|
||||
union u10u10u10u2
|
||||
{
|
||||
struct
|
||||
@@ -248,59 +259,160 @@ namespace detail
|
||||
uint32 pack;
|
||||
};
|
||||
|
||||
union u9u9u9e5
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint x : 9;
|
||||
uint y : 9;
|
||||
uint z : 9;
|
||||
uint w : 5;
|
||||
} data;
|
||||
uint32 pack;
|
||||
};
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_half
|
||||
{};
|
||||
|
||||
template<qualifier Q>
|
||||
struct compute_half<1, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<1, uint16, Q> pack(vec<1, float, Q> const& v)
|
||||
{
|
||||
int16 const Unpack(detail::toFloat16(v.x));
|
||||
u16vec1 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<1, float, Q> unpack(vec<1, uint16, Q> const& v)
|
||||
{
|
||||
i16vec1 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return vec<1, float, Q>(detail::toFloat32(v.x));
|
||||
}
|
||||
};
|
||||
|
||||
template<qualifier Q>
|
||||
struct compute_half<2, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<2, uint16, Q> pack(vec<2, float, Q> const& v)
|
||||
{
|
||||
vec<2, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y));
|
||||
u16vec2 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<2, float, Q> unpack(vec<2, uint16, Q> const& v)
|
||||
{
|
||||
i16vec2 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return vec<2, float, Q>(detail::toFloat32(v.x), detail::toFloat32(v.y));
|
||||
}
|
||||
};
|
||||
|
||||
template<qualifier Q>
|
||||
struct compute_half<3, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<3, uint16, Q> pack(vec<3, float, Q> const& v)
|
||||
{
|
||||
vec<3, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z));
|
||||
u16vec3 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<3, float, Q> unpack(vec<3, uint16, Q> const& v)
|
||||
{
|
||||
i16vec3 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return vec<3, float, Q>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z));
|
||||
}
|
||||
};
|
||||
|
||||
template<qualifier Q>
|
||||
struct compute_half<4, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<4, uint16, Q> pack(vec<4, float, Q> const& v)
|
||||
{
|
||||
vec<4, int16, Q> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w));
|
||||
u16vec4 Packed;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER static vec<4, float, Q> unpack(vec<4, uint16, Q> const& v)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return vec<4, float, Q>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z), detail::toFloat32(v.w));
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float v)
|
||||
{
|
||||
return static_cast<uint8>(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p)
|
||||
{
|
||||
float const Unpack(p);
|
||||
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm2x8(vec2 const & v)
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm2x8(vec2 const& v)
|
||||
{
|
||||
u8vec2 const Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
return reinterpret_cast<uint16 const &>(Topack);
|
||||
|
||||
uint16 Unpack = 0;
|
||||
memcpy(&Unpack, &Topack, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
|
||||
{
|
||||
vec2 const Unpack(reinterpret_cast<u8vec2 const &>(p));
|
||||
return Unpack * float(0.0039215686274509803921568627451); // 1 / 255
|
||||
u8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return vec2(Unpack) * float(0.0039215686274509803921568627451); // 1 / 255
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float v)
|
||||
{
|
||||
int8 const Topack(static_cast<int8>(round(clamp(v ,-1.0f, 1.0f) * 127.0f)));
|
||||
return reinterpret_cast<uint8 const &>(Topack);
|
||||
uint8 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p)
|
||||
{
|
||||
float const Unpack(reinterpret_cast<int8 const &>(p));
|
||||
int8 Unpack = 0;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
Unpack * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
static_cast<float>(Unpack) * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packSnorm2x8(vec2 const & v)
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packSnorm2x8(vec2 const& v)
|
||||
{
|
||||
i8vec2 const Topack(round(clamp(v, -1.0f, 1.0f) * 127.0f));
|
||||
return reinterpret_cast<uint16 const &>(Topack);
|
||||
uint16 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
|
||||
{
|
||||
vec2 const Unpack(reinterpret_cast<i8vec2 const &>(p));
|
||||
i8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
Unpack * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
vec2(Unpack) * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float s)
|
||||
{
|
||||
return static_cast<uint16>(round(clamp(s, 0.0f, 1.0f) * 65535.0f));
|
||||
@@ -312,72 +424,86 @@ namespace detail
|
||||
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packUnorm4x16(vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint64 packUnorm4x16(vec4 const& v)
|
||||
{
|
||||
u16vec4 const Topack(round(clamp(v , 0.0f, 1.0f) * 65535.0f));
|
||||
return reinterpret_cast<uint64 const &>(Topack);
|
||||
uint64 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
|
||||
{
|
||||
vec4 const Unpack(reinterpret_cast<u16vec4 const &>(p));
|
||||
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
u16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return vec4(Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float v)
|
||||
{
|
||||
int16 const Topack = static_cast<int16>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||
return reinterpret_cast<uint16 const &>(Topack);
|
||||
uint16 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p)
|
||||
{
|
||||
float const Unpack(reinterpret_cast<int16 const &>(p));
|
||||
int16 Unpack = 0;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
static_cast<float>(Unpack) * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packSnorm4x16(vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint64 packSnorm4x16(vec4 const& v)
|
||||
{
|
||||
i16vec4 const Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||
return reinterpret_cast<uint64 const &>(Topack);
|
||||
uint64 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
|
||||
{
|
||||
vec4 const Unpack(reinterpret_cast<i16vec4 const &>(p));
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return clamp(
|
||||
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
vec4(Unpack) * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
|
||||
-1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v)
|
||||
{
|
||||
int16 const Topack(detail::toFloat16(v));
|
||||
return reinterpret_cast<uint16 const &>(Topack);
|
||||
uint16 Packed = 0;
|
||||
memcpy(&Packed, &Topack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v)
|
||||
{
|
||||
return detail::toFloat32(reinterpret_cast<int16 const &>(v));
|
||||
int16 Unpack = 0;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return detail::toFloat32(Unpack);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packHalf4x16(glm::vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint64 packHalf4x16(glm::vec4 const& v)
|
||||
{
|
||||
i16vec4 Unpack(
|
||||
i16vec4 const Unpack(
|
||||
detail::toFloat16(v.x),
|
||||
detail::toFloat16(v.y),
|
||||
detail::toFloat16(v.z),
|
||||
detail::toFloat16(v.w));
|
||||
|
||||
return reinterpret_cast<uint64 const &>(Unpack);
|
||||
uint64 Packed = 0;
|
||||
memcpy(&Packed, &Unpack, sizeof(Packed));
|
||||
return Packed;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
|
||||
{
|
||||
i16vec4 Unpack(reinterpret_cast<i16vec4 const &>(v));
|
||||
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &v, sizeof(Unpack));
|
||||
return vec4(
|
||||
detail::toFloat32(Unpack.x),
|
||||
detail::toFloat32(Unpack.y),
|
||||
@@ -385,14 +511,14 @@ namespace detail
|
||||
detail::toFloat32(Unpack.w));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packI3x10_1x2(ivec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint32 packI3x10_1x2(ivec4 const& v)
|
||||
{
|
||||
detail::i10i10i10i2 Result;
|
||||
Result.data.x = v.x;
|
||||
Result.data.y = v.y;
|
||||
Result.data.z = v.z;
|
||||
Result.data.w = v.w;
|
||||
return Result.pack;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
|
||||
@@ -406,14 +532,14 @@ namespace detail
|
||||
Unpack.data.w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packU3x10_1x2(uvec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint32 packU3x10_1x2(uvec4 const& v)
|
||||
{
|
||||
detail::u10u10u10u2 Result;
|
||||
Result.data.x = v.x;
|
||||
Result.data.y = v.y;
|
||||
Result.data.z = v.z;
|
||||
Result.data.w = v.w;
|
||||
return Result.pack;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
|
||||
@@ -427,13 +553,15 @@ namespace detail
|
||||
Unpack.data.w);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packSnorm3x10_1x2(vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint32 packSnorm3x10_1x2(vec4 const& v)
|
||||
{
|
||||
ivec4 const Pack(round(clamp(v,-1.0f, 1.0f) * vec4(511.f, 511.f, 511.f, 1.f)));
|
||||
|
||||
detail::i10i10i10i2 Result;
|
||||
Result.data.x = int(round(clamp(v.x,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.y = int(round(clamp(v.y,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.z = int(round(clamp(v.z,-1.0f, 1.0f) * 511.f));
|
||||
Result.data.w = int(round(clamp(v.w,-1.0f, 1.0f) * 1.f));
|
||||
Result.data.x = Pack.x;
|
||||
Result.data.y = Pack.y;
|
||||
Result.data.z = Pack.z;
|
||||
Result.data.w = Pack.w;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
@@ -441,15 +569,13 @@ namespace detail
|
||||
{
|
||||
detail::i10i10i10i2 Unpack;
|
||||
Unpack.pack = v;
|
||||
vec4 Result;
|
||||
Result.x = clamp(float(Unpack.data.x) / 511.f, -1.0f, 1.0f);
|
||||
Result.y = clamp(float(Unpack.data.y) / 511.f, -1.0f, 1.0f);
|
||||
Result.z = clamp(float(Unpack.data.z) / 511.f, -1.0f, 1.0f);
|
||||
Result.w = clamp(float(Unpack.data.w) / 1.f, -1.0f, 1.0f);
|
||||
return Result;
|
||||
|
||||
vec4 const Result(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w);
|
||||
|
||||
return clamp(Result * vec4(1.f / 511.f, 1.f / 511.f, 1.f / 511.f, 1.f), -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const& v)
|
||||
{
|
||||
uvec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(1023.f, 1023.f, 1023.f, 3.f)));
|
||||
|
||||
@@ -470,7 +596,7 @@ namespace detail
|
||||
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactors;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v)
|
||||
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const& v)
|
||||
{
|
||||
return
|
||||
((detail::floatTo11bit(v.x) & ((1 << 11) - 1)) << 0) |
|
||||
@@ -486,4 +612,327 @@ namespace detail
|
||||
detail::packed10bitToFloat(v >> 22));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packF3x9_E1x5(vec3 const& v)
|
||||
{
|
||||
float const SharedExpMax = (pow(2.0f, 9.0f - 1.0f) / pow(2.0f, 9.0f)) * pow(2.0f, 31.f - 15.f);
|
||||
vec3 const Color = clamp(v, 0.0f, SharedExpMax);
|
||||
float const MaxColor = max(Color.x, max(Color.y, Color.z));
|
||||
|
||||
float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f;
|
||||
float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 15.f - 9.f)) + 0.5f);
|
||||
float const ExpShared = equal(MaxShared, pow(2.0f, 9.0f), epsilon<float>()) ? ExpSharedP + 1.0f : ExpSharedP;
|
||||
|
||||
uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f));
|
||||
|
||||
detail::u9u9u9e5 Unpack;
|
||||
Unpack.data.x = ColorComp.x;
|
||||
Unpack.data.y = ColorComp.y;
|
||||
Unpack.data.z = ColorComp.z;
|
||||
Unpack.data.w = uint(ExpShared);
|
||||
return Unpack.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec3 unpackF3x9_E1x5(uint32 v)
|
||||
{
|
||||
detail::u9u9u9e5 Unpack;
|
||||
Unpack.pack = v;
|
||||
|
||||
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * pow(2.0f, Unpack.data.w - 15.f - 9.f);
|
||||
}
|
||||
|
||||
// Based on Brian Karis http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, T, Q> packRGBM(vec<3, T, Q> const& rgb)
|
||||
{
|
||||
vec<3, T, Q> const Color(rgb * static_cast<T>(1.0 / 6.0));
|
||||
T Alpha = clamp(max(max(Color.x, Color.y), max(Color.z, static_cast<T>(1e-6))), static_cast<T>(0), static_cast<T>(1));
|
||||
Alpha = ceil(Alpha * static_cast<T>(255.0)) / static_cast<T>(255.0);
|
||||
return vec<4, T, Q>(Color / Alpha, Alpha);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, Q> unpackRGBM(vec<4, T, Q> const& rgbm)
|
||||
{
|
||||
return vec<3, T, Q>(rgbm.x, rgbm.y, rgbm.z) * rgbm.w * static_cast<T>(6);
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, uint16, Q> packHalf(vec<L, float, Q> const& v)
|
||||
{
|
||||
return detail::compute_half<L, Q>::pack(v);
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, float, Q> unpackHalf(vec<L, uint16, Q> const& v)
|
||||
{
|
||||
return detail::compute_half<L, Q>::unpack(v);
|
||||
}
|
||||
|
||||
template<typename uintType, length_t L, typename floatType, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, uintType, Q> packUnorm(vec<L, floatType, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
|
||||
|
||||
return vec<L, uintType, Q>(round(clamp(v, static_cast<floatType>(0), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<uintType>::max())));
|
||||
}
|
||||
|
||||
template<typename floatType, length_t L, typename uintType, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, floatType, Q> unpackUnorm(vec<L, uintType, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
|
||||
|
||||
return vec<L, float, Q>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<uintType>::max()));
|
||||
}
|
||||
|
||||
template<typename intType, length_t L, typename floatType, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, intType, Q> packSnorm(vec<L, floatType, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
|
||||
|
||||
return vec<L, intType, Q>(round(clamp(v , static_cast<floatType>(-1), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<intType>::max())));
|
||||
}
|
||||
|
||||
template<typename floatType, length_t L, typename intType, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, floatType, Q> unpackSnorm(vec<L, intType, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
|
||||
|
||||
return clamp(vec<L, floatType, Q>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<intType>::max())), static_cast<floatType>(-1), static_cast<floatType>(1));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packUnorm2x4(vec2 const& v)
|
||||
{
|
||||
u32vec2 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f));
|
||||
detail::u4u4 Result;
|
||||
Result.data.x = Unpack.x;
|
||||
Result.data.y = Unpack.y;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x4(uint8 v)
|
||||
{
|
||||
float const ScaleFactor(1.f / 15.f);
|
||||
detail::u4u4 Unpack;
|
||||
Unpack.pack = v;
|
||||
return vec2(Unpack.data.x, Unpack.data.y) * ScaleFactor;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm4x4(vec4 const& v)
|
||||
{
|
||||
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f));
|
||||
detail::u4u4u4u4 Result;
|
||||
Result.data.x = Unpack.x;
|
||||
Result.data.y = Unpack.y;
|
||||
Result.data.z = Unpack.z;
|
||||
Result.data.w = Unpack.w;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x4(uint16 v)
|
||||
{
|
||||
float const ScaleFactor(1.f / 15.f);
|
||||
detail::u4u4u4u4 Unpack;
|
||||
Unpack.pack = v;
|
||||
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm1x5_1x6_1x5(vec3 const& v)
|
||||
{
|
||||
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(31.f, 63.f, 31.f)));
|
||||
detail::u5u6u5 Result;
|
||||
Result.data.x = Unpack.x;
|
||||
Result.data.y = Unpack.y;
|
||||
Result.data.z = Unpack.z;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec3 unpackUnorm1x5_1x6_1x5(uint16 v)
|
||||
{
|
||||
vec3 const ScaleFactor(1.f / 31.f, 1.f / 63.f, 1.f / 31.f);
|
||||
detail::u5u6u5 Unpack;
|
||||
Unpack.pack = v;
|
||||
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUnorm3x5_1x1(vec4 const& v)
|
||||
{
|
||||
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(31.f, 31.f, 31.f, 1.f)));
|
||||
detail::u5u5u5u1 Result;
|
||||
Result.data.x = Unpack.x;
|
||||
Result.data.y = Unpack.y;
|
||||
Result.data.z = Unpack.z;
|
||||
Result.data.w = Unpack.w;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x5_1x1(uint16 v)
|
||||
{
|
||||
vec4 const ScaleFactor(1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f);
|
||||
detail::u5u5u5u1 Unpack;
|
||||
Unpack.pack = v;
|
||||
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint8 packUnorm2x3_1x2(vec3 const& v)
|
||||
{
|
||||
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(7.f, 7.f, 3.f)));
|
||||
detail::u3u3u2 Result;
|
||||
Result.data.x = Unpack.x;
|
||||
Result.data.y = Unpack.y;
|
||||
Result.data.z = Unpack.z;
|
||||
return Result.pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec3 unpackUnorm2x3_1x2(uint8 v)
|
||||
{
|
||||
vec3 const ScaleFactor(1.f / 7.f, 1.f / 7.f, 1.f / 3.f);
|
||||
detail::u3u3u2 Unpack;
|
||||
Unpack.pack = v;
|
||||
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int16 packInt2x8(i8vec2 const& v)
|
||||
{
|
||||
int16 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER i8vec2 unpackInt2x8(int16 p)
|
||||
{
|
||||
i8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint16 packUint2x8(u8vec2 const& v)
|
||||
{
|
||||
uint16 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u8vec2 unpackUint2x8(uint16 p)
|
||||
{
|
||||
u8vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int32 packInt4x8(i8vec4 const& v)
|
||||
{
|
||||
int32 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER i8vec4 unpackInt4x8(int32 p)
|
||||
{
|
||||
i8vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint32 packUint4x8(u8vec4 const& v)
|
||||
{
|
||||
uint32 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u8vec4 unpackUint4x8(uint32 p)
|
||||
{
|
||||
u8vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int packInt2x16(i16vec2 const& v)
|
||||
{
|
||||
int Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER i16vec2 unpackInt2x16(int p)
|
||||
{
|
||||
i16vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 packInt4x16(i16vec4 const& v)
|
||||
{
|
||||
int64 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER i16vec4 unpackInt4x16(int64 p)
|
||||
{
|
||||
i16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packUint2x16(u16vec2 const& v)
|
||||
{
|
||||
uint Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u16vec2 unpackUint2x16(uint p)
|
||||
{
|
||||
u16vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packUint4x16(u16vec4 const& v)
|
||||
{
|
||||
uint64 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u16vec4 unpackUint4x16(uint64 p)
|
||||
{
|
||||
u16vec4 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 packInt2x32(i32vec2 const& v)
|
||||
{
|
||||
int64 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER i32vec2 unpackInt2x32(int64 p)
|
||||
{
|
||||
i32vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint64 packUint2x32(u32vec2 const& v)
|
||||
{
|
||||
uint64 Pack = 0;
|
||||
memcpy(&Pack, &v, sizeof(Pack));
|
||||
return Pack;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER u32vec2 unpackUint2x32(uint64 p)
|
||||
{
|
||||
u32vec2 Unpack;
|
||||
memcpy(&Unpack, &p, sizeof(Unpack));
|
||||
return Unpack;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
|
||||
@@ -1,56 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_quaternion
|
||||
/// @file glm/gtc/quaternion.hpp
|
||||
/// @date 2009-05-21 / 2012-12-20
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_constants (dependence)
|
||||
///
|
||||
/// @defgroup gtc_quaternion GLM_GTC_quaternion
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Defines a templated quaternion type and several quaternion operations.
|
||||
///
|
||||
/// <glm/gtc/quaternion.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/quaternion.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Defines a templated quaternion type and several quaternion operations.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "../mat3x3.hpp"
|
||||
#include "../mat4x4.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
#include "../gtc/matrix_transform.hpp"
|
||||
#include "../ext/vector_relational.hpp"
|
||||
#include "../ext/quaternion_common.hpp"
|
||||
#include "../ext/quaternion_float.hpp"
|
||||
#include "../ext/quaternion_float_precision.hpp"
|
||||
#include "../ext/quaternion_double.hpp"
|
||||
#include "../ext/quaternion_double_precision.hpp"
|
||||
#include "../ext/quaternion_relational.hpp"
|
||||
#include "../ext/quaternion_geometric.hpp"
|
||||
#include "../ext/quaternion_trigonometric.hpp"
|
||||
#include "../ext/quaternion_transform.hpp"
|
||||
#include "../detail/type_mat3x3.hpp"
|
||||
#include "../detail/type_mat4x4.hpp"
|
||||
#include "../detail/type_vec3.hpp"
|
||||
#include "../detail/type_vec4.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_quaternion extension included")
|
||||
#endif
|
||||
|
||||
@@ -59,331 +40,133 @@ namespace glm
|
||||
/// @addtogroup gtc_quaternion
|
||||
/// @{
|
||||
|
||||
template <typename T, precision P = defaultp>
|
||||
struct tquat
|
||||
{
|
||||
// -- Implementation detail --
|
||||
|
||||
typedef tquat<T, P> type;
|
||||
typedef T value_type;
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
static GLM_RELAXED_CONSTEXPR length_t components = 4;
|
||||
static GLM_RELAXED_CONSTEXPR precision prec = P;
|
||||
# endif//GLM_META_PROG_HELPERS
|
||||
|
||||
// -- Data --
|
||||
|
||||
T x, y, z, w;
|
||||
|
||||
// -- Component accesses --
|
||||
|
||||
# ifdef GLM_FORCE_SIZE_FUNC
|
||||
typedef size_t size_type;
|
||||
/// Return the count of components of a quaternion
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
|
||||
|
||||
GLM_FUNC_DECL T & operator[](size_type i);
|
||||
GLM_FUNC_DECL T const & operator[](size_type i) const;
|
||||
# else
|
||||
typedef length_t length_type;
|
||||
/// Return the count of components of a quaternion
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
|
||||
|
||||
GLM_FUNC_DECL T & operator[](length_type i);
|
||||
GLM_FUNC_DECL T const & operator[](length_type i) const;
|
||||
# endif//GLM_FORCE_SIZE_FUNC
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL tquat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL tquat(tquat<T, P> const & q) GLM_DEFAULT;
|
||||
template <precision Q>
|
||||
GLM_FUNC_DECL tquat(tquat<T, Q> const & q);
|
||||
|
||||
// -- Explicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL explicit tquat(ctor);
|
||||
GLM_FUNC_DECL explicit tquat(T const & s, tvec3<T, P> const & v);
|
||||
GLM_FUNC_DECL tquat(T const & w, T const & x, T const & y, T const & z);
|
||||
|
||||
// -- Conversion constructors --
|
||||
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_DECL GLM_EXPLICIT tquat(tquat<U, Q> const & q);
|
||||
|
||||
/// Explicit conversion operators
|
||||
# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
|
||||
GLM_FUNC_DECL explicit operator tmat3x3<T, P>();
|
||||
GLM_FUNC_DECL explicit operator tmat4x4<T, P>();
|
||||
# endif
|
||||
|
||||
/// Create a quaternion from two normalized axis
|
||||
///
|
||||
/// @param u A first normalized axis
|
||||
/// @param v A second normalized axis
|
||||
/// @see gtc_quaternion
|
||||
/// @see http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
||||
GLM_FUNC_DECL explicit tquat(tvec3<T, P> const & u, tvec3<T, P> const & v);
|
||||
|
||||
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
|
||||
GLM_FUNC_DECL explicit tquat(tvec3<T, P> const & eulerAngles);
|
||||
GLM_FUNC_DECL explicit tquat(tmat3x3<T, P> const & m);
|
||||
GLM_FUNC_DECL explicit tquat(tmat4x4<T, P> const & m);
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
GLM_FUNC_DECL tquat<T, P> & operator=(tquat<T, P> const & m) GLM_DEFAULT;
|
||||
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tquat<T, P> & operator=(tquat<U, P> const & m);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<U, P> const & q);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<U, P> const & q);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tquat<T, P> & operator*=(U s);
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tquat<T, P> & operator/=(U s);
|
||||
};
|
||||
|
||||
// -- Unary bit operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
|
||||
|
||||
// -- Binary operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P> const & q, T const & s);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(T const & s, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator/(tquat<T, P> const & q, T const & s);
|
||||
|
||||
// -- Boolean operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL bool operator==(tquat<T, P> const & q1, tquat<T, P> const & q2);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL bool operator!=(tquat<T, P> const & q1, tquat<T, P> const & q2);
|
||||
|
||||
/// Returns the length of the quaternion.
|
||||
///
|
||||
/// Returns euler angles, pitch as x, yaw as y, roll as z.
|
||||
/// The result is expressed in radians.
|
||||
///
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T length(tquat<T, P> const & q);
|
||||
|
||||
/// Returns the normalized quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> normalize(tquat<T, P> const & q);
|
||||
|
||||
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P, template <typename, precision> class quatType>
|
||||
GLM_FUNC_DECL T dot(quatType<T, P> const & x, quatType<T, P> const & y);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented and the rotation is performed at constant speed.
|
||||
/// For short path spherical linear interpolation, use the slerp function.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
/// @see - slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T a);
|
||||
|
||||
/// Linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined in the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T a);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation always take the short path and the rotation is performed at constant speed.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T a);
|
||||
|
||||
/// Returns the q conjugate.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> conjugate(tquat<T, P> const & q);
|
||||
|
||||
/// Returns the q inverse.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> inverse(tquat<T, P> const & q);
|
||||
|
||||
/// Rotates a quaternion from a vector of 3 components axis and an angle.
|
||||
///
|
||||
/// @param q Source orientation
|
||||
/// @param angle Angle expressed in radians.
|
||||
/// @param axis Axis of the rotation
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & axis);
|
||||
|
||||
/// Returns euler angles, yitch as x, yaw as y, roll as z.
|
||||
/// The result is expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> eulerAngles(tquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> eulerAngles(qua<T, Q> const& x);
|
||||
|
||||
/// Returns roll value of euler angles expressed in radians.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T roll(tquat<T, P> const & x);
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T roll(qua<T, Q> const& x);
|
||||
|
||||
/// Returns pitch value of euler angles expressed in radians.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T pitch(tquat<T, P> const & x);
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T pitch(qua<T, Q> const& x);
|
||||
|
||||
/// Returns yaw value of euler angles expressed in radians.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T yaw(tquat<T, P> const & x);
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL T yaw(qua<T, Q> const& x);
|
||||
|
||||
/// Converts a quaternion to a 3 * 3 matrix.
|
||||
///
|
||||
///
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat3x3<T, P> mat3_cast(tquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<3, 3, T, Q> mat3_cast(qua<T, Q> const& x);
|
||||
|
||||
/// Converts a quaternion to a 4 * 4 matrix.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> mat4_cast(tquat<T, P> const & x);
|
||||
|
||||
/// Converts a 3 * 3 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat3x3<T, P> const & x);
|
||||
|
||||
/// Converts a 4 * 4 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat4x4<T, P> const & x);
|
||||
|
||||
/// Returns the quaternion rotation angle.
|
||||
///
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T angle(tquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<4, 4, T, Q> mat4_cast(qua<T, Q> const& x);
|
||||
|
||||
/// Returns the q rotation axis.
|
||||
/// Converts a pure rotation 3 * 3 matrix to a quaternion.
|
||||
///
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> axis(tquat<T, P> const & x);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL qua<T, Q> quat_cast(mat<3, 3, T, Q> const& x);
|
||||
|
||||
/// Build a quaternion from an angle and a normalized axis.
|
||||
/// Converts a pure rotation 4 * 4 matrix to a quaternion.
|
||||
///
|
||||
/// @param angle Angle expressed in radians.
|
||||
/// @param axis Axis of the quaternion, must be normalized.
|
||||
/// @tparam T Floating-point scalar types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & axis);
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL qua<T, Q> quat_cast(mat<4, 4, T, Q> const& x);
|
||||
|
||||
/// Returns the component-wise comparison result of x < y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @tparam T Floating-point scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see ext_quaternion_relational
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, bool, Q> lessThan(qua<T, Q> const& x, qua<T, Q> const& y);
|
||||
|
||||
/// Returns the component-wise comparison of result x <= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
/// @tparam T Floating-point scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @see ext_quaternion_relational
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, bool, Q> lessThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
|
||||
|
||||
/// Returns the component-wise comparison of result x > y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
/// @tparam T Floating-point scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @see ext_quaternion_relational
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, bool, Q> greaterThan(qua<T, Q> const& x, qua<T, Q> const& y);
|
||||
|
||||
/// Returns the component-wise comparison of result x >= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
/// @tparam T Floating-point scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @see ext_quaternion_relational
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
|
||||
|
||||
/// Returns the component-wise comparison of result x == y.
|
||||
/// Build a look at quaternion based on the default handedness.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @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);
|
||||
|
||||
/// Returns the component-wise comparison of result x != y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
/// Build a right-handed look at quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @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
|
||||
|
||||
|
||||
@@ -1,609 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_quaternion
|
||||
/// @file glm/gtc/quaternion.inl
|
||||
/// @date 2009-05-21 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../trigonometric.hpp"
|
||||
#include "../geometric.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include "epsilon.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<tquat, T, P>
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, Q> eulerAngles(qua<T, Q> const& x)
|
||||
{
|
||||
static GLM_FUNC_QUALIFIER T call(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
|
||||
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
// -- Component accesses --
|
||||
|
||||
# ifdef GLM_FORCE_SIZE_FUNC
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::size_type tquat<T, P>::size() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::size_type i)
|
||||
{
|
||||
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::size_type i) const
|
||||
{
|
||||
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||
return (&x)[i];
|
||||
}
|
||||
# else
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::length_type tquat<T, P>::length() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::length_type i)
|
||||
{
|
||||
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::length_type i) const
|
||||
{
|
||||
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||
return (&x)[i];
|
||||
}
|
||||
# endif//GLM_FORCE_SIZE_FUNC
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0), y(0), z(0), w(1)
|
||||
# endif
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q)
|
||||
: x(q.x), y(q.y), z(q.z), w(q.w)
|
||||
{}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template <typename T, precision P>
|
||||
template <precision Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, Q> const & q)
|
||||
: x(q.x), y(q.y), z(q.z), w(q.w)
|
||||
{}
|
||||
|
||||
// -- Explicit basic constructors --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & s, tvec3<T, P> const & v)
|
||||
: x(v.x), y(v.y), z(v.z), w(s)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & w, T const & x, T const & y, T const & z)
|
||||
: x(x), y(y), z(z), w(w)
|
||||
{}
|
||||
|
||||
// -- Conversion constructors --
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<U, Q> const & q)
|
||||
: x(static_cast<T>(q.x))
|
||||
, y(static_cast<T>(q.y))
|
||||
, z(static_cast<T>(q.z))
|
||||
, w(static_cast<T>(q.w))
|
||||
{}
|
||||
|
||||
//template <typename valType>
|
||||
//GLM_FUNC_QUALIFIER tquat<valType>::tquat
|
||||
//(
|
||||
// valType const & pitch,
|
||||
// valType const & yaw,
|
||||
// valType const & roll
|
||||
//)
|
||||
//{
|
||||
// tvec3<valType> eulerAngle(pitch * valType(0.5), yaw * valType(0.5), roll * valType(0.5));
|
||||
// tvec3<valType> c = glm::cos(eulerAngle * valType(0.5));
|
||||
// tvec3<valType> s = glm::sin(eulerAngle * valType(0.5));
|
||||
//
|
||||
// this->w = c.x * c.y * c.z + s.x * s.y * s.z;
|
||||
// this->x = s.x * c.y * c.z - c.x * s.y * s.z;
|
||||
// this->y = c.x * s.y * c.z + s.x * c.y * s.z;
|
||||
// this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
||||
//}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & u, tvec3<T, P> const & v)
|
||||
{
|
||||
tvec3<T, P> const LocalW(cross(u, v));
|
||||
T Dot = detail::compute_dot<tvec3, T, P>::call(u, v);
|
||||
tquat<T, P> q(T(1) + Dot, LocalW.x, LocalW.y, LocalW.z);
|
||||
|
||||
*this = normalize(q);
|
||||
return vec<3, T, Q>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & eulerAngle)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T roll(qua<T, Q> const& q)
|
||||
{
|
||||
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5));
|
||||
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5));
|
||||
|
||||
this->w = c.x * c.y * c.z + s.x * s.y * s.z;
|
||||
this->x = s.x * c.y * c.z - c.x * s.y * s.z;
|
||||
this->y = c.x * s.y * c.z + s.x * c.y * s.z;
|
||||
this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
||||
return static_cast<T>(atan(static_cast<T>(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T pitch(qua<T, Q> const& q)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
//return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
T const y = static_cast<T>(2) * (q.y * q.z + q.w * q.x);
|
||||
T const x = q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z;
|
||||
|
||||
if(all(equal(vec<2, T, Q>(x, y), vec<2, T, Q>(0), epsilon<T>()))) //avoid atan2(0,0) - handle singularity - Matiis
|
||||
return static_cast<T>(static_cast<T>(2) * atan(q.x, q.w));
|
||||
|
||||
return static_cast<T>(atan(y, x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T yaw(qua<T, Q> const& q)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
return asin(clamp(static_cast<T>(-2) * (q.x * q.z - q.w * q.y), static_cast<T>(-1), static_cast<T>(1)));
|
||||
}
|
||||
|
||||
# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat3x3<T, P>()
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> mat3_cast(qua<T, Q> const& q)
|
||||
{
|
||||
return mat3_cast(*this);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat4x4<T, P>()
|
||||
{
|
||||
return mat4_cast(*this);
|
||||
}
|
||||
# endif//GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q)
|
||||
{
|
||||
return tquat<T, P>(q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> inverse(tquat<T, P> const & q)
|
||||
{
|
||||
return conjugate(q) / dot(q, q);
|
||||
}
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator=(tquat<T, P> const & q)
|
||||
{
|
||||
this->w = q.w;
|
||||
this->x = q.x;
|
||||
this->y = q.y;
|
||||
this->z = q.z;
|
||||
return *this;
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator=(tquat<U, P> const & q)
|
||||
{
|
||||
this->w = static_cast<T>(q.w);
|
||||
this->x = static_cast<T>(q.x);
|
||||
this->y = static_cast<T>(q.y);
|
||||
this->z = static_cast<T>(q.z);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator+=(tquat<U, P> const & q)
|
||||
{
|
||||
this->w += static_cast<T>(q.w);
|
||||
this->x += static_cast<T>(q.x);
|
||||
this->y += static_cast<T>(q.y);
|
||||
this->z += static_cast<T>(q.z);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(tquat<U, P> const & r)
|
||||
{
|
||||
tquat<T, P> const p(*this);
|
||||
tquat<T, P> const q(r);
|
||||
|
||||
this->w = p.w * q.w - p.x * q.x - p.y * q.y - p.z * q.z;
|
||||
this->x = p.w * q.x + p.x * q.w + p.y * q.z - p.z * q.y;
|
||||
this->y = p.w * q.y + p.y * q.w + p.z * q.x - p.x * q.z;
|
||||
this->z = p.w * q.z + p.z * q.w + p.x * q.y - p.y * q.x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(U s)
|
||||
{
|
||||
this->w *= static_cast<U>(s);
|
||||
this->x *= static_cast<U>(s);
|
||||
this->y *= static_cast<U>(s);
|
||||
this->z *= static_cast<U>(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator/=(U s)
|
||||
{
|
||||
this->w /= static_cast<U>(s);
|
||||
this->x /= static_cast<U>(s);
|
||||
this->y /= static_cast<U>(s);
|
||||
this->z /= static_cast<U>(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// -- Unary bit operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q)
|
||||
{
|
||||
return q;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
|
||||
{
|
||||
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
// -- Binary operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) += p;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) *= p;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v)
|
||||
{
|
||||
tvec3<T, P> const QuatVector(q.x, q.y, q.z);
|
||||
tvec3<T, P> const uv(glm::cross(QuatVector, v));
|
||||
tvec3<T, P> const uuv(glm::cross(QuatVector, uv));
|
||||
|
||||
return v + ((uv * q.w) + uuv) * static_cast<T>(2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v)
|
||||
{
|
||||
return tvec4<T, P>(q * tvec3<T, P>(v), v.w);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, T const & s)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
q.w * s, q.x * s, q.y * s, q.z * s);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(T const & s, tquat<T, P> const & q)
|
||||
{
|
||||
return q * s;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator/(tquat<T, P> const & q, T const & s)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
q.w / s, q.x / s, q.y / s, q.z / s);
|
||||
}
|
||||
|
||||
// -- Boolean operators --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator==(tquat<T, P> const & q1, tquat<T, P> const & q2)
|
||||
{
|
||||
return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator!=(tquat<T, P> const & q1, tquat<T, P> const & q2)
|
||||
{
|
||||
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w);
|
||||
}
|
||||
|
||||
// -- Operations --
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T length(tquat<T, P> const & q)
|
||||
{
|
||||
return glm::sqrt(dot(q, q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> normalize(tquat<T, P> const & q)
|
||||
{
|
||||
T len = length(q);
|
||||
if(len <= T(0)) // Problem
|
||||
return tquat<T, P>(1, 0, 0, 0);
|
||||
T oneOverLen = T(1) / len;
|
||||
return tquat<T, P>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> cross(tquat<T, P> const & q1, tquat<T, P> const & q2)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
|
||||
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
|
||||
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
|
||||
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x);
|
||||
}
|
||||
/*
|
||||
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle))
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
{
|
||||
if(a <= T(0)) return x;
|
||||
if(a >= T(1)) return y;
|
||||
|
||||
float fCos = dot(x, y);
|
||||
tquat<T, P> y2(y); //BUG!!! tquat<T, P> y2;
|
||||
if(fCos < T(0))
|
||||
{
|
||||
y2 = -y;
|
||||
fCos = -fCos;
|
||||
}
|
||||
|
||||
//if(fCos > 1.0f) // problem
|
||||
float k0, k1;
|
||||
if(fCos > T(0.9999))
|
||||
{
|
||||
k0 = T(1) - a;
|
||||
k1 = T(0) + a; //BUG!!! 1.0f + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
T fSin = sqrt(T(1) - fCos * fCos);
|
||||
T fAngle = atan(fSin, fCos);
|
||||
T fOneOverSin = static_cast<T>(1) / fSin;
|
||||
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
|
||||
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
|
||||
}
|
||||
|
||||
return tquat<T, P>(
|
||||
k0 * x.w + k1 * y2.w,
|
||||
k0 * x.x + k1 * y2.x,
|
||||
k0 * x.y + k1 * y2.y,
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix2
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
bool flip = false;
|
||||
if(a <= static_cast<T>(0)) return x;
|
||||
if(a >= static_cast<T>(1)) return y;
|
||||
|
||||
T cos_t = dot(x, y);
|
||||
if(cos_t < T(0))
|
||||
{
|
||||
cos_t = -cos_t;
|
||||
flip = true;
|
||||
}
|
||||
|
||||
T alpha(0), beta(0);
|
||||
|
||||
if(T(1) - cos_t < 1e-7)
|
||||
beta = static_cast<T>(1) - alpha;
|
||||
else
|
||||
{
|
||||
T theta = acos(cos_t);
|
||||
T sin_t = sin(theta);
|
||||
beta = sin(theta * (T(1) - alpha)) / sin_t;
|
||||
alpha = sin(alpha * theta) / sin_t;
|
||||
}
|
||||
|
||||
if(flip)
|
||||
alpha = -alpha;
|
||||
|
||||
return normalize(beta * x + alpha * y);
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T a)
|
||||
{
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return tquat<T, P>(
|
||||
mix(x.w, y.w, a),
|
||||
mix(x.x, y.x, a),
|
||||
mix(x.y, y.y, a),
|
||||
mix(x.z, y.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * y) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T a)
|
||||
{
|
||||
// Lerp is only defined in [0, 1]
|
||||
assert(a >= static_cast<T>(0));
|
||||
assert(a <= static_cast<T>(1));
|
||||
|
||||
return x * (T(1) - a) + (y * a);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T a)
|
||||
{
|
||||
tquat<T, P> z = y;
|
||||
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// If cosTheta < 0, the interpolation will take the long way around the sphere.
|
||||
// To fix this, one quat must be negated.
|
||||
if (cosTheta < T(0))
|
||||
{
|
||||
z = -y;
|
||||
cosTheta = -cosTheta;
|
||||
}
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return tquat<T, P>(
|
||||
mix(x.w, z.w, a),
|
||||
mix(x.x, z.x, a),
|
||||
mix(x.y, z.y, a),
|
||||
mix(x.z, z.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * z) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & v)
|
||||
{
|
||||
tvec3<T, P> Tmp = v;
|
||||
|
||||
// Axis of rotation must be normalised
|
||||
T len = glm::length(Tmp);
|
||||
if(abs(len - T(1)) > T(0.001))
|
||||
{
|
||||
T oneOverLen = static_cast<T>(1) / len;
|
||||
Tmp.x *= oneOverLen;
|
||||
Tmp.y *= oneOverLen;
|
||||
Tmp.z *= oneOverLen;
|
||||
}
|
||||
|
||||
T const AngleRad(angle);
|
||||
T const Sin = sin(AngleRad * T(0.5));
|
||||
|
||||
return q * tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
|
||||
//return gtc::quaternion::cross(q, tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles(tquat<T, P> const & x)
|
||||
{
|
||||
return tvec3<T, P>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T roll(tquat<T, P> const & q)
|
||||
{
|
||||
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T pitch(tquat<T, P> const & q)
|
||||
{
|
||||
return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T yaw(tquat<T, P> const & q)
|
||||
{
|
||||
return asin(clamp(T(-2) * (q.x * q.z - q.w * q.y), T(-1), T(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast(tquat<T, P> const & q)
|
||||
{
|
||||
tmat3x3<T, P> Result(T(1));
|
||||
mat<3, 3, T, Q> Result(T(1));
|
||||
T qxx(q.x * q.x);
|
||||
T qyy(q.y * q.y);
|
||||
T qzz(q.z * q.z);
|
||||
@@ -614,28 +51,28 @@ namespace detail
|
||||
T qwy(q.w * q.y);
|
||||
T qwz(q.w * q.z);
|
||||
|
||||
Result[0][0] = 1 - 2 * (qyy + qzz);
|
||||
Result[0][1] = 2 * (qxy + qwz);
|
||||
Result[0][2] = 2 * (qxz - qwy);
|
||||
Result[0][0] = T(1) - T(2) * (qyy + qzz);
|
||||
Result[0][1] = T(2) * (qxy + qwz);
|
||||
Result[0][2] = T(2) * (qxz - qwy);
|
||||
|
||||
Result[1][0] = 2 * (qxy - qwz);
|
||||
Result[1][1] = 1 - 2 * (qxx + qzz);
|
||||
Result[1][2] = 2 * (qyz + qwx);
|
||||
Result[1][0] = T(2) * (qxy - qwz);
|
||||
Result[1][1] = T(1) - T(2) * (qxx + qzz);
|
||||
Result[1][2] = T(2) * (qyz + qwx);
|
||||
|
||||
Result[2][0] = 2 * (qxz + qwy);
|
||||
Result[2][1] = 2 * (qyz - qwx);
|
||||
Result[2][2] = 1 - 2 * (qxx + qyy);
|
||||
Result[2][0] = T(2) * (qxz + qwy);
|
||||
Result[2][1] = T(2) * (qyz - qwx);
|
||||
Result[2][2] = T(1) - T(2) * (qxx + qyy);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast(tquat<T, P> const & q)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> mat4_cast(qua<T, Q> const& q)
|
||||
{
|
||||
return tmat4x4<T, P>(mat3_cast(q));
|
||||
return mat<4, 4, T, Q>(mat3_cast(q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat3x3<T, P> const & m)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER qua<T, Q> quat_cast(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2];
|
||||
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
|
||||
@@ -660,132 +97,104 @@ namespace detail
|
||||
biggestIndex = 3;
|
||||
}
|
||||
|
||||
T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5);
|
||||
T biggestVal = sqrt(fourBiggestSquaredMinus1 + static_cast<T>(1)) * static_cast<T>(0.5);
|
||||
T mult = static_cast<T>(0.25) / biggestVal;
|
||||
|
||||
tquat<T, P> Result(uninitialize);
|
||||
switch(biggestIndex)
|
||||
{
|
||||
case 0:
|
||||
Result.w = biggestVal;
|
||||
Result.x = (m[1][2] - m[2][1]) * mult;
|
||||
Result.y = (m[2][0] - m[0][2]) * mult;
|
||||
Result.z = (m[0][1] - m[1][0]) * mult;
|
||||
break;
|
||||
return qua<T, Q>(biggestVal, (m[1][2] - m[2][1]) * mult, (m[2][0] - m[0][2]) * mult, (m[0][1] - m[1][0]) * mult);
|
||||
case 1:
|
||||
Result.w = (m[1][2] - m[2][1]) * mult;
|
||||
Result.x = biggestVal;
|
||||
Result.y = (m[0][1] + m[1][0]) * mult;
|
||||
Result.z = (m[2][0] + m[0][2]) * mult;
|
||||
break;
|
||||
return qua<T, Q>((m[1][2] - m[2][1]) * mult, biggestVal, (m[0][1] + m[1][0]) * mult, (m[2][0] + m[0][2]) * mult);
|
||||
case 2:
|
||||
Result.w = (m[2][0] - m[0][2]) * mult;
|
||||
Result.x = (m[0][1] + m[1][0]) * mult;
|
||||
Result.y = biggestVal;
|
||||
Result.z = (m[1][2] + m[2][1]) * mult;
|
||||
break;
|
||||
return qua<T, Q>((m[2][0] - m[0][2]) * mult, (m[0][1] + m[1][0]) * mult, biggestVal, (m[1][2] + m[2][1]) * mult);
|
||||
case 3:
|
||||
Result.w = (m[0][1] - m[1][0]) * mult;
|
||||
Result.x = (m[2][0] + m[0][2]) * mult;
|
||||
Result.y = (m[1][2] + m[2][1]) * mult;
|
||||
Result.z = biggestVal;
|
||||
break;
|
||||
|
||||
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
|
||||
return qua<T, Q>((m[0][1] - m[1][0]) * mult, (m[2][0] + m[0][2]) * mult, (m[1][2] + m[2][1]) * mult, biggestVal);
|
||||
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
|
||||
assert(false);
|
||||
break;
|
||||
return qua<T, Q>(1, 0, 0, 0);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat4x4<T, P> const & m4)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER qua<T, Q> quat_cast(mat<4, 4, T, Q> const& m4)
|
||||
{
|
||||
return quat_cast(tmat3x3<T, P>(m4));
|
||||
return quat_cast(mat<3, 3, T, Q>(m4));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T angle(tquat<T, P> const & x)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> lessThan(qua<T, Q> const& x, qua<T, Q> const& y)
|
||||
{
|
||||
return acos(x.w) * T(2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> axis(tquat<T, P> const & x)
|
||||
{
|
||||
T tmp1 = static_cast<T>(1) - x.w * x.w;
|
||||
if(tmp1 <= static_cast<T>(0))
|
||||
return tvec3<T, P>(0, 0, 1);
|
||||
T tmp2 = static_cast<T>(1) / sqrt(tmp1);
|
||||
return tvec3<T, P>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & v)
|
||||
{
|
||||
tquat<T, P> Result(uninitialize);
|
||||
|
||||
T const a(angle);
|
||||
T const s = glm::sin(a * static_cast<T>(0.5));
|
||||
|
||||
Result.w = glm::cos(a * static_cast<T>(0.5));
|
||||
Result.x = v.x * s;
|
||||
Result.y = v.y * s;
|
||||
Result.z = v.z * s;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
vec<4, bool, Q> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] < y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> lessThanEqual(qua<T, Q> const& x, qua<T, Q> const& y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
vec<4, bool, Q> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] <= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> greaterThan(qua<T, Q> const& x, qua<T, Q> const& y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
vec<4, bool, Q> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] > y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
vec<4, bool, Q> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] >= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAt(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
Result[i] = x[i] == y[i];
|
||||
return Result;
|
||||
# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT
|
||||
return quatLookAtLH(direction, up);
|
||||
# else
|
||||
return quatLookAtRH(direction, up);
|
||||
# endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER qua<T, Q> quatLookAtRH(vec<3, T, Q> const& direction, vec<3, T, Q> const& up)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
Result[i] = x[i] != y[i];
|
||||
return Result;
|
||||
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
|
||||
|
||||
#if GLM_CONFIG_SIMD == GLM_ENABLE
|
||||
# include "quaternion_simd.inl"
|
||||
#endif
|
||||
|
||||
|
||||
0
includes/glm/gtc/quaternion_simd.inl
Normal file
0
includes/glm/gtc/quaternion_simd.inl
Normal file
@@ -1,53 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_random
|
||||
/// @file glm/gtc/random.hpp
|
||||
/// @date 2011-09-18 / 2011-09-18
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtx_random (extended)
|
||||
///
|
||||
/// @defgroup gtc_random GLM_GTC_random
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Generate random number from various distribution methods.
|
||||
///
|
||||
/// <glm/gtc/random.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/random.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Generate random number from various distribution methods.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../ext/scalar_int_sized.hpp"
|
||||
#include "../ext/scalar_uint_sized.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_random extension included")
|
||||
#endif
|
||||
|
||||
@@ -55,65 +26,56 @@ namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_random
|
||||
/// @{
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a linear distribution
|
||||
///
|
||||
/// @param Min
|
||||
/// @param Max
|
||||
/// @tparam genType Value type. Currently supported: half (not recommanded), float or double scalars and vectors.
|
||||
/// @see gtc_random
|
||||
template <typename genTYpe>
|
||||
GLM_FUNC_DECL genTYpe linearRand(
|
||||
genTYpe Min,
|
||||
genTYpe Max);
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> linearRand(
|
||||
vecType<T, P> const & Min,
|
||||
vecType<T, P> const & Max);
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a gaussian distribution
|
||||
///
|
||||
/// @param Mean
|
||||
/// @param Deviation
|
||||
/// Generate random numbers in the interval [Min, Max], according a linear distribution
|
||||
///
|
||||
/// @param Min Minimum value included in the sampling
|
||||
/// @param Max Maximum value included in the sampling
|
||||
/// @tparam genType Value type. Currently supported: float or double scalars.
|
||||
/// @see gtc_random
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType gaussRand(
|
||||
genType Mean,
|
||||
genType Deviation);
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType linearRand(genType Min, genType Max);
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a linear distribution
|
||||
///
|
||||
/// @param Min Minimum value included in the sampling
|
||||
/// @param Max Maximum value included in the sampling
|
||||
/// @tparam T Value type. Currently supported: float or double.
|
||||
///
|
||||
/// @see gtc_random
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> linearRand(vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
|
||||
|
||||
/// Generate random numbers in the interval [Min, Max], according a gaussian distribution
|
||||
///
|
||||
/// @see gtc_random
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType gaussRand(genType Mean, genType Deviation);
|
||||
|
||||
/// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
///
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tvec2<T, defaultp> circularRand(
|
||||
T Radius);
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL vec<2, T, defaultp> circularRand(T Radius);
|
||||
|
||||
/// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
///
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tvec3<T, defaultp> sphericalRand(
|
||||
T Radius);
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL vec<3, T, defaultp> sphericalRand(T Radius);
|
||||
|
||||
/// Generate a random 2D vector which coordinates are regulary distributed within the area of a disk of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
///
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tvec2<T, defaultp> diskRand(
|
||||
T Radius);
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL vec<2, T, defaultp> diskRand(T Radius);
|
||||
|
||||
/// Generate a random 3D vector which coordinates are regulary distributed within the volume of a ball of a given radius
|
||||
///
|
||||
/// @param Radius
|
||||
///
|
||||
/// @see gtc_random
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL tvec3<T, defaultp> ballRand(
|
||||
T Radius);
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL vec<3, T, defaultp> ballRand(T Radius);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
|
||||
@@ -1,89 +1,60 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_random
|
||||
/// @file glm/gtc/random.inl
|
||||
/// @date 2011-09-19 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../geometric.hpp"
|
||||
#include "../exponential.hpp"
|
||||
#include "../trigonometric.hpp"
|
||||
#include "../detail/type_vec1.hpp"
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P, template <class, precision> class vecType>
|
||||
template <length_t L, typename T, qualifier Q>
|
||||
struct compute_rand
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call();
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call();
|
||||
};
|
||||
|
||||
template <precision P>
|
||||
struct compute_rand<uint8, P, tvec1>
|
||||
template <qualifier P>
|
||||
struct compute_rand<1, uint8, P>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec1<uint8, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<1, uint8, P> call()
|
||||
{
|
||||
return tvec1<uint8, P>(
|
||||
return vec<1, uint8, P>(
|
||||
std::rand() % std::numeric_limits<uint8>::max());
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P>
|
||||
struct compute_rand<uint8, P, tvec2>
|
||||
template <qualifier P>
|
||||
struct compute_rand<2, uint8, P>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec2<uint8, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<2, uint8, P> call()
|
||||
{
|
||||
return tvec2<uint8, P>(
|
||||
return vec<2, uint8, P>(
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
std::rand() % std::numeric_limits<uint8>::max());
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P>
|
||||
struct compute_rand<uint8, P, tvec3>
|
||||
template <qualifier P>
|
||||
struct compute_rand<3, uint8, P>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec3<uint8, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<3, uint8, P> call()
|
||||
{
|
||||
return tvec3<uint8, P>(
|
||||
return vec<3, uint8, P>(
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
std::rand() % std::numeric_limits<uint8>::max());
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P>
|
||||
struct compute_rand<uint8, P, tvec4>
|
||||
template <qualifier P>
|
||||
struct compute_rand<4, uint8, P>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<uint8, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<4, uint8, P> call()
|
||||
{
|
||||
return tvec4<uint8, P>(
|
||||
return vec<4, uint8, P>(
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
std::rand() % std::numeric_limits<uint8>::max(),
|
||||
@@ -91,289 +62,242 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_rand<uint16, P, vecType>
|
||||
template <length_t L, qualifier Q>
|
||||
struct compute_rand<L, uint16, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint16, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint16, Q> call()
|
||||
{
|
||||
return
|
||||
(vecType<uint16, P>(compute_rand<uint8, P, vecType>::call()) << static_cast<uint16>(8)) |
|
||||
(vecType<uint16, P>(compute_rand<uint8, P, vecType>::call()) << static_cast<uint16>(0));
|
||||
(vec<L, uint16, Q>(compute_rand<L, uint8, Q>::call()) << static_cast<uint16>(8)) |
|
||||
(vec<L, uint16, Q>(compute_rand<L, uint8, Q>::call()) << static_cast<uint16>(0));
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_rand<uint32, P, vecType>
|
||||
template <length_t L, qualifier Q>
|
||||
struct compute_rand<L, uint32, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint32, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint32, Q> call()
|
||||
{
|
||||
return
|
||||
(vecType<uint32, P>(compute_rand<uint16, P, vecType>::call()) << static_cast<uint32>(16)) |
|
||||
(vecType<uint32, P>(compute_rand<uint16, P, vecType>::call()) << static_cast<uint32>(0));
|
||||
(vec<L, uint32, Q>(compute_rand<L, uint16, Q>::call()) << static_cast<uint32>(16)) |
|
||||
(vec<L, uint32, Q>(compute_rand<L, uint16, Q>::call()) << static_cast<uint32>(0));
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_rand<uint64, P, vecType>
|
||||
template <length_t L, qualifier Q>
|
||||
struct compute_rand<L, uint64, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint64, P> call()
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint64, Q> call()
|
||||
{
|
||||
return
|
||||
(vecType<uint64, P>(compute_rand<uint32, P, vecType>::call()) << static_cast<uint64>(32)) |
|
||||
(vecType<uint64, P>(compute_rand<uint32, P, vecType>::call()) << static_cast<uint64>(0));
|
||||
(vec<L, uint64, Q>(compute_rand<L, uint32, Q>::call()) << static_cast<uint64>(32)) |
|
||||
(vec<L, uint64, Q>(compute_rand<L, uint32, Q>::call()) << static_cast<uint64>(0));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <class, precision> class vecType>
|
||||
template <length_t L, typename T, qualifier Q>
|
||||
struct compute_linearRand
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & Min, vecType<T, P> const & Max);
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<int8, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, int8, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<int8, P> call(vecType<int8, P> const & Min, vecType<int8, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, int8, Q> call(vec<L, int8, Q> const& Min, vec<L, int8, Q> const& Max)
|
||||
{
|
||||
return (vecType<int8, P>(compute_rand<uint8, P, vecType>::call() % vecType<uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
|
||||
return (vec<L, int8, Q>(compute_rand<L, uint8, Q>::call() % vec<L, uint8, Q>(Max + static_cast<int8>(1) - Min))) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<uint8, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, uint8, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint8, P> call(vecType<uint8, P> const & Min, vecType<uint8, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint8, Q> call(vec<L, uint8, Q> const& Min, vec<L, uint8, Q> const& Max)
|
||||
{
|
||||
return (compute_rand<uint8, P, vecType>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
|
||||
return (compute_rand<L, uint8, Q>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<int16, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, int16, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<int16, P> call(vecType<int16, P> const & Min, vecType<int16, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, int16, Q> call(vec<L, int16, Q> const& Min, vec<L, int16, Q> const& Max)
|
||||
{
|
||||
return (vecType<int16, P>(compute_rand<uint16, P, vecType>::call() % vecType<uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
|
||||
return (vec<L, int16, Q>(compute_rand<L, uint16, Q>::call() % vec<L, uint16, Q>(Max + static_cast<int16>(1) - Min))) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<uint16, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, uint16, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint16, P> call(vecType<uint16, P> const & Min, vecType<uint16, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint16, Q> call(vec<L, uint16, Q> const& Min, vec<L, uint16, Q> const& Max)
|
||||
{
|
||||
return (compute_rand<uint16, P, vecType>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
|
||||
return (compute_rand<L, uint16, Q>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<int32, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, int32, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<int32, P> call(vecType<int32, P> const & Min, vecType<int32, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, int32, Q> call(vec<L, int32, Q> const& Min, vec<L, int32, Q> const& Max)
|
||||
{
|
||||
return (vecType<int32, P>(compute_rand<uint32, P, vecType>::call() % vecType<uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
|
||||
return (vec<L, int32, Q>(compute_rand<L, uint32, Q>::call() % vec<L, uint32, Q>(Max + static_cast<int32>(1) - Min))) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<uint32, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, uint32, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint32, P> call(vecType<uint32, P> const & Min, vecType<uint32, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint32, Q> call(vec<L, uint32, Q> const& Min, vec<L, uint32, Q> const& Max)
|
||||
{
|
||||
return (compute_rand<uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
|
||||
return (compute_rand<L, uint32, Q>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<int64, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, int64, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<int64, P> call(vecType<int64, P> const & Min, vecType<int64, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, int64, Q> call(vec<L, int64, Q> const& Min, vec<L, int64, Q> const& Max)
|
||||
{
|
||||
return (vecType<int64, P>(compute_rand<uint64, P, vecType>::call() % vecType<uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
|
||||
return (vec<L, int64, Q>(compute_rand<L, uint64, Q>::call() % vec<L, uint64, Q>(Max + static_cast<int64>(1) - Min))) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P, template <class, precision> class vecType>
|
||||
struct compute_linearRand<uint64, P, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, uint64, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<uint64, P> call(vecType<uint64, P> const & Min, vecType<uint64, P> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, uint64, Q> call(vec<L, uint64, Q> const& Min, vec<L, uint64, Q> const& Max)
|
||||
{
|
||||
return (compute_rand<uint64, P, vecType>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
|
||||
return (compute_rand<L, uint64, Q>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<float, lowp, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, float, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<float, lowp> call(vecType<float, lowp> const & Min, vecType<float, lowp> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, float, Q> call(vec<L, float, Q> const& Min, vec<L, float, Q> const& Max)
|
||||
{
|
||||
return vecType<float, lowp>(compute_rand<uint8, lowp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
|
||||
return vec<L, float, Q>(compute_rand<L, uint32, Q>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<float, mediump, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, double, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<float, mediump> call(vecType<float, mediump> const & Min, vecType<float, mediump> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, double, Q> call(vec<L, double, Q> const& Min, vec<L, double, Q> const& Max)
|
||||
{
|
||||
return vecType<float, mediump>(compute_rand<uint16, mediump, vecType>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
|
||||
return vec<L, double, Q>(compute_rand<L, uint64, Q>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<float, highp, vecType>
|
||||
template<length_t L, qualifier Q>
|
||||
struct compute_linearRand<L, long double, Q>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<float, highp> call(vecType<float, highp> const & Min, vecType<float, highp> const & Max)
|
||||
GLM_FUNC_QUALIFIER static vec<L, long double, Q> call(vec<L, long double, Q> const& Min, vec<L, long double, Q> const& Max)
|
||||
{
|
||||
return vecType<float, highp>(compute_rand<uint32, highp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<double, lowp, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<double, lowp> call(vecType<double, lowp> const & Min, vecType<double, lowp> const & Max)
|
||||
{
|
||||
return vecType<double, lowp>(compute_rand<uint16, lowp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<double, mediump, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<double, mediump> call(vecType<double, mediump> const & Min, vecType<double, mediump> const & Max)
|
||||
{
|
||||
return vecType<double, mediump>(compute_rand<uint32, mediump, vecType>::call()) / static_cast<double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<double, highp, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<double, highp> call(vecType<double, highp> const & Min, vecType<double, highp> const & Max)
|
||||
{
|
||||
return vecType<double, highp>(compute_rand<uint64, highp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<long double, lowp, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<long double, lowp> call(vecType<long double, lowp> const & Min, vecType<long double, lowp> const & Max)
|
||||
{
|
||||
return vecType<long double, lowp>(compute_rand<uint32, lowp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<long double, mediump, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<long double, mediump> call(vecType<long double, mediump> const & Min, vecType<long double, mediump> const & Max)
|
||||
{
|
||||
return vecType<long double, mediump>(compute_rand<uint64, mediump, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class, precision> class vecType>
|
||||
struct compute_linearRand<long double, highp, vecType>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<long double, highp> call(vecType<long double, highp> const & Min, vecType<long double, highp> const & Max)
|
||||
{
|
||||
return vecType<long double, highp>(compute_rand<uint64, highp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
|
||||
return vec<L, long double, Q>(compute_rand<L, uint64, Q>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType linearRand(genType Min, genType Max)
|
||||
{
|
||||
return detail::compute_linearRand<genType, highp, tvec1>::call(
|
||||
tvec1<genType, highp>(Min),
|
||||
tvec1<genType, highp>(Max)).x;
|
||||
return detail::compute_linearRand<1, genType, highp>::call(
|
||||
vec<1, genType, highp>(Min),
|
||||
vec<1, genType, highp>(Max)).x;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> linearRand(vecType<T, P> const & Min, vecType<T, P> const & Max)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> linearRand(vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
|
||||
{
|
||||
return detail::compute_linearRand<T, P, vecType>::call(Min, Max);
|
||||
return detail::compute_linearRand<L, T, Q>::call(Min, Max);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType gaussRand(genType Mean, genType Deviation)
|
||||
{
|
||||
genType w, x1, x2;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
x1 = linearRand(genType(-1), genType(1));
|
||||
x2 = linearRand(genType(-1), genType(1));
|
||||
|
||||
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while(w > genType(1));
|
||||
|
||||
|
||||
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> gaussRand(vecType<T, P> const & Mean, vecType<T, P> const & Deviation)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> gaussRand(vec<L, T, Q> const& Mean, vec<L, T, Q> const& Deviation)
|
||||
{
|
||||
return detail::functor2<T, P, vecType>::call(gaussRand, Mean, Deviation);
|
||||
return detail::functor2<vec, L, T, Q>::call(gaussRand, Mean, Deviation);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec2<T, defaultp> diskRand(T Radius)
|
||||
{
|
||||
tvec2<T, defaultp> Result(T(0));
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<2, T, defaultp> diskRand(T Radius)
|
||||
{
|
||||
assert(Radius > static_cast<T>(0));
|
||||
|
||||
vec<2, T, defaultp> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(
|
||||
tvec2<T, defaultp>(-Radius),
|
||||
tvec2<T, defaultp>(Radius));
|
||||
vec<2, T, defaultp>(-Radius),
|
||||
vec<2, T, defaultp>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, defaultp> ballRand(T Radius)
|
||||
{
|
||||
tvec3<T, defaultp> Result(T(0));
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, defaultp> ballRand(T Radius)
|
||||
{
|
||||
assert(Radius > static_cast<T>(0));
|
||||
|
||||
vec<3, T, defaultp> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(
|
||||
tvec3<T, defaultp>(-Radius),
|
||||
tvec3<T, defaultp>(Radius));
|
||||
vec<3, T, defaultp>(-Radius),
|
||||
vec<3, T, defaultp>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec2<T, defaultp> circularRand(T Radius)
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<2, T, defaultp> circularRand(T Radius)
|
||||
{
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
return tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
|
||||
assert(Radius > static_cast<T>(0));
|
||||
|
||||
T a = linearRand(T(0), static_cast<T>(6.283185307179586476925286766559));
|
||||
return vec<2, T, defaultp>(glm::cos(a), glm::sin(a)) * Radius;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, defaultp> sphericalRand(T Radius)
|
||||
|
||||
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 r = sqrt(T(1) - z * z);
|
||||
|
||||
T x = r * cos(a);
|
||||
T y = r * sin(a);
|
||||
|
||||
return tvec3<T, defaultp>(x, y, z) * Radius;
|
||||
assert(Radius > static_cast<T>(0));
|
||||
|
||||
T theta = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
T phi = std::acos(linearRand(T(-1.0f), T(1.0f)));
|
||||
|
||||
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;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,50 +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 gtc_reciprocal
|
||||
/// @file glm/gtc/reciprocal.hpp
|
||||
/// @date 2008-10-09 / 2012-01-25
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_reciprocal GLM_GTC_reciprocal
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Define secant, cosecant and cotangent functions.
|
||||
///
|
||||
/// <glm/gtc/reciprocal.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/reciprocal.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Define secant, cosecant and cotangent functions.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_reciprocal extension included")
|
||||
#endif
|
||||
|
||||
@@ -53,80 +24,110 @@ namespace glm
|
||||
/// @addtogroup gtc_reciprocal
|
||||
/// @{
|
||||
|
||||
/// Secant function.
|
||||
/// Secant function.
|
||||
/// hypotenuse / adjacent or 1 / cos(x)
|
||||
///
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType sec(genType const & angle);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType sec(genType angle);
|
||||
|
||||
/// Cosecant function.
|
||||
/// Cosecant function.
|
||||
/// hypotenuse / opposite or 1 / sin(x)
|
||||
///
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType csc(genType const & angle);
|
||||
|
||||
/// Cotangent function.
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType csc(genType angle);
|
||||
|
||||
/// Cotangent function.
|
||||
/// adjacent / opposite or 1 / tan(x)
|
||||
///
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType cot(genType const & angle);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType cot(genType angle);
|
||||
|
||||
/// Inverse secant function.
|
||||
///
|
||||
/// Inverse secant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType asec(genType const & x);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType asec(genType x);
|
||||
|
||||
/// Inverse cosecant function.
|
||||
///
|
||||
/// Inverse cosecant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acsc(genType const & x);
|
||||
|
||||
/// Inverse cotangent function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acot(genType const & x);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType acsc(genType x);
|
||||
|
||||
/// Secant hyperbolic function.
|
||||
///
|
||||
/// Inverse cotangent function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType sech(genType const & angle);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType acot(genType x);
|
||||
|
||||
/// Cosecant hyperbolic function.
|
||||
///
|
||||
/// Secant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType csch(genType const & angle);
|
||||
|
||||
/// Cotangent hyperbolic function.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType coth(genType const & angle);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType sech(genType angle);
|
||||
|
||||
/// Inverse secant hyperbolic function.
|
||||
///
|
||||
/// Cosecant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType asech(genType const & x);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType csch(genType angle);
|
||||
|
||||
/// Inverse cosecant hyperbolic function.
|
||||
///
|
||||
/// Cotangent hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acsch(genType const & x);
|
||||
|
||||
/// Inverse cotangent hyperbolic function.
|
||||
///
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType coth(genType angle);
|
||||
|
||||
/// Inverse secant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType acoth(genType const & x);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType asech(genType x);
|
||||
|
||||
/// Inverse cosecant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType acsch(genType x);
|
||||
|
||||
/// Inverse cotangent hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_reciprocal
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType acoth(genType x);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,34 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_reciprocal
|
||||
/// @file glm/gtc/reciprocal.inl
|
||||
/// @date 2008-10-09 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../trigonometric.hpp"
|
||||
#include <limits>
|
||||
@@ -36,84 +6,84 @@
|
||||
namespace glm
|
||||
{
|
||||
// sec
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sec(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
|
||||
return genType(1) / glm::cos(angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> sec(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sec(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sec' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(sec, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(sec, x);
|
||||
}
|
||||
|
||||
// csc
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csc(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
|
||||
return genType(1) / glm::sin(angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> csc(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csc(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csc' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(csc, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(csc, x);
|
||||
}
|
||||
|
||||
// cot
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType cot(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
|
||||
|
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
|
||||
return glm::tan(pi_over_2 - angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> cot(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> cot(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cot' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(cot, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(cot, x);
|
||||
}
|
||||
|
||||
// asec
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asec(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
|
||||
return acos(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> asec(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asec(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asec' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(asec, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(asec, x);
|
||||
}
|
||||
|
||||
// acsc
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsc(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
|
||||
return asin(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> acsc(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsc(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsc' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(acsc, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(acsc, x);
|
||||
}
|
||||
|
||||
// acot
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acot(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
|
||||
@@ -122,100 +92,100 @@ namespace glm
|
||||
return pi_over_2 - atan(x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> acot(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acot(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acot' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(acot, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(acot, x);
|
||||
}
|
||||
|
||||
// sech
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sech(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
|
||||
return genType(1) / glm::cosh(angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> sech(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sech(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sech' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(sech, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(sech, x);
|
||||
}
|
||||
|
||||
// csch
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csch(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
|
||||
return genType(1) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> csch(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csch(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csch' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(csch, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(csch, x);
|
||||
}
|
||||
|
||||
// coth
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType coth(genType angle)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
|
||||
return glm::cosh(angle) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> coth(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> coth(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'coth' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(coth, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(coth, x);
|
||||
}
|
||||
|
||||
// asech
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asech(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
|
||||
return acosh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> asech(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asech(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asech' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(asech, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(asech, x);
|
||||
}
|
||||
|
||||
// acsch
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsch(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
|
||||
return acsch(genType(1) / x);
|
||||
return asinh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> acsch(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsch(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsch' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(acsch, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(acsch, x);
|
||||
}
|
||||
|
||||
// acoth
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acoth(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
|
||||
return atanh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> acoth(vecType<T, P> const & x)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acoth(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acoth' only accept floating-point inputs");
|
||||
return detail::functor1<T, T, P, vecType>::call(acoth, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(acoth, x);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,56 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_round
|
||||
/// @file glm/gtc/round.hpp
|
||||
/// @date 2014-11-03 / 2014-11-03
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_round (dependence)
|
||||
///
|
||||
/// @defgroup gtc_round GLM_GTC_round
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief rounding value to specific boundings
|
||||
///
|
||||
/// <glm/gtc/round.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/round.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Rounding value to specific boundings
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/_vectorize.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include <limits>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_integer extension included")
|
||||
#endif
|
||||
|
||||
@@ -62,140 +33,168 @@ namespace glm
|
||||
/// Return true if the value is a power of two number.
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL bool isPowerOfTwo(genIUType Value);
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL bool isPowerOfTwo(genIUType v);
|
||||
|
||||
/// Return true if the value is a power of two number.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> isPowerOfTwo(vecType<T, P> const & value);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& v);
|
||||
|
||||
/// Return the power of two number which value is just higher the input value,
|
||||
/// round up to a power of two.
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType Value);
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType v);
|
||||
|
||||
/// Return the power of two number which value is just higher the input value,
|
||||
/// round up to a power of two.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & value);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> ceilPowerOfTwo(vec<L, T, Q> const& v);
|
||||
|
||||
/// Return the power of two number which value is just lower the input value,
|
||||
/// round down to a power of two.
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType Value);
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType v);
|
||||
|
||||
/// Return the power of two number which value is just lower the input value,
|
||||
/// round down to a power of two.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> floorPowerOfTwo(vecType<T, P> const & value);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> floorPowerOfTwo(vec<L, T, Q> const& v);
|
||||
|
||||
/// Return the power of two number which value is the closet to the input value.
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType Value);
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType v);
|
||||
|
||||
/// Return the power of two number which value is the closet to the input value.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> roundPowerOfTwo(vecType<T, P> const & value);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> roundPowerOfTwo(vec<L, T, Q> const& v);
|
||||
|
||||
/// Return true if the 'Value' is a multiple of 'Multiple'.
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL bool isMultiple(genIUType Value, genIUType Multiple);
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL bool isMultiple(genIUType v, genIUType Multiple);
|
||||
|
||||
/// Return true if the 'Value' is a multiple of 'Multiple'.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, T Multiple);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, T Multiple);
|
||||
|
||||
/// Return true if the 'Value' is a multiple of 'Multiple'.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, vecType<T, P> const & Multiple);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
|
||||
|
||||
/// Higher multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
///
|
||||
/// @param v Source value to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType ceilMultiple(genType Source, genType Multiple);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType ceilMultiple(genType v, genType Multiple);
|
||||
|
||||
/// Higher multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @param v Source values to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> ceilMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
|
||||
|
||||
/// Lower multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
///
|
||||
/// @param v Source value to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType floorMultiple(
|
||||
genType Source,
|
||||
genType Multiple);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType floorMultiple(genType v, genType Multiple);
|
||||
|
||||
/// Lower multiple number of Source.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @param v Source values to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> floorMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
|
||||
|
||||
/// Lower multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
///
|
||||
/// @param v Source value to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> floorMultiple(
|
||||
vecType<T, P> const & Source,
|
||||
vecType<T, P> const & Multiple);
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType roundMultiple(genType v, genType Multiple);
|
||||
|
||||
/// Lower multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point or integer scalar types
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @param v Source values to which is applied the function
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType roundMultiple(
|
||||
genType Source,
|
||||
genType Multiple);
|
||||
|
||||
/// Lower multiple number of Source.
|
||||
///
|
||||
/// @tparam genType Floating-point or integer scalar or vector types.
|
||||
/// @param Source
|
||||
/// @param Multiple Must be a null or positive value
|
||||
///
|
||||
/// @see gtc_round
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> roundMultiple(
|
||||
vecType<T, P> const & Source,
|
||||
vecType<T, P> const & Multiple);
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> roundMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
@@ -1,106 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_round
|
||||
/// @file glm/gtc/round.inl
|
||||
/// @date 2014-11-03 / 2014-11-03
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
#include "../integer.hpp"
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
|
||||
template<length_t L, typename T, qualifier Q, bool compute = false>
|
||||
struct compute_ceilShift
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v, T)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
struct compute_ceilShift<T, P, vecType, true>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_ceilShift<L, T, Q, true>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Shift)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v, T Shift)
|
||||
{
|
||||
return v | (v >> Shift);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType, bool isSigned = true>
|
||||
template<length_t L, typename T, qualifier Q, bool isSigned = true>
|
||||
struct compute_ceilPowerOfTwo
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
|
||||
|
||||
vecType<T, P> const Sign(sign(x));
|
||||
vec<L, T, Q> const Sign(sign(x));
|
||||
|
||||
vecType<T, P> v(abs(x));
|
||||
vec<L, T, Q> v(abs(x));
|
||||
|
||||
v = v - static_cast<T>(1);
|
||||
v = v | (v >> static_cast<T>(1));
|
||||
v = v | (v >> static_cast<T>(2));
|
||||
v = v | (v >> static_cast<T>(4));
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 8>::call(v, 32);
|
||||
return (v + static_cast<T>(1)) * Sign;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
struct compute_ceilPowerOfTwo<T, P, vecType, false>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_ceilPowerOfTwo<L, T, Q, false>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
|
||||
|
||||
vecType<T, P> v(x);
|
||||
vec<L, T, Q> v(x);
|
||||
|
||||
v = v - static_cast<T>(1);
|
||||
v = v | (v >> static_cast<T>(1));
|
||||
v = v | (v >> static_cast<T>(2));
|
||||
v = v | (v >> static_cast<T>(4));
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 8>::call(v, 32);
|
||||
return v + static_cast<T>(1);
|
||||
}
|
||||
};
|
||||
|
||||
template <bool is_float, bool is_signed>
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_ceilMultiple{};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_ceilMultiple<true, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source > genType(0))
|
||||
@@ -110,10 +81,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_ceilMultiple<false, false>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
genType Tmp = Source - genType(1);
|
||||
@@ -121,10 +92,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_ceilMultiple<false, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source > genType(0))
|
||||
@@ -137,13 +108,13 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <bool is_float, bool is_signed>
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_floorMultiple{};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_floorMultiple<true, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -153,10 +124,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_floorMultiple<false, false>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -169,10 +140,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_floorMultiple<false, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -185,13 +156,13 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <bool is_float, bool is_signed>
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_roundMultiple{};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_roundMultiple<true, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -204,10 +175,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_roundMultiple<false, false>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -220,10 +191,10 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct compute_roundMultiple<false, true>
|
||||
{
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
@@ -240,133 +211,133 @@ namespace detail
|
||||
////////////////
|
||||
// isPowerOfTwo
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType Value)
|
||||
{
|
||||
genType const Result = glm::abs(Value);
|
||||
return !(Result & (Result - 1));
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> isPowerOfTwo(vecType<T, P> const & Value)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& Value)
|
||||
{
|
||||
vecType<T, P> const Result(abs(Value));
|
||||
return equal(Result & (Result - 1), vecType<T, P>(0));
|
||||
vec<L, T, Q> const Result(abs(Value));
|
||||
return equal(Result & (Result - 1), vec<L, T, Q>(0));
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// ceilPowerOfTwo
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo(genType value)
|
||||
{
|
||||
return detail::compute_ceilPowerOfTwo<genType, defaultp, tvec1, std::numeric_limits<genType>::is_signed>::call(tvec1<genType, defaultp>(value)).x;
|
||||
return detail::compute_ceilPowerOfTwo<1, genType, defaultp, std::numeric_limits<genType>::is_signed>::call(vec<1, genType, defaultp>(value)).x;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & v)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> ceilPowerOfTwo(vec<L, T, Q> const& v)
|
||||
{
|
||||
return detail::compute_ceilPowerOfTwo<T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
|
||||
return detail::compute_ceilPowerOfTwo<L, T, Q, std::numeric_limits<T>::is_signed>::call(v);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// floorPowerOfTwo
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType floorPowerOfTwo(genType value)
|
||||
{
|
||||
return isPowerOfTwo(value) ? value : highestBitValue(value);
|
||||
return isPowerOfTwo(value) ? value : static_cast<genType>(1) << findMSB(value);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> floorPowerOfTwo(vecType<T, P> const & v)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> floorPowerOfTwo(vec<L, T, Q> const& v)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(floorPowerOfTwo, v);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(floorPowerOfTwo, v);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// roundPowerOfTwo
|
||||
|
||||
template <typename genIUType>
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType roundPowerOfTwo(genIUType value)
|
||||
{
|
||||
if(isPowerOfTwo(value))
|
||||
return value;
|
||||
|
||||
genIUType const prev = highestBitValue(value);
|
||||
genIUType const next = prev << 1;
|
||||
genIUType const prev = static_cast<genIUType>(1) << findMSB(value);
|
||||
genIUType const next = prev << static_cast<genIUType>(1);
|
||||
return (next - value) < (value - prev) ? next : prev;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> roundPowerOfTwo(vecType<T, P> const & v)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> roundPowerOfTwo(vec<L, T, Q> const& v)
|
||||
{
|
||||
return detail::functor1<T, T, P, vecType>::call(roundPowerOfTwo, v);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(roundPowerOfTwo, v);
|
||||
}
|
||||
|
||||
////////////////
|
||||
// isMultiple
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isMultiple(genType Value, genType Multiple)
|
||||
{
|
||||
return isMultiple(tvec1<genType>(Value), tvec1<genType>(Multiple)).x;
|
||||
return isMultiple(vec<1, genType>(Value), vec<1, genType>(Multiple)).x;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> isMultiple(vecType<T, P> const & Value, T Multiple)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, T Multiple)
|
||||
{
|
||||
return (Value % Multiple) == vecType<T, P>(0);
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> isMultiple(vecType<T, P> const & Value, vecType<T, P> const & Multiple)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
return (Value % Multiple) == vecType<T, P>(0);
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// ceilMultiple
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType ceilMultiple(genType Source, genType Multiple)
|
||||
{
|
||||
return detail::compute_ceilMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> ceilMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
return detail::functor2<T, P, vecType>::call(ceilMultiple, Source, Multiple);
|
||||
return detail::functor2<vec, L, T, Q>::call(ceilMultiple, Source, Multiple);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// floorMultiple
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType floorMultiple(genType Source, genType Multiple)
|
||||
{
|
||||
return detail::compute_floorMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> floorMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> floorMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
return detail::functor2<T, P, vecType>::call(floorMultiple, Source, Multiple);
|
||||
return detail::functor2<vec, L, T, Q>::call(floorMultiple, Source, Multiple);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// roundMultiple
|
||||
|
||||
template <typename genType>
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType roundMultiple(genType Source, genType Multiple)
|
||||
{
|
||||
return detail::compute_roundMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> roundMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> roundMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
return detail::functor2<T, P, vecType>::call(roundMultiple, Source, Multiple);
|
||||
return detail::functor2<vec, L, T, Q>::call(roundMultiple, Source, Multiple);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
1315
includes/glm/gtc/type_aligned.hpp
Normal file
1315
includes/glm/gtc/type_aligned.hpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_swizzle
|
||||
/// @file glm/gtc/swizzle.inl
|
||||
/// @date 2009-06-14 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ref gtc_precision
|
||||
|
||||
namespace glm
|
||||
{
|
||||
|
||||
@@ -1,69 +1,41 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_type_ptr
|
||||
/// @file glm/gtc/type_ptr.hpp
|
||||
/// @date 2009-05-06 / 2011-06-05
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
/// @see gtc_quaternion (dependence)
|
||||
///
|
||||
/// @defgroup gtc_type_ptr GLM_GTC_type_ptr
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Handles the interaction between pointers and vector, matrix types.
|
||||
///
|
||||
/// This extension defines an overloaded function, glm::value_ptr, which
|
||||
/// takes any of the \ref core_template "core template types". It returns
|
||||
/// Include <glm/gtc/type_ptr.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Handles the interaction between pointers and vector, matrix types.
|
||||
///
|
||||
/// This extension defines an overloaded function, glm::value_ptr. It returns
|
||||
/// a pointer to the memory layout of the object. Matrix types store their values
|
||||
/// in column-major order.
|
||||
///
|
||||
///
|
||||
/// This is useful for uploading data to matrices or copying data to buffer objects.
|
||||
///
|
||||
/// Example:
|
||||
/// @code
|
||||
/// #include <glm/glm.hpp>
|
||||
/// #include <glm/gtc/type_ptr.hpp>
|
||||
///
|
||||
///
|
||||
/// glm::vec3 aVector(3);
|
||||
/// glm::mat4 someMatrix(1.0);
|
||||
///
|
||||
///
|
||||
/// glUniform3fv(uniformLoc, 1, glm::value_ptr(aVector));
|
||||
/// glUniformMatrix4fv(uniformMatrixLoc, 1, GL_FALSE, glm::value_ptr(someMatrix));
|
||||
/// @endcode
|
||||
///
|
||||
/// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// <glm/gtc/type_ptr.hpp> need to be included to use the features of this extension.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "../gtc/quaternion.hpp"
|
||||
#include "../gtc/vec1.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
@@ -78,7 +50,7 @@
|
||||
#include "../mat4x4.hpp"
|
||||
#include <cstring>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_type_ptr extension included")
|
||||
#endif
|
||||
|
||||
@@ -90,87 +62,167 @@ namespace glm
|
||||
/// Return the constant address to the data of the input parameter.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const & vec);
|
||||
GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<1, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<2, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<3, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<4, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<1, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<2, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<3, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<4, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<1, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<2, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<3, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<4, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<1, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<2, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<3, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<4, T, Q> const& v);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tvec2<T, defaultp> make_vec2(T const * const ptr);
|
||||
GLM_FUNC_DECL vec<2, T, defaultp> make_vec2(T const * const ptr);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tvec3<T, defaultp> make_vec3(T const * const ptr);
|
||||
GLM_FUNC_DECL vec<3, T, defaultp> make_vec3(T const * const ptr);
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tvec4<T, defaultp> make_vec4(T const * const ptr);
|
||||
GLM_FUNC_DECL vec<4, T, defaultp> make_vec4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat2x2<T, defaultp> make_mat2x2(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<2, 2, T, defaultp> make_mat2x2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat2x3<T, defaultp> make_mat2x3(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<2, 3, T, defaultp> make_mat2x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat2x4<T, defaultp> make_mat2x4(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<2, 4, T, defaultp> make_mat2x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat3x2<T, defaultp> make_mat3x2(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<3, 2, T, defaultp> make_mat3x2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat3x3<T, defaultp> make_mat3x3(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<3, 3, T, defaultp> make_mat3x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat3x4<T, defaultp> make_mat3x4(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<3, 4, T, defaultp> make_mat3x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat4x2<T, defaultp> make_mat4x2(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<4, 2, T, defaultp> make_mat4x2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat4x3<T, defaultp> make_mat4x3(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<4, 3, T, defaultp> make_mat4x3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> make_mat4x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat2x2<T, defaultp> make_mat2(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> make_mat4x4(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat3x3<T, defaultp> make_mat3(T const * const ptr);
|
||||
|
||||
GLM_FUNC_DECL mat<2, 2, T, defaultp> make_mat2(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tmat4x4<T, defaultp> make_mat4(T const * const ptr);
|
||||
GLM_FUNC_DECL mat<3, 3, T, defaultp> make_mat3(T const * const ptr);
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> make_mat4(T const * const ptr);
|
||||
|
||||
/// Build a quaternion from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T>
|
||||
GLM_FUNC_DECL tquat<T, defaultp> make_quat(T const * const ptr);
|
||||
GLM_FUNC_DECL qua<T, defaultp> make_quat(T const * const ptr);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,34 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_type_ptr
|
||||
/// @file glm/gtc/type_ptr.inl
|
||||
/// @date 2011-06-15 / 2011-12-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -37,440 +7,377 @@ namespace glm
|
||||
/// @addtogroup gtc_type_ptr
|
||||
/// @{
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tvec2<T, P> const & vec
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(vec<2, T, Q> const& v)
|
||||
{
|
||||
return &(vec.x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tvec2<T, P> & vec
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(vec<2, T, Q>& v)
|
||||
{
|
||||
return &(vec.x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tvec3<T, P> const & vec
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr(vec<3, T, Q> const& v)
|
||||
{
|
||||
return &(vec.x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tvec3<T, P> & vec
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(vec<3, T, Q>& v)
|
||||
{
|
||||
return &(vec.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the vector input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tvec4<T, P> const & vec
|
||||
)
|
||||
{
|
||||
return &(vec.x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the vector input.
|
||||
//! From GLM_GTC_type_ptr extension.
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tvec4<T, P> & vec
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(vec<4, T, Q> const& v)
|
||||
{
|
||||
return &(vec.x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat2x2<T, P> const & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(vec<4, T, Q>& v)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(v.x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat2x2<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 2, T, Q> const& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat3x3<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat3x3<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 2, T, Q>& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat4x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
//! From GLM_GTC_type_ptr extension.
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat4x4<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat2x3<T, P> const & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 3, T, Q>& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat2x3<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 4, T, Q> const& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat3x2<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat3x2<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<4, 4, T, Q>& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat2x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat2x4<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 3, T, Q> const& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat4x2<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat4x2<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 3, T, Q>& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat3x4<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
//! Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tmat3x4<T, P> & mat
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 2, T, Q> const& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tmat4x3<T, P> const & mat
|
||||
)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
/// Return the address to the data of the matrix input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr(tmat4x3<T, P> & mat)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 2, T, Q>& m)
|
||||
{
|
||||
return &(mat[0].x);
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
/// Return the constant address to the data of the input parameter.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 4, T, Q> const& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 4, T, Q>& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 2, T, Q> const& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<4, 2, T, Q>& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 4, T, Q> const& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 4, T, Q>& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 3, T, Q> const& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr(mat<4, 3, T, Q>& m)
|
||||
{
|
||||
return &(m[0].x);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T const * value_ptr(qua<T, Q> const& q)
|
||||
{
|
||||
return &(q[0]);
|
||||
}
|
||||
|
||||
/// Return the address to the data of the quaternion input.
|
||||
/// @see gtc_type_ptr
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T * value_ptr
|
||||
(
|
||||
tquat<T, P> & q
|
||||
)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T* value_ptr(qua<T, Q>& q)
|
||||
{
|
||||
return &(q[0]);
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec2<T, defaultp> make_vec2(T const * const ptr)
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<1, T, Q> make_vec1(vec<1, T, Q> const& v)
|
||||
{
|
||||
tvec2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tvec2<T, defaultp>));
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<1, T, Q> make_vec1(vec<2, T, Q> const& v)
|
||||
{
|
||||
return vec<1, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<1, T, Q> make_vec1(vec<3, T, Q> const& v)
|
||||
{
|
||||
return vec<1, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<1, T, Q> make_vec1(vec<4, T, Q> const& v)
|
||||
{
|
||||
return vec<1, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<2, T, Q> make_vec2(vec<1, T, Q> const& v)
|
||||
{
|
||||
return vec<2, T, Q>(v.x, static_cast<T>(0));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<2, T, Q> make_vec2(vec<2, T, Q> const& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<2, T, Q> make_vec2(vec<3, T, Q> const& v)
|
||||
{
|
||||
return vec<2, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<2, T, Q> make_vec2(vec<4, T, Q> const& v)
|
||||
{
|
||||
return vec<2, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<3, T, Q> make_vec3(vec<1, T, Q> const& v)
|
||||
{
|
||||
return vec<3, T, Q>(v.x, static_cast<T>(0), static_cast<T>(0));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<3, T, Q> make_vec3(vec<2, T, Q> const& v)
|
||||
{
|
||||
return vec<3, T, Q>(v.x, v.y, static_cast<T>(0));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<3, T, Q> make_vec3(vec<3, T, Q> const& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<3, T, Q> make_vec3(vec<4, T, Q> const& v)
|
||||
{
|
||||
return vec<3, T, Q>(v);
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<4, T, Q> make_vec4(vec<1, T, Q> const& v)
|
||||
{
|
||||
return vec<4, T, Q>(v.x, static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<4, T, Q> make_vec4(vec<2, T, Q> const& v)
|
||||
{
|
||||
return vec<4, T, Q>(v.x, v.y, static_cast<T>(0), static_cast<T>(1));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<4, T, Q> make_vec4(vec<3, T, Q> const& v)
|
||||
{
|
||||
return vec<4, T, Q>(v.x, v.y, v.z, static_cast<T>(1));
|
||||
}
|
||||
|
||||
template <typename T, qualifier Q>
|
||||
inline vec<4, T, Q> make_vec4(vec<4, T, Q> const& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<2, T, defaultp> make_vec2(T const *const ptr)
|
||||
{
|
||||
vec<2, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(vec<2, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, defaultp> make_vec3(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, defaultp> make_vec3(T const *const ptr)
|
||||
{
|
||||
tvec3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tvec3<T, defaultp>));
|
||||
vec<3, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(vec<3, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a vector from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, defaultp> make_vec4(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER vec<4, T, defaultp> make_vec4(T const *const ptr)
|
||||
{
|
||||
tvec4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tvec4<T, defaultp>));
|
||||
vec<4, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(vec<4, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2x2(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<2, 2, T, defaultp> make_mat2x2(T const *const ptr)
|
||||
{
|
||||
tmat2x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat2x2<T, defaultp>));
|
||||
mat<2, 2, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<2, 2, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat2x3<T, defaultp> make_mat2x3(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<2, 3, T, defaultp> make_mat2x3(T const *const ptr)
|
||||
{
|
||||
tmat2x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat2x3<T, defaultp>));
|
||||
mat<2, 3, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<2, 3, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat2x4<T, defaultp> make_mat2x4(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<2, 4, T, defaultp> make_mat2x4(T const *const ptr)
|
||||
{
|
||||
tmat2x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat2x4<T, defaultp>));
|
||||
mat<2, 4, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<2, 4, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat3x2<T, defaultp> make_mat3x2(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<3, 2, T, defaultp> make_mat3x2(T const *const ptr)
|
||||
{
|
||||
tmat3x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat3x2<T, defaultp>));
|
||||
mat<3, 2, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<3, 2, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, defaultp> make_mat3x3(T const *const ptr)
|
||||
{
|
||||
tmat3x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat3x3<T, defaultp>));
|
||||
mat<3, 3, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<3, 3, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat3x4<T, defaultp> make_mat3x4(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<3, 4, T, defaultp> make_mat3x4(T const *const ptr)
|
||||
{
|
||||
tmat3x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat3x4<T, defaultp>));
|
||||
mat<3, 4, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<3, 4, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x2<T, defaultp> make_mat4x2(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<4, 2, T, defaultp> make_mat4x2(T const *const ptr)
|
||||
{
|
||||
tmat4x2<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat4x2<T, defaultp>));
|
||||
mat<4, 2, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<4, 2, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x3<T, defaultp> make_mat4x3(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<4, 3, T, defaultp> make_mat4x3(T const *const ptr)
|
||||
{
|
||||
tmat4x3<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat4x3<T, defaultp>));
|
||||
mat<4, 3, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<4, 3, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4x4(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> make_mat4x4(T const *const ptr)
|
||||
{
|
||||
tmat4x4<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tmat4x4<T, defaultp>));
|
||||
mat<4, 4, T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(mat<4, 4, T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<2, 2, T, defaultp> make_mat2(T const *const ptr)
|
||||
{
|
||||
return make_mat2x2(ptr);
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, defaultp> make_mat3(T const *const ptr)
|
||||
{
|
||||
return make_mat3x3(ptr);
|
||||
}
|
||||
|
||||
//! Build a matrix from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4(T const * const ptr)
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> make_mat4(T const *const ptr)
|
||||
{
|
||||
return make_mat4x4(ptr);
|
||||
}
|
||||
|
||||
//! Build a quaternion from a pointer.
|
||||
/// @see gtc_type_ptr
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tquat<T, defaultp> make_quat(T const * const ptr)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER qua<T, defaultp> make_quat(T const *const ptr)
|
||||
{
|
||||
tquat<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(tquat<T, defaultp>));
|
||||
qua<T, defaultp> Result;
|
||||
memcpy(value_ptr(Result), ptr, sizeof(qua<T, defaultp>));
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,92 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_ulp
|
||||
/// @file glm/gtc/ulp.hpp
|
||||
/// @date 2011-02-21 / 2011-12-12
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_ulp GLM_GTC_ulp
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Allow the measurement of the accuracy of a function against a reference
|
||||
/// implementation. This extension works on floating-point data and provide results
|
||||
///
|
||||
/// Include <glm/gtc/ulp.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Allow the measurement of the accuracy of a function against a reference
|
||||
/// implementation. This extension works on floating-point data and provide results
|
||||
/// in ULP.
|
||||
/// <glm/gtc/ulp.hpp> need to be included to use these features.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/type_int.hpp"
|
||||
#include "../ext/scalar_ulp.hpp"
|
||||
#include "../ext/vector_ulp.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_ulp extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtc_ulp
|
||||
/// @{
|
||||
|
||||
/// Return the next ULP value(s) after the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType const & x);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType const & x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType const & x, uint const & Distance);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
/// @see gtc_ulp
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType const & x, uint const & Distance);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 scalars.
|
||||
/// @see gtc_ulp
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL uint float_distance(T const & x, T const & y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 vectors.
|
||||
/// @see gtc_ulp
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_DECL vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y);
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
||||
#include "ulp.inl"
|
||||
|
||||
@@ -1,350 +1,3 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_ulp
|
||||
/// @file glm/gtc/ulp.inl
|
||||
/// @date 2011-03-07 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
///
|
||||
/// Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
/// Permission to use, copy, modify, and distribute this
|
||||
/// software is freely granted, provided that this notice
|
||||
/// is preserved.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../detail/type_int.hpp"
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <limits>
|
||||
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
typedef union
|
||||
{
|
||||
float value;
|
||||
/* FIXME: Assumes 32 bit int. */
|
||||
unsigned int word;
|
||||
} ieee_float_shape_type;
|
||||
|
||||
typedef union
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
glm::detail::int32 lsw;
|
||||
glm::detail::int32 msw;
|
||||
} parts;
|
||||
} ieee_double_shape_type;
|
||||
|
||||
#define GLM_EXTRACT_WORDS(ix0,ix1,d) \
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_GET_FLOAT_WORD(i,d) \
|
||||
do { \
|
||||
ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_SET_FLOAT_WORD(d,i) \
|
||||
do { \
|
||||
ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_INSERT_WORDS(d,ix0,ix1) \
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER float nextafterf(float x, float y)
|
||||
{
|
||||
volatile float t;
|
||||
glm::detail::int32 hx, hy, ix, iy;
|
||||
|
||||
GLM_GET_FLOAT_WORD(hx, x);
|
||||
GLM_GET_FLOAT_WORD(hy, y);
|
||||
ix = hx&0x7fffffff; // |x|
|
||||
iy = hy&0x7fffffff; // |y|
|
||||
|
||||
if((ix>0x7f800000) || // x is nan
|
||||
(iy>0x7f800000)) // y is nan
|
||||
return x+y;
|
||||
if(x==y) return y; // x=y, return y
|
||||
if(ix==0) { // x == 0
|
||||
GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal
|
||||
t = x*x;
|
||||
if(t==x) return t; else return x; // raise underflow flag
|
||||
}
|
||||
if(hx>=0) { // x > 0
|
||||
if(hx>hy) { // x > y, x -= ulp
|
||||
hx -= 1;
|
||||
} else { // x < y, x += ulp
|
||||
hx += 1;
|
||||
}
|
||||
} else { // x < 0
|
||||
if(hy>=0||hx>hy){ // x < y, x -= ulp
|
||||
hx -= 1;
|
||||
} else { // x > y, x += ulp
|
||||
hx += 1;
|
||||
}
|
||||
}
|
||||
hy = hx&0x7f800000;
|
||||
if(hy>=0x7f800000) return x+x; // overflow
|
||||
if(hy<0x00800000) { // underflow
|
||||
t = x*x;
|
||||
if(t!=x) { // raise underflow flag
|
||||
GLM_SET_FLOAT_WORD(y,hx);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
GLM_SET_FLOAT_WORD(x,hx);
|
||||
return x;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double nextafter(double x, double y)
|
||||
{
|
||||
volatile double t;
|
||||
glm::detail::int32 hx, hy, ix, iy;
|
||||
glm::detail::uint32 lx, ly;
|
||||
|
||||
GLM_EXTRACT_WORDS(hx, lx, x);
|
||||
GLM_EXTRACT_WORDS(hy, ly, y);
|
||||
ix = hx & 0x7fffffff; // |x|
|
||||
iy = hy & 0x7fffffff; // |y|
|
||||
|
||||
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan
|
||||
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan
|
||||
return x+y;
|
||||
if(x==y) return y; // x=y, return y
|
||||
if((ix|lx)==0) { // x == 0
|
||||
GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal
|
||||
t = x*x;
|
||||
if(t==x) return t; else return x; // raise underflow flag
|
||||
}
|
||||
if(hx>=0) { // x > 0
|
||||
if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp
|
||||
if(lx==0) hx -= 1;
|
||||
lx -= 1;
|
||||
} else { // x < y, x += ulp
|
||||
lx += 1;
|
||||
if(lx==0) hx += 1;
|
||||
}
|
||||
} else { // x < 0
|
||||
if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){// x < y, x -= ulp
|
||||
if(lx==0) hx -= 1;
|
||||
lx -= 1;
|
||||
} else { // x > y, x += ulp
|
||||
lx += 1;
|
||||
if(lx==0) hx += 1;
|
||||
}
|
||||
}
|
||||
hy = hx&0x7ff00000;
|
||||
if(hy>=0x7ff00000) return x+x; // overflow
|
||||
if(hy<0x00100000) { // underflow
|
||||
t = x*x;
|
||||
if(t!=x) { // raise underflow flag
|
||||
GLM_INSERT_WORDS(y,hx,lx);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
GLM_INSERT_WORDS(x,hx,lx);
|
||||
return x;
|
||||
}
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::max());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MAX);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafterf(x, FLT_MAX);
|
||||
# else
|
||||
return nextafterf(x, FLT_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafter(x, FLT_MAX);
|
||||
# else
|
||||
return nextafter(x, DBL_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x)
|
||||
{
|
||||
vecType<T, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::min());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MIN);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafterf(x, FLT_MIN);
|
||||
# else
|
||||
return nextafterf(x, FLT_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::min());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return _nextafter(x, DBL_MIN);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafter(x, DBL_MIN);
|
||||
# else
|
||||
return nextafter(x, DBL_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x)
|
||||
{
|
||||
vecType<T, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(uint i = 0; i < ulps; ++i)
|
||||
temp = next_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
|
||||
{
|
||||
vecType<T, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
|
||||
Result[i] = next_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(uint i = 0; i < ulps; ++i)
|
||||
temp = prev_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
|
||||
{
|
||||
vecType<T, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
|
||||
Result[i] = prev_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
|
||||
{
|
||||
uint ulp = 0;
|
||||
|
||||
if(x < y)
|
||||
{
|
||||
T temp = x;
|
||||
while(temp != y)// && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else if(y < x)
|
||||
{
|
||||
T temp = y;
|
||||
while(temp != x)// && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else // ==
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return ulp;
|
||||
}
|
||||
|
||||
template<typename T, precision P, template<typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<uint, P> float_distance(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||
{
|
||||
vecType<uint, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -1,193 +1,30 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_vec1
|
||||
/// @file glm/gtc/vec1.hpp
|
||||
/// @date 2010-02-08 / 2011-06-07
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_vec1 GLM_GTC_vec1
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// @brief Add vec1, ivec1, uvec1 and bvec1 types.
|
||||
/// <glm/gtc/vec1.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Include <glm/gtc/vec1.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Add vec1, ivec1, uvec1 and bvec1 types.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
#include "../detail/type_vec1.hpp"
|
||||
#include "../ext/vector_bool1.hpp"
|
||||
#include "../ext/vector_bool1_precision.hpp"
|
||||
#include "../ext/vector_float1.hpp"
|
||||
#include "../ext/vector_float1_precision.hpp"
|
||||
#include "../ext/vector_double1.hpp"
|
||||
#include "../ext/vector_double1_precision.hpp"
|
||||
#include "../ext/vector_int1.hpp"
|
||||
#include "../ext/vector_int1_precision.hpp"
|
||||
#include "../ext/vector_uint1.hpp"
|
||||
#include "../ext/vector_uint1_precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_vec1 extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// 1 component vector of high precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_vec1_t highp_vec1;
|
||||
|
||||
/// 1 component vector of medium precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef mediump_vec1_t mediump_vec1;
|
||||
|
||||
/// 1 component vector of low precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef lowp_vec1_t lowp_vec1;
|
||||
|
||||
/// 1 component vector of high precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_dvec1_t highp_dvec1;
|
||||
|
||||
/// 1 component vector of medium precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef mediump_dvec1_t mediump_dvec1;
|
||||
|
||||
/// 1 component vector of low precision floating-point numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef lowp_dvec1_t lowp_dvec1;
|
||||
|
||||
/// 1 component vector of high precision signed integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_ivec1_t highp_ivec1;
|
||||
|
||||
/// 1 component vector of medium precision signed integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef mediump_ivec1_t mediump_ivec1;
|
||||
|
||||
/// 1 component vector of low precision signed integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef lowp_ivec1_t lowp_ivec1;
|
||||
|
||||
/// 1 component vector of high precision unsigned integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_uvec1_t highp_uvec1;
|
||||
|
||||
/// 1 component vector of medium precision unsigned integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef mediump_uvec1_t mediump_uvec1;
|
||||
|
||||
/// 1 component vector of low precision unsigned integer numbers.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef lowp_uvec1_t lowp_uvec1;
|
||||
|
||||
/// 1 component vector of high precision boolean.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_bvec1_t highp_bvec1;
|
||||
|
||||
/// 1 component vector of medium precision boolean.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef mediump_bvec1_t mediump_bvec1;
|
||||
|
||||
/// 1 component vector of low precision boolean.
|
||||
/// There is no guarantee on the actual precision.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef lowp_bvec1_t lowp_bvec1;
|
||||
|
||||
//////////////////////////
|
||||
// vec1 definition
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_BOOL))
|
||||
typedef highp_bvec1 bvec1;
|
||||
#elif(defined(GLM_PRECISION_MEDIUMP_BOOL))
|
||||
typedef mediump_bvec1 bvec1;
|
||||
#elif(defined(GLM_PRECISION_LOWP_BOOL))
|
||||
typedef lowp_bvec1 bvec1;
|
||||
#else
|
||||
/// 1 component vector of boolean.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_bvec1 bvec1;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_FLOAT))
|
||||
typedef highp_vec1 vec1;
|
||||
#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
|
||||
typedef mediump_vec1 vec1;
|
||||
#elif(defined(GLM_PRECISION_LOWP_FLOAT))
|
||||
typedef lowp_vec1 vec1;
|
||||
#else
|
||||
/// 1 component vector of floating-point numbers.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_vec1 vec1;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_DOUBLE))
|
||||
typedef highp_dvec1 dvec1;
|
||||
#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE))
|
||||
typedef mediump_dvec1 dvec1;
|
||||
#elif(defined(GLM_PRECISION_LOWP_DOUBLE))
|
||||
typedef lowp_dvec1 dvec1;
|
||||
#else
|
||||
/// 1 component vector of floating-point numbers.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_dvec1 dvec1;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_INT))
|
||||
typedef highp_ivec1 ivec1;
|
||||
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
|
||||
typedef mediump_ivec1 ivec1;
|
||||
#elif(defined(GLM_PRECISION_LOWP_INT))
|
||||
typedef lowp_ivec1 ivec1;
|
||||
#else
|
||||
/// 1 component vector of signed integer numbers.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_ivec1 ivec1;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
#if(defined(GLM_PRECISION_HIGHP_UINT))
|
||||
typedef highp_uvec1 uvec1;
|
||||
#elif(defined(GLM_PRECISION_MEDIUMP_UINT))
|
||||
typedef mediump_uvec1 uvec1;
|
||||
#elif(defined(GLM_PRECISION_LOWP_UINT))
|
||||
typedef lowp_uvec1 uvec1;
|
||||
#else
|
||||
/// 1 component vector of unsigned integer numbers.
|
||||
/// @see gtc_vec1 extension.
|
||||
typedef highp_uvec1 uvec1;
|
||||
#endif//GLM_PRECISION
|
||||
|
||||
}// namespace glm
|
||||
|
||||
#include "vec1.inl"
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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 gtc_vec1
|
||||
/// @file glm/gtc/vec1.inl
|
||||
/// @date 2013-03-16 / 2013-03-16
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user