Updated version of glm

This commit is contained in:
KimLS
2015-01-22 16:52:50 -08:00
parent a71690b725
commit 03286f540a
270 changed files with 17903 additions and 16363 deletions
+236
View File
@@ -0,0 +1,236 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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"
+542
View File
@@ -0,0 +1,542 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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(0xFFFF00000000FFFF);
REG2 = ((REG2 << 32) | REG2) & glm::uint64(0xFFFF00000000FFFF);
REG3 = ((REG3 << 32) | REG3) & glm::uint64(0xFFFF00000000FFFF);
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FF);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FF);
REG3 = ((REG3 << 16) | REG3) & glm::uint64(0x00FF0000FF0000FF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0xF00F00F00F00F00F);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0xF00F00F00F00F00F);
REG3 = ((REG3 << 8) | REG3) & glm::uint64(0xF00F00F00F00F00F);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3);
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249);
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249);
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(0xFFFF00000000FFFF);
REG2 = ((REG2 << 32) | REG2) & glm::uint64(0xFFFF00000000FFFF);
REG3 = ((REG3 << 32) | REG3) & glm::uint64(0xFFFF00000000FFFF);
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x00FF0000FF0000FF);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x00FF0000FF0000FF);
REG3 = ((REG3 << 16) | REG3) & glm::uint64(0x00FF0000FF0000FF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0xF00F00F00F00F00F);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0xF00F00F00F00F00F);
REG3 = ((REG3 << 8) | REG3) & glm::uint64(0xF00F00F00F00F00F);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x30C30C30C30C30C3);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x30C30C30C30C30C3);
REG3 = ((REG3 << 4) | REG3) & glm::uint64(0x30C30C30C30C30C3);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x9249249249249249);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x9249249249249249);
REG3 = ((REG3 << 2) | REG3) & glm::uint64(0x9249249249249249);
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(0x000000FF000000FF);
REG2 = ((REG2 << 24) | REG2) & glm::uint64(0x000000FF000000FF);
REG3 = ((REG3 << 24) | REG3) & glm::uint64(0x000000FF000000FF);
REG4 = ((REG4 << 24) | REG4) & glm::uint64(0x000000FF000000FF);
REG1 = ((REG1 << 12) | REG1) & glm::uint64(0x000F000F000F000F);
REG2 = ((REG2 << 12) | REG2) & glm::uint64(0x000F000F000F000F);
REG3 = ((REG3 << 12) | REG3) & glm::uint64(0x000F000F000F000F);
REG4 = ((REG4 << 12) | REG4) & glm::uint64(0x000F000F000F000F);
REG1 = ((REG1 << 6) | REG1) & glm::uint64(0x0303030303030303);
REG2 = ((REG2 << 6) | REG2) & glm::uint64(0x0303030303030303);
REG3 = ((REG3 << 6) | REG3) & glm::uint64(0x0303030303030303);
REG4 = ((REG4 << 6) | REG4) & glm::uint64(0x0303030303030303);
REG1 = ((REG1 << 3) | REG1) & glm::uint64(0x1111111111111111);
REG2 = ((REG2 << 3) | REG2) & glm::uint64(0x1111111111111111);
REG3 = ((REG3 << 3) | REG3) & glm::uint64(0x1111111111111111);
REG4 = ((REG4 << 3) | REG4) & glm::uint64(0x1111111111111111);
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
+25 -5
View File
@@ -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,8 +40,7 @@
/// <glm/gtc/constants.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_constants
#define GLM_GTC_constants
#pragma once
// Dependencies
#include "../detail/setup.hpp"
@@ -52,7 +55,6 @@ 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>
GLM_FUNC_DECL genType epsilon();
@@ -72,6 +74,11 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL genType pi();
/// Return pi * 2.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType two_pi();
/// Return square root of pi.
/// @see gtc_constants
template <typename genType>
@@ -82,6 +89,11 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL genType half_pi();
/// Return pi / 2 * 3.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType three_over_two_pi();
/// Return pi / 4.
/// @see gtc_constants
template <typename genType>
@@ -92,11 +104,21 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL genType one_over_pi();
/// Return 1 / (pi * 2).
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType one_over_two_pi();
/// Return 2 / pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType two_over_pi();
/// Return 4 / pi.
/// @see gtc_constants
template <typename genType>
GLM_FUNC_DECL genType four_over_pi();
/// Return 2 / sqrt(pi).
/// @see gtc_constants
template <typename genType>
@@ -181,5 +203,3 @@ namespace glm
} //namespace glm
#include "constants.inl"
#endif//GLM_GTC_constants
+31 -3
View File
@@ -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,9 +24,9 @@
/// 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
///////////////////////////////////////////////////////////////////////////////////
@@ -54,6 +58,12 @@ namespace glm
return genType(3.14159265358979323846264338327950288);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_pi()
{
return genType(6.28318530717958647692528676655900576);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType root_pi()
{
@@ -66,6 +76,12 @@ namespace glm
return genType(1.57079632679489661923132169163975144);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType three_over_two_pi()
{
return genType(4.71238898038468985769396507491925432);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType quarter_pi()
{
@@ -78,12 +94,24 @@ namespace glm
return genType(0.318309886183790671537767526745028724);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType one_over_two_pi()
{
return genType(0.159154943091895335768883763372514362);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_pi()
{
return genType(0.636619772367581343075535053490057448);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType four_over_pi()
{
return genType(1.273239544735162686151070106980114898);
}
template <typename genType>
GLM_FUNC_QUALIFIER genType two_over_root_pi()
{
+5 -4
View File
@@ -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,8 +41,7 @@
/// <glm/gtc/epsilon.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_epsilon
#define GLM_GTC_epsilon
#pragma once
// Dependencies
#include "../detail/setup.hpp"
@@ -97,5 +100,3 @@ namespace glm
}//namespace glm
#include "epsilon.inl"
#endif//GLM_GTC_epsilon
+14 -10
View File
@@ -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
@@ -125,26 +129,26 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonEqual
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & epsilon
)
{
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
return lessThan(abs(v), detail::tvec4<T, P>(epsilon));
tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
return lessThan(abs(v), tvec4<T, P>(epsilon));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonNotEqual
GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonNotEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & epsilon
)
{
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
return greaterThanEqual(abs(v), detail::tvec4<T, P>(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
+105
View File
@@ -0,0 +1,105 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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"
+74
View File
@@ -0,0 +1,74 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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
template <typename T, precision P, template <class, precision> class vecType, typename genType>
struct compute_mod<T, P, vecType, genType, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & a, genType const & b)
{
return a % b;
}
};
}//namespace detail
}//namespace glm
+10 -9
View File
@@ -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,8 +38,7 @@
/// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_access
#define GLM_GTC_matrix_access
#pragma once
// Dependency:
#include "../detail/setup.hpp"
@@ -53,15 +56,15 @@ namespace glm
/// @see gtc_matrix_access
template <typename genType>
GLM_FUNC_DECL typename genType::row_type row(
genType const & m,
length_t const & index);
genType const & m,
length_t index);
/// Set a specific row to a matrix.
/// @see gtc_matrix_access
template <typename genType>
GLM_FUNC_DECL genType row(
genType const & m,
length_t const & index,
length_t index,
typename genType::row_type const & x);
/// Get a specific column of a matrix.
@@ -69,19 +72,17 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL typename genType::col_type column(
genType const & m,
length_t const & index);
length_t 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 const & index,
length_t index,
typename genType::col_type const & x);
/// @}
}//namespace glm
#include "matrix_access.inl"
#endif//GLM_GTC_matrix_access
+14 -10
View File
@@ -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
@@ -32,14 +36,14 @@ namespace glm
GLM_FUNC_QUALIFIER genType row
(
genType const & m,
length_t const & index,
length_t index,
typename genType::row_type const & x
)
{
assert(index >= 0 && index < m[0].length());
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
genType Result = m;
for(length_t i = 0; i < m.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
Result[i][index] = x[i];
return Result;
}
@@ -48,13 +52,13 @@ namespace glm
GLM_FUNC_QUALIFIER typename genType::row_type row
(
genType const & m,
length_t const & index
length_t index
)
{
assert(index >= 0 && index < m[0].length());
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m[0]));
typename genType::row_type Result;
for(length_t i = 0; i < m.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
Result[i] = m[i][index];
return Result;
}
@@ -63,11 +67,11 @@ namespace glm
GLM_FUNC_QUALIFIER genType column
(
genType const & m,
length_t const & index,
length_t index,
typename genType::col_type const & x
)
{
assert(index >= 0 && index < m.length());
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
genType Result = m;
Result[index] = x;
@@ -78,10 +82,10 @@ namespace glm
GLM_FUNC_QUALIFIER typename genType::col_type column
(
genType const & m,
length_t const & index
length_t index
)
{
assert(index >= 0 && index < m.length());
assert(index >= 0 && static_cast<detail::component_count_t>(index) < detail::component_count(m));
return m[index];
}
+77 -76
View File
@@ -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,8 +38,7 @@
/// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_integer
#define GLM_GTC_matrix_integer
#pragma once
// Dependency:
#include "../mat2x2.hpp"
@@ -59,300 +62,300 @@ namespace glm
/// High-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, highp> highp_imat2;
typedef tmat2x2<int, highp> highp_imat2;
/// High-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, highp> highp_imat3;
typedef tmat3x3<int, highp> highp_imat3;
/// High-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, highp> highp_imat4;
typedef tmat4x4<int, highp> highp_imat4;
/// High-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, highp> highp_imat2x2;
typedef tmat2x2<int, highp> highp_imat2x2;
/// High-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<int, highp> highp_imat2x3;
typedef tmat2x3<int, highp> highp_imat2x3;
/// High-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<int, highp> highp_imat2x4;
typedef tmat2x4<int, highp> highp_imat2x4;
/// High-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<int, highp> highp_imat3x2;
typedef tmat3x2<int, highp> highp_imat3x2;
/// High-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, highp> highp_imat3x3;
typedef tmat3x3<int, highp> highp_imat3x3;
/// High-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<int, highp> highp_imat3x4;
typedef tmat3x4<int, highp> highp_imat3x4;
/// High-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<int, highp> highp_imat4x2;
typedef tmat4x2<int, highp> highp_imat4x2;
/// High-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<int, highp> highp_imat4x3;
typedef tmat4x3<int, highp> highp_imat4x3;
/// High-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, highp> highp_imat4x4;
typedef tmat4x4<int, highp> highp_imat4x4;
/// Medium-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, mediump> mediump_imat2;
typedef tmat2x2<int, mediump> mediump_imat2;
/// Medium-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, mediump> mediump_imat3;
typedef tmat3x3<int, mediump> mediump_imat3;
/// Medium-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, mediump> mediump_imat4;
typedef tmat4x4<int, mediump> mediump_imat4;
/// Medium-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, mediump> mediump_imat2x2;
typedef tmat2x2<int, mediump> mediump_imat2x2;
/// Medium-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<int, mediump> mediump_imat2x3;
typedef tmat2x3<int, mediump> mediump_imat2x3;
/// Medium-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<int, mediump> mediump_imat2x4;
typedef tmat2x4<int, mediump> mediump_imat2x4;
/// Medium-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<int, mediump> mediump_imat3x2;
typedef tmat3x2<int, mediump> mediump_imat3x2;
/// Medium-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, mediump> mediump_imat3x3;
typedef tmat3x3<int, mediump> mediump_imat3x3;
/// Medium-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<int, mediump> mediump_imat3x4;
typedef tmat3x4<int, mediump> mediump_imat3x4;
/// Medium-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<int, mediump> mediump_imat4x2;
typedef tmat4x2<int, mediump> mediump_imat4x2;
/// Medium-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<int, mediump> mediump_imat4x3;
typedef tmat4x3<int, mediump> mediump_imat4x3;
/// Medium-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, mediump> mediump_imat4x4;
typedef tmat4x4<int, mediump> mediump_imat4x4;
/// Low-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, lowp> lowp_imat2;
typedef tmat2x2<int, lowp> lowp_imat2;
/// Low-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, lowp> lowp_imat3;
typedef tmat3x3<int, lowp> lowp_imat3;
/// Low-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, lowp> lowp_imat4;
typedef tmat4x4<int, lowp> lowp_imat4;
/// Low-precision signed integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<int, lowp> lowp_imat2x2;
typedef tmat2x2<int, lowp> lowp_imat2x2;
/// Low-precision signed integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<int, lowp> lowp_imat2x3;
typedef tmat2x3<int, lowp> lowp_imat2x3;
/// Low-precision signed integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<int, lowp> lowp_imat2x4;
typedef tmat2x4<int, lowp> lowp_imat2x4;
/// Low-precision signed integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<int, lowp> lowp_imat3x2;
typedef tmat3x2<int, lowp> lowp_imat3x2;
/// Low-precision signed integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<int, lowp> lowp_imat3x3;
typedef tmat3x3<int, lowp> lowp_imat3x3;
/// Low-precision signed integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<int, lowp> lowp_imat3x4;
typedef tmat3x4<int, lowp> lowp_imat3x4;
/// Low-precision signed integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<int, lowp> lowp_imat4x2;
typedef tmat4x2<int, lowp> lowp_imat4x2;
/// Low-precision signed integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<int, lowp> lowp_imat4x3;
typedef tmat4x3<int, lowp> lowp_imat4x3;
/// Low-precision signed integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<int, lowp> lowp_imat4x4;
typedef tmat4x4<int, lowp> lowp_imat4x4;
/// High-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, highp> highp_umat2;
typedef tmat2x2<uint, highp> highp_umat2;
/// High-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, highp> highp_umat3;
typedef tmat3x3<uint, highp> highp_umat3;
/// High-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, highp> highp_umat4;
typedef tmat4x4<uint, highp> highp_umat4;
/// High-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, highp> highp_umat2x2;
typedef tmat2x2<uint, highp> highp_umat2x2;
/// High-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<uint, highp> highp_umat2x3;
typedef tmat2x3<uint, highp> highp_umat2x3;
/// High-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<uint, highp> highp_umat2x4;
typedef tmat2x4<uint, highp> highp_umat2x4;
/// High-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<uint, highp> highp_umat3x2;
typedef tmat3x2<uint, highp> highp_umat3x2;
/// High-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, highp> highp_umat3x3;
typedef tmat3x3<uint, highp> highp_umat3x3;
/// High-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<uint, highp> highp_umat3x4;
typedef tmat3x4<uint, highp> highp_umat3x4;
/// High-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<uint, highp> highp_umat4x2;
typedef tmat4x2<uint, highp> highp_umat4x2;
/// High-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<uint, highp> highp_umat4x3;
typedef tmat4x3<uint, highp> highp_umat4x3;
/// High-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, highp> highp_umat4x4;
typedef tmat4x4<uint, highp> highp_umat4x4;
/// Medium-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, mediump> mediump_umat2;
typedef tmat2x2<uint, mediump> mediump_umat2;
/// Medium-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, mediump> mediump_umat3;
typedef tmat3x3<uint, mediump> mediump_umat3;
/// Medium-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, mediump> mediump_umat4;
typedef tmat4x4<uint, mediump> mediump_umat4;
/// Medium-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, mediump> mediump_umat2x2;
typedef tmat2x2<uint, mediump> mediump_umat2x2;
/// Medium-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<uint, mediump> mediump_umat2x3;
typedef tmat2x3<uint, mediump> mediump_umat2x3;
/// Medium-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<uint, mediump> mediump_umat2x4;
typedef tmat2x4<uint, mediump> mediump_umat2x4;
/// Medium-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<uint, mediump> mediump_umat3x2;
typedef tmat3x2<uint, mediump> mediump_umat3x2;
/// Medium-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, mediump> mediump_umat3x3;
typedef tmat3x3<uint, mediump> mediump_umat3x3;
/// Medium-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<uint, mediump> mediump_umat3x4;
typedef tmat3x4<uint, mediump> mediump_umat3x4;
/// Medium-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<uint, mediump> mediump_umat4x2;
typedef tmat4x2<uint, mediump> mediump_umat4x2;
/// Medium-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<uint, mediump> mediump_umat4x3;
typedef tmat4x3<uint, mediump> mediump_umat4x3;
/// Medium-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, mediump> mediump_umat4x4;
typedef tmat4x4<uint, mediump> mediump_umat4x4;
/// Low-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, lowp> lowp_umat2;
typedef tmat2x2<uint, lowp> lowp_umat2;
/// Low-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, lowp> lowp_umat3;
typedef tmat3x3<uint, lowp> lowp_umat3;
/// Low-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, lowp> lowp_umat4;
typedef tmat4x4<uint, lowp> lowp_umat4;
/// Low-precision unsigned integer 2x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x2<uint, lowp> lowp_umat2x2;
typedef tmat2x2<uint, lowp> lowp_umat2x2;
/// Low-precision unsigned integer 2x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x3<uint, lowp> lowp_umat2x3;
typedef tmat2x3<uint, lowp> lowp_umat2x3;
/// Low-precision unsigned integer 2x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat2x4<uint, lowp> lowp_umat2x4;
typedef tmat2x4<uint, lowp> lowp_umat2x4;
/// Low-precision unsigned integer 3x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x2<uint, lowp> lowp_umat3x2;
typedef tmat3x2<uint, lowp> lowp_umat3x2;
/// Low-precision unsigned integer 3x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x3<uint, lowp> lowp_umat3x3;
typedef tmat3x3<uint, lowp> lowp_umat3x3;
/// Low-precision unsigned integer 3x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat3x4<uint, lowp> lowp_umat3x4;
typedef tmat3x4<uint, lowp> lowp_umat3x4;
/// Low-precision unsigned integer 4x2 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x2<uint, lowp> lowp_umat4x2;
typedef tmat4x2<uint, lowp> lowp_umat4x2;
/// Low-precision unsigned integer 4x3 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x3<uint, lowp> lowp_umat4x3;
typedef tmat4x3<uint, lowp> lowp_umat4x3;
/// Low-precision unsigned integer 4x4 matrix.
/// @see gtc_matrix_integer
typedef detail::tmat4x4<uint, lowp> lowp_umat4x4;
typedef tmat4x4<uint, lowp> lowp_umat4x4;
#if(defined(GLM_PRECISION_HIGHP_INT))
typedef highp_imat2 imat2;
@@ -510,5 +513,3 @@ namespace glm
/// @}
}//namespace glm
#endif//GLM_GTC_matrix_integer
+11 -7
View File
@@ -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,11 +38,14 @@
/// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_inverse
#define GLM_GTC_matrix_inverse
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../matrix.hpp"
#include "../mat2x2.hpp"
#include "../mat3x3.hpp"
#include "../mat4x4.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_inverse extension included")
@@ -62,13 +69,10 @@ namespace glm
/// @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_DECL 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
+18 -33
View File
@@ -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,49 +30,36 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "../mat2x2.hpp"
#include "../mat3x3.hpp"
#include "../mat4x4.hpp"
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> affineInverse
(
detail::tmat3x3<T, P> const & m
)
GLM_FUNC_QUALIFIER tmat3x3<T, P> affineInverse(tmat3x3<T, P> const & m)
{
detail::tmat3x3<T, P> Result(m);
Result[2] = detail::tvec3<T, P>(0, 0, 1);
tmat3x3<T, P> Result(m);
Result[2] = tvec3<T, P>(0, 0, 1);
Result = transpose(Result);
detail::tvec3<T, P> Translation = Result * detail::tvec3<T, P>(-detail::tvec2<T, P>(m[2]), m[2][2]);
tvec3<T, P> Translation = Result * tvec3<T, P>(-tvec2<T, P>(m[2]), m[2][2]);
Result[2] = Translation;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> affineInverse
(
detail::tmat4x4<T, P> const & m
)
GLM_FUNC_QUALIFIER tmat4x4<T, P> affineInverse(tmat4x4<T, P> const & m)
{
detail::tmat4x4<T, P> Result(m);
Result[3] = detail::tvec4<T, P>(0, 0, 0, 1);
tmat4x4<T, P> Result(m);
Result[3] = tvec4<T, P>(0, 0, 0, 1);
Result = transpose(Result);
detail::tvec4<T, P> Translation = Result * detail::tvec4<T, P>(-detail::tvec3<T, P>(m[3]), m[3][3]);
tvec4<T, P> Translation = Result * tvec4<T, P>(-tvec3<T, P>(m[3]), m[3][3]);
Result[3] = Translation;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat2x2<T, P> inverseTranspose
(
detail::tmat2x2<T, P> const & m
)
GLM_FUNC_QUALIFIER tmat2x2<T, P> inverseTranspose(tmat2x2<T, P> const & m)
{
T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
detail::tmat2x2<T, P> Inverse(
tmat2x2<T, P> Inverse(
+ m[1][1] / Determinant,
- m[0][1] / Determinant,
- m[1][0] / Determinant,
@@ -78,17 +69,14 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> inverseTranspose
(
detail::tmat3x3<T, P> const & m
)
GLM_FUNC_QUALIFIER tmat3x3<T, P> inverseTranspose(tmat3x3<T, P> const & m)
{
T Determinant =
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
detail::tmat3x3<T, P> 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]);
@@ -104,10 +92,7 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> inverseTranspose
(
detail::tmat4x4<T, P> const & m
)
GLM_FUNC_QUALIFIER tmat4x4<T, P> inverseTranspose(tmat4x4<T, P> const & m)
{
T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
@@ -129,7 +114,7 @@ namespace glm
T SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
T SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
detail::tmat4x4<T, P> 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);
+114 -104
View File
@@ -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,14 +47,14 @@
/// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_matrix_transform
#define GLM_GTC_matrix_transform
#pragma once
// Dependency:
// Dependencies
#include "../mat4x4.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/constants.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
@@ -77,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, P> const & m, T x, T y, T z)
/// @see - translate(detail::tvec3<T, P> 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 detail::tmat4x4<T, P> translate(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v);
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 angle Rotation angle expressed in radians.
/// @param axis Rotation axis, recommanded 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, P> const & m, T angle, T x, T y, T z)
/// @see - rotate(T angle, detail::tvec3<T, P> const & v)
/// @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 detail::tmat4x4<T, P> rotate(
detail::tmat4x4<T, P> const & m,
T const & angle,
detail::tvec3<T, P> const & axis);
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.
///
@@ -109,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, P> const & m, T x, T y, T z)
/// @see - scale(detail::tvec3<T, P> 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 detail::tmat4x4<T, P> scale(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v);
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.
///
@@ -130,13 +128,13 @@ namespace glm
/// @see gtc_matrix_transform
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top)
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> ortho(
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & zNear,
T const & zFar);
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.
///
@@ -148,11 +146,11 @@ namespace glm
/// @see gtc_matrix_transform
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar)
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> ortho(
T const & left,
T const & right,
T const & bottom,
T const & top);
GLM_FUNC_DECL tmat4x4<T, defaultp> ortho(
T left,
T right,
T bottom,
T top);
/// Creates a frustum matrix.
///
@@ -164,100 +162,114 @@ 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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> 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.
///
/// @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 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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> 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.
///
/// @param fov Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @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 T, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> perspectiveFov(
T const & fov,
T const & width,
T const & height,
T const & near,
T const & far);
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> perspectiveFov(
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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> 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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> 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, precision P>
GLM_FUNC_DECL detail::tvec3<T, P> project(
detail::tvec3<T, P> const & obj,
detail::tmat4x4<T, P> const & model,
detail::tmat4x4<T, P> const & proj,
detail::tvec4<U, P> const & viewport);
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, precision P>
GLM_FUNC_DECL detail::tvec3<T, P> unProject(
detail::tvec3<T, P> const & win,
detail::tmat4x4<T, P> const & model,
detail::tmat4x4<T, P> const & proj,
detail::tvec4<U, P> const & viewport);
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
///
@@ -268,10 +280,10 @@ namespace glm
/// @tparam U Currently supported: Floating-point types and integer types.
/// @see gtc_matrix_transform
template <typename T, precision P, typename U>
GLM_FUNC_DECL detail::tmat4x4<T, P> pickMatrix(
detail::tvec2<T, P> const & center,
detail::tvec2<T, P> const & delta,
detail::tvec4<U, P> const & viewport);
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.
///
@@ -281,14 +293,12 @@ namespace glm
/// @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 detail::tmat4x4<T, P> lookAt(
detail::tvec3<T, P> const & eye,
detail::tvec3<T, P> const & center,
detail::tvec3<T, P> const & up);
GLM_FUNC_DECL tmat4x4<T, P> lookAt(
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
+182 -197
View File
@@ -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,38 +37,33 @@
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> translate
GLM_FUNC_QUALIFIER tmat4x4<T, P> translate
(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v
tmat4x4<T, P> const & m,
tvec3<T, P> const & v
)
{
detail::tmat4x4<T, P> 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, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate
(
detail::tmat4x4<T, P> const & m,
T const & angle,
detail::tvec3<T, P> const & v
tmat4x4<T, P> const & m,
T angle,
tvec3<T, P> const & v
)
{
#ifdef GLM_FORCE_RADIANS
T a = angle;
#else
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
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, P> axis(normalize(v));
detail::tvec3<T, P> temp((T(1) - c) * axis);
tvec3<T, P> axis(normalize(v));
tvec3<T, P> temp((T(1) - c) * axis);
detail::tmat4x4<T, P> Rotate(detail::tmat4x4<T, P>::_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];
@@ -77,7 +76,7 @@ namespace glm
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
Rotate[2][2] = c + temp[2] * axis[2];
detail::tmat4x4<T, P> Result(detail::tmat4x4<T, P>::_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];
@@ -86,24 +85,19 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate_slow
GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate_slow
(
detail::tmat4x4<T, P> const & m,
T const & angle,
detail::tvec3<T, P> const & v
tmat4x4<T, P> const & m,
T angle,
tvec3<T, P> const & v
)
{
#ifdef GLM_FORCE_RADIANS
T const a = angle;
#else
# pragma message("GLM: rotate_slow function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const a = radians(angle);
#endif
T c = cos(a);
T s = sin(a);
detail::tmat4x4<T, P> Result;
T const c = cos(a);
T const s = sin(a);
tmat4x4<T, P> Result;
detail::tvec3<T, P> 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;
@@ -120,18 +114,18 @@ namespace glm
Result[2][2] = c + (1 - c) * axis.z * axis.z;
Result[2][3] = 0;
Result[3] = detail::tvec4<T, P>(0, 0, 0, 1);
Result[3] = tvec4<T, P>(0, 0, 0, 1);
return m * Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> scale
(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v
)
GLM_FUNC_QUALIFIER tmat4x4<T, P> scale
(
tmat4x4<T, P> const & m,
tvec3<T, P> const & v
)
{
detail::tmat4x4<T, P> Result(detail::tmat4x4<T, P>::_null);
tmat4x4<T, P> Result(uninitialize);
Result[0] = m[0] * v[0];
Result[1] = m[1] * v[1];
Result[2] = m[2] * v[2];
@@ -140,13 +134,13 @@ namespace glm
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> scale_slow
GLM_FUNC_QUALIFIER tmat4x4<T, P> scale_slow
(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v
tmat4x4<T, P> const & m,
tvec3<T, P> const & v
)
{
detail::tmat4x4<T, P> Result(T(1));
tmat4x4<T, P> Result(T(1));
Result[0][0] = v.x;
Result[1][1] = v.y;
Result[2][2] = v.z;
@@ -154,20 +148,20 @@ namespace glm
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> ortho
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
(
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & zNear,
T const & zFar
T left,
T right,
T bottom,
T top,
T zNear,
T zFar
)
{
detail::tmat4x4<T, defaultp> Result(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] = - T(2) / (zFar - zNear);
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);
@@ -175,127 +169,110 @@ namespace glm
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> ortho
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho
(
T const & left,
T const & right,
T const & bottom,
T const & top
T left,
T right,
T bottom,
T top
)
{
detail::tmat4x4<T, defaultp> Result(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] = - T(1);
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, defaultp> 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, defaultp> 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);
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspective
(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar
)
{
assert(aspect != valType(0));
assert(zFar != zNear);
#ifdef GLM_FORCE_RADIANS
valType const rad = fovy;
#else
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
valType const rad = glm::radians(fovy);
#endif
valType tanHalfFovy = tan(rad / valType(2));
detail::tmat4x4<valType, defaultp> Result(valType(0));
Result[0][0] = valType(1) / (aspect * tanHalfFovy);
Result[1][1] = valType(1) / (tanHalfFovy);
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspectiveFov
(
valType const & fov,
valType const & width,
valType const & height,
valType const & zNear,
valType const & zFar
)
{
assert(width > valType(0));
assert(height > valType(0));
assert(fov > valType(0));
#ifdef GLM_FORCE_RADIANS
valType rad = fov;
#else
# pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
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)?
detail::tmat4x4<valType, defaultp> 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);
Result[2][3] = static_cast<T>(-1);
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> infinitePerspective
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspective
(
T fovy,
T aspect,
T zNear,
T zFar
)
{
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
assert(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 tmat4x4<T, defaultp> perspectiveFov
(
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
# pragma message("GLM: infinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
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, defaultp> 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);
@@ -304,44 +281,52 @@ namespace glm
return Result;
}
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
(
T fovy,
T aspect,
T zNear,
T ep
)
{
T const range = tan(fovy / T(2)) * zNear;
T const left = -range * aspect;
T const right = range * aspect;
T const bottom = -range;
T const top = range;
tmat4x4<T, defaultp> Result(T(0));
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
Result[2][2] = ep - static_cast<T>(1);
Result[2][3] = static_cast<T>(-1);
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
(
T fovy,
T aspect,
T zNear
)
{
#ifdef GLM_FORCE_RADIANS
T range = tan(fovy / T(2)) * zNear;
#else
# pragma message("GLM: tweakedInfinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T range = tan(radians(fovy / T(2))) * zNear;
#endif
T left = -range * aspect;
T right = range * aspect;
T bottom = -range;
T top = range;
detail::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] = static_cast<T>(0.0001) - T(1);
Result[2][3] = static_cast<T>(-1);
Result[3][2] = - (T(0.0001) - T(2)) * zNear;
return Result;
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
GLM_FUNC_QUALIFIER tvec3<T, P> project
(
detail::tvec3<T, P> const & obj,
detail::tmat4x4<T, P> const & model,
detail::tmat4x4<T, P> const & proj,
detail::tvec4<U, P> const & viewport
tvec3<T, P> const & obj,
tmat4x4<T, P> const & model,
tmat4x4<T, P> const & proj,
tvec4<U, P> const & viewport
)
{
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(obj, T(1));
tvec4<T, P> tmp = tvec4<T, P>(obj, T(1));
tmp = model * tmp;
tmp = proj * tmp;
@@ -350,68 +335,68 @@ 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, P>(tmp);
return tvec3<T, P>(tmp);
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> unProject
GLM_FUNC_QUALIFIER tvec3<T, P> unProject
(
detail::tvec3<T, P> const & win,
detail::tmat4x4<T, P> const & model,
detail::tmat4x4<T, P> const & proj,
detail::tvec4<U, P> 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, P> Inverse = inverse(proj * model);
tmat4x4<T, P> Inverse = inverse(proj * model);
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(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, P> obj = Inverse * tmp;
tvec4<T, P> obj = Inverse * tmp;
obj /= obj.w;
return detail::tvec3<T, P>(obj);
return tvec3<T, P>(obj);
}
template <typename T, precision P, typename U>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> pickMatrix
GLM_FUNC_QUALIFIER tmat4x4<T, P> pickMatrix
(
detail::tvec2<T, P> const & center,
detail::tvec2<T, P> const & delta,
detail::tvec4<U, P> 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, P> Result(1.0f);
tmat4x4<T, P> Result(1.0f);
if(!(delta.x > T(0) && delta.y > T(0)))
return Result; // Error
detail::tvec3<T, P> 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, P>(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, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> lookAt
GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAt
(
detail::tvec3<T, P> const & eye,
detail::tvec3<T, P> const & center,
detail::tvec3<T, P> const & up
tvec3<T, P> const & eye,
tvec3<T, P> const & center,
tvec3<T, P> const & up
)
{
detail::tvec3<T, P> f(normalize(center - eye));
detail::tvec3<T, P> s(normalize(cross(f, up)));
detail::tvec3<T, P> u(cross(s, f));
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));
detail::tmat4x4<T, P> Result(1);
tmat4x4<T, P> Result(1);
Result[0][0] = s.x;
Result[1][0] = s.y;
Result[2][0] = s.z;
+12 -4
View File
@@ -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,12 +42,18 @@
/// <glm/gtc/noise.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_noise
#define GLM_GTC_noise
#pragma once
// 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_INCLUDED))
# pragma message("GLM: GLM_GTC_noise extension included")
@@ -77,5 +87,3 @@ namespace glm
}//namespace glm
#include "noise.inl"
#endif//GLM_GTC_noise
File diff suppressed because it is too large Load Diff
+24 -24
View File
@@ -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,8 +40,7 @@
/// <glm/gtc/packing.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_packing
#define GLM_GTC_packing
#pragma once
// Dependency:
#include "type_precision.hpp"
@@ -62,7 +65,7 @@ namespace glm
/// @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 const & v);
GLM_FUNC_DECL uint8 packUnorm1x8(float v);
/// Convert a single 8-bit integer to a normalized floating-point value.
///
@@ -74,7 +77,7 @@ namespace glm
/// @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 const & p);
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.
@@ -106,7 +109,7 @@ namespace glm
/// @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 const & p);
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.
@@ -119,7 +122,7 @@ namespace glm
/// @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 const & s);
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.
@@ -132,7 +135,7 @@ namespace glm
/// @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 const & p);
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.
@@ -164,7 +167,7 @@ namespace glm
/// @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 const & p);
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.
@@ -177,7 +180,7 @@ namespace glm
/// @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 const & v);
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.
@@ -190,7 +193,7 @@ namespace glm
/// @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 const & p);
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.
@@ -222,7 +225,7 @@ namespace glm
/// @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 const & p);
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.
@@ -235,7 +238,7 @@ namespace glm
/// @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 const & v);
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.
@@ -248,7 +251,7 @@ namespace glm
/// @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 const & p);
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.
@@ -291,7 +294,7 @@ namespace glm
/// @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 const & v);
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,
@@ -302,7 +305,7 @@ namespace glm
/// @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 const & v);
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,
@@ -328,7 +331,7 @@ namespace glm
/// @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 const & p);
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,
@@ -352,7 +355,7 @@ namespace glm
/// @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 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,
@@ -376,7 +379,7 @@ namespace glm
/// @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 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.
@@ -411,7 +414,7 @@ namespace glm
/// @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 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.
@@ -446,7 +449,7 @@ namespace glm
/// @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 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.
@@ -467,12 +470,9 @@ namespace glm
///
/// @see gtc_packing
/// @see uint32 packF2x11_1x10(vec3 const & v)
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 const & p);
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
/// @}
}// namespace glm
#include "packing.inl"
#endif//GLM_GTC_packing
+65 -32
View File
@@ -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,11 +35,12 @@
#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 const & f)
GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
@@ -53,7 +58,7 @@ namespace detail
((f >> 13) & 0x03ff); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 const & f)
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
@@ -71,7 +76,7 @@ namespace detail
((f >> 17) & 0x003f); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 const & p)
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 p)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
@@ -89,7 +94,7 @@ namespace detail
((p & 0x003f) << 17); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 const & f)
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 f)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
@@ -110,7 +115,7 @@ namespace detail
((f >> 18) & 0x001f); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 const & p)
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 p)
{
// 10 bits => EE EEEFFFFF
// 11 bits => EEE EEFFFFFF
@@ -131,7 +136,7 @@ namespace detail
((p & 0x001f) << 18); // Mantissa
}
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint const & h)
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint h)
{
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
}
@@ -145,7 +150,14 @@ namespace detail
else if(glm::isinf(x))
return 0x1f << 6;
return float2packed11(reinterpret_cast<uint&>(x));
# 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 float2packed11(Pack);
}
GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x)
@@ -157,8 +169,15 @@ namespace detail
else if(x == (0x1f << 6))
return ~0;//Inf
uint result = packed11ToFloat(x);
return reinterpret_cast<float&>(result);
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)
@@ -170,7 +189,14 @@ namespace detail
else if(glm::isinf(x))
return 0x1f << 5;
return float2packed10(reinterpret_cast<uint&>(x));
# 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)
@@ -182,8 +208,15 @@ namespace detail
else if(x == (0x1f << 5))
return ~0;//Inf
uint result = packed10ToFloat(x);
return reinterpret_cast<float&>(result);
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)
@@ -217,12 +250,12 @@ namespace detail
}//namespace detail
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float const & v)
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 const & p)
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p)
{
float Unpack(static_cast<float>(p));
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
@@ -235,20 +268,20 @@ namespace detail
return *Packed;
}
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 const & p)
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
{
u8vec2* Unpacked = reinterpret_cast<u8vec2*>(const_cast<uint16*>(&p));
return vec2(*Unpacked) * float(0.0039215686274509803921568627451); // 1 / 255
}
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float const & v)
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float v)
{
int8 Topack(static_cast<int8>(round(clamp(v ,-1.0f, 1.0f) * 127.0f)));
uint8* Packed = reinterpret_cast<uint8*>(&Topack);
return *Packed;
}
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 const & p)
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p)
{
float Unpack(static_cast<float>(*const_cast<uint8*>(&p)));
return clamp(
@@ -263,7 +296,7 @@ namespace detail
return *Packed;
}
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 const & p)
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
{
i8vec2* Unpack = reinterpret_cast<i8vec2*>(const_cast<uint16*>(&p));
return clamp(
@@ -271,12 +304,12 @@ namespace detail
-1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float const & s)
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 const & p)
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p)
{
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
@@ -289,20 +322,20 @@ namespace detail
return *Packed;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 const & p)
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
{
u16vec4* Unpack = reinterpret_cast<u16vec4*>(const_cast<uint64*>(&p));
return vec4(*Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
}
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float const & v)
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float v)
{
int16 Topack = static_cast<int16>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
return *Packed;
}
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 const & p)
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p)
{
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
return clamp(
@@ -317,7 +350,7 @@ namespace detail
return *Packed;
}
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 const & p)
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
{
i16vec4* Unpack(reinterpret_cast<i16vec4*>(const_cast<uint64*>(&p)));
return clamp(
@@ -325,14 +358,14 @@ namespace detail
-1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float const & v)
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v)
{
int16 Topack = detail::toFloat16(v);
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
return *Packed;
}
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 const & v)
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v)
{
int16* Unpack = reinterpret_cast<int16*>(const_cast<uint16*>(&v));
return detail::toFloat32(*Unpack);
@@ -350,7 +383,7 @@ namespace detail
return *Packed;
}
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 const & v)
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
{
i16vec4* p = reinterpret_cast<i16vec4*>(const_cast<uint64*>(&v));
i16vec4 Unpack(*p);
@@ -372,7 +405,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@@ -393,7 +426,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
{
detail::u10u10u10u2 Unpack;
Unpack.pack = v;
@@ -414,7 +447,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@@ -436,7 +469,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@@ -456,7 +489,7 @@ namespace detail
((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22);
}
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 const & v)
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 v)
{
return vec3(
detail::packed11bitToFloat(v >> 0),
+104 -140
View File
@@ -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,8 +41,7 @@
/// <glm/gtc/quaternion.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_quaternion
#define GLM_GTC_quaternion
#pragma once
// Dependency:
#include "../mat3x3.hpp"
@@ -51,58 +54,84 @@
# pragma message("GLM: GLM_GTC_quaternion extension included")
#endif
namespace glm{
namespace detail
namespace glm
{
/// @addtogroup gtc_quaternion
/// @{
template <typename T, precision P>
struct tquat
{
enum ctor{null};
typedef tvec4<bool, P> bool_type;
typedef tquat<T, P> type;
typedef T value_type;
public:
T x, y, z, w;
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
//////////////////////////////////////
// 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
// Constructors
GLM_FUNC_DECL tquat();
template <typename U, precision Q>
GLM_FUNC_DECL explicit tquat(
tquat<U, Q> const & q);
GLM_FUNC_DECL 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);
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);
//////////////////////////////////////
// Convertions
# ifdef GLM_FORCE_EXPLICIT_CTOR
template <typename U, precision Q>
GLM_FUNC_DECL explicit tquat(tquat<U, Q> const & q);
# else
template <typename U, precision Q>
GLM_FUNC_DECL tquat(tquat<U, Q> const & q);
# endif
// 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(
detail::tvec3<T, P> const & u,
detail::tvec3<T, P> const & v);
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);
// Accesses
GLM_FUNC_DECL T & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](length_t i) const;
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);
//////////////////////////////////////
// Operators
GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<T, P> const & q);
@@ -111,80 +140,52 @@ namespace detail
};
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> operator- (
detail::tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> operator+ (
detail::tquat<T, P> const & q,
detail::tquat<T, P> const & 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 detail::tquat<T, P> operator* (
detail::tquat<T, P> const & q,
detail::tquat<T, P> const & 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 detail::tvec3<T, P> operator* (
detail::tquat<T, P> const & q,
detail::tvec3<T, P> const & v);
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 detail::tvec3<T, P> operator* (
detail::tvec3<T, P> const & v,
detail::tquat<T, P> const & q);
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 detail::tvec4<T, P> operator* (
detail::tquat<T, P> const & q,
detail::tvec4<T, P> const & v);
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 detail::tvec4<T, P> operator* (
detail::tvec4<T, P> const & v,
detail::tquat<T, P> const & q);
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 detail::tquat<T, P> operator* (
detail::tquat<T, P> const & q,
T const & s);
GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P> const & q, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> operator* (
T const & s,
detail::tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> operator*(T const & s, tquat<T, P> const & q);
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> operator/ (
detail::tquat<T, P> const & q,
T const & s);
} //namespace detail
/// @addtogroup gtc_quaternion
/// @{
GLM_FUNC_DECL tquat<T, P> operator/(tquat<T, P> const & q, T const & s);
/// Returns the length of the quaternion.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL T length(
detail::tquat<T, P> const & q);
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 detail::tquat<T, P> normalize(
detail::tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> normalize(tquat<T, P> const & q);
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
///
/// @see gtc_quaternion
template <typename T, precision P, template <typename, precision> class quatType>
GLM_FUNC_DECL T dot(
quatType<T, P> const & x,
quatType<T, P> const & y);
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.
@@ -195,12 +196,9 @@ 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, P> const & x, detail::tquat<T, P> 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 detail::tquat<T, P> mix(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a);
GLM_FUNC_DECL tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T a);
/// Linear interpolation of two quaternions.
/// The interpolation is oriented.
@@ -211,10 +209,7 @@ namespace detail
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> lerp(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a);
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.
@@ -225,115 +220,99 @@ namespace detail
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> slerp(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a);
GLM_FUNC_DECL tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T a);
/// Returns the q conjugate.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> conjugate(
detail::tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> conjugate(tquat<T, P> const & q);
/// Returns the q inverse.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> inverse(
detail::tquat<T, P> const & q);
GLM_FUNC_DECL tquat<T, P> inverse(tquat<T, P> const & q);
/// Rotates a quaternion from a vector of 3 components axis and an angle.
///
/// @param q Source orientation
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
/// @param angle Angle expressed in radians.
/// @param axis Axis of the rotation
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> rotate(
detail::tquat<T, P> const & q,
T const & angle,
detail::tvec3<T, P> const & axis);
GLM_FUNC_DECL tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & axis);
/// Returns euler angles, yitch as x, yaw as y, roll as z.
/// The result is expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec3<T, P> eulerAngles(
detail::tquat<T, P> const & x);
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 defined or degrees otherwise.
/// Returns roll value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename T, precision P>
GLM_FUNC_DECL T roll(detail::tquat<T, P> const & x);
GLM_FUNC_DECL T roll(tquat<T, P> const & x);
/// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
/// Returns pitch value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename T, precision P>
GLM_FUNC_DECL T pitch(detail::tquat<T, P> const & x);
GLM_FUNC_DECL T pitch(tquat<T, P> const & x);
/// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
/// Returns yaw value of euler angles expressed in radians.
///
/// @see gtx_quaternion
template <typename T, precision P>
GLM_FUNC_DECL T yaw(detail::tquat<T, P> const & x);
GLM_FUNC_DECL T yaw(tquat<T, P> const & x);
/// Converts a quaternion to a 3 * 3 matrix.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tmat3x3<T, P> mat3_cast(
detail::tquat<T, P> const & x);
GLM_FUNC_DECL tmat3x3<T, P> mat3_cast(tquat<T, P> const & x);
/// Converts a quaternion to a 4 * 4 matrix.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> mat4_cast(
detail::tquat<T, P> const & x);
GLM_FUNC_DECL tmat4x4<T, P> mat4_cast(tquat<T, P> const & x);
/// Converts a 3 * 3 matrix to a quaternion.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
detail::tmat3x3<T, P> const & x);
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat3x3<T, P> const & x);
/// Converts a 4 * 4 matrix to a quaternion.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> quat_cast(
detail::tmat4x4<T, P> const & x);
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat4x4<T, P> const & x);
/// Returns the quaternion rotation angle.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL T angle(detail::tquat<T, P> const & x);
GLM_FUNC_DECL T angle(tquat<T, P> const & x);
/// Returns the q rotation axis.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec3<T, P> axis(
detail::tquat<T, P> const & x);
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 angle Angle expressed in radians.
/// @param axis Axis of the quaternion, must be normalized.
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tquat<T, P> angleAxis(
T const & angle,
detail::tvec3<T, P> const & axis);
GLM_FUNC_DECL tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & axis);
/// Returns the component-wise comparison result of x < y.
///
@@ -341,9 +320,7 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> lessThan(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
GLM_FUNC_DECL tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y);
/// Returns the component-wise comparison of result x <= y.
///
@@ -351,9 +328,7 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> lessThanEqual(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
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.
///
@@ -361,9 +336,7 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThan(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
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.
///
@@ -371,9 +344,7 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThanEqual(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
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.
///
@@ -381,9 +352,7 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> equal(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
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.
///
@@ -391,13 +360,8 @@ namespace detail
///
/// @see gtc_quaternion
template <typename T, precision P>
GLM_FUNC_DECL detail::tvec4<bool, P> notEqual(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y);
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
+208 -385
View File
@@ -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,59 +39,105 @@ namespace glm{
namespace detail
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tquat<T, P>::length() const
struct compute_dot<tquat, T, P>
{
return 4;
}
static GLM_FUNC_QUALIFIER T call(tquat<T, P> const & x, tquat<T, P> const & y)
{
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
}
};
}//namespace detail
//////////////////////////////////////
// Component accesses
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::size_type tquat<T, P>::size() const
{
return 4;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::size_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::size_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::length_type tquat<T, P>::length() const
{
return 4;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::length_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::length_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat() :
x(0),
y(0),
z(0),
w(1)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(1)
# endif
{}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
tquat<U, Q> const & q
) :
x(q.x),
y(q.y),
z(q.z),
w(q.w)
template <precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, Q> const & q)
: x(q.x), y(q.y), z(q.z), w(q.w)
{}
//////////////////////////////////////
// Explicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
T const & s,
tvec3<T, P> const & v
) :
x(v.x),
y(v.y),
z(v.z),
w(s)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & s, tvec3<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(s)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
T const & w,
T const & x,
T const & y,
T const & z
) :
x(x),
y(y),
z(z),
w(w)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & w, T const & x, T const & y, T const & z)
: x(x), y(y), z(z), w(w)
{}
//////////////////////////////////////////////////////////////
// tquat conversions
// Conversions
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<U, Q> const & q)
: x(static_cast<T>(q.x))
, y(static_cast<T>(q.y))
, z(static_cast<T>(q.z))
, w(static_cast<T>(q.w))
{}
//template <typename valType>
//GLM_FUNC_QUALIFIER tquat<valType>::tquat
@@ -108,24 +158,17 @@ namespace detail
//}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
detail::tvec3<T, P> const & u,
detail::tvec3<T, P> const & v
)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & u, tvec3<T, P> const & v)
{
detail::tvec3<T, P> w = cross(u, v);
T Dot = detail::compute_dot<detail::tvec3, T, P>::call(u, v);
detail::tquat<T, P> q(T(1) + Dot, w.x, w.y, w.z);
tvec3<T, P> const LocalW(cross(u, v));
T Dot = detail::compute_dot<tvec3, T, P>::call(u, v);
tquat<T, P> q(T(1) + Dot, LocalW.x, LocalW.y, LocalW.z);
*this = normalize(q);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
tvec3<T, P> const & eulerAngle
)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & eulerAngle)
{
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5));
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5));
@@ -137,69 +180,48 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
tmat3x3<T, P> const & m
)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<T, P> const & m)
{
*this = quat_cast(m);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(
tmat4x4<T, P> const & m
)
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<T, P> const & m)
{
*this = quat_cast(m);
}
//////////////////////////////////////////////////////////////
// tquat<T, P> accesses
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[] (length_t i)
# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat3x3<T, P>()
{
assert(i >= 0 && i < this->length());
return (&x)[i];
return mat3_cast(*this);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat4x4<T, P>()
{
return mat4_cast(*this);
}
# endif//GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q)
{
return tquat<T, P>(q.w, -q.x, -q.y, -q.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[] (length_t i) const
{
assert(i >= 0 && i < this->length());
return (&x)[i];
}
}//namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> conjugate
(
detail::tquat<T, P> const & q
)
{
return detail::tquat<T, P>(q.w, -q.x, -q.y, -q.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> inverse
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> inverse(tquat<T, P> const & q)
{
return conjugate(q) / dot(q, q);
}
namespace detail
{
//////////////////////////////////////////////////////////////
// tquat<valType> operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator +=
(
tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator+=(tquat<T, P> const & q)
{
this->w += q.w;
this->x += q.x;
@@ -209,10 +231,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
(
tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(tquat<T, P> const & q)
{
tquat<T, P> const p(*this);
@@ -224,10 +243,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
(
T const & s
)
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(T const & s)
{
this->w *= s;
this->x *= s;
@@ -237,10 +253,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator /=
(
T const & s
)
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator/=(T const & s)
{
this->w /= s;
this->x /= s;
@@ -249,130 +262,73 @@ namespace detail
return *this;
}
//////////////////////////////////////////////////////////////
// tquat<T, P> external functions
template <typename T, precision P>
struct compute_dot<tquat, T, P>
{
static T call(tquat<T, P> const & x, tquat<T, P> const & y)
{
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
}
};
//////////////////////////////////////////////////////////////
// tquat<T, P> external operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator-
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
{
return detail::tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator+
(
detail::tquat<T, P> const & q,
detail::tquat<T, P> const & p
)
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
{
return detail::tquat<T, P>(q) += p;
return tquat<T, P>(q) += p;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
(
detail::tquat<T, P> const & q,
detail::tquat<T, P> const & p
)
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p)
{
return detail::tquat<T, P>(q) *= p;
return tquat<T, P>(q) *= p;
}
// Transformation
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> operator*
(
detail::tquat<T, P> const & q,
detail::tvec3<T, P> const & v
)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v)
{
T Two(2);
tvec3<T, P> const QuatVector(q.x, q.y, q.z);
tvec3<T, P> const uv(glm::cross(QuatVector, v));
tvec3<T, P> const uuv(glm::cross(QuatVector, uv));
detail::tvec3<T, P> uv, uuv;
detail::tvec3<T, P> QuatVector(q.x, q.y, q.z);
uv = glm::cross(QuatVector, v);
uuv = glm::cross(QuatVector, uv);
uv *= (Two * q.w);
uuv *= Two;
return v + uv + uuv;
return v + ((uv * q.w) + uuv) * static_cast<T>(2);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> operator*
(
detail::tvec3<T, P> const & v,
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q)
{
return glm::inverse(q) * v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<T, P> operator*
(
detail::tquat<T, P> const & q,
detail::tvec4<T, P> const & v
)
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v)
{
return detail::tvec4<T, P>(q * detail::tvec3<T, P>(v), v.w);
return tvec4<T, P>(q * tvec3<T, P>(v), v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<T, P> operator*
(
detail::tvec4<T, P> const & v,
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q)
{
return glm::inverse(q) * v;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
(
detail::tquat<T, P> const & q,
T const & s
)
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, T const & s)
{
return detail::tquat<T, P>(
return tquat<T, P>(
q.w * s, q.x * s, q.y * s, q.z * s);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator*
(
T const & s,
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> operator*(T const & s, tquat<T, P> const & q)
{
return q * s;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator/
(
detail::tquat<T, P> const & q,
T const & s
)
GLM_FUNC_QUALIFIER tquat<T, P> operator/(tquat<T, P> const & q, T const & s)
{
return detail::tquat<T, P>(
return tquat<T, P>(
q.w / s, q.x / s, q.y / s, q.z / s);
}
@@ -380,58 +336,38 @@ namespace detail
// Boolean operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator==
(
detail::tquat<T, P> const & q1,
detail::tquat<T, P> const & q2
)
GLM_FUNC_QUALIFIER bool operator==(tquat<T, P> const & q1, tquat<T, P> const & q2)
{
return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool operator!=
(
detail::tquat<T, P> const & q1,
detail::tquat<T, P> const & q2
)
GLM_FUNC_QUALIFIER bool operator!=(tquat<T, P> const & q1, tquat<T, P> const & q2)
{
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w);
}
}//namespace detail
////////////////////////////////////////////////////////
template <typename T, precision P>
GLM_FUNC_QUALIFIER T length
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER T length(tquat<T, P> const & q)
{
return glm::sqrt(dot(q, q));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> normalize
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tquat<T, P> normalize(tquat<T, P> const & q)
{
T len = length(q);
if(len <= T(0)) // Problem
return detail::tquat<T, P>(1, 0, 0, 0);
return tquat<T, P>(1, 0, 0, 0);
T oneOverLen = T(1) / len;
return detail::tquat<T, P>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
return tquat<T, P>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> cross
(
detail::tquat<T, P> const & q1,
detail::tquat<T, P> const & q2
)
GLM_FUNC_QUALIFIER tquat<T, P> cross(tquat<T, P> const & q1, tquat<T, P> const & q2)
{
return detail::tquat<T, P>(
return tquat<T, P>(
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
@@ -440,18 +376,13 @@ namespace detail
/*
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle))
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a
)
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
{
if(a <= T(0)) return x;
if(a >= T(1)) return y;
float fCos = dot(x, y);
detail::tquat<T, P> y2(y); //BUG!!! tquat<T, P> y2;
tquat<T, P> y2(y); //BUG!!! tquat<T, P> y2;
if(fCos < T(0))
{
y2 = -y;
@@ -474,7 +405,7 @@ namespace detail
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
}
return detail::tquat<T, P>(
return tquat<T, P>(
k0 * x.w + k1 * y2.w,
k0 * x.x + k1 * y2.x,
k0 * x.y + k1 * y2.y,
@@ -482,10 +413,10 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix2
GLM_FUNC_QUALIFIER tquat<T, P> mix2
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & a
)
{
@@ -520,12 +451,7 @@ namespace detail
*/
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> mix
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a
)
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T a)
{
T cosTheta = dot(x, y);
@@ -533,7 +459,7 @@ namespace detail
if(cosTheta > T(1) - epsilon<T>())
{
// Linear interpolation
return detail::tquat<T, P>(
return tquat<T, P>(
mix(x.w, y.w, a),
mix(x.x, y.x, a),
mix(x.y, y.y, a),
@@ -548,12 +474,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> lerp
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a
)
GLM_FUNC_QUALIFIER tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T a)
{
// Lerp is only defined in [0, 1]
assert(a >= static_cast<T>(0));
@@ -563,14 +484,9 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> slerp
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
T const & a
)
GLM_FUNC_QUALIFIER tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T a)
{
detail::tquat<T, P> z = y;
tquat<T, P> z = y;
T cosTheta = dot(x, y);
@@ -586,11 +502,11 @@ namespace detail
if(cosTheta > T(1) - epsilon<T>())
{
// Linear interpolation
return detail::tquat<T, P>(
mix(x.w, y.w, a),
mix(x.x, y.x, a),
mix(x.y, y.y, a),
mix(x.z, y.z, a));
return tquat<T, P>(
mix(x.w, z.w, a),
mix(x.x, z.x, a),
mix(x.y, z.y, a),
mix(x.z, z.z, a));
}
else
{
@@ -601,14 +517,9 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotate
(
detail::tquat<T, P> const & q,
T const & angle,
detail::tvec3<T, P> const & v
)
GLM_FUNC_QUALIFIER tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & v)
{
detail::tvec3<T, P> Tmp = v;
tvec3<T, P> Tmp = v;
// Axis of rotation must be normalised
T len = glm::length(Tmp);
@@ -620,76 +531,41 @@ namespace detail
Tmp.z *= oneOverLen;
}
#ifdef GLM_FORCE_RADIANS
T const AngleRad(angle);
#else
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const AngleRad = radians(angle);
#endif
T const Sin = sin(AngleRad * T(0.5));
return q * detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
//return gtc::quaternion::cross(q, detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
return q * tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
//return gtc::quaternion::cross(q, tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> eulerAngles
(
detail::tquat<T, P> const & x
)
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles(tquat<T, P> const & x)
{
return detail::tvec3<T, P>(pitch(x), yaw(x), roll(x));
return tvec3<T, P>(pitch(x), yaw(x), roll(x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T roll
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER T roll(tquat<T, P> const & q)
{
#ifdef GLM_FORCE_RADIANS
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
#else
# pragma message("GLM: roll function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
#endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T pitch
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER T pitch(tquat<T, P> const & q)
{
#ifdef GLM_FORCE_RADIANS
return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
#else
# pragma message("GLM: pitch function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
#endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T yaw
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER T yaw(tquat<T, P> const & q)
{
#ifdef GLM_FORCE_RADIANS
return asin(T(-2) * (q.x * q.z - q.w * q.y));
#else
# pragma message("GLM: yaw function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(asin(T(-2) * (q.x * q.z - q.w * q.y)));
#endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> mat3_cast
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast(tquat<T, P> const & q)
{
detail::tmat3x3<T, P> Result(T(1));
tmat3x3<T, P> Result(T(1));
T qxx(q.x * q.x);
T qyy(q.y * q.y);
T qzz(q.z * q.z);
@@ -715,19 +591,13 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> mat4_cast
(
detail::tquat<T, P> const & q
)
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast(tquat<T, P> const & q)
{
return detail::tmat4x4<T, P>(mat3_cast(q));
return tmat4x4<T, P>(mat3_cast(q));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> quat_cast
(
detail::tmat3x3<T, P> const & m
)
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat3x3<T, P> const & m)
{
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2];
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
@@ -755,7 +625,7 @@ namespace detail
T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5);
T mult = static_cast<T>(0.25) / biggestVal;
detail::tquat<T, P> Result;
tquat<T, P> Result(uninitialize);
switch(biggestIndex)
{
case 0:
@@ -791,139 +661,92 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> quat_cast
(
detail::tmat4x4<T, P> const & m4
)
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat4x4<T, P> const & m4)
{
return quat_cast(detail::tmat3x3<T, P>(m4));
return quat_cast(tmat3x3<T, P>(m4));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T angle
(
detail::tquat<T, P> const & x
)
GLM_FUNC_QUALIFIER T angle(tquat<T, P> const & x)
{
#ifdef GLM_FORCE_RADIANS
return acos(x.w) * T(2);
#else
# pragma message("GLM: angle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(acos(x.w) * T(2));
#endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> axis
(
detail::tquat<T, P> const & x
)
GLM_FUNC_QUALIFIER tvec3<T, P> axis(tquat<T, P> const & x)
{
T tmp1 = static_cast<T>(1) - x.w * x.w;
if(tmp1 <= static_cast<T>(0))
return detail::tvec3<T, P>(0, 0, 1);
return tvec3<T, P>(0, 0, 1);
T tmp2 = static_cast<T>(1) / sqrt(tmp1);
return detail::tvec3<T, P>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
return tvec3<T, P>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tquat<T, P> angleAxis
(
T const & angle,
detail::tvec3<T, P> const & v
)
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & v)
{
detail::tquat<T, P> result;
tquat<T, P> Result(uninitialize);
#ifdef GLM_FORCE_RADIANS
T const a(angle);
#else
# pragma message("GLM: angleAxis function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const a(glm::radians(angle));
#endif
T s = glm::sin(a * T(0.5));
T const s = glm::sin(a * static_cast<T>(0.5));
result.w = glm::cos(a * T(0.5));
result.x = v.x * s;
result.y = v.y * s;
result.z = v.z * s;
return result;
Result.w = glm::cos(a * static_cast<T>(0.5));
Result.x = v.x * s;
Result.y = v.y * s;
Result.z = v.z * s;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThan
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] < y[i];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThanEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] <= y[i];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThan
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] > y[i];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThanEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] >= y[i];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> equal
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] == y[i];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> notEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y)
{
detail::tvec4<bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
tvec4<bool, P> Result(uninitialize);
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] != y[i];
return Result;
}
+24 -18
View File
@@ -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,8 +41,7 @@
/// <glm/gtc/random.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_random
#define GLM_GTC_random
#pragma once
// Dependency:
#include "../vec2.hpp"
@@ -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>
GLM_FUNC_DECL 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
///
@@ -71,44 +79,42 @@ namespace glm
/// @see gtc_random
template <typename genType>
GLM_FUNC_DECL genType gaussRand(
genType const & Mean,
genType const & Deviation);
genType Mean,
genType Deviation);
/// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius
///
/// @param Radius
/// @see gtc_random
template <typename T>
GLM_FUNC_DECL detail::tvec2<T, defaultp> circularRand(
T const & Radius);
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>
GLM_FUNC_DECL detail::tvec3<T, defaultp> sphericalRand(
T const & Radius);
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>
GLM_FUNC_DECL detail::tvec2<T, defaultp> diskRand(
T const & Radius);
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_DECL detail::tvec3<T, defaultp> ballRand(
T const & Radius);
GLM_FUNC_DECL tvec3<T, defaultp> ballRand(
T Radius);
/// @}
}//namespace glm
#include "random.inl"
#endif//GLM_GTC_random
+268 -60
View File
@@ -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,55 +39,267 @@
namespace glm{
namespace detail
{
struct compute_linearRand
template <typename T, precision P, template <class, precision> class vecType>
struct compute_rand
{
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();
};
template <>
GLM_FUNC_QUALIFIER float compute_linearRand::operator()<float> (float const & Min, float const & Max) const
template <precision P>
struct compute_rand<uint8, P, tvec1>
{
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
}
GLM_FUNC_QUALIFIER static tvec1<uint8, P> call()
{
return tvec1<uint8, P>(
std::rand()) % std::numeric_limits<uint8>::max();
}
};
template <>
GLM_FUNC_QUALIFIER double compute_linearRand::operator()<double> (double const & Min, double const & Max) const
template <precision P>
struct compute_rand<uint8, P, tvec2>
{
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
}
GLM_FUNC_QUALIFIER static tvec2<uint8, P> call()
{
return tvec2<uint8, P>(
std::rand(),
std::rand()) % std::numeric_limits<uint8>::max();
}
};
template <>
GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
template <precision P>
struct compute_rand<uint8, P, tvec3>
{
return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
}
GLM_FUNC_QUALIFIER static tvec3<uint8, P> call()
{
return tvec3<uint8, P>(
std::rand(),
std::rand(),
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::rand(),
std::rand(),
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
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & Min, vecType<T, P> const & Max);
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int8, P, vecType>
{
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 <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint8, P, vecType>
{
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>
{
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;
@@ -98,22 +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, defaultp> diskRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec2<T, defaultp> diskRand(T Radius)
{
detail::tvec2<T, defaultp> Result(T(0));
tvec2<T, defaultp> Result(T(0));
T LenRadius(T(0));
do
{
Result = linearRand(
detail::tvec2<T, defaultp>(-Radius),
detail::tvec2<T, defaultp>(Radius));
tvec2<T, defaultp>(-Radius),
tvec2<T, defaultp>(Radius));
LenRadius = length(Result);
}
while(LenRadius > Radius);
@@ -122,19 +339,16 @@ namespace detail
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> ballRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec3<T, defaultp> ballRand(T Radius)
{
detail::tvec3<T, defaultp> Result(T(0));
tvec3<T, defaultp> Result(T(0));
T LenRadius(T(0));
do
{
Result = linearRand(
detail::tvec3<T, defaultp>(-Radius),
detail::tvec3<T, defaultp>(Radius));
tvec3<T, defaultp>(-Radius),
tvec3<T, defaultp>(Radius));
LenRadius = length(Result);
}
while(LenRadius > Radius);
@@ -143,20 +357,14 @@ namespace detail
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T, defaultp> circularRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec2<T, defaultp> circularRand(T Radius)
{
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
return detail::tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
return tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> sphericalRand
(
T const & Radius
)
GLM_FUNC_QUALIFIER tvec3<T, defaultp> sphericalRand(T Radius)
{
T z = linearRand(T(-1), T(1));
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
@@ -166,6 +374,6 @@ namespace detail
T x = r * cos(a);
T y = r * sin(a);
return detail::tvec3<T, defaultp>(x, y, z) * Radius;
return tvec3<T, defaultp>(x, y, z) * Radius;
}
}//namespace glm
+5 -4
View File
@@ -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,8 +39,7 @@
/// <glm/gtc/reciprocal.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_reciprocal
#define GLM_GTC_reciprocal
#pragma once
// Dependencies
#include "../detail/setup.hpp"
@@ -129,5 +132,3 @@ namespace glm
}//namespace glm
#include "reciprocal.inl"
#endif//GLM_GTC_reciprocal
+92 -73
View File
@@ -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,80 +37,84 @@ namespace glm
{
// sec
template <typename genType>
GLM_FUNC_QUALIFIER genType sec
(
genType const & angle
)
GLM_FUNC_QUALIFIER genType sec(genType angle)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
return genType(1) / glm::cos(angle);
}
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(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(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
return genType(1) / glm::tan(angle);
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(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(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(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
@@ -114,89 +122,100 @@ namespace glm
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(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(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(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(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(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
return asinh(genType(1) / x);
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(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
View File
@@ -0,0 +1,203 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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"
+378
View File
@@ -0,0 +1,378 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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))
{
genType Tmp = Source - genType(1);
return Tmp + (Multiple - std::fmod(Tmp, 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
{
genType Tmp = Source + genType(1);
return Tmp - std::fmod(Tmp, 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
+102 -86
View File
@@ -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
@@ -40,11 +44,11 @@
/// <glm/gtc/type_precision.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_type_precision
#define GLM_GTC_type_precision
#pragma once
// Dependency:
#include "../gtc/quaternion.hpp"
#include "../gtc/vec1.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
@@ -231,6 +235,12 @@ namespace glm
/// @see gtc_type_precision
typedef detail::int64 int64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::int8_t;
using std::int16_t;
using std::int32_t;
using std::int64_t;
#else
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 int8_t;
@@ -246,6 +256,7 @@ namespace glm
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 int64_t;
#endif
/// 8 bit signed integer type.
/// @see gtc_type_precision
@@ -266,70 +277,70 @@ namespace glm
/// 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<i8, defaultp> i8vec1;
typedef tvec1<i8, defaultp> i8vec1;
/// 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<i8, defaultp> i8vec2;
typedef tvec2<i8, defaultp> i8vec2;
/// 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<i8, defaultp> i8vec3;
typedef tvec3<i8, defaultp> i8vec3;
/// 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<i8, defaultp> i8vec4;
typedef tvec4<i8, defaultp> i8vec4;
/// 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<i16, defaultp> i16vec1;
typedef tvec1<i16, defaultp> i16vec1;
/// 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<i16, defaultp> i16vec2;
typedef tvec2<i16, defaultp> i16vec2;
/// 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<i16, defaultp> i16vec3;
typedef tvec3<i16, defaultp> i16vec3;
/// 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<i16, defaultp> i16vec4;
typedef tvec4<i16, defaultp> i16vec4;
/// 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<i32, defaultp> i32vec1;
typedef tvec1<i32, defaultp> i32vec1;
/// 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<i32, defaultp> i32vec2;
typedef tvec2<i32, defaultp> i32vec2;
/// 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<i32, defaultp> i32vec3;
typedef tvec3<i32, defaultp> i32vec3;
/// 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<i32, defaultp> i32vec4;
typedef tvec4<i32, defaultp> i32vec4;
/// 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<i64, defaultp> i64vec1;
typedef tvec1<i64, defaultp> i64vec1;
/// 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<i64, defaultp> i64vec2;
typedef tvec2<i64, defaultp> i64vec2;
/// 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<i64, defaultp> i64vec3;
typedef tvec3<i64, defaultp> i64vec3;
/// 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<i64, defaultp> i64vec4;
typedef tvec4<i64, defaultp> i64vec4;
/////////////////////////////
@@ -495,6 +506,12 @@ namespace glm
/// @see gtc_type_precision
typedef detail::uint64 uint64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
#else
/// Default precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 uint8_t;
@@ -510,6 +527,7 @@ namespace glm
/// Default precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 uint64_t;
#endif
/// Default precision 8 bit unsigned integer type.
/// @see gtc_type_precision
@@ -531,70 +549,70 @@ namespace glm
/// Default precision 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<u8, defaultp> u8vec1;
typedef tvec1<u8, defaultp> u8vec1;
/// Default precision 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<u8, defaultp> u8vec2;
typedef tvec2<u8, defaultp> u8vec2;
/// Default precision 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<u8, defaultp> u8vec3;
typedef tvec3<u8, defaultp> u8vec3;
/// Default precision 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<u8, defaultp> u8vec4;
typedef tvec4<u8, defaultp> u8vec4;
/// Default precision 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<u16, defaultp> u16vec1;
typedef tvec1<u16, defaultp> u16vec1;
/// Default precision 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<u16, defaultp> u16vec2;
typedef tvec2<u16, defaultp> u16vec2;
/// Default precision 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<u16, defaultp> u16vec3;
typedef tvec3<u16, defaultp> u16vec3;
/// Default precision 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<u16, defaultp> u16vec4;
typedef tvec4<u16, defaultp> u16vec4;
/// Default precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<u32, defaultp> u32vec1;
typedef tvec1<u32, defaultp> u32vec1;
/// Default precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<u32, defaultp> u32vec2;
typedef tvec2<u32, defaultp> u32vec2;
/// Default precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<u32, defaultp> u32vec3;
typedef tvec3<u32, defaultp> u32vec3;
/// Default precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<u32, defaultp> u32vec4;
typedef tvec4<u32, defaultp> u32vec4;
/// Default precision 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef detail::tvec1<u64, defaultp> u64vec1;
typedef tvec1<u64, defaultp> u64vec1;
/// Default precision 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef detail::tvec2<u64, defaultp> u64vec2;
typedef tvec2<u64, defaultp> u64vec2;
/// Default precision 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef detail::tvec3<u64, defaultp> u64vec3;
typedef tvec3<u64, defaultp> u64vec3;
/// Default precision 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef detail::tvec4<u64, defaultp> u64vec4;
typedef tvec4<u64, defaultp> u64vec4;
//////////////////////
@@ -629,53 +647,53 @@ namespace glm
/// Single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef detail::tvec1<float, defaultp> fvec1;
typedef tvec1<float, defaultp> fvec1;
/// Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef detail::tvec2<float, defaultp> fvec2;
typedef tvec2<float, defaultp> fvec2;
/// Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef detail::tvec3<float, defaultp> fvec3;
typedef tvec3<float, defaultp> fvec3;
/// Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef detail::tvec4<float, defaultp> fvec4;
typedef tvec4<float, defaultp> fvec4;
/// Single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef detail::tvec1<f32, defaultp> f32vec1;
typedef tvec1<f32, defaultp> f32vec1;
/// Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef detail::tvec2<f32, defaultp> f32vec2;
typedef tvec2<f32, defaultp> f32vec2;
/// Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef detail::tvec3<f32, defaultp> f32vec3;
typedef tvec3<f32, defaultp> f32vec3;
/// Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef detail::tvec4<f32, defaultp> f32vec4;
typedef tvec4<f32, defaultp> f32vec4;
/// Double-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef detail::tvec1<f64, defaultp> f64vec1;
typedef tvec1<f64, defaultp> f64vec1;
/// Double-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef detail::tvec2<f64, defaultp> f64vec2;
typedef tvec2<f64, defaultp> f64vec2;
/// Double-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef detail::tvec3<f64, defaultp> f64vec3;
typedef tvec3<f64, defaultp> f64vec3;
/// Double-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef detail::tvec4<f64, defaultp> f64vec4;
typedef tvec4<f64, defaultp> f64vec4;
//////////////////////
@@ -687,15 +705,15 @@ namespace glm
/// Single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f32, defaultp> fmat2;
typedef tmat2x2<f32, defaultp> fmat2;
/// Single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f32, defaultp> fmat3;
typedef tmat3x3<f32, defaultp> fmat3;
/// Single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f32, defaultp> fmat4;
typedef tmat4x4<f32, defaultp> fmat4;
/// Single-precision floating-point 1x1 matrix.
@@ -704,39 +722,39 @@ namespace glm
/// Single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f32, defaultp> fmat2x2;
typedef tmat2x2<f32, defaultp> fmat2x2;
/// Single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x3<f32, defaultp> fmat2x3;
typedef tmat2x3<f32, defaultp> fmat2x3;
/// Single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x4<f32, defaultp> fmat2x4;
typedef tmat2x4<f32, defaultp> fmat2x4;
/// Single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x2<f32, defaultp> fmat3x2;
typedef tmat3x2<f32, defaultp> fmat3x2;
/// Single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f32, defaultp> fmat3x3;
typedef tmat3x3<f32, defaultp> fmat3x3;
/// Single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x4<f32, defaultp> fmat3x4;
typedef tmat3x4<f32, defaultp> fmat3x4;
/// Single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x2<f32, defaultp> fmat4x2;
typedef tmat4x2<f32, defaultp> fmat4x2;
/// Single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x3<f32, defaultp> fmat4x3;
typedef tmat4x3<f32, defaultp> fmat4x3;
/// Single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f32, defaultp> fmat4x4;
typedef tmat4x4<f32, defaultp> fmat4x4;
/// Single-precision floating-point 1x1 matrix.
@@ -745,15 +763,15 @@ namespace glm
/// Single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f32, defaultp> f32mat2;
typedef tmat2x2<f32, defaultp> f32mat2;
/// Single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f32, defaultp> f32mat3;
typedef tmat3x3<f32, defaultp> f32mat3;
/// Single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f32, defaultp> f32mat4;
typedef tmat4x4<f32, defaultp> f32mat4;
/// Single-precision floating-point 1x1 matrix.
@@ -762,39 +780,39 @@ namespace glm
/// Single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f32, defaultp> f32mat2x2;
typedef tmat2x2<f32, defaultp> f32mat2x2;
/// Single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x3<f32, defaultp> f32mat2x3;
typedef tmat2x3<f32, defaultp> f32mat2x3;
/// Single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x4<f32, defaultp> f32mat2x4;
typedef tmat2x4<f32, defaultp> f32mat2x4;
/// Single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x2<f32, defaultp> f32mat3x2;
typedef tmat3x2<f32, defaultp> f32mat3x2;
/// Single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f32, defaultp> f32mat3x3;
typedef tmat3x3<f32, defaultp> f32mat3x3;
/// Single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x4<f32, defaultp> f32mat3x4;
typedef tmat3x4<f32, defaultp> f32mat3x4;
/// Single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x2<f32, defaultp> f32mat4x2;
typedef tmat4x2<f32, defaultp> f32mat4x2;
/// Single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x3<f32, defaultp> f32mat4x3;
typedef tmat4x3<f32, defaultp> f32mat4x3;
/// Single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f32, defaultp> f32mat4x4;
typedef tmat4x4<f32, defaultp> f32mat4x4;
/// Double-precision floating-point 1x1 matrix.
@@ -803,15 +821,15 @@ namespace glm
/// Double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f64, defaultp> f64mat2;
typedef tmat2x2<f64, defaultp> f64mat2;
/// Double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f64, defaultp> f64mat3;
typedef tmat3x3<f64, defaultp> f64mat3;
/// Double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f64, defaultp> f64mat4;
typedef tmat4x4<f64, defaultp> f64mat4;
/// Double-precision floating-point 1x1 matrix.
@@ -820,39 +838,39 @@ namespace glm
/// Double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x2<f64, defaultp> f64mat2x2;
typedef tmat2x2<f64, defaultp> f64mat2x2;
/// Double-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x3<f64, defaultp> f64mat2x3;
typedef tmat2x3<f64, defaultp> f64mat2x3;
/// Double-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat2x4<f64, defaultp> f64mat2x4;
typedef tmat2x4<f64, defaultp> f64mat2x4;
/// Double-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x2<f64, defaultp> f64mat3x2;
typedef tmat3x2<f64, defaultp> f64mat3x2;
/// Double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x3<f64, defaultp> f64mat3x3;
typedef tmat3x3<f64, defaultp> f64mat3x3;
/// Double-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat3x4<f64, defaultp> f64mat3x4;
typedef tmat3x4<f64, defaultp> f64mat3x4;
/// Double-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x2<f64, defaultp> f64mat4x2;
typedef tmat4x2<f64, defaultp> f64mat4x2;
/// Double-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x3<f64, defaultp> f64mat4x3;
typedef tmat4x3<f64, defaultp> f64mat4x3;
/// Double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef detail::tmat4x4<f64, defaultp> f64mat4x4;
typedef tmat4x4<f64, defaultp> f64mat4x4;
//////////////////////////
@@ -860,15 +878,13 @@ namespace glm
/// Single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef detail::tquat<f32, defaultp> f32quat;
typedef tquat<f32, defaultp> f32quat;
/// Double-precision floating-point quaternion.
/// @see gtc_type_precision
typedef detail::tquat<f64, defaultp> f64quat;
typedef tquat<f64, defaultp> f64quat;
/// @}
}//namespace glm
#include "type_precision.inl"
#endif//GLM_GTC_type_precision
+4
View File
@@ -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
+21 -22
View File
@@ -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,8 +60,7 @@
/// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_type_ptr
#define GLM_GTC_type_ptr
#pragma once
// Dependency:
#include "../gtc/quaternion.hpp"
@@ -92,88 +95,84 @@ namespace glm
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template<typename T>
GLM_FUNC_DECL detail::tvec2<T, defaultp> 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>
GLM_FUNC_DECL detail::tvec3<T, defaultp> 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>
GLM_FUNC_DECL detail::tvec4<T, defaultp> 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>
GLM_FUNC_DECL detail::tmat2x2<T, defaultp> make_mat2x2(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>
GLM_FUNC_DECL detail::tmat2x3<T, defaultp> make_mat2x3(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>
GLM_FUNC_DECL detail::tmat2x4<T, defaultp> make_mat2x4(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>
GLM_FUNC_DECL detail::tmat3x2<T, defaultp> make_mat3x2(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>
GLM_FUNC_DECL detail::tmat3x3<T, defaultp> make_mat3x3(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>
GLM_FUNC_DECL detail::tmat3x4<T, defaultp> make_mat3x4(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>
GLM_FUNC_DECL detail::tmat4x2<T, defaultp> make_mat4x2(
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 detail::tmat4x3<T, defaultp> make_mat4x3(T const * const ptr);
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 detail::tmat4x4<T, defaultp> make_mat4x4(T const * const ptr);
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 detail::tmat2x2<T, defaultp> make_mat2(T const * const ptr);
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 detail::tmat3x3<T, defaultp> make_mat3(T const * const ptr);
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>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> 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>
GLM_FUNC_DECL detail::tquat<T, defaultp> 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
+72 -68
View File
@@ -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,7 +42,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec2<T, P> const & vec
tvec2<T, P> const & vec
)
{
return &(vec.x);
@@ -49,7 +53,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec2<T, P> & vec
tvec2<T, P> & vec
)
{
return &(vec.x);
@@ -60,7 +64,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec3<T, P> const & vec
tvec3<T, P> const & vec
)
{
return &(vec.x);
@@ -71,7 +75,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec3<T, P> & vec
tvec3<T, P> & vec
)
{
return &(vec.x);
@@ -82,7 +86,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tvec4<T, P> const & vec
tvec4<T, P> const & vec
)
{
return &(vec.x);
@@ -93,7 +97,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tvec4<T, P> & vec
tvec4<T, P> & vec
)
{
return &(vec.x);
@@ -104,7 +108,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x2<T, P> const & mat
tmat2x2<T, P> const & mat
)
{
return &(mat[0].x);
@@ -115,7 +119,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x2<T, P> & mat
tmat2x2<T, P> & mat
)
{
return &(mat[0].x);
@@ -126,7 +130,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x3<T, P> const & mat
tmat3x3<T, P> const & mat
)
{
return &(mat[0].x);
@@ -137,7 +141,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x3<T, P> & mat
tmat3x3<T, P> & mat
)
{
return &(mat[0].x);
@@ -148,7 +152,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x4<T, P> const & mat
tmat4x4<T, P> const & mat
)
{
return &(mat[0].x);
@@ -159,7 +163,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat4x4<T, P> & mat
tmat4x4<T, P> & mat
)
{
return &(mat[0].x);
@@ -170,7 +174,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x3<T, P> const & mat
tmat2x3<T, P> const & mat
)
{
return &(mat[0].x);
@@ -181,7 +185,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x3<T, P> & mat
tmat2x3<T, P> & mat
)
{
return &(mat[0].x);
@@ -192,7 +196,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x2<T, P> const & mat
tmat3x2<T, P> const & mat
)
{
return &(mat[0].x);
@@ -203,7 +207,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x2<T, P> & mat
tmat3x2<T, P> & mat
)
{
return &(mat[0].x);
@@ -214,7 +218,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat2x4<T, P> const & mat
tmat2x4<T, P> const & mat
)
{
return &(mat[0].x);
@@ -225,7 +229,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat2x4<T, P> & mat
tmat2x4<T, P> & mat
)
{
return &(mat[0].x);
@@ -236,7 +240,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x2<T, P> const & mat
tmat4x2<T, P> const & mat
)
{
return &(mat[0].x);
@@ -247,7 +251,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat4x2<T, P> & mat
tmat4x2<T, P> & mat
)
{
return &(mat[0].x);
@@ -258,7 +262,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat3x4<T, P> const & mat
tmat3x4<T, P> const & mat
)
{
return &(mat[0].x);
@@ -269,7 +273,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tmat3x4<T, P> & mat
tmat3x4<T, P> & mat
)
{
return &(mat[0].x);
@@ -280,7 +284,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tmat4x3<T, P> const & mat
tmat4x3<T, P> const & mat
)
{
return &(mat[0].x);
@@ -289,7 +293,7 @@ namespace glm
/// 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(detail::tmat4x3<T, P> & mat)
GLM_FUNC_QUALIFIER T * value_ptr(tmat4x3<T, P> & mat)
{
return &(mat[0].x);
}
@@ -299,7 +303,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T const * value_ptr
(
detail::tquat<T, P> const & q
tquat<T, P> const & q
)
{
return &(q[0]);
@@ -310,7 +314,7 @@ namespace glm
template<typename T, precision P>
GLM_FUNC_QUALIFIER T * value_ptr
(
detail::tquat<T, P> & q
tquat<T, P> & q
)
{
return &(q[0]);
@@ -319,127 +323,127 @@ namespace glm
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T, defaultp> make_vec2(T const * const ptr)
GLM_FUNC_QUALIFIER tvec2<T, defaultp> make_vec2(T const * const ptr)
{
detail::tvec2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2<T, defaultp>));
tvec2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tvec2<T, defaultp>));
return Result;
}
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T, defaultp> make_vec3(T const * const ptr)
GLM_FUNC_QUALIFIER tvec3<T, defaultp> make_vec3(T const * const ptr)
{
detail::tvec3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3<T, defaultp>));
tvec3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tvec3<T, defaultp>));
return Result;
}
/// Build a vector from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T, defaultp> make_vec4(T const * const ptr)
GLM_FUNC_QUALIFIER tvec4<T, defaultp> make_vec4(T const * const ptr)
{
detail::tvec4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4<T, defaultp>));
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 detail::tmat2x2<T, defaultp> make_mat2x2(T const * const ptr)
GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2x2(T const * const ptr)
{
detail::tmat2x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2<T, defaultp>));
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 detail::tmat2x3<T, defaultp> make_mat2x3(T const * const ptr)
GLM_FUNC_QUALIFIER tmat2x3<T, defaultp> make_mat2x3(T const * const ptr)
{
detail::tmat2x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3<T, defaultp>));
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 detail::tmat2x4<T, defaultp> make_mat2x4(T const * const ptr)
GLM_FUNC_QUALIFIER tmat2x4<T, defaultp> make_mat2x4(T const * const ptr)
{
detail::tmat2x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4<T, defaultp>));
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 detail::tmat3x2<T, defaultp> make_mat3x2(T const * const ptr)
GLM_FUNC_QUALIFIER tmat3x2<T, defaultp> make_mat3x2(T const * const ptr)
{
detail::tmat3x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2<T, defaultp>));
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::tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
{
detail::tmat3x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3<T, defaultp>));
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, defaultp> make_mat3x4(T const * const ptr)
GLM_FUNC_QUALIFIER tmat3x4<T, defaultp> make_mat3x4(T const * const ptr)
{
detail::tmat3x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4<T, defaultp>));
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, defaultp> make_mat4x2(T const * const ptr)
GLM_FUNC_QUALIFIER tmat4x2<T, defaultp> make_mat4x2(T const * const ptr)
{
detail::tmat4x2<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2<T, defaultp>));
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, defaultp> make_mat4x3(T const * const ptr)
GLM_FUNC_QUALIFIER tmat4x3<T, defaultp> make_mat4x3(T const * const ptr)
{
detail::tmat4x3<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3<T, defaultp>));
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, defaultp> make_mat4x4(T const * const ptr)
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4x4(T const * const ptr)
{
detail::tmat4x4<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4<T, defaultp>));
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, defaultp> make_mat2(T const * const ptr)
GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2(T const * const ptr)
{
return make_mat2x2(ptr);
}
@@ -447,7 +451,7 @@ namespace glm
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T, defaultp> make_mat3(T const * const ptr)
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3(T const * const ptr)
{
return make_mat3x3(ptr);
}
@@ -455,7 +459,7 @@ namespace glm
//! Build a matrix from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> make_mat4(T const * const ptr)
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4(T const * const ptr)
{
return make_mat4x4(ptr);
}
@@ -463,10 +467,10 @@ namespace glm
//! Build a quaternion from a pointer.
/// @see gtc_type_ptr
template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T, defaultp> make_quat(T const * const ptr)
GLM_FUNC_QUALIFIER tquat<T, defaultp> make_quat(T const * const ptr)
{
detail::tquat<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(detail::tquat<T, defaultp>));
tquat<T, defaultp> Result;
memcpy(value_ptr(Result), ptr, sizeof(tquat<T, defaultp>));
return Result;
}
+5 -5
View File
@@ -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,8 +40,7 @@
/// <glm/gtc/ulp.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_ulp
#define GLM_GTC_ulp
#pragma once
// Dependencies
#include "../detail/setup.hpp"
@@ -87,6 +90,3 @@ namespace glm
}// namespace glm
#include "ulp.inl"
#endif//GLM_GTC_ulp
+26 -14
View File
@@ -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
@@ -199,10 +203,12 @@ namespace glm
template <>
GLM_FUNC_QUALIFIER float next_float(float const & x)
{
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
# 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
@@ -211,10 +217,12 @@ namespace glm
template <>
GLM_FUNC_QUALIFIER double next_float(double const & x)
{
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
# 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
@@ -223,18 +231,20 @@ namespace glm
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x)
{
vecType<T, P> Result;
for(length_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)
{
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
# 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
@@ -242,10 +252,12 @@ namespace glm
GLM_FUNC_QUALIFIER double prev_float(double const & x)
{
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
# 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
@@ -254,8 +266,8 @@ namespace glm
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x)
{
vecType<T, P> Result;
for(length_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;
}
@@ -272,8 +284,8 @@ namespace glm
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
{
vecType<T, P> Result;
for(length_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;
}
@@ -290,8 +302,8 @@ namespace glm
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
{
vecType<T, P> Result;
for(length_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;
}
@@ -330,8 +342,8 @@ namespace glm
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint, P> float_distance(vecType<T, P> const & x, vecType<T, P> const & y)
{
vecType<uint, P> Result;
for(length_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
View File
@@ -0,0 +1,193 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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
View File
@@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2014 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
///////////////////////////////////////////////////////////////////////////////////