Updated GLM version w/ now standard radians as angles.

This commit is contained in:
J. de Vries
2016-05-11 20:04:52 +02:00
parent 336df22af5
commit a4c2bb2498
321 changed files with 42426 additions and 35972 deletions

View File

@@ -0,0 +1,236 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../detail/type_int.hpp"
#include "../detail/_vectorize.hpp"
#include <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_bitfield extension included")
#endif
namespace glm
{
/// @addtogroup gtc_bitfield
/// @{
/// Build a mask of 'count' bits
///
/// @see gtc_bitfield
template <typename genIUType>
GLM_FUNC_DECL genIUType mask(genIUType Bits);
/// Build a mask of 'count' bits
///
/// @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);
/// 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>
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.
///
/// @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);
/// 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>
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.
///
/// @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);
/// Set to 1 a range of bits.
///
/// @see gtc_bitfield
template <typename genIUType>
GLM_FUNC_DECL genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount);
/// Set to 1 a range of bits.
///
/// @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);
/// Set to 0 a range of bits.
///
/// @see gtc_bitfield
template <typename genIUType>
GLM_FUNC_DECL genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount);
/// Set to 0 a range of bits.
///
/// @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);
/// 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 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 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, 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.
/// 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.
/// 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.
/// 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.
/// 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.
/// 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.
/// 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.
/// 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);
/// @}
} //namespace glm
#include "bitfield.inl"

View File

@@ -0,0 +1,542 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace detail
{
template <typename PARAM, typename RET>
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y);
template <typename PARAM, typename RET>
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z);
template <typename PARAM, typename RET>
GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w);
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 << 2) | REG1) & glm::uint16(0x3333);
REG2 = ((REG2 << 2) | REG2) & glm::uint16(0x3333);
REG1 = ((REG1 << 1) | REG1) & glm::uint16(0x5555);
REG2 = ((REG2 << 1) | REG2) & glm::uint16(0x5555);
return REG1 | (REG2 << 1);
}
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 << 4) | REG1) & glm::uint32(0x0F0F0F0F);
REG2 = ((REG2 << 4) | REG2) & glm::uint32(0x0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint32(0x33333333);
REG2 = ((REG2 << 2) | REG2) & glm::uint32(0x33333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint32(0x55555555);
REG2 = ((REG2 << 1) | REG2) & glm::uint32(0x55555555);
return REG1 | (REG2 << 1);
}
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 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
return REG1 | (REG2 << 1);
}
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 << 8) | REG1) & glm::uint32(0xF00F00F00F00F00F);
REG2 = ((REG2 << 8) | REG2) & glm::uint32(0xF00F00F00F00F00F);
REG3 = ((REG3 << 8) | REG3) & glm::uint32(0xF00F00F00F00F00F);
REG1 = ((REG1 << 4) | REG1) & glm::uint32(0x30C30C30C30C30C3);
REG2 = ((REG2 << 4) | REG2) & glm::uint32(0x30C30C30C30C30C3);
REG3 = ((REG3 << 4) | REG3) & glm::uint32(0x30C30C30C30C30C3);
REG1 = ((REG1 << 2) | REG1) & glm::uint32(0x9249249249249249);
REG2 = ((REG2 << 2) | REG2) & glm::uint32(0x9249249249249249);
REG3 = ((REG3 << 2) | REG3) & glm::uint32(0x9249249249249249);
return REG1 | (REG2 << 1) | (REG3 << 2);
}
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 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FFull);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FFull);
REG3 = ((REG3 << 16) | REG3) & 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 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3ull);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3ull);
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3ull);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249ull);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249ull);
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249ull);
return REG1 | (REG2 << 1) | (REG3 << 2);
}
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 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FFull);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FFull);
REG3 = ((REG3 << 16) | REG3) & 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 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3ull);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3ull);
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3ull);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249ull);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249ull);
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249ull);
return REG1 | (REG2 << 1) | (REG3 << 2);
}
template <>
GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint8 x, glm::uint8 y, glm::uint8 z, glm::uint8 w)
{
glm::uint32 REG1(x);
glm::uint32 REG2(y);
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 << 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 << 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);
return REG1 | (REG2 << 1) | (REG3 << 2) | (REG4 << 3);
}
template <>
GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w)
{
glm::uint64 REG1(x);
glm::uint64 REG2(y);
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 << 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 << 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 << 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);
return REG1 | (REG2 << 1) | (REG3 << 2) | (REG4 << 3);
}
}//namespace detail
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType mask(genIUType Bits)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'mask' accepts only integer values");
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)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'mask' accepts only integer values");
return detail::functor1<T, T, P, vecIUType>::call(mask, v);
}
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");
int const BitSize = static_cast<genIType>(sizeof(genIType) * 8);
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)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateRight' accepts only integer values");
int const BitSize = static_cast<int>(sizeof(T) * 8);
return (In << static_cast<T>(Shift)) | (In >> static_cast<T>(BitSize - Shift));
}
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");
int const BitSize = static_cast<genIType>(sizeof(genIType) * 8);
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)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateLeft' accepts only integer values");
int const BitSize = static_cast<int>(sizeof(T) * 8);
return (In >> static_cast<T>(Shift)) | (In << static_cast<T>(BitSize - Shift));
}
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)
{
return Value | static_cast<T>(mask(BitCount) << FirstBit);
}
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)
{
return Value & static_cast<T>(~(mask(BitCount) << FirstBit));
}
GLM_FUNC_QUALIFIER int16 bitfieldInterleave(int8 x, int8 y)
{
union sign8
{
int8 i;
uint8 u;
} sign_x, sign_y;
union sign16
{
int16 i;
uint16 u;
} result;
sign_x.i = x;
sign_y.i = y;
result.u = bitfieldInterleave(sign_x.u, sign_y.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint16 bitfieldInterleave(uint8 x, uint8 y)
{
return detail::bitfieldInterleave<uint8, uint16>(x, y);
}
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int16 x, int16 y)
{
union sign16
{
int16 i;
uint16 u;
} sign_x, sign_y;
union sign32
{
int32 i;
uint32 u;
} result;
sign_x.i = x;
sign_y.i = y;
result.u = bitfieldInterleave(sign_x.u, sign_y.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint16 x, uint16 y)
{
return detail::bitfieldInterleave<uint16, uint32>(x, y);
}
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y)
{
union sign32
{
int32 i;
uint32 u;
} sign_x, sign_y;
union sign64
{
int64 i;
uint64 u;
} result;
sign_x.i = x;
sign_y.i = y;
result.u = bitfieldInterleave(sign_x.u, sign_y.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint32 x, uint32 y)
{
return detail::bitfieldInterleave<uint32, uint64>(x, y);
}
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z)
{
union sign8
{
int8 i;
uint8 u;
} sign_x, sign_y, sign_z;
union sign32
{
int32 i;
uint32 u;
} result;
sign_x.i = x;
sign_y.i = y;
sign_z.i = z;
result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z)
{
return detail::bitfieldInterleave<uint8, uint32>(x, y, z);
}
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z)
{
union sign16
{
int16 i;
uint16 u;
} sign_x, sign_y, sign_z;
union sign64
{
int64 i;
uint64 u;
} result;
sign_x.i = x;
sign_y.i = y;
sign_z.i = z;
result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z)
{
return detail::bitfieldInterleave<uint32, uint64>(x, y, z);
}
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y, int32 z)
{
union sign16
{
int32 i;
uint32 u;
} sign_x, sign_y, sign_z;
union sign64
{
int64 i;
uint64 u;
} result;
sign_x.i = x;
sign_y.i = y;
sign_z.i = z;
result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z)
{
return detail::bitfieldInterleave<uint32, uint64>(x, y, z);
}
GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w)
{
union sign8
{
int8 i;
uint8 u;
} sign_x, sign_y, sign_z, sign_w;
union sign32
{
int32 i;
uint32 u;
} result;
sign_x.i = x;
sign_y.i = y;
sign_z.i = z;
sign_w.i = w;
result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u, sign_w.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w)
{
return detail::bitfieldInterleave<uint8, uint32>(x, y, z, w);
}
GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w)
{
union sign16
{
int16 i;
uint16 u;
} sign_x, sign_y, sign_z, sign_w;
union sign64
{
int64 i;
uint64 u;
} result;
sign_x.i = x;
sign_y.i = y;
sign_z.i = z;
sign_w.i = w;
result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u, sign_w.u);
return result.i;
}
GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w)
{
return detail::bitfieldInterleave<uint16, uint64>(x, y, z, w);
}
}//namespace glm

View File

@@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../exponential.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_color_space extension included")
#endif
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 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 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 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);
/// @}
} //namespace glm
#include "color_space.inl"

View File

@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////////////////
/// 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>
struct compute_rgbToSrgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & ColorRGB, T GammaCorrection)
{
vecType<T, P> 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),
ClampedColor * static_cast<T>(12.92),
lessThan(ClampedColor, vecType<T, P>(static_cast<T>(0.0031308))));
}
};
template <typename T, precision P>
struct compute_rgbToSrgb<T, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & ColorRGB, T GammaCorrection)
{
return tvec4<T, P>(compute_rgbToSrgb<T, P, tvec3>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.a);
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_srgbToRgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & ColorSRGB, T Gamma)
{
return mix(
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<T, P>(Gamma)),
ColorSRGB * static_cast<T>(0.07739938080495356037151702786378),
lessThanEqual(ColorSRGB, vecType<T, P>(static_cast<T>(0.04045))));
}
};
template <typename T, precision P>
struct compute_srgbToRgb<T, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & ColorSRGB, T Gamma)
{
return tvec4<T, P>(compute_srgbToRgb<T, P, tvec3>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.a);
}
};
}//namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear)
{
return detail::compute_rgbToSrgb<T, P, vecType>::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)
{
return detail::compute_rgbToSrgb<T, P, vecType>::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)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -31,19 +35,17 @@
/// @defgroup gtc_constants GLM_GTC_constants
/// @ingroup gtc
///
/// @brief Allow to perform bit operations on integer values
/// @brief Provide a list of constants and precomputed useful values.
///
/// <glm/gtc/constants.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_constants
#define GLM_GTC_constants GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
// Dependencies
#include "../detail/setup.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_constants extension included")
#endif
@@ -53,134 +55,151 @@ namespace glm
/// @{
/// Return the epsilon constant for floating point types.
/// @todo Implement epsilon for half-precision floating point type.
/// @see gtc_constants
template <typename genType>
genType epsilon();
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon();
/// Return 0.
/// @see gtc_constants
template <typename genType>
genType zero();
GLM_FUNC_DECL GLM_CONSTEXPR genType zero();
/// Return 1.
/// @see gtc_constants
template <typename genType>
genType one();
GLM_FUNC_DECL GLM_CONSTEXPR genType one();
/// Return the pi constant.
/// @see gtc_constants
template <typename genType>
genType pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType pi();
/// Return pi * 2.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType two_pi();
/// Return square root of pi.
/// @see gtc_constants
template <typename genType>
genType root_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_pi();
/// Return pi / 2.
/// @see gtc_constants
template <typename genType>
genType half_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType half_pi();
/// Return pi / 2 * 3.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType three_over_two_pi();
/// Return pi / 4.
/// @see gtc_constants
template <typename genType>
genType quarter_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType quarter_pi();
/// Return 1 / pi.
/// @see gtc_constants
template <typename genType>
genType one_over_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_pi();
/// Return 1 / (pi * 2).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_two_pi();
/// Return 2 / pi.
/// @see gtc_constants
template <typename genType>
genType two_over_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_pi();
/// Return 4 / pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType four_over_pi();
/// Return 2 / sqrt(pi).
/// @see gtc_constants
template <typename genType>
genType two_over_root_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_root_pi();
/// Return 1 / sqrt(2).
/// @see gtc_constants
template <typename genType>
genType one_over_root_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_root_two();
/// Return sqrt(pi / 2).
/// @see gtc_constants
template <typename genType>
genType root_half_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_half_pi();
/// Return sqrt(2 * pi).
/// @see gtc_constants
template <typename genType>
genType root_two_pi();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two_pi();
/// Return sqrt(ln(4)).
/// @see gtc_constants
template <typename genType>
genType root_ln_four();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_ln_four();
/// Return e constant.
/// @see gtc_constants
template <typename genType>
genType e();
GLM_FUNC_DECL GLM_CONSTEXPR genType e();
/// Return Euler's constant.
/// @see gtc_constants
template <typename genType>
genType euler();
GLM_FUNC_DECL GLM_CONSTEXPR genType euler();
/// Return sqrt(2).
/// @see gtc_constants
template <typename genType>
genType root_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_two();
/// Return sqrt(3).
/// @see gtc_constants
template <typename genType>
genType root_three();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_three();
/// Return sqrt(5).
/// @see gtc_constants
template <typename genType>
genType root_five();
GLM_FUNC_DECL GLM_CONSTEXPR genType root_five();
/// Return ln(2).
/// @see gtc_constants
template <typename genType>
genType ln_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_two();
/// Return ln(10).
/// @see gtc_constants
template <typename genType>
genType ln_ten();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ten();
/// Return ln(ln(2)).
/// @see gtc_constants
template <typename genType>
genType ln_ln_two();
GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ln_two();
/// Return 1 / 3.
/// @see gtc_constants
template <typename genType>
genType third();
GLM_FUNC_DECL GLM_CONSTEXPR genType third();
/// Return 2 / 3.
/// @see gtc_constants
template <typename genType>
genType two_thirds();
GLM_FUNC_DECL GLM_CONSTEXPR genType two_thirds();
/// Return the golden ratio constant.
/// @see gtc_constants
template <typename genType>
genType golden_ratio();
GLM_FUNC_DECL GLM_CONSTEXPR genType golden_ratio();
/// @}
} //namespace glm
#include "constants.inl"
#endif//GLM_GTC_constants

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -20,166 +24,186 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_constants
/// @file glm/gtx/constants.inl
/// @date 2011-10-14 / 2012-01-25
/// @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 genType epsilon()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon()
{
return std::numeric_limits<genType>::epsilon();
}
template <>
GLM_FUNC_QUALIFIER half epsilon()
{
return half(1.19209290e-007);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType zero()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType zero()
{
return genType(0);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one()
{
return genType(1);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi()
{
return genType(3.14159265358979323846264338327950288);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_pi()
{
return genType(6.28318530717958647692528676655900576);
}
template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_pi()
{
return genType(1.772453850905516027);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType half_pi()
{
return genType(1.57079632679489661923132169163975144);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType quarter_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType three_over_two_pi()
{
return genType(4.71238898038468985769396507491925432);
}
template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType quarter_pi()
{
return genType(0.785398163397448309615660845819875721);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_pi()
{
return genType(0.318309886183790671537767526745028724);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_two_pi()
{
return genType(0.159154943091895335768883763372514362);
}
template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_pi()
{
return genType(0.636619772367581343075535053490057448);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType four_over_pi()
{
return genType(1.273239544735162686151070106980114898);
}
template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_root_pi()
{
return genType(1.12837916709551257389615890312154517);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_root_two()
{
return genType(0.707106781186547524400844362104849039);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_half_pi()
{
return genType(1.253314137315500251);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two_pi()
{
return genType(2.506628274631000502);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_ln_four()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_ln_four()
{
return genType(1.17741002251547469);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType e()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType e()
{
return genType(2.71828182845904523536);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType euler()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType euler()
{
return genType(0.577215664901532860606);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two()
{
return genType(1.41421356237309504880168872420969808);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_three()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_three()
{
return genType(1.73205080756887729352744634150587236);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_five()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_five()
{
return genType(2.23606797749978969640917366873127623);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_two()
{
return genType(0.693147180559945309417232121458176568);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_ten()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ten()
{
return genType(2.30258509299404568401799145468436421);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ln_ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ln_two()
{
return genType(-0.3665129205816643);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType third()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType third()
{
return genType(0.3333333333333333333333333333333333333333);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_thirds()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_thirds()
{
return genType(0.666666666666666666666666666666666666667);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType golden_ratio()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType golden_ratio()
{
return genType(1.61803398874989484820458683436563811);
}

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -37,15 +41,13 @@
/// <glm/gtc/epsilon.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_epsilon
#define GLM_GTC_epsilon GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../gtc/quaternion.hpp"
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_epsilon extension included")
#endif
@@ -54,41 +56,47 @@ namespace glm
/// @addtogroup gtc_epsilon
/// @{
/// Returns the component-wise compare of |x - y| < epsilon.
/// Returns the component-wise comparison of |x - y| < epsilon.
/// 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);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @see gtc_epsilon
template <typename genType>
typename genType::boolType epsilonEqual(
GLM_FUNC_DECL bool epsilonEqual(
genType const & x,
genType const & y,
typename genType::value_type const & epsilon);
/// Returns the component-wise compare of |x - y| < epsilon.
/// @see gtc_epsilon
template <typename genType>
typename genType::boolType epsilonEqual(
genType const & x,
genType const & y,
genType const & epsilon);
/// Returns the component-wise compare of |x - y| < epsilon.
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is not satisfied.
///
/// @see gtc_epsilon
template <typename genType>
typename genType::boolType epsilonNotEqual(
GLM_FUNC_DECL typename genType::boolType epsilonNotEqual(
genType const & x,
genType const & y,
typename genType::value_type const & epsilon);
/// Returns the component-wise compare of |x - y| >= epsilon.
/// Returns the component-wise comparison of |x - y| >= epsilon.
/// True if this expression is not satisfied.
///
/// @see gtc_epsilon
template <typename genType>
typename genType::boolType epsilonNotEqual(
genType const & x,
genType const & y,
GLM_FUNC_DECL bool epsilonNotEqual(
genType const & x,
genType const & y,
genType const & epsilon);
/// @}
}//namespace glm
#include "epsilon.inl"
#endif//GLM_GTC_epsilon

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -26,261 +30,125 @@
/// @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 <>
GLM_FUNC_QUALIFIER bool epsilonEqual
(
glm::half const & x,
glm::half const & y,
glm::half const & epsilon
)
{
return abs(x - y) < epsilon;
}
GLM_FUNC_QUALIFIER bool epsilonEqual
(
float const & x,
float const & y,
float const & x,
float const & y,
float const & epsilon
)
{
return abs(x - y) < epsilon;
}
template <>
GLM_FUNC_QUALIFIER bool epsilonEqual
(
double const & x,
double const & y,
double const & x,
double const & y,
double const & epsilon
)
{
return abs(x - y) < epsilon;
}
template <>
GLM_FUNC_QUALIFIER bool epsilonNotEqual
(
glm::half const & x,
glm::half const & y,
glm::half const & epsilon
)
{
return abs(x - y) >= epsilon;
}
GLM_FUNC_QUALIFIER bool epsilonNotEqual
(
float const & x,
float const & y,
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 & x,
double const & y,
double const & epsilon
)
{
return abs(x - y) >= epsilon;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
valType const & epsilon)
{
return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon
vecType<T, P> const & x,
vecType<T, P> const & y,
T const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y);
return lessThan(abs(x - y), vecType<T, P>(epsilon));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
valType const & epsilon)
{
return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<T, P> const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z);
return lessThan(abs(x - y), vecType<T, P>(epsilon));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
valType const & epsilon
vecType<T, P> const & x,
vecType<T, P> const & y,
T const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon,
abs(x.w - y.w) < epsilon);
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<T, P> const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z,
abs(x.w - y.w) < epsilon.w);
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonEqual
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
valType const & epsilon
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= 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 valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonNotEqual
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
valType const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon,
abs(x.w - y.w) >= epsilon);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z,
abs(x.w - y.w) >= epsilon.w);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
(
detail::tquat<valType> const & x,
detail::tquat<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon,
abs(x.w - y.w) < epsilon);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
(
detail::tquat<valType> const & x,
detail::tquat<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon,
abs(x.w - y.w) >= 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));
}
}//namespace glm

View File

@@ -1,454 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 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.
///
/// 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_half_float
/// @file glm/gtc/half_float.hpp
/// @date 2009-04-29 / 2012-11-06
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtc_half_float GLM_GTC_half_float
/// @ingroup gtc
///
/// Defines the half-precision floating-point type, along with various typedefs for vectors and matrices.
/// <glm/gtc/half_float.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_half_float
#define GLM_GTC_half_float GLM_VERSION
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
# pragma message("GLM: GLM_GTC_half_float extension included")
#endif
namespace glm{
namespace detail
{
#if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
template <>
struct tvec2<half>
{
enum ctor{null};
typedef half value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type value_size();
typedef tvec2<half> type;
typedef tvec2<bool> bool_type;
//////////////////////////////////////
// Data
half x, y;
//////////////////////////////////////
// Accesses
half & operator[](size_type i);
half const & operator[](size_type i) const;
//////////////////////////////////////
// Implicit basic constructors
tvec2();
tvec2(tvec2<half> const & v);
//////////////////////////////////////
// Explicit basic constructors
explicit tvec2(ctor);
explicit tvec2(
half const & s);
explicit tvec2(
half const & s1,
half const & s2);
//////////////////////////////////////
// Swizzle constructors
tvec2(tref2<half> const & r);
//////////////////////////////////////
// Convertion scalar constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec2(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V>
explicit tvec2(U const & x, V const & y);
//////////////////////////////////////
// Convertion vector constructors
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec2(tvec2<U> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec2(tvec3<U> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec2(tvec4<U> const & v);
//////////////////////////////////////
// Unary arithmetic operators
tvec2<half>& operator= (tvec2<half> const & v);
tvec2<half>& operator+=(half const & s);
tvec2<half>& operator+=(tvec2<half> const & v);
tvec2<half>& operator-=(half const & s);
tvec2<half>& operator-=(tvec2<half> const & v);
tvec2<half>& operator*=(half const & s);
tvec2<half>& operator*=(tvec2<half> const & v);
tvec2<half>& operator/=(half const & s);
tvec2<half>& operator/=(tvec2<half> const & v);
tvec2<half>& operator++();
tvec2<half>& operator--();
//////////////////////////////////////
// Swizzle operators
half swizzle(comp X) const;
tvec2<half> swizzle(comp X, comp Y) const;
tvec3<half> swizzle(comp X, comp Y, comp Z) const;
tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
tref2<half> swizzle(comp X, comp Y);
};
template <>
struct tvec3<half>
{
enum ctor{null};
typedef half value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type value_size();
typedef tvec3<half> type;
typedef tvec3<bool> bool_type;
//////////////////////////////////////
// Data
half x, y, z;
//////////////////////////////////////
// Accesses
half & operator[](size_type i);
half const & operator[](size_type i) const;
//////////////////////////////////////
// Implicit basic constructors
tvec3();
tvec3(tvec3<half> const & v);
//////////////////////////////////////
// Explicit basic constructors
explicit tvec3(ctor);
explicit tvec3(
half const & s);
explicit tvec3(
half const & s1,
half const & s2,
half const & s3);
//////////////////////////////////////
// Swizzle constructors
tvec3(tref3<half> const & r);
//////////////////////////////////////
// Convertion scalar constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec3(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V, typename W>
explicit tvec3(U const & x, V const & y, W const & z);
//////////////////////////////////////
// Convertion vector constructors
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec3(tvec2<A> const & v, B const & s);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec3(A const & s, tvec2<B> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec3(tvec3<U> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec3(tvec4<U> const & v);
//////////////////////////////////////
// Unary arithmetic operators
tvec3<half>& operator= (tvec3<half> const & v);
tvec3<half>& operator+=(half const & s);
tvec3<half>& operator+=(tvec3<half> const & v);
tvec3<half>& operator-=(half const & s);
tvec3<half>& operator-=(tvec3<half> const & v);
tvec3<half>& operator*=(half const & s);
tvec3<half>& operator*=(tvec3<half> const & v);
tvec3<half>& operator/=(half const & s);
tvec3<half>& operator/=(tvec3<half> const & v);
tvec3<half>& operator++();
tvec3<half>& operator--();
//////////////////////////////////////
// Swizzle operators
half swizzle(comp X) const;
tvec2<half> swizzle(comp X, comp Y) const;
tvec3<half> swizzle(comp X, comp Y, comp Z) const;
tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
tref3<half> swizzle(comp X, comp Y, comp Z);
};
template <>
struct tvec4<half>
{
enum ctor{null};
typedef half value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type value_size();
typedef tvec4<half> type;
typedef tvec4<bool> bool_type;
//////////////////////////////////////
// Data
half x, y, z, w;
//////////////////////////////////////
// Accesses
half & operator[](size_type i);
half const & operator[](size_type i) const;
//////////////////////////////////////
// Implicit basic constructors
tvec4();
tvec4(tvec4<half> const & v);
//////////////////////////////////////
// Explicit basic constructors
explicit tvec4(ctor);
explicit tvec4(
half const & s);
explicit tvec4(
half const & s0,
half const & s1,
half const & s2,
half const & s3);
//////////////////////////////////////
// Swizzle constructors
tvec4(tref4<half> const & r);
//////////////////////////////////////
// Convertion scalar constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec4(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, typename D>
explicit tvec4(A const & x, B const & y, C const & z, D const & w);
//////////////////////////////////////
// Convertion vector constructors
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(tvec3<A> const & v, B const & s);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(A const & s, tvec3<B> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec4(tvec4<U> const & v);
//////////////////////////////////////
// Unary arithmetic operators
tvec4<half>& operator= (tvec4<half> const & v);
tvec4<half>& operator+=(half const & s);
tvec4<half>& operator+=(tvec4<half> const & v);
tvec4<half>& operator-=(half const & s);
tvec4<half>& operator-=(tvec4<half> const & v);
tvec4<half>& operator*=(half const & s);
tvec4<half>& operator*=(tvec4<half> const & v);
tvec4<half>& operator/=(half const & s);
tvec4<half>& operator/=(tvec4<half> const & v);
tvec4<half>& operator++();
tvec4<half>& operator--();
//////////////////////////////////////
// Swizzle operators
half swizzle(comp X) const;
tvec2<half> swizzle(comp X, comp Y) const;
tvec3<half> swizzle(comp X, comp Y, comp Z) const;
tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
tref4<half> swizzle(comp X, comp Y, comp Z, comp W);
};
#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98)
}
//namespace detail
/// @addtogroup gtc_half_float
/// @{
/// Type for half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::half half;
/// Vector of 2 half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tvec2<detail::half> hvec2;
/// Vector of 3 half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tvec3<detail::half> hvec3;
/// Vector of 4 half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tvec4<detail::half> hvec4;
/// 2 * 2 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat2x2<detail::half> hmat2;
/// 3 * 3 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat3x3<detail::half> hmat3;
/// 4 * 4 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat4x4<detail::half> hmat4;
/// 2 * 2 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat2x2<detail::half> hmat2x2;
/// 2 * 3 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat2x3<detail::half> hmat2x3;
/// 2 * 4 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat2x4<detail::half> hmat2x4;
/// 3 * 2 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat3x2<detail::half> hmat3x2;
/// 3 * 3 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat3x3<detail::half> hmat3x3;
/// 3 * 4 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat3x4<detail::half> hmat3x4;
/// 4 * 2 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat4x2<detail::half> hmat4x2;
/// 4 * 3 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat4x3<detail::half> hmat4x3;
/// 4 * 4 matrix of half-precision floating-point numbers.
/// @see gtc_half_float
typedef detail::tmat4x4<detail::half> hmat4x4;
/// Returns the absolute value of a half-precision floating-point value
/// @see gtc_half_float
half abs(half const & x);
/// Returns the absolute value of a half-precision floating-point two dimensional vector
/// @see gtc_half_float
hvec2 abs(hvec2 const & x);
/// Returns the absolute value of a half-precision floating-point three dimensional vector
/// @see gtc_half_float
hvec3 abs(hvec3 const & x);
/// Returns the absolute value of a half-precision floating-point four dimensional vector
/// @see gtc_half_float
hvec4 abs(hvec4 const & x);
/// Selects which vector each returned component comes
/// from. For a component of <a> that is false, the
/// corresponding component of x is returned. For a
/// component of a that is true, the corresponding
/// component of y is returned. Components of x and y that
/// are not selected are allowed to be invalid floating point
/// values and will have no effect on the results. Thus, this
/// provides different functionality than
/// genType mix(genType x, genType y, genType(a))
/// where a is a Boolean vector.
///
/// @see gtc_half_float
half mix(half const & x, half const & y, bool const & a);
/// @}
}// namespace glm
#include "half_float.inl"
#endif//GLM_GTC_half_float

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,105 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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
///
/// @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 <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_integer extension included")
#endif
namespace glm
{
/// @addtogroup gtc_integer
/// @{
/// 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>
GLM_FUNC_DECL genIUType log2(genIUType x);
/// Modulus. Returns x % y
/// for each component in x using the floating point value y.
///
/// @tparam genIUType Integer-point scalar or 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 genIUType>
GLM_FUNC_DECL genIUType mod(genIUType x, genIUType 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, 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);
/// @}
} //namespace glm
#include "integer.inl"

View File

@@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & vec)
{
//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));
}
};
# if GLM_HAS_BITSCAN_WINDOWS
template <precision P>
struct compute_log2<int, P, tvec4, false>
{
GLM_FUNC_QUALIFIER static tvec4<int, P> call(tvec4<int, P> const & vec)
{
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);
return Result;
}
};
# endif//GLM_HAS_BITSCAN_WINDOWS
}//namespace detail
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -34,13 +38,12 @@
/// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_access
#define GLM_GTC_matrix_access GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../detail/setup.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_access extension included")
#endif
@@ -51,37 +54,35 @@ namespace glm
/// Get a specific row of a matrix.
/// @see gtc_matrix_access
template <typename genType>
typename genType::row_type row(
genType const & m,
int index);
template <typename genType>
GLM_FUNC_DECL typename genType::row_type row(
genType const & m,
length_t index);
/// Set a specific row to a matrix.
/// @see gtc_matrix_access
template <typename genType>
genType row(
genType const & m,
int index,
template <typename genType>
GLM_FUNC_DECL genType row(
genType const & m,
length_t index,
typename genType::row_type const & x);
/// Get a specific column of a matrix.
/// @see gtc_matrix_access
template <typename genType>
typename genType::col_type column(
genType const & m,
int index);
template <typename genType>
GLM_FUNC_DECL typename genType::col_type column(
genType const & m,
length_t index);
/// Set a specific column to a matrix.
/// @see gtc_matrix_access
template <typename genType>
genType column(
genType const & m,
int index,
/// Set a specific column to a matrix.
/// @see gtc_matrix_access
template <typename genType>
GLM_FUNC_DECL genType column(
genType const & m,
length_t index,
typename genType::col_type const & x);
/// @}
}//namespace glm
#include "matrix_access.inl"
#endif//GLM_GTC_matrix_access

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -31,13 +35,15 @@ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType row
(
genType const & m,
int index,
genType const & m,
length_t index,
typename genType::row_type const & x
)
{
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
genType Result = m;
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
Result[i][index] = x[i];
return Result;
}
@@ -45,12 +51,14 @@ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::row_type row
(
genType const & m,
int index
genType const & m,
length_t index
)
{
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
typename genType::row_type Result;
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
Result[i] = m[i][index];
return Result;
}
@@ -58,11 +66,13 @@ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType column
(
genType const & m,
int index,
genType const & m,
length_t index,
typename genType::col_type const & x
)
{
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
genType Result = m;
Result[index] = x;
return Result;
@@ -71,10 +81,12 @@ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::col_type column
(
genType const & m,
int index
genType const & m,
length_t index
)
{
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
return m[index];
}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -34,13 +38,20 @@
/// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_integer
#define GLM_GTC_matrix_integer GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../mat2x2.hpp"
#include "../mat2x3.hpp"
#include "../mat2x4.hpp"
#include "../mat3x2.hpp"
#include "../mat3x3.hpp"
#include "../mat3x4.hpp"
#include "../mat4x2.hpp"
#include "../mat4x3.hpp"
#include "../mat4x4.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_integer extension included")
#endif
@@ -51,300 +62,300 @@ namespace glm
/// High-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<highp_int> highp_imat2;
typedef tmat2x2<int, highp> highp_imat2;
/// High-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<highp_int> highp_imat3;
typedef tmat3x3<int, highp> highp_imat3;
/// High-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<highp_int> highp_imat4;
typedef tmat4x4<int, highp> highp_imat4;
/// High-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<highp_int> highp_imat2x2;
typedef tmat2x2<int, highp> highp_imat2x2;
/// High-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<highp_int> highp_imat2x3;
typedef tmat2x3<int, highp> highp_imat2x3;
/// High-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<highp_int> highp_imat2x4;
typedef tmat2x4<int, highp> highp_imat2x4;
/// High-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<highp_int> highp_imat3x2;
typedef tmat3x2<int, highp> highp_imat3x2;
/// High-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<highp_int> highp_imat3x3;
typedef tmat3x3<int, highp> highp_imat3x3;
/// High-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<highp_int> highp_imat3x4;
typedef tmat3x4<int, highp> highp_imat3x4;
/// High-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<highp_int> highp_imat4x2;
typedef tmat4x2<int, highp> highp_imat4x2;
/// High-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<highp_int> highp_imat4x3;
typedef tmat4x3<int, highp> highp_imat4x3;
/// High-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<highp_int> highp_imat4x4;
typedef tmat4x4<int, highp> highp_imat4x4;
/// Medium-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<mediump_int> mediump_imat2;
typedef tmat2x2<int, mediump> mediump_imat2;
/// Medium-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<mediump_int> mediump_imat3;
typedef tmat3x3<int, mediump> mediump_imat3;
/// Medium-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<mediump_int> mediump_imat4;
typedef tmat4x4<int, mediump> mediump_imat4;
/// Medium-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<mediump_int> mediump_imat2x2;
typedef tmat2x2<int, mediump> mediump_imat2x2;
/// Medium-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<mediump_int> mediump_imat2x3;
typedef tmat2x3<int, mediump> mediump_imat2x3;
/// Medium-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<mediump_int> mediump_imat2x4;
typedef tmat2x4<int, mediump> mediump_imat2x4;
/// Medium-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<mediump_int> mediump_imat3x2;
typedef tmat3x2<int, mediump> mediump_imat3x2;
/// Medium-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<mediump_int> mediump_imat3x3;
typedef tmat3x3<int, mediump> mediump_imat3x3;
/// Medium-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<mediump_int> mediump_imat3x4;
typedef tmat3x4<int, mediump> mediump_imat3x4;
/// Medium-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<mediump_int> mediump_imat4x2;
typedef tmat4x2<int, mediump> mediump_imat4x2;
/// Medium-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<mediump_int> mediump_imat4x3;
typedef tmat4x3<int, mediump> mediump_imat4x3;
/// Medium-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<mediump_int> mediump_imat4x4;
typedef tmat4x4<int, mediump> mediump_imat4x4;
/// Low-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<lowp_int> lowp_imat2;
typedef tmat2x2<int, lowp> lowp_imat2;
/// Low-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<lowp_int> lowp_imat3;
typedef tmat3x3<int, lowp> lowp_imat3;
/// Low-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<lowp_int> lowp_imat4;
typedef tmat4x4<int, lowp> lowp_imat4;
/// Low-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<lowp_int> lowp_imat2x2;
typedef tmat2x2<int, lowp> lowp_imat2x2;
/// Low-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<lowp_int> lowp_imat2x3;
typedef tmat2x3<int, lowp> lowp_imat2x3;
/// Low-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<lowp_int> lowp_imat2x4;
typedef tmat2x4<int, lowp> lowp_imat2x4;
/// Low-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<lowp_int> lowp_imat3x2;
typedef tmat3x2<int, lowp> lowp_imat3x2;
/// Low-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<lowp_int> lowp_imat3x3;
typedef tmat3x3<int, lowp> lowp_imat3x3;
/// Low-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<lowp_int> lowp_imat3x4;
typedef tmat3x4<int, lowp> lowp_imat3x4;
/// Low-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<lowp_int> lowp_imat4x2;
typedef tmat4x2<int, lowp> lowp_imat4x2;
/// Low-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<lowp_int> lowp_imat4x3;
typedef tmat4x3<int, lowp> lowp_imat4x3;
/// Low-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<lowp_int> lowp_imat4x4;
typedef tmat4x4<int, lowp> lowp_imat4x4;
/// High-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<highp_uint> highp_umat2;
typedef tmat2x2<uint, highp> highp_umat2;
/// High-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<highp_uint> highp_umat3;
typedef tmat3x3<uint, highp> highp_umat3;
/// High-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<highp_uint> highp_umat4;
typedef tmat4x4<uint, highp> highp_umat4;
/// High-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<highp_uint> highp_umat2x2;
typedef tmat2x2<uint, highp> highp_umat2x2;
/// High-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<highp_uint> highp_umat2x3;
typedef tmat2x3<uint, highp> highp_umat2x3;
/// High-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<highp_uint> highp_umat2x4;
typedef tmat2x4<uint, highp> highp_umat2x4;
/// High-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<highp_uint> highp_umat3x2;
typedef tmat3x2<uint, highp> highp_umat3x2;
/// High-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<highp_uint> highp_umat3x3;
typedef tmat3x3<uint, highp> highp_umat3x3;
/// High-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<highp_uint> highp_umat3x4;
typedef tmat3x4<uint, highp> highp_umat3x4;
/// High-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<highp_uint> highp_umat4x2;
typedef tmat4x2<uint, highp> highp_umat4x2;
/// High-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<highp_uint> highp_umat4x3;
typedef tmat4x3<uint, highp> highp_umat4x3;
/// High-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<highp_uint> highp_umat4x4;
typedef tmat4x4<uint, highp> highp_umat4x4;
/// Medium-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<mediump_uint> mediump_umat2;
typedef tmat2x2<uint, mediump> mediump_umat2;
/// Medium-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<mediump_uint> mediump_umat3;
typedef tmat3x3<uint, mediump> mediump_umat3;
/// Medium-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<mediump_uint> mediump_umat4;
typedef tmat4x4<uint, mediump> mediump_umat4;
/// Medium-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<mediump_uint> mediump_umat2x2;
typedef tmat2x2<uint, mediump> mediump_umat2x2;
/// Medium-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<mediump_uint> mediump_umat2x3;
typedef tmat2x3<uint, mediump> mediump_umat2x3;
/// Medium-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<mediump_uint> mediump_umat2x4;
typedef tmat2x4<uint, mediump> mediump_umat2x4;
/// Medium-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<mediump_uint> mediump_umat3x2;
typedef tmat3x2<uint, mediump> mediump_umat3x2;
/// Medium-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<mediump_uint> mediump_umat3x3;
typedef tmat3x3<uint, mediump> mediump_umat3x3;
/// Medium-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<mediump_uint> mediump_umat3x4;
typedef tmat3x4<uint, mediump> mediump_umat3x4;
/// Medium-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<mediump_uint> mediump_umat4x2;
typedef tmat4x2<uint, mediump> mediump_umat4x2;
/// Medium-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<mediump_uint> mediump_umat4x3;
typedef tmat4x3<uint, mediump> mediump_umat4x3;
/// Medium-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<mediump_uint> mediump_umat4x4;
typedef tmat4x4<uint, mediump> mediump_umat4x4;
/// Low-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<lowp_uint> lowp_umat2;
typedef tmat2x2<uint, lowp> lowp_umat2;
/// Low-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<lowp_uint> lowp_umat3;
typedef tmat3x3<uint, lowp> lowp_umat3;
/// Low-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<lowp_uint> lowp_umat4;
typedef tmat4x4<uint, lowp> lowp_umat4;
/// Low-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<lowp_uint> lowp_umat2x2;
typedef tmat2x2<uint, lowp> lowp_umat2x2;
/// Low-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<lowp_uint> lowp_umat2x3;
typedef tmat2x3<uint, lowp> lowp_umat2x3;
/// Low-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<lowp_uint> lowp_umat2x4;
typedef tmat2x4<uint, lowp> lowp_umat2x4;
/// Low-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<lowp_uint> lowp_umat3x2;
typedef tmat3x2<uint, lowp> lowp_umat3x2;
/// Low-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<lowp_uint> lowp_umat3x3;
typedef tmat3x3<uint, lowp> lowp_umat3x3;
/// Low-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<lowp_uint> lowp_umat3x4;
typedef tmat3x4<uint, lowp> lowp_umat3x4;
/// Low-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<lowp_uint> lowp_umat4x2;
typedef tmat4x2<uint, lowp> lowp_umat4x2;
/// Low-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<lowp_uint> lowp_umat4x3;
typedef tmat4x3<uint, lowp> lowp_umat4x3;
/// Low-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<lowp_uint> lowp_umat4x4;
typedef tmat4x4<uint, lowp> lowp_umat4x4;
#if(defined(GLM_PRECISION_HIGHP_INT))
typedef highp_imat2 imat2;
@@ -451,7 +462,7 @@ namespace glm
typedef lowp_umat4x4 umat4x4;
#else //if(defined(GLM_PRECISION_MEDIUMP_UINT))
/// Unsigned integer 2x2 matrix.
/// Unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef mediump_umat2 umat2;
@@ -502,5 +513,3 @@ namespace glm
/// @}
}//namespace glm
#endif//GLM_GTC_matrix_integer

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -34,13 +38,16 @@
/// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_inverse
#define GLM_GTC_matrix_inverse GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
// Dependencies
#include "../detail/setup.hpp"
#include "../matrix.hpp"
#include "../mat2x2.hpp"
#include "../mat3x3.hpp"
#include "../mat4x4.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_inverse extension included")
#endif
@@ -55,20 +62,17 @@ namespace glm
/// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate.
/// @see gtc_matrix_inverse
template <typename genType>
genType affineInverse(genType const & m);
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.
/// @see gtc_matrix_inverse
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type inverseTranspose(
genType const & m);
template <typename genType>
GLM_FUNC_DECL genType inverseTranspose(genType const & m);
/// @}
}//namespace glm
#include "matrix_inverse.inl"
#endif//GLM_GTC_matrix_inverse

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -28,63 +32,52 @@
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
(
detail::tmat3x3<T> const & m
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> affineInverse(tmat3x3<T, P> const & m)
{
detail::tmat3x3<T> Result(m);
Result[2] = detail::tvec3<T>(0, 0, 1);
Result = transpose(Result);
detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]);
Result[2] = Translation;
return Result;
tmat2x2<T, P> const Inv(inverse(tmat2x2<T, P>(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)));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse
(
detail::tmat4x4<T> const & m
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> affineInverse(tmat4x4<T, P> const & m)
{
detail::tmat4x4<T> Result(m);
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
Result = transpose(Result);
detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]);
Result[3] = Translation;
return Result;
tmat3x3<T, P> const Inv(inverse(tmat3x3<T, P>(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)));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose
(
detail::tmat2x2<valType> const & m
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> inverseTranspose(tmat2x2<T, P> const & m)
{
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
detail::tmat2x2<valType> Inverse(
tmat2x2<T, P> Inverse(
+ m[1][1] / Determinant,
- m[0][1] / Determinant,
- m[1][0] / Determinant,
- m[1][0] / Determinant,
+ m[0][0] / Determinant);
return Inverse;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose
(
detail::tmat3x3<valType> const & m
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> inverseTranspose(tmat3x3<T, P> const & m)
{
valType Determinant =
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]);
detail::tmat3x3<valType> Inverse;
tmat3x3<T, P> Inverse(uninitialize);
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]);
@@ -99,33 +92,30 @@ namespace glm
return Inverse;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose
(
detail::tmat4x4<valType> const & m
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> inverseTranspose(tmat4x4<T, P> const & m)
{
valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
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];
T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
T SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
T SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
T SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
T SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
T SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
T SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
T SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
T SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
T SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
T SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
T SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
T SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
T SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
T SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
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];
detail::tmat4x4<valType> Inverse;
tmat4x4<T, P> Inverse(uninitialize);
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);
@@ -146,14 +136,14 @@ namespace glm
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
valType Determinant =
+ m[0][0] * Inverse[0][0]
+ m[0][1] * Inverse[0][1]
+ m[0][2] * Inverse[0][2]
T Determinant =
+ m[0][0] * Inverse[0][0]
+ m[0][1] * Inverse[0][1]
+ m[0][2] * Inverse[0][2]
+ m[0][3] * Inverse[0][3];
Inverse /= Determinant;
return Inverse;
}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -43,13 +47,16 @@
/// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_transform
#define GLM_GTC_matrix_transform GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
// Dependencies
#include "../mat4x4.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/constants.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
#endif
@@ -74,31 +81,27 @@ namespace glm
/// // 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 gtx_transform
/// @see - translate(T x, T y, T z)
/// @see - translate(detail::tmat4x4<T> const & m, T x, T y, T z)
/// @see - translate(detail::tvec3<T> const & v)
template <typename T>
detail::tmat4x4<T> translate(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v);
/// @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 if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param axis Rotation axis, recommanded to be normalized.
/// @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 gtx_transform
/// @see - rotate(T angle, T x, T y, T z)
/// @see - rotate(detail::tmat4x4<T> const & m, T angle, T x, T y, T z)
/// @see - rotate(T angle, detail::tvec3<T> const & v)
template <typename T>
detail::tmat4x4<T> rotate(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & axis);
/// @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.
///
@@ -106,14 +109,12 @@ namespace glm
/// @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 gtx_transform
/// @see - scale(T x, T y, T z) scale(T const & x, T const & y, T const & z)
/// @see - scale(detail::tmat4x4<T> const & m, T x, T y, T z)
/// @see - scale(detail::tvec3<T> const & v)
template <typename T>
detail::tmat4x4<T> scale(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v);
/// @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.
///
@@ -126,14 +127,14 @@ namespace glm
/// @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>
detail::tmat4x4<T> 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,
T zNear,
T zFar);
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
///
@@ -143,13 +144,13 @@ namespace glm
/// @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>
detail::tmat4x4<T> ortho(
T const & left,
T const & right,
T const & bottom,
T const & top);
/// @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.
///
@@ -161,131 +162,233 @@ namespace glm
/// @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>
detail::tmat4x4<T> frustum(
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & near,
T const & far);
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.
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
///
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param aspect
/// @param near
/// @param far
/// @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>
detail::tmat4x4<T> perspective(
T const & fovy,
T const & aspect,
T const & near,
T const & far);
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> perspective(
T fovy,
T aspect,
T near,
T far);
/// Builds a perspective projection matrix based on a field of view.
/// Creates a matrix for a right handed, symetric perspective-view frustum.
///
/// @param fov Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @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
/// @param far
/// @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 valType>
detail::tmat4x4<valType> perspectiveFov(
valType const & fov,
valType const & width,
valType const & height,
valType const & near,
valType const & far);
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 Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param aspect
/// @param near
/// @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>
detail::tmat4x4<T> infinitePerspective(
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 Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param aspect
/// @param near
/// @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>
detail::tmat4x4<T> tweakedInfinitePerspective(
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
/// @param model
/// @param proj
/// @param viewport
/// @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>
detail::tvec3<T> project(
detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport);
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
/// @param model
/// @param proj
/// @param viewport
///
/// @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>
detail::tvec3<T> unProject(
detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport);
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 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, typename U>
detail::tmat4x4<T> pickMatrix(
detail::tvec2<T> const & center,
detail::tvec2<T> const & delta,
detail::tvec4<U> const & viewport);
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.
///
/// 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>
detail::tmat4x4<T> lookAt(
detail::tvec3<T> const & eye,
detail::tvec3<T> const & center,
detail::tvec3<T> const & up);
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"
#endif//GLM_GTC_matrix_transform

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -26,41 +30,40 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../geometric.hpp"
#include "../trigonometric.hpp"
#include "../matrix.hpp"
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> translate
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
tmat4x4<T, P> const & m,
tvec3<T, P> const & v
)
{
detail::tmat4x4<T> Result(m);
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>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
tmat4x4<T, P> const & m,
T angle,
tvec3<T, P> const & v
)
{
#ifdef GLM_FORCE_RADIANS
T a = angle;
#else
T a = radians(angle);
#endif
T c = cos(a);
T s = sin(a);
T const a = angle;
T const c = cos(a);
T const s = sin(a);
detail::tvec3<T> axis = normalize(v);
tvec3<T, P> axis(normalize(v));
tvec3<T, P> temp((T(1) - c) * axis);
detail::tvec3<T> temp = (T(1) - c) * axis;
detail::tmat4x4<T> Rotate(detail::tmat4x4<T>::null);
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];
@@ -73,67 +76,28 @@ namespace glm
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
Rotate[2][2] = c + temp[2] * axis[2];
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
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>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
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>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<T> Result(T(1));
Result[3] = detail::tvec4<T>(v, T(1));
return m * Result;
//detail::tmat4x4<valType> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
//Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
//Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
//Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2];
//Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3];
//return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate_slow
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
tmat4x4<T, P> const & m,
T angle,
tvec3<T, P> const & v
)
{
#ifdef GLM_FORCE_RADIANS
T const a = angle;
#else
T const a = radians(angle);
#endif
T c = cos(a);
T s = sin(a);
detail::tmat4x4<T> Result;
T const c = cos(a);
T const s = sin(a);
tmat4x4<T, P> Result;
detail::tvec3<T> axis = normalize(v);
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;
@@ -150,159 +114,246 @@ namespace glm
Result[2][2] = c + (1 - c) * axis.z * axis.z;
Result[2][3] = 0;
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
Result[3] = tvec4<T, P>(0, 0, 0, 1);
return m * Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale_slow
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> scale
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
tmat4x4<T, P> const & m,
tvec3<T, P> const & v
)
{
detail::tmat4x4<T> Result(T(1));
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 valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & zNear,
valType const & zFar
T left,
T right,
T bottom,
T top,
T zNear,
T zFar
)
{
detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom);
Result[2][2] = - valType(2) / (zFar - zNear);
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 valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
(
T left,
T right,
T bottom,
T top
)
{
detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom);
Result[2][2] = - valType(1);
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 valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum
(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & nearVal,
valType const & farVal
T left,
T right,
T bottom,
T top,
T nearVal,
T farVal
)
{
detail::tmat4x4<valType> Result(0);
Result[0][0] = (valType(2) * nearVal) / (right - left);
Result[1][1] = (valType(2) * nearVal) / (top - bottom);
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] = valType(-1);
Result[3][2] = -(valType(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 valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspective
(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar
T fovy,
T aspect,
T zNear,
T zFar
)
{
#ifdef GLM_FORCE_RADIANS
valType const rad = fovy;
#else
valType const rad = glm::radians(fovy);
#endif
valType range = tan(rad / valType(2)) * zNear;
valType left = -range * aspect;
valType right = range * aspect;
valType bottom = -range;
valType top = range;
#ifdef GLM_LEFT_HANDED
return perspectiveLH(fovy, aspect, zNear, zFar);
#else
return perspectiveRH(fovy, aspect, zNear, zFar);
#endif
}
detail::tmat4x4<valType> Result(valType(0));
Result[0][0] = (valType(2) * zNear) / (right - left);
Result[1][1] = (valType(2) * zNear) / (top - bottom);
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] = - valType(1);
Result[3][2] = - (valType(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 valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov
(
valType const & fov,
valType const & width,
valType const & height,
valType const & zNear,
valType const & zFar
)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveLH
(
T fovy,
T aspect,
T zNear,
T zFar
)
{
#ifdef GLM_FORCE_RADIANS
valType rad = fov;
#else
valType rad = glm::radians(fov);
#endif
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
valType w = h * height / width; ///todo max(width , Height) / min(width , Height)?
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
detail::tmat4x4<valType> Result(valType(0));
Result[0][0] = w;
Result[1][1] = h;
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
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 detail::tmat4x4<T> infinitePerspective
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFov
(
T fovy,
T aspect,
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
)
{
#ifdef GLM_FORCE_RADIANS
T const range = tan(fovy / T(2)) * zNear;
#else
T const range = tan(radians(fovy / T(2))) * zNear;
#endif
T left = -range * aspect;
T right = range * aspect;
T bottom = -range;
T top = range;
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;
detail::tmat4x4<T> Result(T(0));
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);
@@ -311,43 +362,52 @@ namespace glm
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective
// 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 fovy,
T aspect,
T zNear,
T ep
)
{
#ifdef GLM_FORCE_RADIANS
T range = tan(fovy / T(2)) * zNear;
#else
T range = tan(radians(fovy / T(2))) * zNear;
#endif
T left = -range * aspect;
T right = range * aspect;
T bottom = -range;
T top = range;
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;
detail::tmat4x4<T> Result(T(0));
Result[0][0] = (T(2) * zNear) / (right - left);
Result[1][1] = (T(2) * zNear) / (top - bottom);
Result[2][2] = T(0.0001) - T(1);
Result[2][3] = T(-1);
Result[3][2] = - (T(0.0001) - T(2)) * zNear;
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, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> project
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
(
detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport
T fovy,
T aspect,
T zNear
)
{
detail::tvec4<T> tmp = detail::tvec4<T>(obj, T(1));
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;
@@ -356,69 +416,83 @@ namespace glm
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
return detail::tvec3<T>(tmp);
return tvec3<T, P>(tmp);
}
template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> unProject
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> unProject
(
detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport
tvec3<T, P> const & win,
tmat4x4<T, P> const & model,
tmat4x4<T, P> const & proj,
tvec4<U, P> const & viewport
)
{
detail::tmat4x4<T> inverse = glm::inverse(proj * model);
tmat4x4<T, P> Inverse = inverse(proj * model);
detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1));
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);
detail::tvec4<T> obj = inverse * tmp;
tvec4<T, P> obj = Inverse * tmp;
obj /= obj.w;
return detail::tvec3<T>(obj);
return tvec3<T, P>(obj);
}
template <typename T, typename U>
detail::tmat4x4<T> pickMatrix
template <typename T, precision P, typename U>
GLM_FUNC_QUALIFIER tmat4x4<T, P> pickMatrix
(
detail::tvec2<T> const & center,
detail::tvec2<T> const & delta,
detail::tvec4<U> const & viewport
tvec2<T, P> const & center,
tvec2<T, P> const & delta,
tvec4<U, P> const & viewport
)
{
assert(delta.x > T(0) && delta.y > T(0));
detail::tmat4x4<T> Result(1.0f);
tmat4x4<T, P> Result(1.0f);
if(!(delta.x > T(0) && delta.y > T(0)))
if(!(delta.x > T(0) && delta.y > T(0)))
return Result; // Error
detail::tvec3<T> Temp(
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, detail::tvec3<T>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
return scale(Result, tvec3<T, P>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAt
(
detail::tvec3<T> const & eye,
detail::tvec3<T> const & center,
detail::tvec3<T> const & up
tvec3<T, P> const & eye,
tvec3<T, P> const & center,
tvec3<T, P> const & up
)
{
detail::tvec3<T> f = normalize(center - eye);
detail::tvec3<T> u = normalize(up);
detail::tvec3<T> s = normalize(cross(f, u));
u = cross(s, f);
#ifdef GLM_LEFT_HANDED
return lookAtLH(eye, center, up);
#else
return lookAtRH(eye, center, up);
#endif
}
detail::tmat4x4<T> Result(1);
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;
@@ -433,4 +507,32 @@ namespace glm
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

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -38,13 +42,20 @@
/// <glm/gtc/noise.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_noise
#define GLM_GTC_noise GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../detail/_noise.hpp"
#include "../geometric.hpp"
#include "../common.hpp"
#include "../vector_relational.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_noise extension included")
#endif
@@ -54,27 +65,25 @@ namespace glm
/// @{
/// Classic perlin noise.
/// @see gtc_noise
template <typename T, template<typename> class vecType>
T perlin(
vecType<T> const & p);
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p);
/// Periodic perlin noise.
/// @see gtc_noise
template <typename T, template<typename> class vecType>
T perlin(
vecType<T> const & p,
vecType<T> const & rep);
template <typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p,
vecType<T, P> const & rep);
/// Simplex noise.
/// @see gtc_noise
template <typename T, template<typename> class vecType>
T simplex(
vecType<T> const & p);
template <typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_DECL T simplex(
vecType<T, P> const & p);
/// @}
}//namespace glm
#include "noise.inl"
#endif//GLM_GTC_noise

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,478 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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
/// 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))
# pragma message("GLM: GLM_GTC_packing extension included")
#endif
namespace glm
{
/// @addtogroup gtc_packing
/// @{
/// First, converts the normalized floating-point value v into a 8-bit integer value.
/// Then, the results are packed into the returned 8-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm1x8: round(clamp(c, 0, +1) * 255.0)
///
/// @see gtc_packing
/// @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)
/// @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 float unpackUnorm1x8(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.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm2x8: round(clamp(c, 0, +1) * 255.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// 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 <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);
/// 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 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.
///
/// The conversion to fixed point is done as follows:
/// packSnorm1x8: round(clamp(s, -1, +1) * 127.0)
///
/// @see gtc_packing
/// @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.
/// 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.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packSnorm2x8: round(clamp(c, -1, +1) * 127.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// 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 <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);
/// 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 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.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0)
///
/// @see gtc_packing
/// @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.
/// 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
///
/// @see gtc_packing
/// @see vec2 unpackUnorm2x16(uint32 p)
/// @see vec4 unpackUnorm4x16(uint64 p)
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 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 unpackUnorm1x16(uint16 p);
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
/// Then, the results are packed into the returned 64-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm4x16: round(clamp(c, 0, +1) * 65535.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// 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 <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);
/// 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;
/// the last component will be extracted from the most significant bits.
///
/// @see gtc_packing
/// @see float unpackUnorm1x16(uint16 p)
/// @see vec2 unpackUnorm2x16(uint32 p)
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 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 unpackUnorm4x16(uint64 p);
/// First, converts the normalized floating-point value v into 16-bit integer value.
/// Then, the results are packed into the returned 16-bit unsigned integer.
///
/// The conversion to fixed point is done as follows:
/// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0)
///
/// @see gtc_packing
/// @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.
/// 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)
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.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 unpackSnorm1x16(uint16 p);
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
/// Then, the results are packed into the returned 64-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packSnorm2x8: round(clamp(c, -1, +1) * 32767.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// 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 <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);
/// 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 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 <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 <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,
/// 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 forth component specifies the 16 most-significant bits.
///
/// @see gtc_packing
/// @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);
/// 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,
/// 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 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,
/// 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 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);
/// 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);
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,
/// 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 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);
/// 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);
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.
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// 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 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);
/// 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 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)
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.
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// 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 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);
/// 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 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)
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 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);
/// 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.
///
/// @see gtc_packing
/// @see uint32 packF2x11_1x10(vec3 const & v)
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
/// @}
}// namespace glm
#include "packing.inl"

View File

@@ -0,0 +1,489 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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 "../common.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../detail/type_half.hpp"
#include <cstring>
namespace glm{
namespace detail
{
GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
// Half bits => SEEEEEFF FFFFFFFF
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
// 0x00007c00 => 00000000 00000000 01111100 00000000
// 0x000003ff => 00000000 00000000 00000011 11111111
// 0x38000000 => 00111000 00000000 00000000 00000000
// 0x7f800000 => 01111111 10000000 00000000 00000000
// 0x00008000 => 00000000 00000000 10000000 00000000
return
((f >> 16) & 0x8000) | // sign
((((f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | // exponential
((f >> 13) & 0x03ff); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
// Half bits => SEEEEEFF FFFFFFFF
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
// 0x000007c0 => 00000000 00000000 00000111 11000000
// 0x00007c00 => 00000000 00000000 01111100 00000000
// 0x000003ff => 00000000 00000000 00000011 11111111
// 0x38000000 => 00111000 00000000 00000000 00000000
// 0x7f800000 => 01111111 10000000 00000000 00000000
// 0x00008000 => 00000000 00000000 10000000 00000000
return
((((f & 0x7f800000) - 0x38000000) >> 17) & 0x07c0) | // exponential
((f >> 17) & 0x003f); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 p)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
// Half bits => SEEEEEFF FFFFFFFF
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
// 0x000007c0 => 00000000 00000000 00000111 11000000
// 0x00007c00 => 00000000 00000000 01111100 00000000
// 0x000003ff => 00000000 00000000 00000011 11111111
// 0x38000000 => 00111000 00000000 00000000 00000000
// 0x7f800000 => 01111111 10000000 00000000 00000000
// 0x00008000 => 00000000 00000000 10000000 00000000
return
((((p & 0x07c0) << 17) + 0x38000000) & 0x7f800000) | // exponential
((p & 0x003f) << 17); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
// Half bits => SEEEEEFF FFFFFFFF
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
// 0x0000001F => 00000000 00000000 00000000 00011111
// 0x0000003F => 00000000 00000000 00000000 00111111
// 0x000003E0 => 00000000 00000000 00000011 11100000
// 0x000007C0 => 00000000 00000000 00000111 11000000
// 0x00007C00 => 00000000 00000000 01111100 00000000
// 0x000003FF => 00000000 00000000 00000011 11111111
// 0x38000000 => 00111000 00000000 00000000 00000000
// 0x7f800000 => 01111111 10000000 00000000 00000000
// 0x00008000 => 00000000 00000000 10000000 00000000
return
((((f & 0x7f800000) - 0x38000000) >> 18) & 0x03E0) | // exponential
((f >> 18) & 0x001f); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 p)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
// Half bits => SEEEEEFF FFFFFFFF
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
// 0x0000001F => 00000000 00000000 00000000 00011111
// 0x0000003F => 00000000 00000000 00000000 00111111
// 0x000003E0 => 00000000 00000000 00000011 11100000
// 0x000007C0 => 00000000 00000000 00000111 11000000
// 0x00007C00 => 00000000 00000000 01111100 00000000
// 0x000003FF => 00000000 00000000 00000011 11111111
// 0x38000000 => 00111000 00000000 00000000 00000000
// 0x7f800000 => 01111111 10000000 00000000 00000000
// 0x00008000 => 00000000 00000000 10000000 00000000
return
((((p & 0x03E0) << 18) + 0x38000000) & 0x7f800000) | // exponential
((p & 0x001f) << 18); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint h)
{
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
}
GLM_FUNC_QUALIFIER glm::uint floatTo11bit(float x)
{
if(x == 0.0f)
return 0u;
else if(glm::isnan(x))
return ~0u;
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
return float2packed11(Pack);
}
GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x)
{
if(x == 0)
return 0.0f;
else if(x == ((1 << 11) - 1))
return ~0;//NaN
else if(x == (0x1f << 6))
return ~0;//Inf
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
}
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
{
if(x == 0.0f)
return 0u;
else if(glm::isnan(x))
return ~0u;
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
return float2packed10(Pack);
}
GLM_FUNC_QUALIFIER float packed10bitToFloat(glm::uint x)
{
if(x == 0)
return 0.0f;
else if(x == ((1 << 10) - 1))
return ~0;//NaN
else if(x == (0x1f << 5))
return ~0;//Inf
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
}
// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
// {
// return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22);
// }
union u10u10u10u2
{
struct
{
uint x : 10;
uint y : 10;
uint z : 10;
uint w : 2;
} data;
uint32 pack;
};
union i10i10i10i2
{
struct
{
int x : 10;
int y : 10;
int z : 10;
int w : 2;
} data;
uint32 pack;
};
}//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)
{
u8vec2 const Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
return reinterpret_cast<uint16 const &>(Topack);
}
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
{
vec2 const Unpack(reinterpret_cast<u8vec2 const &>(p));
return 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);
}
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p)
{
float const Unpack(reinterpret_cast<int8 const &>(p));
return clamp(
Unpack * 0.00787401574803149606299212598425f, // 1.0f / 127.0f
-1.0f, 1.0f);
}
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);
}
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
{
vec2 const Unpack(reinterpret_cast<i8vec2 const &>(p));
return clamp(
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));
}
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p)
{
float const Unpack(p);
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
}
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);
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
{
vec4 const Unpack(reinterpret_cast<u16vec4 const &>(p));
return 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);
}
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p)
{
float const Unpack(reinterpret_cast<int16 const &>(p));
return clamp(
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
-1.0f, 1.0f);
}
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);
}
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
{
vec4 const Unpack(reinterpret_cast<i16vec4 const &>(p));
return clamp(
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);
}
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v)
{
return detail::toFloat32(reinterpret_cast<int16 const &>(v));
}
GLM_FUNC_QUALIFIER uint64 packHalf4x16(glm::vec4 const & v)
{
i16vec4 Unpack(
detail::toFloat16(v.x),
detail::toFloat16(v.y),
detail::toFloat16(v.z),
detail::toFloat16(v.w));
return reinterpret_cast<uint64 const &>(Unpack);
}
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
{
i16vec4 Unpack(reinterpret_cast<i16vec4 const &>(v));
return vec4(
detail::toFloat32(Unpack.x),
detail::toFloat32(Unpack.y),
detail::toFloat32(Unpack.z),
detail::toFloat32(Unpack.w));
}
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;
}
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
return ivec4(
Unpack.data.x,
Unpack.data.y,
Unpack.data.z,
Unpack.data.w);
}
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;
}
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
{
detail::u10u10u10u2 Unpack;
Unpack.pack = v;
return uvec4(
Unpack.data.x,
Unpack.data.y,
Unpack.data.z,
Unpack.data.w);
}
GLM_FUNC_QUALIFIER uint32 packSnorm3x10_1x2(vec4 const & v)
{
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));
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v)
{
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;
}
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)));
detail::u10u10u10u2 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 unpackUnorm3x10_1x2(uint32 v)
{
vec4 const ScaleFactors(1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 3.f);
detail::u10u10u10u2 Unpack;
Unpack.pack = v;
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactors;
}
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v)
{
return
((detail::floatTo11bit(v.x) & ((1 << 11) - 1)) << 0) |
((detail::floatTo11bit(v.y) & ((1 << 11) - 1)) << 11) |
((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22);
}
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 v)
{
return vec3(
detail::packed11bitToFloat(v >> 0),
detail::packed11bitToFloat(v >> 11),
detail::packed10bitToFloat(v >> 22));
}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -37,139 +41,174 @@
/// <glm/gtc/quaternion.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_quaternion
#define GLM_GTC_quaternion GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../mat3x3.hpp"
#include "../mat4x4.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/constants.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_quaternion extension included")
#endif
namespace glm{
namespace detail
namespace glm
{
template <typename T>
struct tquat// : public genType<T, tquat>
{
enum ctor{null};
typedef T value_type;
typedef std::size_t size_type;
public:
value_type x, y, z, w;
GLM_FUNC_DECL size_type length() const;
// Constructors
tquat();
explicit tquat(
value_type const & s,
glm::detail::tvec3<T> const & v);
explicit tquat(
value_type const & w,
value_type const & x,
value_type const & y,
value_type const & z);
// Convertions
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
explicit tquat(
tvec3<T> const & eulerAngles);
explicit tquat(
tmat3x3<T> const & m);
explicit tquat(
tmat4x4<T> const & m);
// Accesses
value_type & operator[](int i);
value_type const & operator[](int i) const;
// Operators
tquat<T> & operator*=(value_type const & s);
tquat<T> & operator/=(value_type const & s);
};
template <typename T>
detail::tquat<T> operator- (
detail::tquat<T> const & q);
template <typename T>
detail::tquat<T> operator+ (
detail::tquat<T> const & q,
detail::tquat<T> const & p);
template <typename T>
detail::tquat<T> operator* (
detail::tquat<T> const & q,
detail::tquat<T> const & p);
template <typename T>
detail::tvec3<T> operator* (
detail::tquat<T> const & q,
detail::tvec3<T> const & v);
template <typename T>
detail::tvec3<T> operator* (
detail::tvec3<T> const & v,
detail::tquat<T> const & q);
template <typename T>
detail::tvec4<T> operator* (
detail::tquat<T> const & q,
detail::tvec4<T> const & v);
template <typename T>
detail::tvec4<T> operator* (
detail::tvec4<T> const & v,
detail::tquat<T> const & q);
template <typename T>
detail::tquat<T> operator* (
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s);
template <typename T>
detail::tquat<T> operator* (
typename detail::tquat<T>::value_type const & s,
detail::tquat<T> const & q);
template <typename T>
detail::tquat<T> operator/ (
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s);
} //namespace detail
/// @addtogroup gtc_quaternion
/// @{
/// Returns the length of the quaternion.
///
/// @see gtc_quaternion
template <typename T>
T length(
detail::tquat<T> const & q);
template <typename T, precision P = defaultp>
struct tquat
{
// -- Implementation detail --
/// Returns the normalized quaternion.
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.
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> normalize(
detail::tquat<T> const & q);
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] + ...
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
///
/// @see gtc_quaternion
template <typename T>
T dot(
detail::tquat<T> const & q1,
detail::tquat<T> const & q2);
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.
@@ -180,14 +219,11 @@ namespace detail
/// @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(detail::tquat<T> const & x, detail::tquat<T> const & y, T const & a)
template <typename T>
detail::tquat<T> mix(
detail::tquat<T> const & x,
detail::tquat<T> const & y,
T const & a);
/// @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.
/// Linear interpolation of two quaternions.
/// The interpolation is oriented.
///
/// @param x A quaternion
@@ -195,11 +231,8 @@ namespace detail
/// @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>
detail::tquat<T> lerp(
detail::tquat<T> const & x,
detail::tquat<T> const & y,
T const & a);
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.
@@ -209,173 +242,149 @@ namespace detail
/// @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>
detail::tquat<T> slerp(
detail::tquat<T> const & x,
detail::tquat<T> const & y,
T const & a);
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.
/// Returns the q conjugate.
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> conjugate(
detail::tquat<T> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> conjugate(tquat<T, P> const & q);
/// Returns the q inverse.
/// Returns the q inverse.
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> inverse(
detail::tquat<T> const & q);
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> inverse(tquat<T, P> const & q);
/// Rotates a quaternion from an vector of 3 components axis and an angle.
/// Rotates a quaternion from a vector of 3 components axis and an angle.
///
/// @param q Source orientation
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param axis Axis of the rotation, must be normalized.
/// @param angle Angle expressed in radians.
/// @param axis Axis of the rotation
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> rotate(
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & angle,
detail::tvec3<T> const & axis);
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.
/// 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>
detail::tvec3<T> eulerAngles(
detail::tquat<T> const & x);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> eulerAngles(tquat<T, P> const & x);
/// Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// Returns roll value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename valType>
valType roll(
detail::tquat<valType> const & x);
template <typename T, precision P>
GLM_FUNC_DECL T roll(tquat<T, P> const & x);
/// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// Returns pitch value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename valType>
valType pitch(
detail::tquat<valType> const & x);
template <typename T, precision P>
GLM_FUNC_DECL T pitch(tquat<T, P> const & x);
/// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// Returns yaw value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename valType>
valType yaw(
detail::tquat<valType> const & x);
template <typename T, precision P>
GLM_FUNC_DECL T yaw(tquat<T, P> const & x);
/// Converts a quaternion to a 3 * 3 matrix.
/// Converts a quaternion to a 3 * 3 matrix.
///
/// @see gtc_quaternion
template <typename T>
detail::tmat3x3<T> mat3_cast(
detail::tquat<T> const & x);
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> mat3_cast(tquat<T, P> const & x);
/// Converts a quaternion to a 4 * 4 matrix.
/// Converts a quaternion to a 4 * 4 matrix.
///
/// @see gtc_quaternion
template <typename T>
detail::tmat4x4<T> mat4_cast(
detail::tquat<T> const & x);
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.
/// Converts a 3 * 3 matrix to a quaternion.
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> quat_cast(
detail::tmat3x3<T> const & x);
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.
/// Converts a 4 * 4 matrix to a quaternion.
///
/// @see gtc_quaternion
template <typename T>
detail::tquat<T> quat_cast(
detail::tmat4x4<T> const & x);
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat4x4<T, P> const & x);
/// Returns the quaternion rotation angle.
/// Returns the quaternion rotation angle.
///
/// @see gtc_quaternion
template <typename valType>
valType angle(
detail::tquat<valType> const & x);
template <typename T, precision P>
GLM_FUNC_DECL T angle(tquat<T, P> const & x);
/// Returns the q rotation axis.
/// Returns the q rotation axis.
///
/// @see gtc_quaternion
template <typename valType>
detail::tvec3<valType> axis(
detail::tquat<valType> const & x);
/// Build a quaternion from an angle and a normalized axis.
///
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param x x component of the x-axis, x, y, z must be a normalized axis
/// @param y y component of the y-axis, x, y, z must be a normalized axis
/// @param z z component of the z-axis, x, y, z must be a normalized axis
///
/// @see gtc_quaternion
template <typename valType>
detail::tquat<valType> angleAxis(
valType const & angle,
valType const & x,
valType const & y,
valType const & z);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> axis(tquat<T, P> const & x);
/// Build a quaternion from an angle and a normalized axis.
///
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param axis Axis of the quaternion, must be normalized.
/// @param angle Angle expressed in radians.
/// @param axis Axis of the quaternion, must be normalized.
///
/// @see gtc_quaternion
template <typename valType>
detail::tquat<valType> angleAxis(
valType const & angle,
detail::tvec3<valType> const & axis);
template <typename T, precision P>
GLM_FUNC_DECL tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & axis);
/// Quaternion of floating-point numbers.
/// Returns the component-wise comparison result of x < y.
///
/// @tparam quatType Floating-point quaternion types.
///
/// @see gtc_quaternion
typedef detail::tquat<float> quat;
template <typename T, precision P>
GLM_FUNC_DECL tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y);
/// Quaternion of half-precision floating-point numbers.
/// Returns the component-wise comparison of result x <= y.
///
/// @tparam quatType Floating-point quaternion types.
///
/// @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);
/// Returns the component-wise comparison of result x > y.
///
/// @tparam quatType Floating-point quaternion types.
///
/// @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);
/// Returns the component-wise comparison of result x >= y.
///
/// @tparam quatType Floating-point quaternion types.
///
/// @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);
/// Returns the component-wise comparison of result x == y.
///
/// @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);
/// Returns the component-wise comparison of result x != y.
///
/// @tparam quatType Floating-point quaternion types.
///
/// @see gtc_quaternion
typedef detail::tquat<detail::half> hquat;
/// Quaternion of single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef detail::tquat<float> fquat;
/// Quaternion of double-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef detail::tquat<double> dquat;
/// Quaternion of low precision floating-point numbers.
///
/// @see gtc_quaternion
typedef detail::tquat<lowp_float> lowp_quat;
/// Quaternion of medium precision floating-point numbers.
///
/// @see gtc_quaternion
typedef detail::tquat<mediump_float> mediump_quat;
/// Quaternion of high precision floating-point numbers.
///
/// @see gtc_quaternion
typedef detail::tquat<highp_float> highp_quat;
template <typename T, precision P>
GLM_FUNC_DECL tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y);
/// @}
} //namespace glm
#include "quaternion.inl"
#endif//GLM_GTC_quaternion

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -37,14 +41,13 @@
/// <glm/gtc/random.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_random
#define GLM_GTC_random GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_random extension included")
#endif
@@ -59,10 +62,15 @@ namespace glm
/// @param Max
/// @tparam genType Value type. Currently supported: half (not recommanded), float or double scalars and vectors.
/// @see gtc_random
template <typename genType>
genType linearRand(
genType const & Min,
genType const & Max);
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
///
@@ -70,45 +78,43 @@ namespace glm
/// @param Deviation
/// @see gtc_random
template <typename genType>
genType gaussRand(
genType const & Mean,
genType const & Deviation);
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>
detail::tvec2<T> circularRand(
T const & Radius);
template <typename T>
GLM_FUNC_DECL tvec2<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>
detail::tvec3<T> sphericalRand(
T const & Radius);
template <typename T>
GLM_FUNC_DECL tvec3<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>
detail::tvec2<T> diskRand(
T const & Radius);
template <typename T>
GLM_FUNC_DECL tvec2<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_QUALIFIER detail::tvec3<T> ballRand(
T const & Radius);
GLM_FUNC_DECL tvec3<T, defaultp> ballRand(
T Radius);
/// @}
}//namespace glm
#include "random.inl"
#endif//GLM_GTC_random

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -26,67 +30,276 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../geometric.hpp"
#include "../exponential.hpp"
#include <cstdlib>
#include <ctime>
#include <cassert>
namespace glm{
namespace detail
{
template <typename T, precision P, template <class, precision> class vecType>
struct compute_rand
{
GLM_FUNC_QUALIFIER static vecType<T, P> call();
};
template <precision P>
struct compute_rand<uint8, P, tvec1>
{
GLM_FUNC_QUALIFIER static tvec1<uint8, P> call()
{
return tvec1<uint8, P>(
std::rand() % std::numeric_limits<uint8>::max());
}
};
template <precision P>
struct compute_rand<uint8, P, tvec2>
{
GLM_FUNC_QUALIFIER static tvec2<uint8, P> call()
{
return tvec2<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>
{
GLM_FUNC_QUALIFIER static tvec3<uint8, P> call()
{
return tvec3<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>
{
GLM_FUNC_QUALIFIER static tvec4<uint8, P> call()
{
return tvec4<uint8, P>(
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max(),
std::rand() % std::numeric_limits<uint8>::max());
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint16, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint16, P> 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));
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint32, P> 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));
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint64, P> 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));
}
};
template <typename T, precision P, template <class, precision> class vecType>
struct compute_linearRand
{
template <typename T>
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const;
/*
{
GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
return Min;
}
*/
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & Min, vecType<T, P> const & Max);
};
template <>
GLM_FUNC_QUALIFIER half compute_linearRand::operator()<half> (half const & Min, half const & Max) const
{
return half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min));
}
template <>
GLM_FUNC_QUALIFIER float compute_linearRand::operator()<float> (float const & Min, float const & Max) const
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int8, P, vecType>
{
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
}
GLM_FUNC_QUALIFIER static vecType<int8, P> call(vecType<int8, P> const & Min, vecType<int8, P> const & Max)
{
return (vecType<int8, P>(compute_rand<uint8, P, vecType>::call() % vecType<uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
}
};
template <>
GLM_FUNC_QUALIFIER double compute_linearRand::operator()<double> (double const & Min, double const & Max) const
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint8, P, vecType>
{
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
}
template <>
GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
GLM_FUNC_QUALIFIER static vecType<uint8, P> call(vecType<uint8, P> const & Min, vecType<uint8, P> const & Max)
{
return (compute_rand<uint8, P, vecType>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int16, P, vecType>
{
return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
}
GLM_FUNC_QUALIFIER static vecType<int16, P> call(vecType<int16, P> const & Min, vecType<int16, P> const & Max)
{
return (vecType<int16, P>(compute_rand<uint16, P, vecType>::call() % vecType<uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint16, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint16, P> call(vecType<uint16, P> const & Min, vecType<uint16, P> const & Max)
{
return (compute_rand<uint16, P, vecType>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int32, P> call(vecType<int32, P> const & Min, vecType<int32, P> const & Max)
{
return (vecType<int32, P>(compute_rand<uint32, P, vecType>::call() % vecType<uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint32, P> call(vecType<uint32, P> const & Min, vecType<uint32, P> const & Max)
{
return (compute_rand<uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int64, P> call(vecType<int64, P> const & Min, vecType<int64, P> const & Max)
{
return (vecType<int64, P>(compute_rand<uint64, P, vecType>::call() % vecType<uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint64, P> call(vecType<uint64, P> const & Min, vecType<uint64, P> const & Max)
{
return (compute_rand<uint64, P, vecType>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, lowp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, lowp> call(vecType<float, lowp> const & Min, vecType<float, lowp> const & Max)
{
return vecType<float, lowp>(compute_rand<uint8, lowp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, mediump, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, mediump> call(vecType<float, mediump> const & Min, vecType<float, mediump> const & Max)
{
return vecType<float, mediump>(compute_rand<uint16, mediump, vecType>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, highp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, highp> call(vecType<float, highp> const & Min, vecType<float, highp> 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;
}
};
}//namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType linearRand
(
genType const & Min,
genType const & Max
)
template <typename genType>
GLM_FUNC_QUALIFIER genType linearRand(genType Min, genType Max)
{
return detail::compute_linearRand()(Min, Max);
return detail::compute_linearRand<genType, highp, tvec1>::call(
tvec1<genType, highp>(Min),
tvec1<genType, highp>(Max)).x;
}
VECTORIZE_VEC_VEC(linearRand)
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)
{
return detail::compute_linearRand<T, P, vecType>::call(Min, Max);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType gaussRand
(
genType const & Mean,
genType const & Deviation
)
template <typename genType>
GLM_FUNC_QUALIFIER genType gaussRand(genType Mean, genType Deviation)
{
genType w, x1, x2;
@@ -101,20 +314,23 @@ namespace detail
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
}
VECTORIZE_VEC_VEC(gaussRand)
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)
{
return detail::functor2<T, P, vecType>::call(gaussRand, Mean, Deviation);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec2<T, defaultp> diskRand(T Radius)
{
detail::tvec2<T> Result(T(0));
tvec2<T, defaultp> Result(T(0));
T LenRadius(T(0));
do
{
Result = linearRand(detail::tvec2<T>(-Radius), detail::tvec2<T>(Radius));
Result = linearRand(
tvec2<T, defaultp>(-Radius),
tvec2<T, defaultp>(Radius));
LenRadius = length(Result);
}
while(LenRadius > Radius);
@@ -123,17 +339,16 @@ namespace detail
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec3<T, defaultp> ballRand(T Radius)
{
detail::tvec3<T> Result(T(0));
tvec3<T, defaultp> Result(T(0));
T LenRadius(T(0));
do
{
Result = linearRand(detail::tvec3<T>(-Radius), detail::tvec3<T>(Radius));
Result = linearRand(
tvec3<T, defaultp>(-Radius),
tvec3<T, defaultp>(Radius));
LenRadius = length(Result);
}
while(LenRadius > Radius);
@@ -141,21 +356,15 @@ namespace detail
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> circularRand
(
T const & Radius
)
template <typename T>
GLM_FUNC_QUALIFIER tvec2<T, defaultp> circularRand(T Radius)
{
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
return detail::tvec2<T>(cos(a), sin(a)) * Radius;
return tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sphericalRand
(
T const & Radius
)
template <typename T>
GLM_FUNC_QUALIFIER tvec3<T, defaultp> sphericalRand(T Radius)
{
T z = linearRand(T(-1), T(1));
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
@@ -165,6 +374,6 @@ namespace detail
T x = r * cos(a);
T y = r * sin(a);
return detail::tvec3<T>(x, y, z) * Radius;
return tvec3<T, defaultp>(x, y, z) * Radius;
}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -35,13 +39,12 @@
/// <glm/gtc/reciprocal.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_reciprocal
#define GLM_GTC_reciprocal GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
// Dependencies
#include "../detail/setup.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_reciprocal extension included")
#endif
@@ -55,79 +58,77 @@ namespace glm
///
/// @see gtc_reciprocal
template <typename genType>
genType sec(genType const & angle);
GLM_FUNC_DECL genType sec(genType const & angle);
/// Cosecant function.
/// hypotenuse / opposite or 1 / sin(x)
///
/// @see gtc_reciprocal
template <typename genType>
genType csc(genType const & angle);
GLM_FUNC_DECL genType csc(genType const & angle);
/// Cotangent function.
/// adjacent / opposite or 1 / tan(x)
///
/// @see gtc_reciprocal
template <typename genType>
genType cot(genType const & angle);
GLM_FUNC_DECL genType cot(genType const & angle);
/// Inverse secant function.
///
/// @see gtc_reciprocal
template <typename genType>
genType asec(genType const & x);
GLM_FUNC_DECL genType asec(genType const & x);
/// Inverse cosecant function.
///
/// @see gtc_reciprocal
template <typename genType>
genType acsc(genType const & x);
GLM_FUNC_DECL genType acsc(genType const & x);
/// Inverse cotangent function.
///
/// @see gtc_reciprocal
template <typename genType>
genType acot(genType const & x);
GLM_FUNC_DECL genType acot(genType const & x);
/// Secant hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType sech(genType const & angle);
GLM_FUNC_DECL genType sech(genType const & angle);
/// Cosecant hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType csch(genType const & angle);
GLM_FUNC_DECL genType csch(genType const & angle);
/// Cotangent hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType coth(genType const & angle);
GLM_FUNC_DECL genType coth(genType const & angle);
/// Inverse secant hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType asech(genType const & x);
GLM_FUNC_DECL genType asech(genType const & x);
/// Inverse cosecant hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType acsch(genType const & x);
GLM_FUNC_DECL genType acsch(genType const & x);
/// Inverse cotangent hyperbolic function.
///
/// @see gtc_reciprocal
template <typename genType>
genType acoth(genType const & x);
GLM_FUNC_DECL genType acoth(genType const & x);
/// @}
}//namespace glm
#include "reciprocal.inl"
#endif//GLM_GTC_reciprocal

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -26,174 +30,192 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../trigonometric.hpp"
#include <limits>
namespace glm
{
// sec
template <typename genType>
GLM_FUNC_QUALIFIER genType sec
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType sec(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
return genType(1) / glm::cos(angle);
}
VECTORIZE_VEC(sec)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> sec(vecType<T, P> 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);
}
// csc
template <typename genType>
GLM_FUNC_QUALIFIER genType csc
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType csc(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
return genType(1) / glm::sin(angle);
}
VECTORIZE_VEC(csc)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> csc(vecType<T, P> 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);
}
// cot
template <typename genType>
GLM_FUNC_QUALIFIER genType cot
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType cot(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
return genType(1) / glm::tan(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);
}
VECTORIZE_VEC(cot)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> cot(vecType<T, P> 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);
}
// asec
template <typename genType>
GLM_FUNC_QUALIFIER genType asec
(
genType const & x
)
GLM_FUNC_QUALIFIER genType asec(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
return acos(genType(1) / x);
}
VECTORIZE_VEC(asec)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> asec(vecType<T, P> 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);
}
// acsc
template <typename genType>
GLM_FUNC_QUALIFIER genType acsc
(
genType const & x
)
GLM_FUNC_QUALIFIER genType acsc(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
return asin(genType(1) / x);
}
VECTORIZE_VEC(acsc)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acsc(vecType<T, P> 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);
}
// acot
template <typename genType>
GLM_FUNC_QUALIFIER genType acot
(
genType const & x
)
GLM_FUNC_QUALIFIER genType acot(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
return pi_over_2 - atan(x);
}
VECTORIZE_VEC(acot)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acot(vecType<T, P> 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);
}
// sech
template <typename genType>
GLM_FUNC_QUALIFIER genType sech
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType sech(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
return genType(1) / glm::cosh(angle);
}
VECTORIZE_VEC(sech)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> sech(vecType<T, P> 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);
}
// csch
template <typename genType>
GLM_FUNC_QUALIFIER genType csch
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType csch(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
return genType(1) / glm::sinh(angle);
}
VECTORIZE_VEC(csch)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> csch(vecType<T, P> 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);
}
// coth
template <typename genType>
GLM_FUNC_QUALIFIER genType coth
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType coth(genType angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
return glm::cosh(angle) / glm::sinh(angle);
}
VECTORIZE_VEC(coth)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> coth(vecType<T, P> 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);
}
// asech
template <typename genType>
GLM_FUNC_QUALIFIER genType asech
(
genType const & x
)
GLM_FUNC_QUALIFIER genType asech(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
return acosh(genType(1) / x);
}
VECTORIZE_VEC(asech)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> asech(vecType<T, P> 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);
}
// acsch
template <typename genType>
GLM_FUNC_QUALIFIER genType acsch
(
genType const & x
)
GLM_FUNC_QUALIFIER genType acsch(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
return asinh(genType(1) / x);
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
return acsch(genType(1) / x);
}
VECTORIZE_VEC(acsch)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acsch(vecType<T, P> 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);
}
// acoth
template <typename genType>
GLM_FUNC_QUALIFIER genType acoth
(
genType const & x
)
GLM_FUNC_QUALIFIER genType acoth(genType x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
return atanh(genType(1) / x);
}
VECTORIZE_VEC(acoth)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acoth(vecType<T, P> 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);
}
}//namespace glm

203
includes/glm/gtc/round.hpp Normal file
View File

@@ -0,0 +1,203 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../detail/_vectorize.hpp"
#include "../vector_relational.hpp"
#include "../common.hpp"
#include <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_integer extension included")
#endif
namespace glm
{
/// @addtogroup gtc_round
/// @{
/// Return true if the value is a power of two number.
///
/// @see gtc_round
template <typename genIUType>
GLM_FUNC_DECL bool isPowerOfTwo(genIUType Value);
/// Return true if the value is a power of two number.
///
/// @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);
/// 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);
/// 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 T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & value);
/// 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);
/// 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 T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> floorPowerOfTwo(vecType<T, P> const & value);
/// 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);
/// Return the power of two number which value is the closet to the input value.
///
/// @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);
/// 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);
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
/// @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);
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
/// @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);
/// Higher 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 genType>
GLM_FUNC_DECL genType ceilMultiple(genType Source, genType Multiple);
/// Higher 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> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & 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 genType>
GLM_FUNC_DECL genType floorMultiple(
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> floorMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & 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 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);
/// @}
} //namespace glm
#include "round.inl"

372
includes/glm/gtc/round.inl Normal file
View File

@@ -0,0 +1,372 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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
{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
struct compute_ceilShift
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T)
{
return v;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilShift<T, P, vecType, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Shift)
{
return v | (v >> Shift);
}
};
template <typename T, precision P, template <typename, precision> class vecType, bool isSigned = true>
struct compute_ceilPowerOfTwo
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> 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));
vecType<T, P> 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);
return (v + static_cast<T>(1)) * Sign;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilPowerOfTwo<T, P, vecType, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<T, P> 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);
return v + static_cast<T>(1);
}
};
template <bool is_float, bool is_signed>
struct compute_ceilMultiple{};
template <>
struct compute_ceilMultiple<true, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source > genType(0))
return Source + (Multiple - std::fmod(Source, Multiple));
else
return Source + std::fmod(-Source, Multiple);
}
};
template <>
struct compute_ceilMultiple<false, false>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
genType Tmp = Source - genType(1);
return Tmp + (Multiple - (Tmp % Multiple));
}
};
template <>
struct compute_ceilMultiple<false, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source > genType(0))
{
genType Tmp = Source - genType(1);
return Tmp + (Multiple - (Tmp % Multiple));
}
else
return Source + (-Source % Multiple);
}
};
template <bool is_float, bool is_signed>
struct compute_floorMultiple{};
template <>
struct compute_floorMultiple<true, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - std::fmod(Source, Multiple);
else
return Source - std::fmod(Source, Multiple) - Multiple;
}
};
template <>
struct compute_floorMultiple<false, false>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - Source % Multiple;
else
{
genType Tmp = Source + genType(1);
return Tmp - Tmp % Multiple - Multiple;
}
}
};
template <>
struct compute_floorMultiple<false, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - Source % Multiple;
else
{
genType Tmp = Source + genType(1);
return Tmp - Tmp % Multiple - Multiple;
}
}
};
template <bool is_float, bool is_signed>
struct compute_roundMultiple{};
template <>
struct compute_roundMultiple<true, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - std::fmod(Source, Multiple);
else
{
genType Tmp = Source + genType(1);
return Tmp - std::fmod(Tmp, Multiple) - Multiple;
}
}
};
template <>
struct compute_roundMultiple<false, false>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - Source % Multiple;
else
{
genType Tmp = Source + genType(1);
return Tmp - Tmp % Multiple - Multiple;
}
}
};
template <>
struct compute_roundMultiple<false, true>
{
template <typename genType>
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
{
if(Source >= genType(0))
return Source - Source % Multiple;
else
{
genType Tmp = Source + genType(1);
return Tmp - Tmp % Multiple - Multiple;
}
}
};
}//namespace detail
////////////////
// isPowerOfTwo
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)
{
vecType<T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vecType<T, P>(0));
}
//////////////////
// ceilPowerOfTwo
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;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & v)
{
return detail::compute_ceilPowerOfTwo<T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
}
///////////////////
// floorPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER genType floorPowerOfTwo(genType value)
{
return isPowerOfTwo(value) ? value : highestBitValue(value);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> floorPowerOfTwo(vecType<T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(floorPowerOfTwo, v);
}
///////////////////
// roundPowerOfTwo
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;
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)
{
return detail::functor1<T, T, P, vecType>::call(roundPowerOfTwo, v);
}
////////////////
// isMultiple
template <typename genType>
GLM_FUNC_QUALIFIER bool isMultiple(genType Value, genType Multiple)
{
return isMultiple(tvec1<genType>(Value), tvec1<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)
{
return (Value % Multiple) == vecType<T, P>(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)
{
return (Value % Multiple) == vecType<T, P>(0);
}
//////////////////////
// ceilMultiple
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)
{
return detail::functor2<T, P, vecType>::call(ceilMultiple, Source, Multiple);
}
//////////////////////
// floorMultiple
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)
{
return detail::functor2<T, P, vecType>::call(floorMultiple, Source, Multiple);
}
//////////////////////
// roundMultiple
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)
{
return detail::functor2<T, P, vecType>::call(roundMultiple, Source, Multiple);
}
}//namespace glm

View File

@@ -1,375 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 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.
///
/// 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.hpp
/// @date 2010-02-20 / 2011-06-05
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtc_swizzle GLM_GTC_swizzle
/// @ingroup gtc
///
/// @brief Provide functions to emulate GLSL swizzle operator fonctionalities.
///
/// <glm/gtc/swizzle.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_swizzle
#define GLM_GTC_swizzle GLM_VERSION
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
# pragma message("GLM: GLM_GTC_swizzle extension included")
#endif
namespace glm
{
/// @addtogroup gtc_swizzle
/// @{
template <typename T, template <typename> class vecType>
T const & swizzle(
vecType<T> const & v,
comp x);
template <typename T, template <typename> class vecType>
detail::tvec2<T> const & swizzle(
vecType<T> const & v,
comp x, comp y);
template <typename T, template <typename> class vecType>
detail::tvec3<T> const & swizzle(
vecType<T> const & v,
comp x, comp y, comp z);
template <typename T, template <typename> class vecType>
detail::tvec4<T> const & swizzle(
vecType<T> const & v,
comp x, comp y, comp z, comp w);
template <typename T, template <typename> class vecType>
T & swizzle(
vecType<T> & v,
comp x);
template <typename T, template <typename> class vecType>
detail::tref2<T> swizzle(
vecType<T> & v,
comp x, comp y);
template <typename T, template <typename> class vecType>
detail::tref3<T> swizzle(
vecType<T> & v,
comp x, comp y, comp z);
template <typename T, template <typename> class vecType>
detail::tref4<T> swizzle(
vecType<T> & v,
comp x, comp y, comp z, comp w);
# define static_swizzle1_const(TYPE, SIZE) \
template <comp x> \
GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE> const & v) \
{return v[x];}
# define static_swizzle1_ref(TYPE, SIZE) \
template <comp x> \
GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE> & v) \
{return v[x];}
static_swizzle1_ref(detail::float16, 2)
static_swizzle1_ref(detail::float16, 3)
static_swizzle1_ref(detail::float16, 4)
static_swizzle1_ref(detail::float32, 2)
static_swizzle1_ref(detail::float32, 3)
static_swizzle1_ref(detail::float32, 4)
static_swizzle1_ref(detail::float64, 2)
static_swizzle1_ref(detail::float64, 3)
static_swizzle1_ref(detail::float64, 4)
static_swizzle1_ref(detail::int8, 2)
static_swizzle1_ref(detail::int8, 3)
static_swizzle1_ref(detail::int8, 4)
static_swizzle1_ref(detail::int16, 2)
static_swizzle1_ref(detail::int16, 3)
static_swizzle1_ref(detail::int16, 4)
static_swizzle1_ref(detail::int32, 2)
static_swizzle1_ref(detail::int32, 3)
static_swizzle1_ref(detail::int32, 4)
static_swizzle1_ref(detail::int64, 2)
static_swizzle1_ref(detail::int64, 3)
static_swizzle1_ref(detail::int64, 4)
static_swizzle1_ref(detail::uint8, 2)
static_swizzle1_ref(detail::uint8, 3)
static_swizzle1_ref(detail::uint8, 4)
static_swizzle1_ref(detail::uint16, 2)
static_swizzle1_ref(detail::uint16, 3)
static_swizzle1_ref(detail::uint16, 4)
static_swizzle1_ref(detail::uint32, 2)
static_swizzle1_ref(detail::uint32, 3)
static_swizzle1_ref(detail::uint32, 4)
static_swizzle1_ref(detail::uint64, 2)
static_swizzle1_ref(detail::uint64, 3)
static_swizzle1_ref(detail::uint64, 4)
/*
# define static_swizzle2_const(TYPE) \
template <comp x, comp y> \
GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
{return TYPE(v[x], v[y]);}
# define static_swizzle3_const(TYPE) \
template <comp x, comp y, comp z> \
GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
{return TYPE(v[x], v[y], v[z]);}
# define static_swizzle4_const(TYPE) \
template <comp x, comp y, comp z, comp w> \
GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
{return TYPE(v[x], v[y], v[z], v[w]);}
*/
# define static_swizzle2_const(TYPE, SIZE) \
template <comp x, comp y> \
GLM_FUNC_QUALIFIER detail::tvec2<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
{return detail::tvec2<TYPE>(v[x], v[y]);}
# define static_swizzle3_const(TYPE, SIZE) \
template <comp x, comp y, comp z> \
GLM_FUNC_QUALIFIER detail::tvec3<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
{return detail::tvec3<TYPE>(v[x], v[y], v[z]);}
# define static_swizzle4_const(TYPE, SIZE) \
template <comp x, comp y, comp z, comp w> \
GLM_FUNC_QUALIFIER detail::tvec4<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
{return detail::tvec4<TYPE>(v[x], v[y], v[z], v[w]);}
static_swizzle2_const(glm::f16, 2)
static_swizzle2_const(glm::f16, 3)
static_swizzle2_const(glm::f16, 4)
static_swizzle2_const(glm::f32, 2)
static_swizzle2_const(glm::f32, 3)
static_swizzle2_const(glm::f32, 4)
static_swizzle2_const(glm::f64, 2)
static_swizzle2_const(glm::f64, 3)
static_swizzle2_const(glm::f64, 4)
static_swizzle2_const(glm::i8, 2)
static_swizzle2_const(glm::i8, 3)
static_swizzle2_const(glm::i8, 4)
static_swizzle2_const(glm::i16, 2)
static_swizzle2_const(glm::i16, 3)
static_swizzle2_const(glm::i16, 4)
static_swizzle2_const(glm::i32, 2)
static_swizzle2_const(glm::i32, 3)
static_swizzle2_const(glm::i32, 4)
static_swizzle2_const(glm::i64, 2)
static_swizzle2_const(glm::i64, 3)
static_swizzle2_const(glm::i64, 4)
static_swizzle2_const(glm::u8, 2)
static_swizzle2_const(glm::u8, 3)
static_swizzle2_const(glm::u8, 4)
static_swizzle2_const(glm::u16, 2)
static_swizzle2_const(glm::u16, 3)
static_swizzle2_const(glm::u16, 4)
static_swizzle2_const(glm::u32, 2)
static_swizzle2_const(glm::u32, 3)
static_swizzle2_const(glm::u32, 4)
static_swizzle2_const(glm::u64, 2)
static_swizzle2_const(glm::u64, 3)
static_swizzle2_const(glm::u64, 4)
static_swizzle3_const(glm::f16, 2)
static_swizzle3_const(glm::f16, 3)
static_swizzle3_const(glm::f16, 4)
static_swizzle3_const(glm::f32, 2)
static_swizzle3_const(glm::f32, 3)
static_swizzle3_const(glm::f32, 4)
static_swizzle3_const(glm::f64, 2)
static_swizzle3_const(glm::f64, 3)
static_swizzle3_const(glm::f64, 4)
static_swizzle3_const(glm::i8, 2)
static_swizzle3_const(glm::i8, 3)
static_swizzle3_const(glm::i8, 4)
static_swizzle3_const(glm::i16, 2)
static_swizzle3_const(glm::i16, 3)
static_swizzle3_const(glm::i16, 4)
static_swizzle3_const(glm::i32, 2)
static_swizzle3_const(glm::i32, 3)
static_swizzle3_const(glm::i32, 4)
static_swizzle3_const(glm::i64, 2)
static_swizzle3_const(glm::i64, 3)
static_swizzle3_const(glm::i64, 4)
static_swizzle3_const(glm::u8, 2)
static_swizzle3_const(glm::u8, 3)
static_swizzle3_const(glm::u8, 4)
static_swizzle3_const(glm::u16, 2)
static_swizzle3_const(glm::u16, 3)
static_swizzle3_const(glm::u16, 4)
static_swizzle3_const(glm::u32, 2)
static_swizzle3_const(glm::u32, 3)
static_swizzle3_const(glm::u32, 4)
static_swizzle3_const(glm::u64, 2)
static_swizzle3_const(glm::u64, 3)
static_swizzle3_const(glm::u64, 4)
static_swizzle4_const(glm::f16, 2)
static_swizzle4_const(glm::f16, 3)
static_swizzle4_const(glm::f16, 4)
static_swizzle4_const(glm::f32, 2)
static_swizzle4_const(glm::f32, 3)
static_swizzle4_const(glm::f32, 4)
static_swizzle4_const(glm::f64, 2)
static_swizzle4_const(glm::f64, 3)
static_swizzle4_const(glm::f64, 4)
static_swizzle4_const(glm::i8, 2)
static_swizzle4_const(glm::i8, 3)
static_swizzle4_const(glm::i8, 4)
static_swizzle4_const(glm::i16, 2)
static_swizzle4_const(glm::i16, 3)
static_swizzle4_const(glm::i16, 4)
static_swizzle4_const(glm::i32, 2)
static_swizzle4_const(glm::i32, 3)
static_swizzle4_const(glm::i32, 4)
static_swizzle4_const(glm::i64, 2)
static_swizzle4_const(glm::i64, 3)
static_swizzle4_const(glm::i64, 4)
static_swizzle4_const(glm::u8, 2)
static_swizzle4_const(glm::u8, 3)
static_swizzle4_const(glm::u8, 4)
static_swizzle4_const(glm::u16, 2)
static_swizzle4_const(glm::u16, 3)
static_swizzle4_const(glm::u16, 4)
static_swizzle4_const(glm::u32, 2)
static_swizzle4_const(glm::u32, 3)
static_swizzle4_const(glm::u32, 4)
static_swizzle4_const(glm::u64, 2)
static_swizzle4_const(glm::u64, 3)
static_swizzle4_const(glm::u64, 4)
# define static_swizzle2_ref(TYPE, SIZE) \
template <glm::comp x, glm::comp y> \
GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
{return glm::detail::tref2<TYPE>(v[x], v[y]);}
# define static_swizzle3_ref(TYPE, SIZE) \
template <glm::comp x, glm::comp y, glm::comp z> \
GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
{return glm::detail::tref3<TYPE>(v[x], v[y], v[z]);}
# define static_swizzle4_ref(TYPE, SIZE) \
template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
{return glm::detail::tref4<TYPE>(v[x], v[y], v[z], v[w]);}
static_swizzle2_ref(glm::f16, 2)
static_swizzle2_ref(glm::f16, 3)
static_swizzle2_ref(glm::f16, 4)
static_swizzle2_ref(glm::f32, 2)
static_swizzle2_ref(glm::f32, 3)
static_swizzle2_ref(glm::f32, 4)
static_swizzle2_ref(glm::f64, 2)
static_swizzle2_ref(glm::f64, 3)
static_swizzle2_ref(glm::f64, 4)
static_swizzle2_ref(glm::i8, 2)
static_swizzle2_ref(glm::i8, 3)
static_swizzle2_ref(glm::i8, 4)
static_swizzle2_ref(glm::i16, 2)
static_swizzle2_ref(glm::i16, 3)
static_swizzle2_ref(glm::i16, 4)
static_swizzle2_ref(glm::i32, 2)
static_swizzle2_ref(glm::i32, 3)
static_swizzle2_ref(glm::i32, 4)
static_swizzle2_ref(glm::i64, 2)
static_swizzle2_ref(glm::i64, 3)
static_swizzle2_ref(glm::i64, 4)
static_swizzle2_ref(glm::u8, 2)
static_swizzle2_ref(glm::u8, 3)
static_swizzle2_ref(glm::u8, 4)
static_swizzle2_ref(glm::u16, 2)
static_swizzle2_ref(glm::u16, 3)
static_swizzle2_ref(glm::u16, 4)
static_swizzle2_ref(glm::u32, 2)
static_swizzle2_ref(glm::u32, 3)
static_swizzle2_ref(glm::u32, 4)
static_swizzle2_ref(glm::u64, 2)
static_swizzle2_ref(glm::u64, 3)
static_swizzle2_ref(glm::u64, 4)
static_swizzle3_ref(glm::f16, 3)
static_swizzle3_ref(glm::f16, 4)
static_swizzle3_ref(glm::f32, 3)
static_swizzle3_ref(glm::f32, 4)
static_swizzle3_ref(glm::f64, 3)
static_swizzle3_ref(glm::f64, 4)
static_swizzle3_ref(glm::i8, 3)
static_swizzle3_ref(glm::i8, 4)
static_swizzle3_ref(glm::i16, 3)
static_swizzle3_ref(glm::i16, 4)
static_swizzle3_ref(glm::i32, 3)
static_swizzle3_ref(glm::i32, 4)
static_swizzle3_ref(glm::i64, 3)
static_swizzle3_ref(glm::i64, 4)
static_swizzle3_ref(glm::u8, 3)
static_swizzle3_ref(glm::u8, 4)
static_swizzle3_ref(glm::u16, 3)
static_swizzle3_ref(glm::u16, 4)
static_swizzle3_ref(glm::u32, 3)
static_swizzle3_ref(glm::u32, 4)
static_swizzle3_ref(glm::u64, 3)
static_swizzle3_ref(glm::u64, 4)
static_swizzle4_ref(glm::f16, 4)
static_swizzle4_ref(glm::f32, 4)
static_swizzle4_ref(glm::f64, 4)
static_swizzle4_ref(glm::i8, 4)
static_swizzle4_ref(glm::i16, 4)
static_swizzle4_ref(glm::i32, 4)
static_swizzle4_ref(glm::i64, 4)
static_swizzle4_ref(glm::u8, 4)
static_swizzle4_ref(glm::u16, 4)
static_swizzle4_ref(glm::u32, 4)
static_swizzle4_ref(glm::u64, 4)
/// @}
}//namespace glm
#include "swizzle.inl"
#endif//GLM_GTC_swizzle

View File

@@ -1,116 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 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.
///
/// 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 2011-01-15 / 2011-06-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER T swizzle
(
vecType<T> const & v,
comp x
)
{
assert(int(x) < int(vecType<T>::value_size));
return v[x];
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec2<T> swizzle
(
vecType<T> const & v,
comp x, comp y
)
{
return detail::tvec2<T>(
v[x],
v[y]);
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec3<T> swizzle
(
vecType<T> const & v,
comp x, comp y, comp z
)
{
return detail::tvec3<T>(
v[x],
v[y],
v[z]);
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec4<T> swizzle
(
vecType<T> const & v,
comp x, comp y, comp z, comp w
)
{
return detail::tvec4<T>(v[x], v[y], v[z], v[w]);
}
template <typename T>
GLM_FUNC_QUALIFIER T& swizzle
(
detail::tvec4<T> & v,
comp x
)
{
return v[x];
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref2<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y
)
{
return detail::tref2<T>(v[x], v[y]);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref3<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y, comp z
)
{
return detail::tref3<T>(v[x], v[y], v[z]);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref4<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y, comp z, comp w
)
{
return detail::tref4<T>(v[x], v[y], v[z], v[w]);
}
}//namespace glm

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -56,114 +60,119 @@
/// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_type_ptr
#define GLM_GTC_type_ptr GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../gtc/quaternion.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../mat2x2.hpp"
#include "../mat2x3.hpp"
#include "../mat2x4.hpp"
#include "../mat3x2.hpp"
#include "../mat3x3.hpp"
#include "../mat3x4.hpp"
#include "../mat4x2.hpp"
#include "../mat4x3.hpp"
#include "../mat4x4.hpp"
#include <cstring>
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_type_ptr extension included")
#endif
namespace glm
{
{
/// @addtogroup gtc_type_ptr
/// @{
/// Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
/// @see gtc_type_ptr
template<typename genType>
typename genType::value_type const * value_ptr(genType const & vec);
GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const & vec);
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tvec2<T> make_vec2(T const * const ptr);
GLM_FUNC_DECL tvec2<T, defaultp> make_vec2(T const * const ptr);
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tvec3<T> make_vec3(T const * const ptr);
GLM_FUNC_DECL tvec3<T, defaultp> make_vec3(T const * const ptr);
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tvec4<T> make_vec4(T const * const ptr);
GLM_FUNC_DECL tvec4<T, defaultp> make_vec4(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat2x2<T> make_mat2x2(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat2x3<T> make_mat2x3(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat2x4<T> make_mat2x4(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat3x2<T> make_mat3x2(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat3x3<T> make_mat3x3(T const * const ptr);
GLM_FUNC_DECL tmat2x2<T, defaultp> make_mat2x2(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat3x4<T> make_mat3x4(T const * const ptr);
GLM_FUNC_DECL tmat2x3<T, defaultp> make_mat2x3(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat4x2<T> make_mat4x2(
T const * const ptr);
GLM_FUNC_DECL tmat2x4<T, defaultp> make_mat2x4(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat4x3<T> make_mat4x3(T const * const ptr);
GLM_FUNC_DECL tmat3x2<T, defaultp> make_mat3x2(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat4x4<T> make_mat4x4(T const * const ptr);
GLM_FUNC_DECL tmat3x3<T, defaultp> make_mat3x3(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat2x2<T> make_mat2(T const * const ptr);
GLM_FUNC_DECL tmat3x4<T, defaultp> make_mat3x4(T const * const ptr);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat3x3<T> make_mat3(T const * const ptr);
GLM_FUNC_DECL tmat4x2<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);
/// 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);
/// 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);
/// Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tmat4x4<T> make_mat4(T const * const ptr);
GLM_FUNC_DECL tmat4x4<T, defaultp> make_mat4(T const * const ptr);
/// Build a quaternion from a pointer.
/// @see gtc_type_ptr
template<typename T>
detail::tquat<T> make_quat(T const * const ptr);
GLM_FUNC_DECL tquat<T, defaultp> make_quat(T const * const ptr);
/// @}
}//namespace glm
#include "type_ptr.inl"
#endif//GLM_GTC_type_ptr

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -26,437 +30,450 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <cstring>
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
)
{
return &(vec.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
)
{
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
(
tvec3<T, P> const & vec
)
{
return &(vec.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
)
{
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 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
)
{
return &(vec.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
)
{
return &(mat[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
(
tmat2x2<T, P> & mat
)
{
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 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
)
{
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 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
)
{
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
(
tmat2x3<T, P> const & mat
)
{
return &(mat[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
)
{
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 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
)
{
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 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
)
{
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 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
)
{
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 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
)
{
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 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)
{
return &(mat[0].x);
}
/// Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
/// @see gtc_type_ptr
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec2<T> const & vec
tquat<T, P> const & q
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec2<T> & vec
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec3<T> const & vec
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec3<T> & vec
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec4<T> const & vec
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension.
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec4<T> & vec
)
{
return &(vec.x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x2<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x3<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
//! From GLM_GTC_type_ptr extension.
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat4x4<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x3<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x2<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x4<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x2<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat4x2<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x4<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x4<T> & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x3<T> const & mat
)
{
return &(mat[0].x);
}
//! Return the constant address to the data of the input parameter.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tquat<T> const & q
)
{
return &(q[0]);
}
//! Get the address of the matrix content.
/// Return the address to the data of the quaternion input.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER T * value_ptr(detail::tmat4x3<T> & mat)
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
tquat<T, P> & q
)
{
return &(mat[0].x);
return &(q[0]);
}
//! Build a vector from a pointer.
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> make_vec2(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tvec2<T, defaultp> make_vec2(T const * const ptr)
{
detail::tvec2<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2<T>));
tvec2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tvec2<T, defaultp>));
return Result;
}
//! Build a vector from a pointer.
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> make_vec3(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tvec3<T, defaultp> make_vec3(T const * const ptr)
{
detail::tvec3<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3<T>));
tvec3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tvec3<T, defaultp>));
return Result;
}
//! Build a vector from a pointer.
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> make_vec4(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tvec4<T, defaultp> make_vec4(T const * const ptr)
{
detail::tvec4<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4<T>));
tvec4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tvec4<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)
{
tmat2x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat2x2<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)
{
tmat2x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat2x3<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)
{
tmat2x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat2x4<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)
{
tmat3x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat3x2<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> make_mat2x2(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
{
detail::tmat2x2<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2<T>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat2x3<T> make_mat2x3(T const * const ptr)
{
detail::tmat2x3<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3<T>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat2x4<T> make_mat2x4(T const * const ptr)
{
detail::tmat2x4<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4<T>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat3x2<T> make_mat3x2(T const * const ptr)
{
detail::tmat3x2<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2<T>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> make_mat3x3(T const * const ptr)
{
detail::tmat3x3<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3<T>));
tmat3x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat3x3<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat3x4<T> make_mat3x4(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat3x4<T, defaultp> make_mat3x4(T const * const ptr)
{
detail::tmat3x4<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4<T>));
tmat3x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat3x4<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat4x2<T> make_mat4x2(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x2<T, defaultp> make_mat4x2(T const * const ptr)
{
detail::tmat4x2<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2<T>));
tmat4x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat4x2<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat4x3<T> make_mat4x3(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x3<T, defaultp> make_mat4x3(T const * const ptr)
{
detail::tmat4x3<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3<T>));
tmat4x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat4x3<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> make_mat4x4(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4x4(T const * const ptr)
{
detail::tmat4x4<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4<T>));
tmat4x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tmat4x4<T, defaultp>));
return Result;
}
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> make_mat2(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat2x2<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 detail::tmat3x3<T> make_mat3(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat3x3<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 detail::tmat4x4<T> make_mat4(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<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 detail::tquat<T> make_quat(T const * const ptr)
template <typename T>
GLM_FUNC_QUALIFIER tquat<T, defaultp> make_quat(T const * const ptr)
{
detail::tquat<T> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tquat<T>));
tquat<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tquat<T, defaultp>));
return Result;
}
/// @}
}//namespace glm

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -36,13 +40,14 @@
/// <glm/gtc/ulp.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_ulp
#define GLM_GTC_ulp GLM_VERSION
#pragma once
// Dependency:
#include "../glm.hpp"
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../detail/type_int.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_ulp extension included")
#endif
@@ -53,38 +58,35 @@ namespace glm
/// Return the next ULP value(s) after the input value(s).
/// @see gtc_ulp
template <typename genType>
genType next_float(genType const & x);
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>
genType prev_float(genType const & x);
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>
genType next_float(genType const & x, uint const & Distance);
/// Return the value(s) ULP distance before the input value(s).
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>
genType prev_float(genType const & x, uint const & Distance);
/// Return the distance in the number of ULP between 2 scalars.
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>
uint float_distance(T const & x, T const & y);
/// Return the distance in the number of ULP between 2 vectors.
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>
vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y);
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"
#endif//GLM_GTC_ulp

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.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
@@ -12,6 +12,10 @@
/// 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
@@ -33,8 +37,10 @@
/// is preserved.
///////////////////////////////////////////////////////////////////////////////////
#include "../detail/type_int.hpp"
#include <cmath>
#include <cfloat>
#include <limits>
#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(push)
@@ -58,34 +64,34 @@ typedef union
} 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; \
#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; \
#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; \
#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; \
#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{
@@ -98,28 +104,28 @@ namespace detail
GLM_GET_FLOAT_WORD(hx, x);
GLM_GET_FLOAT_WORD(hy, y);
ix = hx&0x7fffffff; // |x|
iy = hy&0x7fffffff; // |y|
ix = hx&0x7fffffff; // |x|
iy = hy&0x7fffffff; // |y|
if((ix>0x7f800000) || // x is nan
(iy>0x7f800000)) // y is nan
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
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(t==x) return t; else return x; // raise underflow flag
}
if(hx>=0) { // x > 0
if(hx>hy) { // x > y, x -= ulp
if(hx>=0) { // x > 0
if(hx>hy) { // x > y, x -= ulp
hx -= 1;
} else { // x < y, x += ulp
} else { // x < y, x += ulp
hx += 1;
}
} else { // x < 0
if(hy>=0||hx>hy){ // x < y, x -= ulp
} else { // x < 0
if(hy>=0||hx>hy){ // x < y, x -= ulp
hx -= 1;
} else { // x > y, x += ulp
} else { // x > y, x += ulp
hx += 1;
}
}
@@ -192,50 +198,76 @@ namespace detail
# pragma warning(pop)
#endif
#if((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
# define GLM_NEXT_AFTER_FLT(x, toward) glm::detail::nextafterf((x), (toward))
# define GLM_NEXT_AFTER_DBL(x, toward) _nextafter((x), (toward))
#else
# define GLM_NEXT_AFTER_FLT(x, toward) nextafterf((x), (toward))
# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward))
#endif
namespace glm
{
template <>
GLM_FUNC_QUALIFIER float next_float(float const & x)
{
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max());
# 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)
{
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max());
# 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, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x)
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> Result;
for(std::size_t i = 0; i < Result.length(); ++i)
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)
{
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min());
# 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)
{
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::min());
# 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, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x)
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> Result;
for(std::size_t i = 0; i < Result.length(); ++i)
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;
}
@@ -244,16 +276,16 @@ namespace glm
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
{
T temp = x;
for(std::size_t i = 0; i < ulps; ++i)
for(uint i = 0; i < ulps; ++i)
temp = next_float(temp);
return temp;
}
template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x, vecType<uint> const & ulps)
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> Result;
for(std::size_t i = 0; i < Result.length(); ++i)
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;
}
@@ -262,16 +294,16 @@ namespace glm
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
{
T temp = x;
for(std::size_t i = 0; i < ulps; ++i)
for(uint i = 0; i < ulps; ++i)
temp = prev_float(temp);
return temp;
}
template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x, vecType<uint> const & ulps)
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> Result;
for(std::size_t i = 0; i < Result.length(); ++i)
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;
}
@@ -284,7 +316,7 @@ namespace glm
if(x < y)
{
T temp = x;
while(temp != y && ulp < std::numeric_limits<std::size_t>::max())
while(temp != y)// && ulp < std::numeric_limits<std::size_t>::max())
{
++ulp;
temp = next_float(temp);
@@ -293,7 +325,7 @@ namespace glm
else if(y < x)
{
T temp = y;
while(temp != x && ulp < std::numeric_limits<std::size_t>::max())
while(temp != x)// && ulp < std::numeric_limits<std::size_t>::max())
{
++ulp;
temp = next_float(temp);
@@ -307,11 +339,11 @@ namespace glm
return ulp;
}
template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y)
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> Result;
for(std::size_t i = 0; i < Result.length(); ++i)
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;
}

193
includes/glm/gtc/vec1.hpp Normal file
View File

@@ -0,0 +1,193 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../detail/type_vec1.hpp"
#if(defined(GLM_MESSAGES) && !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"

31
includes/glm/gtc/vec1.inl Normal file
View File

@@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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
///////////////////////////////////////////////////////////////////////////////////