From c068f22329d5cc722622a2183bbb22eef2093df7 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 24 Aug 2026 11:16:07 +0200 Subject: initial import --- src/libraries/glm/gtc/constants.hpp | 186 +++++ src/libraries/glm/gtc/constants.inl | 186 +++++ src/libraries/glm/gtc/epsilon.hpp | 94 +++ src/libraries/glm/gtc/epsilon.inl | 286 ++++++++ src/libraries/glm/gtc/half_float.hpp | 440 ++++++++++++ src/libraries/glm/gtc/half_float.inl | 1039 ++++++++++++++++++++++++++++ src/libraries/glm/gtc/matrix_access.hpp | 87 +++ src/libraries/glm/gtc/matrix_access.inl | 80 +++ src/libraries/glm/gtc/matrix_integer.hpp | 506 ++++++++++++++ src/libraries/glm/gtc/matrix_inverse.hpp | 74 ++ src/libraries/glm/gtc/matrix_inverse.inl | 159 +++++ src/libraries/glm/gtc/matrix_transform.hpp | 291 ++++++++ src/libraries/glm/gtc/matrix_transform.inl | 430 ++++++++++++ src/libraries/glm/gtc/noise.hpp | 80 +++ src/libraries/glm/gtc/noise.inl | 867 +++++++++++++++++++++++ src/libraries/glm/gtc/quaternion.hpp | 381 ++++++++++ src/libraries/glm/gtc/quaternion.inl | 788 +++++++++++++++++++++ src/libraries/glm/gtc/random.hpp | 114 +++ src/libraries/glm/gtc/random.inl | 170 +++++ src/libraries/glm/gtc/reciprocal.hpp | 133 ++++ src/libraries/glm/gtc/reciprocal.inl | 199 ++++++ src/libraries/glm/gtc/swizzle.hpp | 375 ++++++++++ src/libraries/glm/gtc/swizzle.inl | 116 ++++ src/libraries/glm/gtc/type_precision.hpp | 669 ++++++++++++++++++ src/libraries/glm/gtc/type_precision.inl | 32 + src/libraries/glm/gtc/type_ptr.hpp | 169 +++++ src/libraries/glm/gtc/type_ptr.inl | 462 +++++++++++++ src/libraries/glm/gtc/ulp.hpp | 90 +++ src/libraries/glm/gtc/ulp.inl | 314 +++++++++ 29 files changed, 8817 insertions(+) create mode 100755 src/libraries/glm/gtc/constants.hpp create mode 100755 src/libraries/glm/gtc/constants.inl create mode 100755 src/libraries/glm/gtc/epsilon.hpp create mode 100755 src/libraries/glm/gtc/epsilon.inl create mode 100755 src/libraries/glm/gtc/half_float.hpp create mode 100755 src/libraries/glm/gtc/half_float.inl create mode 100755 src/libraries/glm/gtc/matrix_access.hpp create mode 100755 src/libraries/glm/gtc/matrix_access.inl create mode 100755 src/libraries/glm/gtc/matrix_integer.hpp create mode 100755 src/libraries/glm/gtc/matrix_inverse.hpp create mode 100755 src/libraries/glm/gtc/matrix_inverse.inl create mode 100755 src/libraries/glm/gtc/matrix_transform.hpp create mode 100755 src/libraries/glm/gtc/matrix_transform.inl create mode 100755 src/libraries/glm/gtc/noise.hpp create mode 100755 src/libraries/glm/gtc/noise.inl create mode 100755 src/libraries/glm/gtc/quaternion.hpp create mode 100755 src/libraries/glm/gtc/quaternion.inl create mode 100755 src/libraries/glm/gtc/random.hpp create mode 100755 src/libraries/glm/gtc/random.inl create mode 100755 src/libraries/glm/gtc/reciprocal.hpp create mode 100755 src/libraries/glm/gtc/reciprocal.inl create mode 100755 src/libraries/glm/gtc/swizzle.hpp create mode 100755 src/libraries/glm/gtc/swizzle.inl create mode 100755 src/libraries/glm/gtc/type_precision.hpp create mode 100755 src/libraries/glm/gtc/type_precision.inl create mode 100755 src/libraries/glm/gtc/type_ptr.hpp create mode 100755 src/libraries/glm/gtc/type_ptr.inl create mode 100755 src/libraries/glm/gtc/ulp.hpp create mode 100755 src/libraries/glm/gtc/ulp.inl (limited to 'src/libraries/glm/gtc') diff --git a/src/libraries/glm/gtc/constants.hpp b/src/libraries/glm/gtc/constants.hpp new file mode 100755 index 0000000..eba1021 --- /dev/null +++ b/src/libraries/glm/gtc/constants.hpp @@ -0,0 +1,186 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_constants +/// @file glm/gtc/constants.hpp +/// @date 2011-09-30 / 2012-01-25 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// +/// @defgroup gtc_constants GLM_GTC_constants +/// @ingroup gtc +/// +/// @brief Allow to perform bit operations on integer values +/// +/// need to be included to use these features. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_constants +#define GLM_GTC_constants GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_constants extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_constants + /// @{ + + /// Return the epsilon constant for floating point types. + /// @todo Implement epsilon for half-precision floating point type. + /// @see gtc_constants + template + genType epsilon(); + + /// Return 0. + /// @see gtc_constants + template + genType zero(); + + /// Return 1. + /// @see gtc_constants + template + genType one(); + + /// Return the pi constant. + /// @see gtc_constants + template + genType pi(); + + /// Return square root of pi. + /// @see gtc_constants + template + genType root_pi(); + + /// Return pi / 2. + /// @see gtc_constants + template + genType half_pi(); + + /// Return pi / 4. + /// @see gtc_constants + template + genType quarter_pi(); + + /// Return 1 / pi. + /// @see gtc_constants + template + genType one_over_pi(); + + /// Return 2 / pi. + /// @see gtc_constants + template + genType two_over_pi(); + + /// Return 2 / sqrt(pi). + /// @see gtc_constants + template + genType two_over_root_pi(); + + /// Return 1 / sqrt(2). + /// @see gtc_constants + template + genType one_over_root_two(); + + /// Return sqrt(pi / 2). + /// @see gtc_constants + template + genType root_half_pi(); + + /// Return sqrt(2 * pi). + /// @see gtc_constants + template + genType root_two_pi(); + + /// Return sqrt(ln(4)). + /// @see gtc_constants + template + genType root_ln_four(); + + /// Return e constant. + /// @see gtc_constants + template + genType e(); + + /// Return Euler's constant. + /// @see gtc_constants + template + genType euler(); + + /// Return sqrt(2). + /// @see gtc_constants + template + genType root_two(); + + /// Return sqrt(3). + /// @see gtc_constants + template + genType root_three(); + + /// Return sqrt(5). + /// @see gtc_constants + template + genType root_five(); + + /// Return ln(2). + /// @see gtc_constants + template + genType ln_two(); + + /// Return ln(10). + /// @see gtc_constants + template + genType ln_ten(); + + /// Return ln(ln(2)). + /// @see gtc_constants + template + genType ln_ln_two(); + + /// Return 1 / 3. + /// @see gtc_constants + template + genType third(); + + /// Return 2 / 3. + /// @see gtc_constants + template + genType two_thirds(); + + /// Return the golden ratio constant. + /// @see gtc_constants + template + genType golden_ratio(); + + /// @} +} //namespace glm + +#include "constants.inl" + +#endif//GLM_GTC_constants diff --git a/src/libraries/glm/gtc/constants.inl b/src/libraries/glm/gtc/constants.inl new file mode 100755 index 0000000..afe3ddf --- /dev/null +++ b/src/libraries/glm/gtc/constants.inl @@ -0,0 +1,186 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_constants +/// @file glm/gtx/constants.inl +/// @date 2011-10-14 / 2012-01-25 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + GLM_FUNC_QUALIFIER genType epsilon() + { + return std::numeric_limits::epsilon(); + } + + template <> + GLM_FUNC_QUALIFIER half epsilon() + { + return half(1.19209290e-007); + } + + template + GLM_FUNC_QUALIFIER genType zero() + { + return genType(0); + } + + template + GLM_FUNC_QUALIFIER genType one() + { + return genType(1); + } + + template + GLM_FUNC_QUALIFIER genType pi() + { + return genType(3.14159265358979323846264338327950288); + } + + template + GLM_FUNC_QUALIFIER genType root_pi() + { + return genType(1.772453850905516027); + } + + template + GLM_FUNC_QUALIFIER genType half_pi() + { + return genType(1.57079632679489661923132169163975144); + } + + template + GLM_FUNC_QUALIFIER genType quarter_pi() + { + return genType(0.785398163397448309615660845819875721); + } + + template + GLM_FUNC_QUALIFIER genType one_over_pi() + { + return genType(0.318309886183790671537767526745028724); + } + + template + GLM_FUNC_QUALIFIER genType two_over_pi() + { + return genType(0.636619772367581343075535053490057448); + } + + template + GLM_FUNC_QUALIFIER genType two_over_root_pi() + { + return genType(1.12837916709551257389615890312154517); + } + + template + GLM_FUNC_QUALIFIER genType one_over_root_two() + { + return genType(0.707106781186547524400844362104849039); + } + + template + GLM_FUNC_QUALIFIER genType root_half_pi() + { + return genType(1.253314137315500251); + } + + template + GLM_FUNC_QUALIFIER genType root_two_pi() + { + return genType(2.506628274631000502); + } + + template + GLM_FUNC_QUALIFIER genType root_ln_four() + { + return genType(1.17741002251547469); + } + + template + GLM_FUNC_QUALIFIER genType e() + { + return genType(2.71828182845904523536); + } + + template + GLM_FUNC_QUALIFIER genType euler() + { + return genType(0.577215664901532860606); + } + + template + GLM_FUNC_QUALIFIER genType root_two() + { + return genType(1.41421356237309504880168872420969808); + } + + template + GLM_FUNC_QUALIFIER genType root_three() + { + return genType(1.73205080756887729352744634150587236); + } + + template + GLM_FUNC_QUALIFIER genType root_five() + { + return genType(2.23606797749978969640917366873127623); + } + + template + GLM_FUNC_QUALIFIER genType ln_two() + { + return genType(0.693147180559945309417232121458176568); + } + + template + GLM_FUNC_QUALIFIER genType ln_ten() + { + return genType(2.30258509299404568401799145468436421); + } + + template + GLM_FUNC_QUALIFIER genType ln_ln_two() + { + return genType(-0.3665129205816643); + } + + template + GLM_FUNC_QUALIFIER genType third() + { + return genType(0.3333333333333333333333333333333333333333); + } + + template + GLM_FUNC_QUALIFIER genType two_thirds() + { + return genType(0.666666666666666666666666666666666666667); + } + + template + GLM_FUNC_QUALIFIER genType golden_ratio() + { + return genType(1.61803398874989484820458683436563811); + } +} //namespace glm diff --git a/src/libraries/glm/gtc/epsilon.hpp b/src/libraries/glm/gtc/epsilon.hpp new file mode 100755 index 0000000..eab8336 --- /dev/null +++ b/src/libraries/glm/gtc/epsilon.hpp @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_epsilon +/// @file glm/gtc/epsilon.hpp +/// @date 2012-04-07 / 2012-04-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtc_epsilon GLM_GTC_epsilon +/// @ingroup gtc +/// +/// @brief Comparison functions for a user defined epsilon values. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_epsilon +#define GLM_GTC_epsilon GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_epsilon extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_epsilon + /// @{ + + /// Returns the component-wise compare of |x - y| < epsilon. + /// @see gtc_epsilon + template + typename genType::boolType epsilonEqual( + genType const & x, + genType const & y, + typename genType::value_type const & epsilon); + + /// Returns the component-wise compare of |x - y| < epsilon. + /// @see gtc_epsilon + template + typename genType::boolType epsilonEqual( + genType const & x, + genType const & y, + genType const & epsilon); + + /// Returns the component-wise compare of |x - y| < epsilon. + /// @see gtc_epsilon + template + typename genType::boolType epsilonNotEqual( + genType const & x, + genType const & y, + typename genType::value_type const & epsilon); + + /// Returns the component-wise compare of |x - y| >= epsilon. + /// @see gtc_epsilon + template + typename genType::boolType epsilonNotEqual( + genType const & x, + genType const & y, + genType const & epsilon); + + /// @} +}//namespace glm + +#include "epsilon.inl" + +#endif//GLM_GTC_epsilon diff --git a/src/libraries/glm/gtc/epsilon.inl b/src/libraries/glm/gtc/epsilon.inl new file mode 100755 index 0000000..6faef71 --- /dev/null +++ b/src/libraries/glm/gtc/epsilon.inl @@ -0,0 +1,286 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_epsilon +/// @file glm/gtc/epsilon.inl +/// @date 2012-04-07 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + GLM_FUNC_QUALIFIER bool epsilonEqual + ( + glm::half const & x, + glm::half const & y, + glm::half const & epsilon + ) + { + return abs(x - y) < epsilon; + } + + GLM_FUNC_QUALIFIER bool epsilonEqual + ( + float const & x, + float const & y, + float const & epsilon + ) + { + return abs(x - y) < epsilon; + } + + GLM_FUNC_QUALIFIER bool epsilonEqual + ( + double const & x, + double const & y, + double const & epsilon + ) + { + return abs(x - y) < epsilon; + } + + GLM_FUNC_QUALIFIER bool epsilonNotEqual + ( + glm::half const & x, + glm::half const & y, + glm::half const & epsilon + ) + { + return abs(x - y) >= epsilon; + } + + GLM_FUNC_QUALIFIER bool epsilonNotEqual + ( + float const & x, + float const & y, + float const & epsilon + ) + { + return abs(x - y) >= epsilon; + } + + GLM_FUNC_QUALIFIER bool epsilonNotEqual + ( + double const & x, + double const & y, + double const & epsilon + ) + { + return abs(x - y) >= epsilon; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 epsilonEqual + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + valType const & epsilon) + { + return detail::tvec2( + abs(x.x - y.x) < epsilon, + abs(x.y - y.y) < epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 epsilonEqual + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 const & epsilon + ) + { + return detail::tvec2( + abs(x.x - y.x) < epsilon.x, + abs(x.y - y.y) < epsilon.y); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 epsilonEqual + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + valType const & epsilon) + { + return detail::tvec3( + abs(x.x - y.x) < epsilon, + abs(x.y - y.y) < epsilon, + abs(x.z - y.z) < epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 epsilonEqual + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 const & epsilon + ) + { + return detail::tvec3( + abs(x.x - y.x) < epsilon.x, + abs(x.y - y.y) < epsilon.y, + abs(x.z - y.z) < epsilon.z); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonEqual + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) < epsilon, + abs(x.y - y.y) < epsilon, + abs(x.z - y.z) < epsilon, + abs(x.w - y.w) < epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonEqual + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) < epsilon.x, + abs(x.y - y.y) < epsilon.y, + abs(x.z - y.z) < epsilon.z, + abs(x.w - y.w) < epsilon.w); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 epsilonNotEqual + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + valType const & epsilon + ) + { + return detail::tvec2( + abs(x.x - y.x) >= epsilon, + abs(x.y - y.y) >= epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 epsilonNotEqual + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 const & epsilon + ) + { + return detail::tvec2( + abs(x.x - y.x) >= epsilon.x, + abs(x.y - y.y) >= epsilon.y); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 epsilonNotEqual + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + valType const & epsilon + ) + { + return detail::tvec3( + abs(x.x - y.x) >= epsilon, + abs(x.y - y.y) >= epsilon, + abs(x.z - y.z) >= epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 epsilonNotEqual + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 const & epsilon + ) + { + return detail::tvec3( + abs(x.x - y.x) >= epsilon.x, + abs(x.y - y.y) >= epsilon.y, + abs(x.z - y.z) >= epsilon.z); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonNotEqual + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) >= epsilon, + abs(x.y - y.y) >= epsilon, + abs(x.z - y.z) >= epsilon, + abs(x.w - y.w) >= epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonNotEqual + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) >= epsilon.x, + abs(x.y - y.y) >= epsilon.y, + abs(x.z - y.z) >= epsilon.z, + abs(x.w - y.w) >= epsilon.w); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonEqual + ( + detail::tquat const & x, + detail::tquat const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) < epsilon, + abs(x.y - y.y) < epsilon, + abs(x.z - y.z) < epsilon, + abs(x.w - y.w) < epsilon); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonNotEqual + ( + detail::tquat const & x, + detail::tquat const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) >= epsilon, + abs(x.y - y.y) >= epsilon, + abs(x.z - y.z) >= epsilon, + abs(x.w - y.w) >= epsilon); + } +}//namespace glm diff --git a/src/libraries/glm/gtc/half_float.hpp b/src/libraries/glm/gtc/half_float.hpp new file mode 100755 index 0000000..d256a49 --- /dev/null +++ b/src/libraries/glm/gtc/half_float.hpp @@ -0,0 +1,440 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_half_float +/// @file glm/gtc/half_float.hpp +/// @date 2009-04-29 / 2012-11-06 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_half_float GLM_GTC_half_float +/// @ingroup gtc +/// +/// Defines the half-precision floating-point type, along with various typedefs for vectors and matrices. +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_half_float +#define GLM_GTC_half_float GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_half_float extension included") +#endif + +namespace glm{ +namespace detail +{ +#if(GLM_COMPONENT == GLM_COMPONENT_CXX98) + template <> + struct tvec2 + { + enum ctor{null}; + typedef half value_type; + typedef std::size_t size_type; + + GLM_FUNC_DECL size_type length() const; + static GLM_FUNC_DECL size_type value_size(); + + typedef tvec2 type; + typedef tvec2 bool_type; + + ////////////////////////////////////// + // Data + + half x, y; + + ////////////////////////////////////// + // Accesses + + half & operator[](size_type i); + half const & operator[](size_type i) const; + + ////////////////////////////////////// + // Implicit basic constructors + + tvec2(); + tvec2(tvec2 const & v); + + ////////////////////////////////////// + // Explicit basic constructors + + explicit tvec2(ctor); + explicit tvec2( + half const & s); + explicit tvec2( + half const & s1, + half const & s2); + + ////////////////////////////////////// + // Swizzle constructors + + tvec2(tref2 const & r); + + ////////////////////////////////////// + // Convertion scalar constructors + + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec2(U const & x); + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec2(U const & x, V const & y); + + ////////////////////////////////////// + // Convertion vector constructors + + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec2(tvec2 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec2(tvec3 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec2(tvec4 const & v); + + ////////////////////////////////////// + // Unary arithmetic operators + + tvec2& operator= (tvec2 const & v); + + tvec2& operator+=(half const & s); + tvec2& operator+=(tvec2 const & v); + tvec2& operator-=(half const & s); + tvec2& operator-=(tvec2 const & v); + tvec2& operator*=(half const & s); + tvec2& operator*=(tvec2 const & v); + tvec2& operator/=(half const & s); + tvec2& operator/=(tvec2 const & v); + tvec2& operator++(); + tvec2& operator--(); + + ////////////////////////////////////// + // Swizzle operators + + half swizzle(comp X) const; + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref2 swizzle(comp X, comp Y); + }; + + template <> + struct tvec3 + { + enum ctor{null}; + typedef half value_type; + typedef std::size_t size_type; + GLM_FUNC_DECL size_type length() const; + static GLM_FUNC_DECL size_type value_size(); + + typedef tvec3 type; + typedef tvec3 bool_type; + + ////////////////////////////////////// + // Data + + half x, y, z; + + ////////////////////////////////////// + // Accesses + + half & operator[](size_type i); + half const & operator[](size_type i) const; + + ////////////////////////////////////// + // Implicit basic constructors + + tvec3(); + tvec3(tvec3 const & v); + + ////////////////////////////////////// + // Explicit basic constructors + + explicit tvec3(ctor); + explicit tvec3( + half const & s); + explicit tvec3( + half const & s1, + half const & s2, + half const & s3); + + ////////////////////////////////////// + // Swizzle constructors + + tvec3(tref3 const & r); + + ////////////////////////////////////// + // Convertion scalar constructors + + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(U const & x); + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(U const & x, V const & y, W const & z); + + ////////////////////////////////////// + // Convertion vector constructors + + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(tvec2 const & v, B const & s); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(A const & s, tvec2 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(tvec3 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec3(tvec4 const & v); + + ////////////////////////////////////// + // Unary arithmetic operators + + tvec3& operator= (tvec3 const & v); + + tvec3& operator+=(half const & s); + tvec3& operator+=(tvec3 const & v); + tvec3& operator-=(half const & s); + tvec3& operator-=(tvec3 const & v); + tvec3& operator*=(half const & s); + tvec3& operator*=(tvec3 const & v); + tvec3& operator/=(half const & s); + tvec3& operator/=(tvec3 const & v); + tvec3& operator++(); + tvec3& operator--(); + + ////////////////////////////////////// + // Swizzle operators + + half swizzle(comp X) const; + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref3 swizzle(comp X, comp Y, comp Z); + }; + + template <> + struct tvec4 + { + enum ctor{null}; + typedef half value_type; + typedef std::size_t size_type; + GLM_FUNC_DECL size_type length() const; + static GLM_FUNC_DECL size_type value_size(); + + typedef tvec4 type; + typedef tvec4 bool_type; + + ////////////////////////////////////// + // Data + + half x, y, z, w; + + ////////////////////////////////////// + // Accesses + + half & operator[](size_type i); + half const & operator[](size_type i) const; + + ////////////////////////////////////// + // Implicit basic constructors + + tvec4(); + tvec4(tvec4 const & v); + + ////////////////////////////////////// + // Explicit basic constructors + + explicit tvec4(ctor); + explicit tvec4( + half const & s); + explicit tvec4( + half const & s0, + half const & s1, + half const & s2, + half const & s3); + + ////////////////////////////////////// + // Swizzle constructors + + tvec4(tref4 const & r); + + ////////////////////////////////////// + // Convertion scalar constructors + + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(U const & x); + //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(A const & x, B const & y, C const & z, D const & w); + + ////////////////////////////////////// + // Convertion vector constructors + + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(tvec2 const & v, B const & s1, C const & s2); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(A const & s1, tvec2 const & v, C const & s2); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(A const & s1, B const & s2, tvec2 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(tvec3 const & v, B const & s); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(A const & s, tvec3 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(tvec2 const & v1, tvec2 const & v2); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + explicit tvec4(tvec4 const & v); + + ////////////////////////////////////// + // Unary arithmetic operators + + tvec4& operator= (tvec4 const & v); + + tvec4& operator+=(half const & s); + tvec4& operator+=(tvec4 const & v); + tvec4& operator-=(half const & s); + tvec4& operator-=(tvec4 const & v); + tvec4& operator*=(half const & s); + tvec4& operator*=(tvec4 const & v); + tvec4& operator/=(half const & s); + tvec4& operator/=(tvec4 const & v); + tvec4& operator++(); + tvec4& operator--(); + + ////////////////////////////////////// + // Swizzle operators + + half swizzle(comp X) const; + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref4 swizzle(comp X, comp Y, comp Z, comp W); + }; +#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98) +} +//namespace detail + + /// @addtogroup gtc_half_float + /// @{ + + /// Type for half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::half half; + + /// Vector of 2 half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tvec2 hvec2; + + /// Vector of 3 half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tvec3 hvec3; + + /// Vector of 4 half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tvec4 hvec4; + + /// 2 * 2 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat2x2 hmat2; + + /// 3 * 3 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat3x3 hmat3; + + /// 4 * 4 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat4x4 hmat4; + + /// 2 * 2 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat2x2 hmat2x2; + + /// 2 * 3 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat2x3 hmat2x3; + + /// 2 * 4 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat2x4 hmat2x4; + + /// 3 * 2 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat3x2 hmat3x2; + + /// 3 * 3 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat3x3 hmat3x3; + + /// 3 * 4 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat3x4 hmat3x4; + + /// 4 * 2 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat4x2 hmat4x2; + + /// 4 * 3 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat4x3 hmat4x3; + + /// 4 * 4 matrix of half-precision floating-point numbers. + /// @see gtc_half_float + typedef detail::tmat4x4 hmat4x4; + + /// Returns the absolute value of a half-precision floating-point value + /// @see gtc_half_float + half abs(half const & x); + + /// Returns the absolute value of a half-precision floating-point two dimensional vector + /// @see gtc_half_float + hvec2 abs(hvec2 const & x); + + /// Returns the absolute value of a half-precision floating-point three dimensional vector + /// @see gtc_half_float + hvec3 abs(hvec3 const & x); + + /// Returns the absolute value of a half-precision floating-point four dimensional vector + /// @see gtc_half_float + hvec4 abs(hvec4 const & x); + + /// @} +}// namespace glm + +#include "half_float.inl" + +#endif//GLM_GTC_half_float diff --git a/src/libraries/glm/gtc/half_float.inl b/src/libraries/glm/gtc/half_float.inl new file mode 100755 index 0000000..241def4 --- /dev/null +++ b/src/libraries/glm/gtc/half_float.inl @@ -0,0 +1,1039 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_half_float +/// @file glm/gtc/half_float.inl +/// @date 2009-04-29 / 2012-11-06 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail +{ +#if(GLM_COMPONENT == GLM_COMPONENT_CXX98) + + ////////////////////////////////////// + // hvec2 + + GLM_FUNC_QUALIFIER tvec2::size_type tvec2::length() const + { + return 2; + } + + GLM_FUNC_QUALIFIER tvec2::size_type tvec2::value_size() + { + return 2; + } + + ////////////////////////////////////// + // Accesses + + GLM_FUNC_QUALIFIER half & tvec2::operator[](tvec2::size_type i) + { + assert(/*i >= tvec2::size_type(0) && */i < tvec2::value_size()); + return (&x)[i]; + } + + GLM_FUNC_QUALIFIER half const & tvec2::operator[](tvec2::size_type i) const + { + assert(/*i >= tvec2::size_type(0) && */i < tvec2::value_size()); + return (&x)[i]; + } + + ////////////////////////////////////// + // Implicit basic constructors + + GLM_FUNC_QUALIFIER tvec2::tvec2() : + x(half(0.f)), + y(half(0.f)) + {} + + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + tvec2 const & v + ) : + x(v.x), + y(v.y) + {} + + ////////////////////////////////////// + // Explicit basic constructors + + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + half const & s + ) : + x(s), + y(s) + {} + + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + half const & s1, + half const & s2 + ) : + x(s1), + y(s2) + {} + + ////////////////////////////////////// + // Swizzle constructors + + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + tref2 const & r + ) : + x(r.x), + y(r.y) + {} + + ////////////////////////////////////// + // Convertion scalar constructors + + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + U const & x + ) : + x(half(x)), + y(half(x)) + {} + + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + U const & x, + V const & y + ) : + x(half(x)), + y(half(y)) + {} + + ////////////////////////////////////// + // Convertion vector constructors + + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + tvec2 const & v + ) : + x(half(v.x)), + y(half(v.y)) + {} + + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + tvec3 const & v + ) : + x(half(v.x)), + y(half(v.y)) + {} + + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + tvec4 const & v + ) : + x(half(v.x)), + y(half(v.y)) + {} + + ////////////////////////////////////// + // Unary arithmetic operators + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator= + ( + tvec2 const & v + ) + { + this->x = v.x; + this->y = v.y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= + ( + half const & s + ) + { + this->x += s; + this->y += s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= + ( + tvec2 const & v + ) + { + this->x += v.x; + this->y += v.y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= + ( + half const & s + ) + { + this->x -= s; + this->y -= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= + ( + tvec2 const & v + ) + { + this->x -= v.x; + this->y -= v.y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2& tvec2::operator*= + ( + half const & s + ) + { + this->x *= s; + this->y *= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator*= + ( + tvec2 const & v + ) + { + this->x *= v.x; + this->y *= v.y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= + ( + half const & s + ) + { + this->x /= s; + this->y /= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= + ( + tvec2 const & v + ) + { + this->x /= v.x; + this->y /= v.y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator++() + { + ++this->x; + ++this->y; + return *this; + } + + GLM_FUNC_QUALIFIER tvec2& tvec2::operator--() + { + --this->x; + --this->y; + return *this; + } + + ////////////////////////////////////// + // Swizzle operators + + GLM_FUNC_QUALIFIER half tvec2::swizzle(comp x) const + { + return (*this)[x]; + } + + GLM_FUNC_QUALIFIER tvec2 tvec2::swizzle(comp x, comp y) const + { + return tvec2( + (*this)[x], + (*this)[y]); + } + + GLM_FUNC_QUALIFIER tvec3 tvec2::swizzle(comp x, comp y, comp z) const + { + return tvec3( + (*this)[x], + (*this)[y], + (*this)[z]); + } + + GLM_FUNC_QUALIFIER tvec4 tvec2::swizzle(comp x, comp y, comp z, comp w) const + { + return tvec4( + (*this)[x], + (*this)[y], + (*this)[z], + (*this)[w]); + } + + GLM_FUNC_QUALIFIER tref2 tvec2::swizzle(comp x, comp y) + { + return tref2( + (*this)[x], + (*this)[y]); + } + + ////////////////////////////////////// + // hvec3 + + GLM_FUNC_QUALIFIER tvec3::size_type tvec3::length() const + { + return 3; + } + + GLM_FUNC_QUALIFIER tvec3::size_type tvec3::value_size() + { + return 3; + } + + ////////////////////////////////////// + // Accesses + + GLM_FUNC_QUALIFIER half & tvec3::operator[] + ( + tvec3::size_type i + ) + { + assert(/*i >= tvec3::size_type(0) &&*/ i < tvec3::value_size()); + + return (&x)[i]; + } + + GLM_FUNC_QUALIFIER half const & tvec3::operator[] + ( + tvec3::size_type i + ) const + { + assert(/*i >= tvec3::size_type(0) &&*/ i < tvec3::value_size()); + + return (&x)[i]; + } + + ////////////////////////////////////// + // Implicit basic constructors + + GLM_FUNC_QUALIFIER tvec3::tvec3() : + x(half(0)), + y(half(0)), + z(half(0)) + {} + + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + tvec3 const & v + ) : + x(v.x), + y(v.y), + z(v.z) + {} + + ////////////////////////////////////// + // Explicit basic constructors + + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + half const & s + ) : + x(s), + y(s), + z(s) + {} + + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + half const & s0, + half const & s1, + half const & s2 + ) : + x(s0), + y(s1), + z(s2) + {} + + ////////////////////////////////////// + // Swizzle constructors + + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + tref3 const & r + ) : + x(r.x), + y(r.y), + z(r.z) + {} + + ////////////////////////////////////// + // Convertion scalar constructors + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + U const & x + ) : + x(half(x)), + y(half(x)), + z(half(x)) + {} + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + A const & x, + B const & y, + C const & z + ) : + x(half(x)), + y(half(y)), + z(half(z)) + {} + + ////////////////////////////////////// + // Convertion vector constructors + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + tvec2 const & v, + B const & s + ) : + x(half(v.x)), + y(half(v.y)), + z(half(s)) + {} + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + A const & s, + tvec2 const & v + ) : + x(half(s)), + y(half(v.x)), + z(half(v.y)) + {} + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + tvec3 const & v + ) : + x(half(v.x)), + y(half(v.y)), + z(half(v.z)) + {} + + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + tvec4 const & v + ) : + x(half(v.x)), + y(half(v.y)), + z(half(v.z)) + {} + + ////////////////////////////////////// + // Unary arithmetic operators + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator= + ( + tvec3 const & v + ) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= + ( + half const & s + ) + { + this->x += s; + this->y += s; + this->z += s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= + ( + tvec3 const & v + ) + { + this->x += v.x; + this->y += v.y; + this->z += v.z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= + ( + half const & s + ) + { + this->x -= s; + this->y -= s; + this->z -= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= + ( + tvec3 const & v + ) + { + this->x -= v.x; + this->y -= v.y; + this->z -= v.z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= + ( + half const & s + ) + { + this->x *= s; + this->y *= s; + this->z *= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= + ( + tvec3 const & v + ) + { + this->x *= v.x; + this->y *= v.y; + this->z *= v.z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= + ( + half const & s + ) + { + this->x /= s; + this->y /= s; + this->z /= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= + ( + tvec3 const & v + ) + { + this->x /= v.x; + this->y /= v.y; + this->z /= v.z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator++() + { + ++this->x; + ++this->y; + ++this->z; + return *this; + } + + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator--() + { + --this->x; + --this->y; + --this->z; + return *this; + } + + ////////////////////////////////////// + // Swizzle operators + + GLM_FUNC_QUALIFIER half tvec3::swizzle(comp x) const + { + return (*this)[x]; + } + + GLM_FUNC_QUALIFIER tvec2 tvec3::swizzle(comp x, comp y) const + { + return tvec2( + (*this)[x], + (*this)[y]); + } + + GLM_FUNC_QUALIFIER tvec3 tvec3::swizzle(comp x, comp y, comp z) const + { + return tvec3( + (*this)[x], + (*this)[y], + (*this)[z]); + } + + GLM_FUNC_QUALIFIER tvec4 tvec3::swizzle(comp x, comp y, comp z, comp w) const + { + return tvec4( + (*this)[x], + (*this)[y], + (*this)[z], + (*this)[w]); + } + + GLM_FUNC_QUALIFIER tref3 tvec3::swizzle(comp x, comp y, comp z) + { + return tref3( + (*this)[x], + (*this)[y], + (*this)[z]); + } + + ////////////////////////////////////// + // hvec4 + + GLM_FUNC_QUALIFIER tvec4::size_type tvec4::length() const + { + return 4; + } + + GLM_FUNC_QUALIFIER tvec4::size_type tvec4::value_size() + { + return 4; + } + + ////////////////////////////////////// + // Accesses + + GLM_FUNC_QUALIFIER half & tvec4::operator[] + ( + tvec4::size_type i + ) + { + assert(/*i >= tvec4::size_type(0) && */i < tvec4::value_size()); + + return (&x)[i]; + } + + GLM_FUNC_QUALIFIER half const & tvec4::operator[] + ( + tvec4::size_type i + ) const + { + assert(/*i >= tvec4::size_type(0) && */i < tvec4::value_size()); + + return (&x)[i]; + } + + ////////////////////////////////////// + // Implicit basic constructors + + GLM_FUNC_QUALIFIER tvec4::tvec4() : + x(half(0)), + y(half(0)), + z(half(0)), + w(half(0)) + {} + + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec4 const & v + ) : + x(v.x), + y(v.y), + z(v.z), + w(v.w) + {} + + ////////////////////////////////////// + // Explicit basic constructors + + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + half const & s + ) : + x(s), + y(s), + z(s), + w(s) + {} + + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + half const & s1, + half const & s2, + half const & s3, + half const & s4 + ) : + x(s1), + y(s2), + z(s3), + w(s4) + {} + + ////////////////////////////////////// + // Swizzle constructors + + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tref4 const & r + ) : + x(r.x), + y(r.y), + z(r.z), + w(r.w) + {} + + ////////////////////////////////////// + // Convertion scalar constructors + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + U const & x + ) : + x(half(x)), + y(half(x)), + z(half(x)), + w(half(x)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + A const & x, + B const & y, + C const & z, + D const & w + ) : + x(half(x)), + y(half(y)), + z(half(z)), + w(half(w)) + {} + + ////////////////////////////////////// + // Convertion vector constructors + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec2 const & v, + B const & s1, + C const & s2 + ) : + x(half(v.x)), + y(half(v.y)), + z(half(s1)), + w(half(s2)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + A const & s1, + tvec2 const & v, + C const & s2 + ) : + x(half(s1)), + y(half(v.x)), + z(half(v.y)), + w(half(s2)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + A const & s1, + B const & s2, + tvec2 const & v + ) : + x(half(s1)), + y(half(s2)), + z(half(v.x)), + w(half(v.y)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec3 const & v, + B const & s + ) : + x(half(v.x)), + y(half(v.y)), + z(half(v.z)), + w(half(s)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + A const & s, + tvec3 const & v + ) : + x(half(s)), + y(half(v.x)), + z(half(v.y)), + w(half(v.z)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec2 const & v1, + tvec2 const & v2 + ) : + x(half(v1.x)), + y(half(v1.y)), + z(half(v2.x)), + w(half(v2.y)) + {} + + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec4 const & v + ) : + x(half(v.x)), + y(half(v.y)), + z(half(v.z)), + w(half(v.w)) + {} + + ////////////////////////////////////// + // Unary arithmetic operators + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator= + ( + tvec4 const & v + ) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + this->w = v.w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= + ( + half const & s + ) + { + this->x += s; + this->y += s; + this->z += s; + this->w += s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= + ( + tvec4 const & v + ) + { + this->x += v.x; + this->y += v.y; + this->z += v.z; + this->w += v.w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= + ( + half const & s + ) + { + this->x -= s; + this->y -= s; + this->z -= s; + this->w -= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= + ( + tvec4 const & v + ) + { + this->x -= v.x; + this->y -= v.y; + this->z -= v.z; + this->w -= v.w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= + ( + half const & s + ) + { + this->x *= s; + this->y *= s; + this->z *= s; + this->w *= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= + ( + tvec4 const & v + ) + { + this->x *= v.x; + this->y *= v.y; + this->z *= v.z; + this->w *= v.w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= + ( + half const & s + ) + { + this->x /= s; + this->y /= s; + this->z /= s; + this->w /= s; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= + ( + tvec4 const & v + ) + { + this->x /= v.x; + this->y /= v.y; + this->z /= v.z; + this->w /= v.w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator++() + { + ++this->x; + ++this->y; + ++this->z; + ++this->w; + return *this; + } + + GLM_FUNC_QUALIFIER tvec4& tvec4::operator--() + { + --this->x; + --this->y; + --this->z; + --this->w; + return *this; + } + + ////////////////////////////////////// + // Swizzle operators + + GLM_FUNC_QUALIFIER half tvec4::swizzle(comp x) const + { + return (*this)[x]; + } + + GLM_FUNC_QUALIFIER tvec2 tvec4::swizzle(comp x, comp y) const + { + return tvec2( + (*this)[x], + (*this)[y]); + } + + GLM_FUNC_QUALIFIER tvec3 tvec4::swizzle(comp x, comp y, comp z) const + { + return tvec3( + (*this)[x], + (*this)[y], + (*this)[z]); + } + + GLM_FUNC_QUALIFIER tvec4 tvec4::swizzle(comp x, comp y, comp z, comp w) const + { + return tvec4( + (*this)[x], + (*this)[y], + (*this)[z], + (*this)[w]); + } + + GLM_FUNC_QUALIFIER tref4 tvec4::swizzle(comp x, comp y, comp z, comp w) + { + return tref4( + (*this)[x], + (*this)[y], + (*this)[z], + (*this)[w]); + } + +#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98) + +}//namespace detail + + GLM_FUNC_QUALIFIER half abs(half const & x) + { + return float(x) >= float(0) ? x : -x; + } + + GLM_FUNC_QUALIFIER hvec2 abs(hvec2 const & v) + { + return hvec2( + float(v.x) >= float(0) ? v.x : -v.x, + float(v.y) >= float(0) ? v.y : -v.y); + } + + GLM_FUNC_QUALIFIER hvec3 abs(hvec3 const & v) + { + return hvec3( + float(v.x) >= float(0) ? v.x : -v.x, + float(v.y) >= float(0) ? v.y : -v.y, + float(v.z) >= float(0) ? v.z : -v.z); + } + + GLM_FUNC_QUALIFIER hvec4 abs(hvec4 const & v) + { + return hvec4( + float(v.x) >= float(0) ? v.x : -v.x, + float(v.y) >= float(0) ? v.y : -v.y, + float(v.z) >= float(0) ? v.z : -v.z, + float(v.w) >= float(0) ? v.w : -v.w); + } + +}//namespace glm diff --git a/src/libraries/glm/gtc/matrix_access.hpp b/src/libraries/glm/gtc/matrix_access.hpp new file mode 100755 index 0000000..4dfb5fe --- /dev/null +++ b/src/libraries/glm/gtc/matrix_access.hpp @@ -0,0 +1,87 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_access +/// @file glm/gtc/matrix_access.hpp +/// @date 2005-12-27 / 2011-05-16 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_matrix_access GLM_GTC_matrix_access +/// @ingroup gtc +/// +/// Defines functions to access rows or columns of a matrix easily. +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_matrix_access +#define GLM_GTC_matrix_access GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_matrix_access extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_matrix_access + /// @{ + + /// Get a specific row of a matrix. + /// @see gtc_matrix_access + template + typename genType::row_type row( + genType const & m, + int index); + + /// Set a specific row to a matrix. + /// @see gtc_matrix_access + template + genType row( + genType const & m, + int index, + typename genType::row_type const & x); + + /// Get a specific column of a matrix. + /// @see gtc_matrix_access + template + typename genType::col_type column( + genType const & m, + int index); + + /// Set a specific column to a matrix. + /// @see gtc_matrix_access + template + genType column( + genType const & m, + int index, + typename genType::col_type const & x); + + /// @} +}//namespace glm + +#include "matrix_access.inl" + +#endif//GLM_GTC_matrix_access diff --git a/src/libraries/glm/gtc/matrix_access.inl b/src/libraries/glm/gtc/matrix_access.inl new file mode 100755 index 0000000..2f3f500 --- /dev/null +++ b/src/libraries/glm/gtc/matrix_access.inl @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_access +/// @file glm/gtc/matrix_access.inl +/// @date 2005-12-27 / 2011-06-05 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + GLM_FUNC_QUALIFIER genType row + ( + genType const & m, + int index, + typename genType::row_type const & x + ) + { + genType Result = m; + for(typename genType::size_type i = 0; i < genType::row_size(); ++i) + Result[i][index] = x[i]; + return Result; + } + + template + GLM_FUNC_QUALIFIER typename genType::row_type row + ( + genType const & m, + int index + ) + { + typename genType::row_type Result; + for(typename genType::size_type i = 0; i < genType::row_size(); ++i) + Result[i] = m[i][index]; + return Result; + } + + template + GLM_FUNC_QUALIFIER genType column + ( + genType const & m, + int index, + typename genType::col_type const & x + ) + { + genType Result = m; + Result[index] = x; + return Result; + } + + template + GLM_FUNC_QUALIFIER typename genType::col_type column + ( + genType const & m, + int index + ) + { + return m[index]; + } +}//namespace glm diff --git a/src/libraries/glm/gtc/matrix_integer.hpp b/src/libraries/glm/gtc/matrix_integer.hpp new file mode 100755 index 0000000..50f157b --- /dev/null +++ b/src/libraries/glm/gtc/matrix_integer.hpp @@ -0,0 +1,506 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_integer +/// @file glm/gtc/matrix_integer.hpp +/// @date 2011-01-20 / 2011-06-05 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_matrix_integer GLM_GTC_matrix_integer +/// @ingroup gtc +/// +/// Defines a number of matrices with integer types. +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_matrix_integer +#define GLM_GTC_matrix_integer GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_matrix_integer extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_matrix_integer + /// @{ + + /// High-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 highp_imat2; + + /// High-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 highp_imat3; + + /// High-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 highp_imat4; + + /// High-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 highp_imat2x2; + + /// High-precision signed integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 highp_imat2x3; + + /// High-precision signed integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 highp_imat2x4; + + /// High-precision signed integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 highp_imat3x2; + + /// High-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 highp_imat3x3; + + /// High-precision signed integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 highp_imat3x4; + + /// High-precision signed integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 highp_imat4x2; + + /// High-precision signed integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 highp_imat4x3; + + /// High-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 highp_imat4x4; + + + /// Medium-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 mediump_imat2; + + /// Medium-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 mediump_imat3; + + /// Medium-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 mediump_imat4; + + + /// Medium-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 mediump_imat2x2; + + /// Medium-precision signed integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 mediump_imat2x3; + + /// Medium-precision signed integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 mediump_imat2x4; + + /// Medium-precision signed integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 mediump_imat3x2; + + /// Medium-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 mediump_imat3x3; + + /// Medium-precision signed integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 mediump_imat3x4; + + /// Medium-precision signed integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 mediump_imat4x2; + + /// Medium-precision signed integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 mediump_imat4x3; + + /// Medium-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 mediump_imat4x4; + + + /// Low-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 lowp_imat2; + + /// Low-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 lowp_imat3; + + /// Low-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 lowp_imat4; + + + /// Low-precision signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 lowp_imat2x2; + + /// Low-precision signed integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 lowp_imat2x3; + + /// Low-precision signed integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 lowp_imat2x4; + + /// Low-precision signed integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 lowp_imat3x2; + + /// Low-precision signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 lowp_imat3x3; + + /// Low-precision signed integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 lowp_imat3x4; + + /// Low-precision signed integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 lowp_imat4x2; + + /// Low-precision signed integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 lowp_imat4x3; + + /// Low-precision signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 lowp_imat4x4; + + + /// High-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 highp_umat2; + + /// High-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 highp_umat3; + + /// High-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 highp_umat4; + + /// High-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 highp_umat2x2; + + /// High-precision unsigned integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 highp_umat2x3; + + /// High-precision unsigned integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 highp_umat2x4; + + /// High-precision unsigned integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 highp_umat3x2; + + /// High-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 highp_umat3x3; + + /// High-precision unsigned integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 highp_umat3x4; + + /// High-precision unsigned integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 highp_umat4x2; + + /// High-precision unsigned integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 highp_umat4x3; + + /// High-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 highp_umat4x4; + + + /// Medium-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 mediump_umat2; + + /// Medium-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 mediump_umat3; + + /// Medium-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 mediump_umat4; + + + /// Medium-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 mediump_umat2x2; + + /// Medium-precision unsigned integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 mediump_umat2x3; + + /// Medium-precision unsigned integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 mediump_umat2x4; + + /// Medium-precision unsigned integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 mediump_umat3x2; + + /// Medium-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 mediump_umat3x3; + + /// Medium-precision unsigned integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 mediump_umat3x4; + + /// Medium-precision unsigned integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 mediump_umat4x2; + + /// Medium-precision unsigned integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 mediump_umat4x3; + + /// Medium-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 mediump_umat4x4; + + + /// Low-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 lowp_umat2; + + /// Low-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 lowp_umat3; + + /// Low-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 lowp_umat4; + + + /// Low-precision unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x2 lowp_umat2x2; + + /// Low-precision unsigned integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x3 lowp_umat2x3; + + /// Low-precision unsigned integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat2x4 lowp_umat2x4; + + /// Low-precision unsigned integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x2 lowp_umat3x2; + + /// Low-precision unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x3 lowp_umat3x3; + + /// Low-precision unsigned integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat3x4 lowp_umat3x4; + + /// Low-precision unsigned integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x2 lowp_umat4x2; + + /// Low-precision unsigned integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x3 lowp_umat4x3; + + /// Low-precision unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef detail::tmat4x4 lowp_umat4x4; + +#if(defined(GLM_PRECISION_HIGHP_INT)) + typedef highp_imat2 imat2; + typedef highp_imat3 imat3; + typedef highp_imat4 imat4; + typedef highp_imat2x2 imat2x2; + typedef highp_imat2x3 imat2x3; + typedef highp_imat2x4 imat2x4; + typedef highp_imat3x2 imat3x2; + typedef highp_imat3x3 imat3x3; + typedef highp_imat3x4 imat3x4; + typedef highp_imat4x2 imat4x2; + typedef highp_imat4x3 imat4x3; + typedef highp_imat4x4 imat4x4; +#elif(defined(GLM_PRECISION_LOWP_INT)) + typedef lowp_imat2 imat2; + typedef lowp_imat3 imat3; + typedef lowp_imat4 imat4; + typedef lowp_imat2x2 imat2x2; + typedef lowp_imat2x3 imat2x3; + typedef lowp_imat2x4 imat2x4; + typedef lowp_imat3x2 imat3x2; + typedef lowp_imat3x3 imat3x3; + typedef lowp_imat3x4 imat3x4; + typedef lowp_imat4x2 imat4x2; + typedef lowp_imat4x3 imat4x3; + typedef lowp_imat4x4 imat4x4; +#else //if(defined(GLM_PRECISION_MEDIUMP_INT)) + + /// Signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat2 imat2; + + /// Signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat3 imat3; + + /// Signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat4 imat4; + + /// Signed integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat2x2 imat2x2; + + /// Signed integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat2x3 imat2x3; + + /// Signed integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat2x4 imat2x4; + + /// Signed integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat3x2 imat3x2; + + /// Signed integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat3x3 imat3x3; + + /// Signed integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat3x4 imat3x4; + + /// Signed integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat4x2 imat4x2; + + /// Signed integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat4x3 imat4x3; + + /// Signed integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_imat4x4 imat4x4; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_UINT)) + typedef highp_umat2 umat2; + typedef highp_umat3 umat3; + typedef highp_umat4 umat4; + typedef highp_umat2x2 umat2x2; + typedef highp_umat2x3 umat2x3; + typedef highp_umat2x4 umat2x4; + typedef highp_umat3x2 umat3x2; + typedef highp_umat3x3 umat3x3; + typedef highp_umat3x4 umat3x4; + typedef highp_umat4x2 umat4x2; + typedef highp_umat4x3 umat4x3; + typedef highp_umat4x4 umat4x4; +#elif(defined(GLM_PRECISION_LOWP_UINT)) + typedef lowp_umat2 umat2; + typedef lowp_umat3 umat3; + typedef lowp_umat4 umat4; + typedef lowp_umat2x2 umat2x2; + typedef lowp_umat2x3 umat2x3; + typedef lowp_umat2x4 umat2x4; + typedef lowp_umat3x2 umat3x2; + typedef lowp_umat3x3 umat3x3; + typedef lowp_umat3x4 umat3x4; + typedef lowp_umat4x2 umat4x2; + typedef lowp_umat4x3 umat4x3; + typedef lowp_umat4x4 umat4x4; +#else //if(defined(GLM_PRECISION_MEDIUMP_UINT)) + + /// Unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat2 umat2; + + /// Unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat3 umat3; + + /// Unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat4 umat4; + + /// Unsigned integer 2x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat2x2 umat2x2; + + /// Unsigned integer 2x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat2x3 umat2x3; + + /// Unsigned integer 2x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat2x4 umat2x4; + + /// Unsigned integer 3x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat3x2 umat3x2; + + /// Unsigned integer 3x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat3x3 umat3x3; + + /// Unsigned integer 3x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat3x4 umat3x4; + + /// Unsigned integer 4x2 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat4x2 umat4x2; + + /// Unsigned integer 4x3 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat4x3 umat4x3; + + /// Unsigned integer 4x4 matrix. + /// @see gtc_matrix_integer + typedef mediump_umat4x4 umat4x4; +#endif//GLM_PRECISION + + /// @} +}//namespace glm + +#endif//GLM_GTC_matrix_integer diff --git a/src/libraries/glm/gtc/matrix_inverse.hpp b/src/libraries/glm/gtc/matrix_inverse.hpp new file mode 100755 index 0000000..77d702d --- /dev/null +++ b/src/libraries/glm/gtc/matrix_inverse.hpp @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_inverse +/// @file glm/gtc/matrix_inverse.hpp +/// @date 2005-12-21 / 2011-06-05 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_matrix_inverse GLM_GTC_matrix_inverse +/// @ingroup gtc +/// +/// Defines additional matrix inverting functions. +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_matrix_inverse +#define GLM_GTC_matrix_inverse GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_matrix_inverse extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_matrix_inverse + /// @{ + + /// Fast matrix inverse for affine matrix. + /// + /// @param m Input matrix to invert. + /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. + /// @see gtc_matrix_inverse + template + genType affineInverse(genType const & m); + + /// Compute the inverse transpose of a matrix. + /// + /// @param m Input matrix to invert transpose. + /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. + /// @see gtc_matrix_inverse + template + GLM_FUNC_QUALIFIER typename genType::value_type inverseTranspose( + genType const & m); + + /// @} +}//namespace glm + +#include "matrix_inverse.inl" + +#endif//GLM_GTC_matrix_inverse diff --git a/src/libraries/glm/gtc/matrix_inverse.inl b/src/libraries/glm/gtc/matrix_inverse.inl new file mode 100755 index 0000000..c6deb06 --- /dev/null +++ b/src/libraries/glm/gtc/matrix_inverse.inl @@ -0,0 +1,159 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_inverse +/// @file glm/gtc/matrix_inverse.inl +/// @date 2005-12-21 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + GLM_FUNC_QUALIFIER detail::tmat3x3 affineInverse + ( + detail::tmat3x3 const & m + ) + { + detail::tmat3x3 Result(m); + Result[2] = detail::tvec3(0, 0, 1); + Result = transpose(Result); + detail::tvec3 Translation = Result * detail::tvec3(-detail::tvec2(m[2]), m[2][2]); + Result[2] = Translation; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 affineInverse + ( + detail::tmat4x4 const & m + ) + { + detail::tmat4x4 Result(m); + Result[3] = detail::tvec4(0, 0, 0, 1); + Result = transpose(Result); + detail::tvec4 Translation = Result * detail::tvec4(-detail::tvec3(m[3]), m[3][3]); + Result[3] = Translation; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat2x2 inverseTranspose + ( + detail::tmat2x2 const & m + ) + { + valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + + detail::tmat2x2 Inverse( + + m[1][1] / Determinant, + - m[0][1] / Determinant, + - m[1][0] / Determinant, + + m[0][0] / Determinant); + + return Inverse; + } + + template + GLM_FUNC_QUALIFIER detail::tmat3x3 inverseTranspose + ( + detail::tmat3x3 const & m + ) + { + valType 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 Inverse; + Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + Inverse /= Determinant; + + return Inverse; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 inverseTranspose + ( + detail::tmat4x4 const & m + ) + { + valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + detail::tmat4x4 Inverse; + Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02); + Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04); + Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05); + Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05); + + Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02); + Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04); + Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05); + Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05); + + Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08); + Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10); + Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12); + Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12); + + Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15); + Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17); + Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18); + Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18); + + valType Determinant = + + m[0][0] * Inverse[0][0] + + m[0][1] * Inverse[0][1] + + m[0][2] * Inverse[0][2] + + m[0][3] * Inverse[0][3]; + + Inverse /= Determinant; + + return Inverse; + } +}//namespace glm diff --git a/src/libraries/glm/gtc/matrix_transform.hpp b/src/libraries/glm/gtc/matrix_transform.hpp new file mode 100755 index 0000000..128209a --- /dev/null +++ b/src/libraries/glm/gtc/matrix_transform.hpp @@ -0,0 +1,291 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_transform +/// @file glm/gtc/matrix_transform.hpp +/// @date 2009-04-29 / 2011-05-16 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_transform +/// @see gtx_transform2 +/// +/// @defgroup gtc_matrix_transform GLM_GTC_matrix_transform +/// @ingroup gtc +/// +/// @brief Defines functions that generate common transformation matrices. +/// +/// The matrices generated by this extension use standard OpenGL fixed-function +/// conventions. For example, the lookAt function generates a transform from world +/// space into the specific eye space that the projective matrix functions +/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility +/// specifications defines the particular layout of this eye space. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_matrix_transform +#define GLM_GTC_matrix_transform GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_matrix_transform extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_matrix_transform + /// @{ + + /// Builds a translation 4 * 4 matrix created from a vector of 3 components. + /// + /// @param m Input matrix multiplied by this translation matrix. + /// @param v Coordinates of a translation vector. + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @code + /// #include + /// #include + /// ... + /// glm::mat4 m = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f)); + /// // m[0][0] == 1.0f, m[0][1] == 0.0f, m[0][2] == 0.0f, m[0][3] == 0.0f + /// // m[1][0] == 0.0f, m[1][1] == 1.0f, m[1][2] == 0.0f, m[1][3] == 0.0f + /// // m[2][0] == 0.0f, m[2][1] == 0.0f, m[2][2] == 1.0f, m[2][3] == 0.0f + /// // m[3][0] == 1.0f, m[3][1] == 1.0f, m[3][2] == 1.0f, m[3][3] == 1.0f + /// @endcode + /// @see gtc_matrix_transform + /// @see gtx_transform + /// @see - translate(T x, T y, T z) + /// @see - translate(detail::tmat4x4 const & m, T x, T y, T z) + /// @see - translate(detail::tvec3 const & v) + template + detail::tmat4x4 translate( + detail::tmat4x4 const & m, + detail::tvec3 const & v); + + /// Builds a rotation 4 * 4 matrix created from an axis vector and an angle. + /// + /// @param m Input matrix multiplied by this rotation matrix. + /// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// @param axis Rotation axis, recommanded to be normalized. + /// @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 const & m, T angle, T x, T y, T z) + /// @see - rotate(T angle, detail::tvec3 const & v) + template + detail::tmat4x4 rotate( + detail::tmat4x4 const & m, + T const & angle, + detail::tvec3 const & axis); + + /// Builds a scale 4 * 4 matrix created from 3 scalars. + /// + /// @param m Input matrix multiplied by this scale matrix. + /// @param v Ratio of scaling for each axis. + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + /// @see gtx_transform + /// @see - scale(T x, T y, T z) scale(T const & x, T const & y, T const & z) + /// @see - scale(detail::tmat4x4 const & m, T x, T y, T z) + /// @see - scale(detail::tvec3 const & v) + template + detail::tmat4x4 scale( + detail::tmat4x4 const & m, + detail::tvec3 const & v); + + /// Creates a matrix for an orthographic parallel viewing volume. + /// + /// @param left + /// @param right + /// @param bottom + /// @param top + /// @param zNear + /// @param zFar + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + /// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top) + template + detail::tmat4x4 ortho( + T const & left, + T const & right, + T const & bottom, + T const & top, + T const & zNear, + T const & zFar); + + /// Creates a matrix for projecting two-dimensional coordinates onto the screen. + /// + /// @param left + /// @param right + /// @param bottom + /// @param top + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + /// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar) + template + detail::tmat4x4 ortho( + T const & left, + T const & right, + T const & bottom, + T const & top); + + /// Creates a frustum matrix. + /// + /// @param left + /// @param right + /// @param bottom + /// @param top + /// @param near + /// @param far + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + detail::tmat4x4 frustum( + T const & left, + T const & right, + T const & bottom, + T const & top, + T const & near, + T const & 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 + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + detail::tmat4x4 perspective( + T const & fovy, + T const & aspect, + T const & near, + T const & 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 width + /// @param height + /// @param near + /// @param far + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + detail::tmat4x4 perspectiveFov( + valType const & fov, + valType const & width, + valType const & height, + valType const & near, + valType const & 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 + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + detail::tmat4x4 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 + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + detail::tmat4x4 tweakedInfinitePerspective( + T fovy, T aspect, T near); + + /// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates. + /// + /// @param obj + /// @param model + /// @param proj + /// @param viewport + /// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double. + /// @tparam U Currently supported: Floating-point types and integer types. + /// @see gtc_matrix_transform + template + detail::tvec3 project( + detail::tvec3 const & obj, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport); + + /// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates. + /// + /// @param win + /// @param model + /// @param proj + /// @param viewport + /// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double. + /// @tparam U Currently supported: Floating-point types and integer types. + /// @see gtc_matrix_transform + template + detail::tvec3 unProject( + detail::tvec3 const & win, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport); + + /// Define a picking region + /// + /// @param center + /// @param delta + /// @param viewport + /// @tparam T Native type used for the computation. Currently supported: half (not recommanded), float or double. + /// @tparam U Currently supported: Floating-point types and integer types. + /// @see gtc_matrix_transform + template + detail::tmat4x4 pickMatrix( + detail::tvec2 const & center, + detail::tvec2 const & delta, + detail::tvec4 const & viewport); + + /// Build a look at view matrix. + /// + /// @param eye Position of the camera + /// @param center Position where the camera is looking at + /// @param up Normalized up vector, how the camera is oriented. Typically (0, 0, 1) + /// @see gtc_matrix_transform + /// @see - frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) frustum(T const & left, T const & right, T const & bottom, T const & top, T const & nearVal, T const & farVal) + template + detail::tmat4x4 lookAt( + detail::tvec3 const & eye, + detail::tvec3 const & center, + detail::tvec3 const & up); + + /// @} +}//namespace glm + +#include "matrix_transform.inl" + +#endif//GLM_GTC_matrix_transform diff --git a/src/libraries/glm/gtc/matrix_transform.inl b/src/libraries/glm/gtc/matrix_transform.inl new file mode 100755 index 0000000..2245a4f --- /dev/null +++ b/src/libraries/glm/gtc/matrix_transform.inl @@ -0,0 +1,430 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_matrix_transform +/// @file glm/gtc/matrix_transform.inl +/// @date 2009-04-29 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + GLM_FUNC_QUALIFIER detail::tmat4x4 translate + ( + detail::tmat4x4 const & m, + detail::tvec3 const & v + ) + { + detail::tmat4x4 Result(m); + Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 rotate + ( + detail::tmat4x4 const & m, + T const & angle, + detail::tvec3 const & v + ) + { +#ifdef GLM_FORCE_RADIANS + T a = angle; +#else + T a = radians(angle); +#endif + T c = cos(a); + T s = sin(a); + + detail::tvec3 axis = normalize(v); + + detail::tvec3 temp = (T(1) - c) * axis; + + detail::tmat4x4 Rotate(detail::tmat4x4::null); + Rotate[0][0] = c + temp[0] * axis[0]; + Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; + Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; + + Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; + Rotate[1][1] = c + temp[1] * axis[1]; + Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; + + Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; + Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; + Rotate[2][2] = c + temp[2] * axis[2]; + + detail::tmat4x4 Result(detail::tmat4x4::null); + Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2]; + Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2]; + Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2]; + Result[3] = m[3]; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 scale + ( + detail::tmat4x4 const & m, + detail::tvec3 const & v + ) + { + detail::tmat4x4 Result(detail::tmat4x4::null); + Result[0] = m[0] * v[0]; + Result[1] = m[1] * v[1]; + Result[2] = m[2] * v[2]; + Result[3] = m[3]; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 translate_slow + ( + detail::tmat4x4 const & m, + detail::tvec3 const & v + ) + { + detail::tmat4x4 Result(T(1)); + Result[3] = detail::tvec4(v, T(1)); + return m * Result; + + //detail::tmat4x4 Result(m); + Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; + //Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0]; + //Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1]; + //Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; + //Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; + //return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 rotate_slow + ( + detail::tmat4x4 const & m, + T const & angle, + detail::tvec3 const & v + ) + { +#ifdef GLM_FORCE_RADIANS + T const a = angle; +#else + T const a = radians(angle); +#endif + T c = cos(a); + T s = sin(a); + detail::tmat4x4 Result; + + detail::tvec3 axis = normalize(v); + + Result[0][0] = c + (1 - c) * axis.x * axis.x; + Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; + Result[0][3] = 0; + + Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (1 - c) * axis.y * axis.y; + Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; + Result[1][3] = 0; + + Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y; + Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x; + Result[2][2] = c + (1 - c) * axis.z * axis.z; + Result[2][3] = 0; + + Result[3] = detail::tvec4(0, 0, 0, 1); + return m * Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 scale_slow + ( + detail::tmat4x4 const & m, + detail::tvec3 const & v + ) + { + detail::tmat4x4 Result(T(1)); + Result[0][0] = v.x; + Result[1][1] = v.y; + Result[2][2] = v.z; + return m * Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 ortho + ( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top, + valType const & zNear, + valType const & zFar + ) + { + detail::tmat4x4 Result(1); + Result[0][0] = valType(2) / (right - left); + Result[1][1] = valType(2) / (top - bottom); + Result[2][2] = - valType(2) / (zFar - zNear); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - (zFar + zNear) / (zFar - zNear); + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 ortho( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top) + { + detail::tmat4x4 Result(1); + Result[0][0] = valType(2) / (right - left); + Result[1][1] = valType(2) / (top - bottom); + Result[2][2] = - valType(1); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 frustum + ( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top, + valType const & nearVal, + valType const & farVal + ) + { + detail::tmat4x4 Result(0); + Result[0][0] = (valType(2) * nearVal) / (right - left); + Result[1][1] = (valType(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 + GLM_FUNC_QUALIFIER detail::tmat4x4 perspective + ( + valType const & fovy, + valType const & aspect, + valType const & zNear, + valType const & zFar + ) + { + valType range = tan(radians(fovy / valType(2))) * zNear; + valType left = -range * aspect; + valType right = range * aspect; + valType bottom = -range; + valType top = range; + + detail::tmat4x4 Result(valType(0)); + Result[0][0] = (valType(2) * zNear) / (right - left); + Result[1][1] = (valType(2) * zNear) / (top - bottom); + Result[2][2] = - (zFar + zNear) / (zFar - zNear); + Result[2][3] = - valType(1); + Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 perspectiveFov + ( + valType const & fov, + valType const & width, + valType const & height, + valType const & zNear, + valType const & zFar + ) + { +#ifdef GLM_FORCE_RADIANS + valType rad = fov; +#else + valType rad = glm::radians(fov); +#endif + valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad); + valType w = h * height / width; ///todo max(width , Height) / min(width , Height)? + + detail::tmat4x4 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); + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 infinitePerspective + ( + T fovy, + T aspect, + T zNear + ) + { +#ifdef GLM_FORCE_RADIANS + T const range = tan(fovy / T(2)) * zNear; +#else + T const range = tan(radians(fovy / T(2))) * zNear; +#endif + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; + + detail::tmat4x4 Result(T(0)); + Result[0][0] = (T(2) * zNear) / (right - left); + Result[1][1] = (T(2) * zNear) / (top - bottom); + Result[2][2] = - T(1); + Result[2][3] = - T(1); + Result[3][2] = - T(2) * zNear; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 tweakedInfinitePerspective + ( + T fovy, + T aspect, + T zNear + ) + { +#ifdef GLM_FORCE_RADIANS + T range = tan(fovy / T(2)) * zNear; +#else + T range = tan(radians(fovy / T(2))) * zNear; +#endif + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; + + detail::tmat4x4 Result(T(0)); + Result[0][0] = (T(2) * zNear) / (right - left); + Result[1][1] = (T(2) * zNear) / (top - bottom); + Result[2][2] = T(0.0001) - T(1); + Result[2][3] = T(-1); + Result[3][2] = - (T(0.0001) - T(2)) * zNear; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 project + ( + detail::tvec3 const & obj, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport + ) + { + detail::tvec4 tmp = detail::tvec4(obj, T(1)); + tmp = model * tmp; + tmp = proj * tmp; + + tmp /= tmp.w; + tmp = tmp * T(0.5) + T(0.5); + tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); + tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); + + return detail::tvec3(tmp); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 unProject + ( + detail::tvec3 const & win, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport + ) + { + detail::tmat4x4 inverse = glm::inverse(proj * model); + + detail::tvec4 tmp = detail::tvec4(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 obj = inverse * tmp; + obj /= obj.w; + + return detail::tvec3(obj); + } + + template + detail::tmat4x4 pickMatrix + ( + detail::tvec2 const & center, + detail::tvec2 const & delta, + detail::tvec4 const & viewport + ) + { + assert(delta.x > T(0) && delta.y > T(0)); + detail::tmat4x4 Result(1.0f); + + if(!(delta.x > T(0) && delta.y > T(0))) + return Result; // Error + + detail::tvec3 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(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1))); + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 lookAt + ( + detail::tvec3 const & eye, + detail::tvec3 const & center, + detail::tvec3 const & up + ) + { + detail::tvec3 f = normalize(center - eye); + detail::tvec3 u = normalize(up); + detail::tvec3 s = normalize(cross(f, u)); + u = cross(s, f); + + detail::tmat4x4 Result(1); + Result[0][0] = s.x; + Result[1][0] = s.y; + Result[2][0] = s.z; + Result[0][1] = u.x; + Result[1][1] = u.y; + Result[2][1] = u.z; + Result[0][2] =-f.x; + Result[1][2] =-f.y; + Result[2][2] =-f.z; + Result[3][0] =-dot(s, eye); + Result[3][1] =-dot(u, eye); + Result[3][2] = dot(f, eye); + return Result; + } +}//namespace glm diff --git a/src/libraries/glm/gtc/noise.hpp b/src/libraries/glm/gtc/noise.hpp new file mode 100755 index 0000000..d828b40 --- /dev/null +++ b/src/libraries/glm/gtc/noise.hpp @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_noise +/// @file glm/gtc/noise.hpp +/// @date 2011-04-21 / 2011-09-27 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_noise GLM_GTC_noise +/// @ingroup gtc +/// +/// Defines 2D, 3D and 4D procedural noise functions +/// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": +/// https://github.com/ashima/webgl-noise +/// Following Stefan Gustavson's paper "Simplex noise demystified": +/// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_noise +#define GLM_GTC_noise GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_noise extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_noise + /// @{ + + /// Classic perlin noise. + /// @see gtc_noise + template class vecType> + T perlin( + vecType const & p); + + /// Periodic perlin noise. + /// @see gtc_noise + template class vecType> + T perlin( + vecType const & p, + vecType const & rep); + + /// Simplex noise. + /// @see gtc_noise + template class vecType> + T simplex( + vecType const & p); + + /// @} +}//namespace glm + +#include "noise.inl" + +#endif//GLM_GTC_noise diff --git a/src/libraries/glm/gtc/noise.inl b/src/libraries/glm/gtc/noise.inl new file mode 100755 index 0000000..740b159 --- /dev/null +++ b/src/libraries/glm/gtc/noise.inl @@ -0,0 +1,867 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_noise +/// @file glm/gtc/noise.inl +/// @date 2011-04-21 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// +// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": +// https://github.com/ashima/webgl-noise +// Following Stefan Gustavson's paper "Simplex noise demystified": +// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template + GLM_FUNC_QUALIFIER T mod289(T const & x) + { + return x - floor(x * T(1.0 / 289.0)) * T(289.0); + } + + template + GLM_FUNC_QUALIFIER T permute(T const & x) + { + return mod289(((x * T(34)) + T(1)) * x); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType permute(vecType const & x) + { + return mod289(((x * T(34)) + T(1)) * x); + } + + template + GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType fade(vecType const & t) + { + return t * t * t * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 grad4(T const & j, detail::tvec4 const & ip) + { + detail::tvec3 pXYZ = floor(fract(detail::tvec3(j) * detail::tvec3(ip)) * T(7)) * ip[2] - T(1); + T pW = T(1.5) - dot(abs(pXYZ), detail::tvec3(1)); + detail::tvec4 s = detail::tvec4(lessThan(detail::tvec4(pXYZ, pW), detail::tvec4(0.0))); + pXYZ = pXYZ + (detail::tvec3(s) * T(2) - T(1)) * s.w; + return detail::tvec4(pXYZ, pW); + } + + // Classic Perlin noise + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P) + { + detail::tvec4 Pi = glm::floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); + detail::tvec4 Pf = glm::fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); + Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation + detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); + detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); + detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); + detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); + + detail::tvec4 i = glm::permute(glm::permute(ix) + iy); + + detail::tvec4 gx = T(2) * glm::fract(i / T(41)) - T(1); + detail::tvec4 gy = glm::abs(gx) - T(0.5); + detail::tvec4 tx = glm::floor(gx + T(0.5)); + gx = gx - tx; + + detail::tvec2 g00(gx.x, gy.x); + detail::tvec2 g10(gx.y, gy.y); + detail::tvec2 g01(gx.z, gy.z); + detail::tvec2 g11(gx.w, gy.w); + + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); + T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); + T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); + T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); + + detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); + detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); + T n_xy = mix(n_x.x, n_x.y, fade_xy.y); + return T(2.3) * n_xy; + } + + // Classic Perlin noise + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P) + { + detail::tvec3 Pi0 = floor(P); // Integer part for indexing + detail::tvec3 Pi1 = Pi0 + T(1); // Integer part + 1 + Pi0 = mod289(Pi0); + Pi1 = mod289(Pi1); + detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec3 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy = detail::tvec4(detail::tvec2(Pi0.y), detail::tvec2(Pi1.y)); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + + detail::tvec4 gx0 = ixy0 * T(1.0 / 7.0); + detail::tvec4 gy0 = fract(floor(gx0) * T(1.0 / 7.0)) - T(0.5); + gx0 = fract(gx0); + detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); + detail::tvec4 sz0 = step(gz0, detail::tvec4(0.0)); + gx0 -= sz0 * (step(T(0), gx0) - T(0.5)); + gy0 -= sz0 * (step(T(0), gy0) - T(0.5)); + + detail::tvec4 gx1 = ixy1 * T(1.0 / 7.0); + detail::tvec4 gy1 = fract(floor(gx1) * T(1.0 / 7.0)) - T(0.5); + gx1 = fract(gx1); + detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); + detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); + gx1 -= sz1 * (step(T(0), gx1) - T(0.5)); + gy1 -= sz1 * (step(T(0), gy1) - T(0.5)); + + detail::tvec3 g000(gx0.x, gy0.x, gz0.x); + detail::tvec3 g100(gx0.y, gy0.y, gz0.y); + detail::tvec3 g010(gx0.z, gy0.z, gz0.z); + detail::tvec3 g110(gx0.w, gy0.w, gz0.w); + detail::tvec3 g001(gx1.x, gy1.x, gz1.x); + detail::tvec3 g101(gx1.y, gy1.y, gz1.y); + detail::tvec3 g011(gx1.z, gy1.z, gz1.z); + detail::tvec3 g111(gx1.w, gy1.w, gz1.w); + + detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + T n000 = dot(g000, Pf0); + T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); + T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); + T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); + T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); + T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); + T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); + T n111 = dot(g111, Pf1); + + detail::tvec3 fade_xyz = fade(Pf0); + detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); + detail::tvec2 n_yz = mix(detail::tvec2(n_z.x, n_z.y), detail::tvec2(n_z.z, n_z.w), fade_xyz.y); + T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return T(2.2) * n_xyz; + } + /* + // Classic Perlin noise + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P) + { + detail::tvec3 Pi0 = floor(P); // Integer part for indexing + detail::tvec3 Pi1 = Pi0 + T(1); // Integer part + 1 + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec3 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + + detail::tvec4 gx0 = ixy0 / T(7); + detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); + gx0 = fract(gx0); + detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); + detail::tvec4 sz0 = step(gz0, detail::tvec4(0.0)); + gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); + gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); + + detail::tvec4 gx1 = ixy1 / T(7); + detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); + gx1 = fract(gx1); + detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); + detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); + gx1 -= sz1 * (step(T(0), gx1) - T(0.5)); + gy1 -= sz1 * (step(T(0), gy1) - T(0.5)); + + detail::tvec3 g000(gx0.x, gy0.x, gz0.x); + detail::tvec3 g100(gx0.y, gy0.y, gz0.y); + detail::tvec3 g010(gx0.z, gy0.z, gz0.z); + detail::tvec3 g110(gx0.w, gy0.w, gz0.w); + detail::tvec3 g001(gx1.x, gy1.x, gz1.x); + detail::tvec3 g101(gx1.y, gy1.y, gz1.y); + detail::tvec3 g011(gx1.z, gy1.z, gz1.z); + detail::tvec3 g111(gx1.w, gy1.w, gz1.w); + + detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + T n000 = dot(g000, Pf0); + T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); + T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); + T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); + T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); + T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); + T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); + T n111 = dot(g111, Pf1); + + detail::tvec3 fade_xyz = fade(Pf0); + detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); + detail::tvec2 n_yz = mix( + detail::tvec2(n_z.x, n_z.y), + detail::tvec2(n_z.z, n_z.w), fade_xyz.y); + T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return T(2.2) * n_xyz; + } + */ + // Classic Perlin noise + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P) + { + detail::tvec4 Pi0 = floor(P); // Integer part for indexing + detail::tvec4 Pi1 = Pi0 + T(1); // Integer part + 1 + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + detail::tvec4 iw0(Pi0.w); + detail::tvec4 iw1(Pi1.w); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + detail::tvec4 ixy00 = permute(ixy0 + iw0); + detail::tvec4 ixy01 = permute(ixy0 + iw1); + detail::tvec4 ixy10 = permute(ixy1 + iw0); + detail::tvec4 ixy11 = permute(ixy1 + iw1); + + detail::tvec4 gx00 = ixy00 / T(7); + detail::tvec4 gy00 = floor(gx00) / T(7); + detail::tvec4 gz00 = floor(gy00) / T(6); + gx00 = fract(gx00) - T(0.5); + gy00 = fract(gy00) - T(0.5); + gz00 = fract(gz00) - T(0.5); + detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + detail::tvec4 sw00 = step(gw00, detail::tvec4(0.0)); + gx00 -= sw00 * (step(T(0), gx00) - T(0.5)); + gy00 -= sw00 * (step(T(0), gy00) - T(0.5)); + + detail::tvec4 gx01 = ixy01 / T(7); + detail::tvec4 gy01 = floor(gx01) / T(7); + detail::tvec4 gz01 = floor(gy01) / T(6); + gx01 = fract(gx01) - T(0.5); + gy01 = fract(gy01) - T(0.5); + gz01 = fract(gz01) - T(0.5); + detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); + gx01 -= sw01 * (step(T(0), gx01) - T(0.5)); + gy01 -= sw01 * (step(T(0), gy01) - T(0.5)); + + detail::tvec4 gx10 = ixy10 / T(7); + detail::tvec4 gy10 = floor(gx10) / T(7); + detail::tvec4 gz10 = floor(gy10) / T(6); + gx10 = fract(gx10) - T(0.5); + gy10 = fract(gy10) - T(0.5); + gz10 = fract(gz10) - T(0.5); + detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + detail::tvec4 sw10 = step(gw10, detail::tvec4(0)); + gx10 -= sw10 * (step(T(0), gx10) - T(0.5)); + gy10 -= sw10 * (step(T(0), gy10) - T(0.5)); + + detail::tvec4 gx11 = ixy11 / T(7); + detail::tvec4 gy11 = floor(gx11) / T(7); + detail::tvec4 gz11 = floor(gy11) / T(6); + gx11 = fract(gx11) - T(0.5); + gy11 = fract(gy11) - T(0.5); + gz11 = fract(gz11) - T(0.5); + detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); + gx11 -= sw11 * (step(T(0), gx11) - T(0.5)); + gy11 -= sw11 * (step(T(0), gy11) - T(0.5)); + + detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); + detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); + detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); + detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); + detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); + detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); + detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); + detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); + detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); + detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); + detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); + detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); + detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); + detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); + detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); + detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); + + detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + T n0000 = dot(g0000, Pf0); + T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); + T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); + T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); + T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); + T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); + T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); + T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); + T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); + T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); + T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); + T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); + T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); + T n1111 = dot(g1111, Pf1); + + detail::tvec4 fade_xyzw = fade(Pf0); + detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); + T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return T(2.2) * n_xyzw; + } + + // Classic Perlin noise, periodic variant + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P, detail::tvec2 const & rep) + { + detail::tvec4 Pi = floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); + detail::tvec4 Pf = fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); + Pi = mod(Pi, detail::tvec4(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period + Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation + detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); + detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); + detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); + detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); + + detail::tvec4 i = permute(permute(ix) + iy); + + detail::tvec4 gx = T(2) * fract(i / T(41)) - T(1); + detail::tvec4 gy = abs(gx) - T(0.5); + detail::tvec4 tx = floor(gx + T(0.5)); + gx = gx - tx; + + detail::tvec2 g00(gx.x, gy.x); + detail::tvec2 g10(gx.y, gy.y); + detail::tvec2 g01(gx.z, gy.z); + detail::tvec2 g11(gx.w, gy.w); + + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); + T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); + T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); + T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); + + detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); + detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); + T n_xy = mix(n_x.x, n_x.y, fade_xy.y); + return T(2.3) * n_xy; + } + + // Classic Perlin noise, periodic variant + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P, detail::tvec3 const & rep) + { + detail::tvec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period + detail::tvec3 Pi1 = mod(Pi0 + detail::tvec3(1.0), rep); // Integer part + 1, mod period + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec3 Pf1 = Pf0 - detail::tvec3(1.0); // Fractional part - 1.0 + detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + + detail::tvec4 gx0 = ixy0 / T(7); + detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); + gx0 = fract(gx0); + detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); + detail::tvec4 sz0 = step(gz0, detail::tvec4(0)); + gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); + gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); + + detail::tvec4 gx1 = ixy1 / T(7); + detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); + gx1 = fract(gx1); + detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); + detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); + gx1 -= sz1 * (step(0.0, gx1) - T(0.5)); + gy1 -= sz1 * (step(0.0, gy1) - T(0.5)); + + detail::tvec3 g000 = detail::tvec3(gx0.x, gy0.x, gz0.x); + detail::tvec3 g100 = detail::tvec3(gx0.y, gy0.y, gz0.y); + detail::tvec3 g010 = detail::tvec3(gx0.z, gy0.z, gz0.z); + detail::tvec3 g110 = detail::tvec3(gx0.w, gy0.w, gz0.w); + detail::tvec3 g001 = detail::tvec3(gx1.x, gy1.x, gz1.x); + detail::tvec3 g101 = detail::tvec3(gx1.y, gy1.y, gz1.y); + detail::tvec3 g011 = detail::tvec3(gx1.z, gy1.z, gz1.z); + detail::tvec3 g111 = detail::tvec3(gx1.w, gy1.w, gz1.w); + + detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + T n000 = dot(g000, Pf0); + T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); + T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); + T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); + T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); + T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); + T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); + T n111 = dot(g111, Pf1); + + detail::tvec3 fade_xyz = fade(Pf0); + detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); + detail::tvec2 n_yz = mix(detail::tvec2(n_z.x, n_z.y), detail::tvec2(n_z.z, n_z.w), fade_xyz.y); + T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return T(2.2) * n_xyz; + } + + // Classic Perlin noise, periodic version + template + GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P, detail::tvec4 const & rep) + { + detail::tvec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep + detail::tvec4 Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep + detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + detail::tvec4 iw0(Pi0.w); + detail::tvec4 iw1(Pi1.w); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + detail::tvec4 ixy00 = permute(ixy0 + iw0); + detail::tvec4 ixy01 = permute(ixy0 + iw1); + detail::tvec4 ixy10 = permute(ixy1 + iw0); + detail::tvec4 ixy11 = permute(ixy1 + iw1); + + detail::tvec4 gx00 = ixy00 / T(7); + detail::tvec4 gy00 = floor(gx00) / T(7); + detail::tvec4 gz00 = floor(gy00) / T(6); + gx00 = fract(gx00) - T(0.5); + gy00 = fract(gy00) - T(0.5); + gz00 = fract(gz00) - T(0.5); + detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + detail::tvec4 sw00 = step(gw00, detail::tvec4(0)); + gx00 -= sw00 * (step(0.0, gx00) - T(0.5)); + gy00 -= sw00 * (step(0.0, gy00) - T(0.5)); + + detail::tvec4 gx01 = ixy01 / T(7); + detail::tvec4 gy01 = floor(gx01) / T(7); + detail::tvec4 gz01 = floor(gy01) / T(6); + gx01 = fract(gx01) - T(0.5); + gy01 = fract(gy01) - T(0.5); + gz01 = fract(gz01) - T(0.5); + detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); + gx01 -= sw01 * (step(0.0, gx01) - T(0.5)); + gy01 -= sw01 * (step(0.0, gy01) - T(0.5)); + + detail::tvec4 gx10 = ixy10 / T(7); + detail::tvec4 gy10 = floor(gx10) / T(7); + detail::tvec4 gz10 = floor(gy10) / T(6); + gx10 = fract(gx10) - T(0.5); + gy10 = fract(gy10) - T(0.5); + gz10 = fract(gz10) - T(0.5); + detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + detail::tvec4 sw10 = step(gw10, detail::tvec4(0.0)); + gx10 -= sw10 * (step(0.0, gx10) - T(0.5)); + gy10 -= sw10 * (step(0.0, gy10) - T(0.5)); + + detail::tvec4 gx11 = ixy11 / T(7); + detail::tvec4 gy11 = floor(gx11) / T(7); + detail::tvec4 gz11 = floor(gy11) / T(6); + gx11 = fract(gx11) - T(0.5); + gy11 = fract(gy11) - T(0.5); + gz11 = fract(gz11) - T(0.5); + detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); + gx11 -= sw11 * (step(0.0, gx11) - T(0.5)); + gy11 -= sw11 * (step(0.0, gy11) - T(0.5)); + + detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); + detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); + detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); + detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); + detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); + detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); + detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); + detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); + detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); + detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); + detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); + detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); + detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); + detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); + detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); + detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); + + detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + T n0000 = dot(g0000, Pf0); + T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); + T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); + T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); + T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); + T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); + T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); + T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); + T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); + T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); + T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); + T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); + T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); + T n1111 = dot(g1111, Pf1); + + detail::tvec4 fade_xyzw = fade(Pf0); + detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); + T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return T(2.2) * n_xyzw; + } + + template + GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2 const & v) + { + detail::tvec4 const C = detail::tvec4( + T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0 + T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0) + T(-0.577350269189626), // -1.0 + 2.0 * C.x + T( 0.024390243902439)); // 1.0 / 41.0 + + // First corner + detail::tvec2 i = floor(v + dot(v, detail::tvec2(C[1]))); + detail::tvec2 x0 = v - i + dot(i, detail::tvec2(C[0])); + + // Other corners + //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 + //i1.y = 1.0 - i1.x; + detail::tvec2 i1 = (x0.x > x0.y) ? detail::tvec2(1, 0) : detail::tvec2(0, 1); + // x0 = x0 - 0.0 + 0.0 * C.xx ; + // x1 = x0 - i1 + 1.0 * C.xx ; + // x2 = x0 - 1.0 + 2.0 * C.xx ; + detail::tvec4 x12 = detail::tvec4(x0.x, x0.y, x0.x, x0.y) + detail::tvec4(C.x, C.x, C.z, C.z); + x12 = detail::tvec4(detail::tvec2(x12) - i1, x12.z, x12.w); + + // Permutations + i = mod(i, T(289)); // Avoid truncation effects in permutation + detail::tvec3 p = permute( + permute(i.y + detail::tvec3(T(0), i1.y, T(1))) + + i.x + detail::tvec3(T(0), i1.x, T(1))); + + detail::tvec3 m = max(T(0.5) - detail::tvec3( + dot(x0, x0), + dot(detail::tvec2(x12.x, x12.y), detail::tvec2(x12.x, x12.y)), + dot(detail::tvec2(x12.z, x12.w), detail::tvec2(x12.z, x12.w))), T(0)); + m = m * m ; + m = m * m ; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + + detail::tvec3 x = T(2) * fract(p * C.w) - T(1); + detail::tvec3 h = abs(x) - T(0.5); + detail::tvec3 ox = floor(x + T(0.5)); + detail::tvec3 a0 = x - ox; + + // Normalise gradients implicitly by scaling m + // Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h ); + m *= T(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h); + + // Compute final noise value at P + detail::tvec3 g; + g.x = a0.x * x0.x + h.x * x0.y; + //g.yz = a0.yz * x12.xz + h.yz * x12.yw; + g.y = a0.y * x12.x + h.y * x12.y; + g.z = a0.z * x12.z + h.z * x12.w; + return T(130) * dot(m, g); + } + + template + GLM_FUNC_QUALIFIER T simplex(detail::tvec3 const & v) + { + detail::tvec2 const C(1.0 / 6.0, 1.0 / 3.0); + detail::tvec4 const D(0.0, 0.5, 1.0, 2.0); + + // First corner + detail::tvec3 i(floor(v + dot(v, detail::tvec3(C.y)))); + detail::tvec3 x0(v - i + dot(i, detail::tvec3(C.x))); + + // Other corners + detail::tvec3 g(step(detail::tvec3(x0.y, x0.z, x0.x), x0)); + detail::tvec3 l(T(1) - g); + detail::tvec3 i1(min(g, detail::tvec3(l.z, l.x, l.y))); + detail::tvec3 i2(max(g, detail::tvec3(l.z, l.x, l.y))); + + // x0 = x0 - 0.0 + 0.0 * C.xxx; + // x1 = x0 - i1 + 1.0 * C.xxx; + // x2 = x0 - i2 + 2.0 * C.xxx; + // x3 = x0 - 1.0 + 3.0 * C.xxx; + detail::tvec3 x1(x0 - i1 + C.x); + detail::tvec3 x2(x0 - i2 + C.y); // 2.0*C.x = 1/3 = C.y + detail::tvec3 x3(x0 - D.y); // -1.0+3.0*C.x = -0.5 = -D.y + + // Permutations + i = mod289(i); + detail::tvec4 p(permute(permute(permute( + i.z + detail::tvec4(T(0), i1.z, i2.z, T(1))) + + i.y + detail::tvec4(T(0), i1.y, i2.y, T(1))) + + i.x + detail::tvec4(T(0), i1.x, i2.x, T(1)))); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + T n_ = T(0.142857142857); // 1.0/7.0 + detail::tvec3 ns(n_ * detail::tvec3(D.w, D.y, D.z) - detail::tvec3(D.x, D.z, D.x)); + + detail::tvec4 j(p - T(49) * floor(p * ns.z * ns.z)); // mod(p,7*7) + + detail::tvec4 x_(floor(j * ns.z)); + detail::tvec4 y_(floor(j - T(7) * x_)); // mod(j,N) + + detail::tvec4 x(x_ * ns.x + ns.y); + detail::tvec4 y(y_ * ns.x + ns.y); + detail::tvec4 h(T(1) - abs(x) - abs(y)); + + detail::tvec4 b0(x.x, x.y, y.x, y.y); + detail::tvec4 b1(x.z, x.w, y.z, y.w); + + // vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; + // vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; + detail::tvec4 s0(floor(b0) * T(2) + T(1)); + detail::tvec4 s1(floor(b1) * T(2) + T(1)); + detail::tvec4 sh(-step(h, detail::tvec4(0.0))); + + detail::tvec4 a0 = detail::tvec4(b0.x, b0.z, b0.y, b0.w) + detail::tvec4(s0.x, s0.z, s0.y, s0.w) * detail::tvec4(sh.x, sh.x, sh.y, sh.y); + detail::tvec4 a1 = detail::tvec4(b1.x, b1.z, b1.y, b1.w) + detail::tvec4(s1.x, s1.z, s1.y, s1.w) * detail::tvec4(sh.z, sh.z, sh.w, sh.w); + + detail::tvec3 p0(a0.x, a0.y, h.x); + detail::tvec3 p1(a0.z, a0.w, h.y); + detail::tvec3 p2(a1.x, a1.y, h.z); + detail::tvec3 p3(a1.z, a1.w, h.w); + + // Normalise gradients + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + + // Mix final noise value + detail::tvec4 m = max(T(0.6) - detail::tvec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), T(0)); + m = m * m; + return T(42) * dot(m * m, detail::tvec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); + } + + template + GLM_FUNC_QUALIFIER T simplex(detail::tvec4 const & v) + { + detail::tvec4 const C( + 0.138196601125011, // (5 - sqrt(5))/20 G4 + 0.276393202250021, // 2 * G4 + 0.414589803375032, // 3 * G4 + -0.447213595499958); // -1 + 4 * G4 + + // (sqrt(5) - 1)/4 = F4, used once below + T const F4 = T(0.309016994374947451); + + // First corner + detail::tvec4 i = floor(v + dot(v, vec4(F4))); + detail::tvec4 x0 = v - i + dot(i, vec4(C.x)); + + // Other corners + + // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) + detail::tvec4 i0; + detail::tvec3 isX = step(detail::tvec3(x0.y, x0.z, x0.w), detail::tvec3(x0.x)); + detail::tvec3 isYZ = step(detail::tvec3(x0.z, x0.w, x0.w), detail::tvec3(x0.y, x0.y, x0.z)); + // i0.x = dot(isX, vec3(1.0)); + //i0.x = isX.x + isX.y + isX.z; + //i0.yzw = T(1) - isX; + i0 = detail::tvec4(isX.x + isX.y + isX.z, T(1) - isX); + // i0.y += dot(isYZ.xy, vec2(1.0)); + i0.y += isYZ.x + isYZ.y; + //i0.zw += 1.0 - detail::tvec2(isYZ.x, isYZ.y); + i0.z += T(1) - isYZ.x; + i0.w += T(1) - isYZ.y; + i0.z += isYZ.z; + i0.w += T(1) - isYZ.z; + + // i0 now contains the unique values 0,1,2,3 in each channel + detail::tvec4 i3 = clamp(i0, 0.0, 1.0); + detail::tvec4 i2 = clamp(i0 - 1.0, 0.0, 1.0); + detail::tvec4 i1 = clamp(i0 - 2.0, 0.0, 1.0); + + // x0 = x0 - 0.0 + 0.0 * C.xxxx + // x1 = x0 - i1 + 0.0 * C.xxxx + // x2 = x0 - i2 + 0.0 * C.xxxx + // x3 = x0 - i3 + 0.0 * C.xxxx + // x4 = x0 - 1.0 + 4.0 * C.xxxx + detail::tvec4 x1 = x0 - i1 + C.x; + detail::tvec4 x2 = x0 - i2 + C.y; + detail::tvec4 x3 = x0 - i3 + C.z; + detail::tvec4 x4 = x0 + C.w; + + // Permutations + i = mod(i, T(289)); + T j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x); + detail::tvec4 j1 = permute(permute(permute(permute( + i.w + detail::tvec4(i1.w, i2.w, i3.w, T(1))) + + i.z + detail::tvec4(i1.z, i2.z, i3.z, T(1))) + + i.y + detail::tvec4(i1.y, i2.y, i3.y, T(1))) + + i.x + detail::tvec4(i1.x, i2.x, i3.x, T(1))); + + // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope + // 7*7*6 = 294, which is close to the ring size 17*17 = 289. + detail::tvec4 ip = detail::tvec4(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0)); + + detail::tvec4 p0 = grad4(j0, ip); + detail::tvec4 p1 = grad4(j1.x, ip); + detail::tvec4 p2 = grad4(j1.y, ip); + detail::tvec4 p3 = grad4(j1.z, ip); + detail::tvec4 p4 = grad4(j1.w, ip); + + // Normalise gradients + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + p4 *= taylorInvSqrt(dot(p4, p4)); + + // Mix contributions from the five corners + detail::tvec3 m0 = max(T(0.6) - detail::tvec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0)); + detail::tvec2 m1 = max(T(0.6) - detail::tvec2(dot(x3, x3), dot(x4, x4) ), T(0)); + m0 = m0 * m0; + m1 = m1 * m1; + return T(49) * + (dot(m0 * m0, detail::tvec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) + + dot(m1 * m1, detail::tvec2(dot(p3, x3), dot(p4, x4)))); + } +}//namespace glm diff --git a/src/libraries/glm/gtc/quaternion.hpp b/src/libraries/glm/gtc/quaternion.hpp new file mode 100755 index 0000000..8e36a85 --- /dev/null +++ b/src/libraries/glm/gtc/quaternion.hpp @@ -0,0 +1,381 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_quaternion +/// @file glm/gtc/quaternion.hpp +/// @date 2009-05-21 / 2012-12-20 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_constants (dependence) +/// +/// @defgroup gtc_quaternion GLM_GTC_quaternion +/// @ingroup gtc +/// +/// @brief Defines a templated quaternion type and several quaternion operations. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_quaternion +#define GLM_GTC_quaternion GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/constants.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_quaternion extension included") +#endif + +namespace glm{ +namespace detail +{ + template + struct tquat// : public genType + { + enum ctor{null}; + + typedef T value_type; + typedef std::size_t size_type; + + public: + value_type x, y, z, w; + + GLM_FUNC_DECL size_type length() const; + + // Constructors + tquat(); + explicit tquat( + value_type const & s, + glm::detail::tvec3 const & v); + explicit tquat( + value_type const & w, + value_type const & x, + value_type const & y, + value_type const & z); + + // Convertions + + /// Build a quaternion from euler angles (pitch, yaw, roll), in radians. + explicit tquat( + tvec3 const & eulerAngles); + explicit tquat( + tmat3x3 const & m); + explicit tquat( + tmat4x4 const & m); + + // Accesses + value_type & operator[](int i); + value_type const & operator[](int i) const; + + // Operators + tquat & operator*=(value_type const & s); + tquat & operator/=(value_type const & s); + }; + + template + detail::tquat operator- ( + detail::tquat const & q); + + template + detail::tquat operator+ ( + detail::tquat const & q, + detail::tquat const & p); + + template + detail::tquat operator* ( + detail::tquat const & q, + detail::tquat const & p); + + template + detail::tvec3 operator* ( + detail::tquat const & q, + detail::tvec3 const & v); + + template + detail::tvec3 operator* ( + detail::tvec3 const & v, + detail::tquat const & q); + + template + detail::tvec4 operator* ( + detail::tquat const & q, + detail::tvec4 const & v); + + template + detail::tvec4 operator* ( + detail::tvec4 const & v, + detail::tquat const & q); + + template + detail::tquat operator* ( + detail::tquat const & q, + typename detail::tquat::value_type const & s); + + template + detail::tquat operator* ( + typename detail::tquat::value_type const & s, + detail::tquat const & q); + + template + detail::tquat operator/ ( + detail::tquat const & q, + typename detail::tquat::value_type const & s); + +} //namespace detail + + /// @addtogroup gtc_quaternion + /// @{ + + /// Returns the length of the quaternion. + /// + /// @see gtc_quaternion + template + T length( + detail::tquat const & q); + + /// Returns the normalized quaternion. + /// + /// @see gtc_quaternion + template + detail::tquat normalize( + detail::tquat const & q); + + /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... + /// + /// @see gtc_quaternion + template + T dot( + detail::tquat const & q1, + detail::tquat const & q2); + + /// Spherical linear interpolation of two quaternions. + /// The interpolation is oriented and the rotation is performed at constant speed. + /// For short path spherical linear interpolation, use the slerp function. + /// + /// @param x A quaternion + /// @param y A quaternion + /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. + /// @tparam T Value type used to build the quaternion. Supported: half, float or double. + /// @see gtc_quaternion + /// @see - slerp(detail::tquat const & x, detail::tquat const & y, T const & a) + template + detail::tquat mix( + detail::tquat const & x, + detail::tquat const & y, + T const & a); + + /// Linear interpolation of two quaternions. + /// The interpolation is oriented. + /// + /// @param x A quaternion + /// @param y A quaternion + /// @param a Interpolation factor. The interpolation is defined in the range [0, 1]. + /// @tparam T Value type used to build the quaternion. Supported: half, float or double. + /// @see gtc_quaternion + template + detail::tquat lerp( + detail::tquat const & x, + detail::tquat const & y, + T const & a); + + /// Spherical linear interpolation of two quaternions. + /// The interpolation always take the short path and the rotation is performed at constant speed. + /// + /// @param x A quaternion + /// @param y A quaternion + /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. + /// @tparam T Value type used to build the quaternion. Supported: half, float or double. + /// @see gtc_quaternion + template + detail::tquat slerp( + detail::tquat const & x, + detail::tquat const & y, + T const & a); + + /// Returns the q conjugate. + /// + /// @see gtc_quaternion + template + detail::tquat conjugate( + detail::tquat const & q); + + /// Returns the q inverse. + /// + /// @see gtc_quaternion + template + detail::tquat inverse( + detail::tquat const & q); + + /// Rotates a quaternion from an vector of 3 components axis and an angle. + /// + /// @param q Source orientation + /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// @param axis Axis of the rotation, must be normalized. + /// + /// @see gtc_quaternion + template + detail::tquat rotate( + detail::tquat const & q, + typename detail::tquat::value_type const & angle, + detail::tvec3 const & axis); + + /// Returns euler angles, yitch as x, yaw as y, roll as z. + /// + /// @see gtc_quaternion + template + detail::tvec3 eulerAngles( + detail::tquat const & x); + + /// Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// + /// @see gtx_quaternion + template + valType roll( + detail::tquat const & x); + + /// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// + /// @see gtx_quaternion + template + valType pitch( + detail::tquat const & x); + + /// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// + /// @see gtx_quaternion + template + valType yaw( + detail::tquat const & x); + + /// Converts a quaternion to a 3 * 3 matrix. + /// + /// @see gtc_quaternion + template + detail::tmat3x3 mat3_cast( + detail::tquat const & x); + + /// Converts a quaternion to a 4 * 4 matrix. + /// + /// @see gtc_quaternion + template + detail::tmat4x4 mat4_cast( + detail::tquat const & x); + + /// Converts a 3 * 3 matrix to a quaternion. + /// + /// @see gtc_quaternion + template + detail::tquat quat_cast( + detail::tmat3x3 const & x); + + /// Converts a 4 * 4 matrix to a quaternion. + /// + /// @see gtc_quaternion + template + detail::tquat quat_cast( + detail::tmat4x4 const & x); + + /// Returns the quaternion rotation angle. + /// + /// @see gtc_quaternion + template + valType angle( + detail::tquat const & x); + + /// Returns the q rotation axis. + /// + /// @see gtc_quaternion + template + detail::tvec3 axis( + detail::tquat const & x); + + /// Build a quaternion from an angle and a normalized axis. + /// + /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// @param x x component of the x-axis, x, y, z must be a normalized axis + /// @param y y component of the y-axis, x, y, z must be a normalized axis + /// @param z z component of the z-axis, x, y, z must be a normalized axis + /// + /// @see gtc_quaternion + template + detail::tquat angleAxis( + valType const & angle, + valType const & x, + valType const & y, + valType const & z); + + /// Build a quaternion from an angle and a normalized axis. + /// + /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// @param axis Axis of the quaternion, must be normalized. + /// + /// @see gtc_quaternion + template + detail::tquat angleAxis( + valType const & angle, + detail::tvec3 const & axis); + + /// Quaternion of floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat quat; + + /// Quaternion of half-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat hquat; + + /// Quaternion of single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat fquat; + + /// Quaternion of double-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat dquat; + + /// Quaternion of low precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat lowp_quat; + + /// Quaternion of medium precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat mediump_quat; + + /// Quaternion of high precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat highp_quat; + + /// @} +} //namespace glm + +#include "quaternion.inl" + +#endif//GLM_GTC_quaternion diff --git a/src/libraries/glm/gtc/quaternion.inl b/src/libraries/glm/gtc/quaternion.inl new file mode 100755 index 0000000..d1e7602 --- /dev/null +++ b/src/libraries/glm/gtc/quaternion.inl @@ -0,0 +1,788 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_quaternion +/// @file glm/gtc/quaternion.inl +/// @date 2009-05-21 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm{ +namespace detail +{ + template + GLM_FUNC_QUALIFIER typename tquat::size_type tquat::length() const + { + return 4; + } + + template + GLM_FUNC_QUALIFIER tquat::tquat() : + x(0), + y(0), + z(0), + w(1) + {} + + template + GLM_FUNC_QUALIFIER tquat::tquat + ( + value_type const & s, + tvec3 const & v + ) : + x(v.x), + y(v.y), + z(v.z), + w(s) + {} + + template + GLM_FUNC_QUALIFIER tquat::tquat + ( + value_type const & w, + value_type const & x, + value_type const & y, + value_type const & z + ) : + x(x), + y(y), + z(z), + w(w) + {} + + ////////////////////////////////////////////////////////////// + // tquat conversions + + //template + //GLM_FUNC_QUALIFIER tquat::tquat + //( + // valType const & pitch, + // valType const & yaw, + // valType const & roll + //) + //{ + // tvec3 eulerAngle(pitch * valType(0.5), yaw * valType(0.5), roll * valType(0.5)); + // tvec3 c = glm::cos(eulerAngle * valType(0.5)); + // tvec3 s = glm::sin(eulerAngle * valType(0.5)); + // + // this->w = c.x * c.y * c.z + s.x * s.y * s.z; + // this->x = s.x * c.y * c.z - c.x * s.y * s.z; + // this->y = c.x * s.y * c.z + s.x * c.y * s.z; + // this->z = c.x * c.y * s.z - s.x * s.y * c.z; + //} + + template + GLM_FUNC_QUALIFIER tquat::tquat + ( + tvec3 const & eulerAngle + ) + { + tvec3 c = glm::cos(eulerAngle * value_type(0.5)); + tvec3 s = glm::sin(eulerAngle * value_type(0.5)); + + this->w = c.x * c.y * c.z + s.x * s.y * s.z; + this->x = s.x * c.y * c.z - c.x * s.y * s.z; + this->y = c.x * s.y * c.z + s.x * c.y * s.z; + this->z = c.x * c.y * s.z - s.x * s.y * c.z; + } + + template + GLM_FUNC_QUALIFIER tquat::tquat + ( + tmat3x3 const & m + ) + { + *this = quat_cast(m); + } + + template + GLM_FUNC_QUALIFIER tquat::tquat + ( + tmat4x4 const & m + ) + { + *this = quat_cast(m); + } + + ////////////////////////////////////////////////////////////// + // tquat accesses + + template + GLM_FUNC_QUALIFIER typename tquat::value_type & tquat::operator [] (int i) + { + return (&x)[i]; + } + + template + GLM_FUNC_QUALIFIER typename tquat::value_type const & tquat::operator [] (int i) const + { + return (&x)[i]; + } + + ////////////////////////////////////////////////////////////// + // tquat operators + + template + GLM_FUNC_QUALIFIER tquat & tquat::operator *= + ( + value_type const & s + ) + { + this->w *= s; + this->x *= s; + this->y *= s; + this->z *= s; + return *this; + } + + template + GLM_FUNC_QUALIFIER tquat & tquat::operator /= + ( + value_type const & s + ) + { + this->w /= s; + this->x /= s; + this->y /= s; + this->z /= s; + return *this; + } + + ////////////////////////////////////////////////////////////// + // tquat external operators + + template + GLM_FUNC_QUALIFIER detail::tquat operator- + ( + detail::tquat const & q + ) + { + return detail::tquat(-q.w, -q.x, -q.y, -q.z); + } + + template + GLM_FUNC_QUALIFIER detail::tquat operator+ + ( + detail::tquat const & q, + detail::tquat const & p + ) + { + return detail::tquat( + q.w + p.w, + q.x + p.x, + q.y + p.y, + q.z + p.z); + } + + template + GLM_FUNC_QUALIFIER detail::tquat operator* + ( + detail::tquat const & q, + detail::tquat const & p + ) + { + return detail::tquat( + q.w * p.w - q.x * p.x - q.y * p.y - q.z * p.z, + q.w * p.x + q.x * p.w + q.y * p.z - q.z * p.y, + q.w * p.y + q.y * p.w + q.z * p.x - q.x * p.z, + q.w * p.z + q.z * p.w + q.x * p.y - q.y * p.x); + } + + // Transformation + template + GLM_FUNC_QUALIFIER detail::tvec3 operator* + ( + detail::tquat const & q, + detail::tvec3 const & v + ) + { + typename detail::tquat::value_type Two(2); + + detail::tvec3 uv, uuv; + detail::tvec3 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; + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 operator* + ( + detail::tvec3 const & v, + detail::tquat const & q + ) + { + return inverse(q) * v; + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 operator* + ( + detail::tquat const & q, + detail::tvec4 const & v + ) + { + return detail::tvec4(q * detail::tvec3(v), v.w); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 operator* + ( + detail::tvec4 const & v, + detail::tquat const & q + ) + { + return inverse(q) * v; + } + + template + GLM_FUNC_QUALIFIER detail::tquat operator* + ( + detail::tquat const & q, + typename detail::tquat::value_type const & s + ) + { + return detail::tquat( + q.w * s, q.x * s, q.y * s, q.z * s); + } + + template + GLM_FUNC_QUALIFIER detail::tquat operator* + ( + typename detail::tquat::value_type const & s, + detail::tquat const & q + ) + { + return q * s; + } + + template + GLM_FUNC_QUALIFIER detail::tquat operator/ + ( + detail::tquat const & q, + typename detail::tquat::value_type const & s + ) + { + return detail::tquat( + q.w / s, q.x / s, q.y / s, q.z / s); + } + + ////////////////////////////////////// + // Boolean operators + + template + GLM_FUNC_QUALIFIER bool operator== + ( + detail::tquat const & q1, + detail::tquat const & q2 + ) + { + return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w); + } + + template + GLM_FUNC_QUALIFIER bool operator!= + ( + detail::tquat const & q1, + detail::tquat const & q2 + ) + { + return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w); + } + +}//namespace detail + + //////////////////////////////////////////////////////// + template + GLM_FUNC_QUALIFIER T length + ( + detail::tquat const & q + ) + { + return glm::sqrt(dot(q, q)); + } + + template + GLM_FUNC_QUALIFIER detail::tquat normalize + ( + detail::tquat const & q + ) + { + typename detail::tquat::value_type len = length(q); + if(len <= typename detail::tquat::value_type(0)) // Problem + return detail::tquat(1, 0, 0, 0); + typename detail::tquat::value_type oneOverLen = typename detail::tquat::value_type(1) / len; + return detail::tquat(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen); + } + + template + GLM_FUNC_QUALIFIER T dot + ( + detail::tquat const & q1, + detail::tquat const & q2 + ) + { + return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; + } + + template + GLM_FUNC_QUALIFIER detail::tquat cross + ( + detail::tquat const & q1, + detail::tquat const & q2 + ) + { + return detail::tquat( + q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, + q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, + q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, + q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); + } +/* + // (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle)) + template + GLM_FUNC_QUALIFIER detail::tquat mix + ( + detail::tquat const & x, + detail::tquat const & y, + typename detail::tquat::value_type const & a + ) + { + if(a <= typename detail::tquat::value_type(0)) return x; + if(a >= typename detail::tquat::value_type(1)) return y; + + float fCos = dot(x, y); + detail::tquat y2(y); //BUG!!! tquat y2; + if(fCos < typename detail::tquat::value_type(0)) + { + y2 = -y; + fCos = -fCos; + } + + //if(fCos > 1.0f) // problem + float k0, k1; + if(fCos > typename detail::tquat::value_type(0.9999)) + { + k0 = typename detail::tquat::value_type(1) - a; + k1 = typename detail::tquat::value_type(0) + a; //BUG!!! 1.0f + a; + } + else + { + typename detail::tquat::value_type fSin = sqrt(T(1) - fCos * fCos); + typename detail::tquat::value_type fAngle = atan(fSin, fCos); + typename detail::tquat::value_type fOneOverSin = T(1) / fSin; + k0 = sin((typename detail::tquat::value_type(1) - a) * fAngle) * fOneOverSin; + k1 = sin((typename detail::tquat::value_type(0) + a) * fAngle) * fOneOverSin; + } + + return detail::tquat( + k0 * x.w + k1 * y2.w, + k0 * x.x + k1 * y2.x, + k0 * x.y + k1 * y2.y, + k0 * x.z + k1 * y2.z); + } + + template + GLM_FUNC_QUALIFIER detail::tquat mix2 + ( + detail::tquat const & x, + detail::tquat const & y, + T const & a + ) + { + bool flip = false; + if(a <= T(0)) return x; + if(a >= T(1)) return y; + + T cos_t = dot(x, y); + if(cos_t < T(0)) + { + cos_t = -cos_t; + flip = true; + } + + T alpha(0), beta(0); + + if(T(1) - cos_t < 1e-7) + beta = T(1) - alpha; + else + { + T theta = acos(cos_t); + T sin_t = sin(theta); + beta = sin(theta * (T(1) - alpha)) / sin_t; + alpha = sin(alpha * theta) / sin_t; + } + + if(flip) + alpha = -alpha; + + return normalize(beta * x + alpha * y); + } +*/ + + template + GLM_FUNC_QUALIFIER detail::tquat mix + ( + detail::tquat const & x, + detail::tquat const & y, + T const & a + ) + { + T cosTheta = dot(x, y); + + // Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator + if(cosTheta > T(1) - epsilon()) + { + // Linear interpolation + return detail::tquat( + mix(x.w, y.w, a), + mix(x.x, y.x, a), + mix(x.y, y.y, a), + mix(x.z, y.z, a)); + } + else + { + // Essential Mathematics, page 467 + T angle = acos(cosTheta); + return (sin((T(1) - a) * angle) * x + sin(a * angle) * y) / sin(angle); + } + } + + template + GLM_FUNC_QUALIFIER detail::tquat lerp + ( + detail::tquat const & x, + detail::tquat const & y, + T const & a + ) + { + return x * (T(1) - a) + (y * a); + } + + template + GLM_FUNC_QUALIFIER detail::tquat slerp + ( + detail::tquat const & x, + detail::tquat const & y, + T const & a + ) + { + detail::tquat z = y; + + T cosTheta = dot(x, y); + + // If cosTheta < 0, the interpolation will take the long way around the sphere. + // To fix this, one quat must be negated. + if (cosTheta < T(0)) + { + z = -y; + cosTheta = -cosTheta; + } + + // Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator + if(cosTheta > T(1) - epsilon()) + { + // Linear interpolation + return detail::tquat( + mix(x.w, y.w, a), + mix(x.x, y.x, a), + mix(x.y, y.y, a), + mix(x.z, y.z, a)); + } + else + { + // Essential Mathematics, page 467 + T angle = acos(cosTheta); + return (sin((T(1) - a) * angle) * x + sin(a * angle) * z) / sin(angle); + } + } + + template + GLM_FUNC_QUALIFIER detail::tquat conjugate + ( + detail::tquat const & q + ) + { + return detail::tquat(q.w, -q.x, -q.y, -q.z); + } + + template + GLM_FUNC_QUALIFIER detail::tquat inverse + ( + detail::tquat const & q + ) + { + return conjugate(q) / dot(q, q); + } + + template + GLM_FUNC_QUALIFIER detail::tquat rotate + ( + detail::tquat const & q, + typename detail::tquat::value_type const & angle, + detail::tvec3 const & v + ) + { + detail::tvec3 Tmp = v; + + // Axis of rotation must be normalised + typename detail::tquat::value_type len = glm::length(Tmp); + if(abs(len - T(1)) > T(0.001)) + { + T oneOverLen = T(1) / len; + Tmp.x *= oneOverLen; + Tmp.y *= oneOverLen; + Tmp.z *= oneOverLen; + } + +#ifdef GLM_FORCE_RADIANS + typename detail::tquat::value_type const AngleRad(angle); +#else + typename detail::tquat::value_type const AngleRad = radians(angle); +#endif + typename detail::tquat::value_type const Sin = sin(AngleRad * T(0.5)); + + return q * detail::tquat(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin); + //return gtc::quaternion::cross(q, detail::tquat(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 eulerAngles + ( + detail::tquat const & x + ) + { + return detail::tvec3(pitch(x), yaw(x), roll(x)); + } + + template + GLM_FUNC_QUALIFIER valType roll + ( + detail::tquat const & q + ) + { +#ifdef GLM_FORCE_RADIANS + return valType(atan2(valType(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 + return glm::degrees(atan(valType(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 + GLM_FUNC_QUALIFIER valType pitch + ( + detail::tquat const & q + ) + { +#ifdef GLM_FORCE_RADIANS + return valType(atan2(valType(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 + return glm::degrees(atan(valType(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 + GLM_FUNC_QUALIFIER valType yaw + ( + detail::tquat const & q + ) + { +#ifdef GLM_FORCE_RADIANS + return asin(valType(-2) * (q.x * q.z - q.w * q.y)); +#else + return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y))); +#endif + } + + template + GLM_FUNC_QUALIFIER detail::tmat3x3 mat3_cast + ( + detail::tquat const & q + ) + { + detail::tmat3x3 Result(T(1)); + Result[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z; + Result[0][1] = 2 * q.x * q.y + 2 * q.w * q.z; + Result[0][2] = 2 * q.x * q.z - 2 * q.w * q.y; + + Result[1][0] = 2 * q.x * q.y - 2 * q.w * q.z; + Result[1][1] = 1 - 2 * q.x * q.x - 2 * q.z * q.z; + Result[1][2] = 2 * q.y * q.z + 2 * q.w * q.x; + + Result[2][0] = 2 * q.x * q.z + 2 * q.w * q.y; + Result[2][1] = 2 * q.y * q.z - 2 * q.w * q.x; + Result[2][2] = 1 - 2 * q.x * q.x - 2 * q.y * q.y; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tmat4x4 mat4_cast + ( + detail::tquat const & q + ) + { + return detail::tmat4x4(mat3_cast(q)); + } + + template + GLM_FUNC_QUALIFIER detail::tquat quat_cast + ( + detail::tmat3x3 const & m + ) + { + typename detail::tquat::value_type fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; + typename detail::tquat::value_type fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; + typename detail::tquat::value_type fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1]; + typename detail::tquat::value_type fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2]; + + int biggestIndex = 0; + typename detail::tquat::value_type fourBiggestSquaredMinus1 = fourWSquaredMinus1; + if(fourXSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourXSquaredMinus1; + biggestIndex = 1; + } + if(fourYSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourYSquaredMinus1; + biggestIndex = 2; + } + if(fourZSquaredMinus1 > fourBiggestSquaredMinus1) + { + fourBiggestSquaredMinus1 = fourZSquaredMinus1; + biggestIndex = 3; + } + + typename detail::tquat::value_type biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5); + typename detail::tquat::value_type mult = T(0.25) / biggestVal; + + detail::tquat Result; + switch(biggestIndex) + { + case 0: + Result.w = biggestVal; + Result.x = (m[1][2] - m[2][1]) * mult; + Result.y = (m[2][0] - m[0][2]) * mult; + Result.z = (m[0][1] - m[1][0]) * mult; + break; + case 1: + Result.w = (m[1][2] - m[2][1]) * mult; + Result.x = biggestVal; + Result.y = (m[0][1] + m[1][0]) * mult; + Result.z = (m[2][0] + m[0][2]) * mult; + break; + case 2: + Result.w = (m[2][0] - m[0][2]) * mult; + Result.x = (m[0][1] + m[1][0]) * mult; + Result.y = biggestVal; + Result.z = (m[1][2] + m[2][1]) * mult; + break; + case 3: + Result.w = (m[0][1] - m[1][0]) * mult; + Result.x = (m[2][0] + m[0][2]) * mult; + Result.y = (m[1][2] + m[2][1]) * mult; + Result.z = biggestVal; + break; + + default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity. + assert(false); + break; + } + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tquat quat_cast + ( + detail::tmat4x4 const & m4 + ) + { + return quat_cast(detail::tmat3x3(m4)); + } + + template + GLM_FUNC_QUALIFIER T angle + ( + detail::tquat const & x + ) + { +#ifdef GLM_FORCE_RADIANS + return acos(x.w) * T(2); +#else + return glm::degrees(acos(x.w) * T(2)); +#endif + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 axis + ( + detail::tquat const & x + ) + { + T tmp1 = T(1) - x.w * x.w; + if(tmp1 <= T(0)) + return detail::tvec3(0, 0, 1); + T tmp2 = T(1) / sqrt(tmp1); + return detail::tvec3(x.x * tmp2, x.y * tmp2, x.z * tmp2); + } + + template + GLM_FUNC_QUALIFIER detail::tquat angleAxis + ( + valType const & angle, + valType const & x, + valType const & y, + valType const & z + ) + { + return angleAxis(angle, detail::tvec3(x, y, z)); + } + + template + GLM_FUNC_QUALIFIER detail::tquat angleAxis + ( + valType const & angle, + detail::tvec3 const & v + ) + { + detail::tquat result; + +#ifdef GLM_FORCE_RADIANS + valType a(angle); +#else + valType a(glm::radians(angle)); +#endif + valType s = glm::sin(a * valType(0.5)); + + result.w = glm::cos(a * valType(0.5)); + result.x = v.x * s; + result.y = v.y * s; + result.z = v.z * s; + return result; + } + +}//namespace glm diff --git a/src/libraries/glm/gtc/random.hpp b/src/libraries/glm/gtc/random.hpp new file mode 100755 index 0000000..ec03575 --- /dev/null +++ b/src/libraries/glm/gtc/random.hpp @@ -0,0 +1,114 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_random +/// @file glm/gtc/random.hpp +/// @date 2011-09-18 / 2011-09-18 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtx_random (extended) +/// +/// @defgroup gtc_random GLM_GTC_random +/// @ingroup gtc +/// +/// @brief Generate random number from various distribution methods. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_random +#define GLM_GTC_random GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_random extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_random + /// @{ + + /// Generate random numbers in the interval [Min, Max], according a linear distribution + /// + /// @param Min + /// @param Max + /// @tparam genType Value type. Currently supported: half (not recommanded), float or double scalars and vectors. + /// @see gtc_random + template + genType linearRand( + genType const & Min, + genType const & Max); + + /// Generate random numbers in the interval [Min, Max], according a gaussian distribution + /// + /// @param Mean + /// @param Deviation + /// @see gtc_random + template + genType gaussRand( + genType const & Mean, + genType const & Deviation); + + /// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius + /// + /// @param Radius + /// @see gtc_random + template + detail::tvec2 circularRand( + T const & Radius); + + /// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius + /// + /// @param Radius + /// @see gtc_random + template + detail::tvec3 sphericalRand( + T const & 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 + detail::tvec2 diskRand( + T const & 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 + GLM_FUNC_QUALIFIER detail::tvec3 ballRand( + T const & Radius); + + /// @} +}//namespace glm + +#include "random.inl" + +#endif//GLM_GTC_random diff --git a/src/libraries/glm/gtc/random.inl b/src/libraries/glm/gtc/random.inl new file mode 100755 index 0000000..2bb292e --- /dev/null +++ b/src/libraries/glm/gtc/random.inl @@ -0,0 +1,170 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_random +/// @file glm/gtc/random.inl +/// @date 2011-09-19 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +namespace glm{ +namespace detail +{ + struct compute_linearRand + { + template + 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; + } +*/ + }; + + template <> + GLM_FUNC_QUALIFIER half compute_linearRand::operator() (half const & Min, half const & Max) const + { + return half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min)); + } + + template <> + GLM_FUNC_QUALIFIER float compute_linearRand::operator() (float const & Min, float const & Max) const + { + return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min; + } + + template <> + GLM_FUNC_QUALIFIER double compute_linearRand::operator() (double const & Min, double const & Max) const + { + return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min; + } + + template <> + GLM_FUNC_QUALIFIER long double compute_linearRand::operator() (long double const & Min, long double const & Max) const + { + return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min; + } +}//namespace detail + + template + GLM_FUNC_QUALIFIER genType linearRand + ( + genType const & Min, + genType const & Max + ) + { + return detail::compute_linearRand()(Min, Max); + } + + VECTORIZE_VEC_VEC(linearRand) + + template + GLM_FUNC_QUALIFIER genType gaussRand + ( + genType const & Mean, + genType const & Deviation + ) + { + genType w, x1, x2; + + do + { + x1 = linearRand(genType(-1), genType(1)); + x2 = linearRand(genType(-1), genType(1)); + + w = x1 * x1 + x2 * x2; + } while(w > genType(1)); + + return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean; + } + + VECTORIZE_VEC_VEC(gaussRand) + + template + GLM_FUNC_QUALIFIER detail::tvec2 diskRand + ( + T const & Radius + ) + { + detail::tvec2 Result(T(0)); + T LenRadius(T(0)); + + do + { + Result = linearRand(detail::tvec2(-Radius), detail::tvec2(Radius)); + LenRadius = length(Result); + } + while(LenRadius > Radius); + + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 ballRand + ( + T const & Radius + ) + { + detail::tvec3 Result(T(0)); + T LenRadius(T(0)); + + do + { + Result = linearRand(detail::tvec3(-Radius), detail::tvec3(Radius)); + LenRadius = length(Result); + } + while(LenRadius > Radius); + + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 circularRand + ( + T const & Radius + ) + { + T a = linearRand(T(0), T(6.283185307179586476925286766559f)); + return detail::tvec2(cos(a), sin(a)) * Radius; + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 sphericalRand + ( + T const & Radius + ) + { + T z = linearRand(T(-1), T(1)); + T a = linearRand(T(0), T(6.283185307179586476925286766559f)); + + T r = sqrt(T(1) - z * z); + + T x = r * cos(a); + T y = r * sin(a); + + return detail::tvec3(x, y, z) * Radius; + } +}//namespace glm diff --git a/src/libraries/glm/gtc/reciprocal.hpp b/src/libraries/glm/gtc/reciprocal.hpp new file mode 100755 index 0000000..8ebb617 --- /dev/null +++ b/src/libraries/glm/gtc/reciprocal.hpp @@ -0,0 +1,133 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_reciprocal +/// @file glm/gtc/reciprocal.hpp +/// @date 2008-10-09 / 2012-01-25 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_reciprocal GLM_GTC_reciprocal +/// @ingroup gtc +/// +/// @brief Define secant, cosecant and cotangent functions. +/// +/// need to be included to use these features. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_reciprocal +#define GLM_GTC_reciprocal GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_reciprocal extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_reciprocal + /// @{ + + /// Secant function. + /// hypotenuse / adjacent or 1 / cos(x) + /// + /// @see gtc_reciprocal + template + genType sec(genType const & angle); + + /// Cosecant function. + /// hypotenuse / opposite or 1 / sin(x) + /// + /// @see gtc_reciprocal + template + genType csc(genType const & angle); + + /// Cotangent function. + /// adjacent / opposite or 1 / tan(x) + /// + /// @see gtc_reciprocal + template + genType cot(genType const & angle); + + /// Inverse secant function. + /// + /// @see gtc_reciprocal + template + genType asec(genType const & x); + + /// Inverse cosecant function. + /// + /// @see gtc_reciprocal + template + genType acsc(genType const & x); + + /// Inverse cotangent function. + /// + /// @see gtc_reciprocal + template + genType acot(genType const & x); + + /// Secant hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType sech(genType const & angle); + + /// Cosecant hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType csch(genType const & angle); + + /// Cotangent hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType coth(genType const & angle); + + /// Inverse secant hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType asech(genType const & x); + + /// Inverse cosecant hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType acsch(genType const & x); + + /// Inverse cotangent hyperbolic function. + /// + /// @see gtc_reciprocal + template + genType acoth(genType const & x); + + /// @} +}//namespace glm + +#include "reciprocal.inl" + +#endif//GLM_GTC_reciprocal diff --git a/src/libraries/glm/gtc/reciprocal.inl b/src/libraries/glm/gtc/reciprocal.inl new file mode 100755 index 0000000..0543c72 --- /dev/null +++ b/src/libraries/glm/gtc/reciprocal.inl @@ -0,0 +1,199 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_reciprocal +/// @file glm/gtc/reciprocal.inl +/// @date 2008-10-09 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // sec + template + GLM_FUNC_QUALIFIER genType sec + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'sec' only accept floating-point values"); + + return genType(1) / glm::cos(angle); + } + + VECTORIZE_VEC(sec) + + // csc + template + GLM_FUNC_QUALIFIER genType csc + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'csc' only accept floating-point values"); + + return genType(1) / glm::sin(angle); + } + + VECTORIZE_VEC(csc) + + // cot + template + GLM_FUNC_QUALIFIER genType cot + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'cot' only accept floating-point values"); + + return genType(1) / glm::tan(angle); + } + + VECTORIZE_VEC(cot) + + // asec + template + GLM_FUNC_QUALIFIER genType asec + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'asec' only accept floating-point values"); + + return acos(genType(1) / x); + } + + VECTORIZE_VEC(asec) + + // acsc + template + GLM_FUNC_QUALIFIER genType acsc + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'acsc' only accept floating-point values"); + + return asin(genType(1) / x); + } + + VECTORIZE_VEC(acsc) + + // acot + template + GLM_FUNC_QUALIFIER genType acot + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'acot' only accept floating-point values"); + + genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); + return pi_over_2 - atan(x); + } + + VECTORIZE_VEC(acot) + + // sech + template + GLM_FUNC_QUALIFIER genType sech + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'sech' only accept floating-point values"); + + return genType(1) / glm::cosh(angle); + } + + VECTORIZE_VEC(sech) + + // csch + template + GLM_FUNC_QUALIFIER genType csch + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'csch' only accept floating-point values"); + + return genType(1) / glm::sinh(angle); + } + + VECTORIZE_VEC(csch) + + // coth + template + GLM_FUNC_QUALIFIER genType coth + ( + genType const & angle + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'coth' only accept floating-point values"); + + return glm::cosh(angle) / glm::sinh(angle); + } + + VECTORIZE_VEC(coth) + + // asech + template + GLM_FUNC_QUALIFIER genType asech + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'asech' only accept floating-point values"); + + return acosh(genType(1) / x); + } + + VECTORIZE_VEC(asech) + + // acsch + template + GLM_FUNC_QUALIFIER genType acsch + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'acsch' only accept floating-point values"); + + return asinh(genType(1) / x); + } + + VECTORIZE_VEC(acsch) + + // acoth + template + GLM_FUNC_QUALIFIER genType acoth + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type::is_float, "'acoth' only accept floating-point values"); + + return atanh(genType(1) / x); + } + + VECTORIZE_VEC(acoth) +}//namespace glm diff --git a/src/libraries/glm/gtc/swizzle.hpp b/src/libraries/glm/gtc/swizzle.hpp new file mode 100755 index 0000000..455ab7b --- /dev/null +++ b/src/libraries/glm/gtc/swizzle.hpp @@ -0,0 +1,375 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_swizzle +/// @file glm/gtc/swizzle.hpp +/// @date 2010-02-20 / 2011-06-05 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_swizzle GLM_GTC_swizzle +/// @ingroup gtc +/// +/// @brief Provide functions to emulate GLSL swizzle operator fonctionalities. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_swizzle +#define GLM_GTC_swizzle GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/type_precision.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_swizzle extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_swizzle + /// @{ + + template class vecType> + T const & swizzle( + vecType const & v, + comp x); + + template class vecType> + detail::tvec2 const & swizzle( + vecType const & v, + comp x, comp y); + + template class vecType> + detail::tvec3 const & swizzle( + vecType const & v, + comp x, comp y, comp z); + + template class vecType> + detail::tvec4 const & swizzle( + vecType const & v, + comp x, comp y, comp z, comp w); + + template class vecType> + T & swizzle( + vecType & v, + comp x); + + template class vecType> + detail::tref2 swizzle( + vecType & v, + comp x, comp y); + + template class vecType> + detail::tref3 swizzle( + vecType & v, + comp x, comp y, comp z); + + template class vecType> + detail::tref4 swizzle( + vecType & v, + comp x, comp y, comp z, comp w); + +# define static_swizzle1_const(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE const & v) \ + {return v[x];} + +# define static_swizzle1_ref(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE & v) \ + {return v[x];} + + static_swizzle1_ref(detail::float16, 2) + static_swizzle1_ref(detail::float16, 3) + static_swizzle1_ref(detail::float16, 4) + static_swizzle1_ref(detail::float32, 2) + static_swizzle1_ref(detail::float32, 3) + static_swizzle1_ref(detail::float32, 4) + static_swizzle1_ref(detail::float64, 2) + static_swizzle1_ref(detail::float64, 3) + static_swizzle1_ref(detail::float64, 4) + + static_swizzle1_ref(detail::int8, 2) + static_swizzle1_ref(detail::int8, 3) + static_swizzle1_ref(detail::int8, 4) + static_swizzle1_ref(detail::int16, 2) + static_swizzle1_ref(detail::int16, 3) + static_swizzle1_ref(detail::int16, 4) + static_swizzle1_ref(detail::int32, 2) + static_swizzle1_ref(detail::int32, 3) + static_swizzle1_ref(detail::int32, 4) + static_swizzle1_ref(detail::int64, 2) + static_swizzle1_ref(detail::int64, 3) + static_swizzle1_ref(detail::int64, 4) + + static_swizzle1_ref(detail::uint8, 2) + static_swizzle1_ref(detail::uint8, 3) + static_swizzle1_ref(detail::uint8, 4) + static_swizzle1_ref(detail::uint16, 2) + static_swizzle1_ref(detail::uint16, 3) + static_swizzle1_ref(detail::uint16, 4) + static_swizzle1_ref(detail::uint32, 2) + static_swizzle1_ref(detail::uint32, 3) + static_swizzle1_ref(detail::uint32, 4) + static_swizzle1_ref(detail::uint64, 2) + static_swizzle1_ref(detail::uint64, 3) + static_swizzle1_ref(detail::uint64, 4) +/* +# define static_swizzle2_const(TYPE) \ + template \ + GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \ + {return TYPE(v[x], v[y]);} + +# define static_swizzle3_const(TYPE) \ + template \ + GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \ + {return TYPE(v[x], v[y], v[z]);} + +# define static_swizzle4_const(TYPE) \ + template \ + GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \ + {return TYPE(v[x], v[y], v[z], v[w]);} +*/ + +# define static_swizzle2_const(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 swizzle(detail::tvec##SIZE const & v) \ + {return detail::tvec2(v[x], v[y]);} + +# define static_swizzle3_const(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 swizzle(detail::tvec##SIZE const & v) \ + {return detail::tvec3(v[x], v[y], v[z]);} + +# define static_swizzle4_const(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 swizzle(detail::tvec##SIZE const & v) \ + {return detail::tvec4(v[x], v[y], v[z], v[w]);} + + + static_swizzle2_const(glm::f16, 2) + static_swizzle2_const(glm::f16, 3) + static_swizzle2_const(glm::f16, 4) + static_swizzle2_const(glm::f32, 2) + static_swizzle2_const(glm::f32, 3) + static_swizzle2_const(glm::f32, 4) + static_swizzle2_const(glm::f64, 2) + static_swizzle2_const(glm::f64, 3) + static_swizzle2_const(glm::f64, 4) + + static_swizzle2_const(glm::i8, 2) + static_swizzle2_const(glm::i8, 3) + static_swizzle2_const(glm::i8, 4) + static_swizzle2_const(glm::i16, 2) + static_swizzle2_const(glm::i16, 3) + static_swizzle2_const(glm::i16, 4) + static_swizzle2_const(glm::i32, 2) + static_swizzle2_const(glm::i32, 3) + static_swizzle2_const(glm::i32, 4) + static_swizzle2_const(glm::i64, 2) + static_swizzle2_const(glm::i64, 3) + static_swizzle2_const(glm::i64, 4) + + static_swizzle2_const(glm::u8, 2) + static_swizzle2_const(glm::u8, 3) + static_swizzle2_const(glm::u8, 4) + static_swizzle2_const(glm::u16, 2) + static_swizzle2_const(glm::u16, 3) + static_swizzle2_const(glm::u16, 4) + static_swizzle2_const(glm::u32, 2) + static_swizzle2_const(glm::u32, 3) + static_swizzle2_const(glm::u32, 4) + static_swizzle2_const(glm::u64, 2) + static_swizzle2_const(glm::u64, 3) + static_swizzle2_const(glm::u64, 4) + + static_swizzle3_const(glm::f16, 2) + static_swizzle3_const(glm::f16, 3) + static_swizzle3_const(glm::f16, 4) + static_swizzle3_const(glm::f32, 2) + static_swizzle3_const(glm::f32, 3) + static_swizzle3_const(glm::f32, 4) + static_swizzle3_const(glm::f64, 2) + static_swizzle3_const(glm::f64, 3) + static_swizzle3_const(glm::f64, 4) + + static_swizzle3_const(glm::i8, 2) + static_swizzle3_const(glm::i8, 3) + static_swizzle3_const(glm::i8, 4) + static_swizzle3_const(glm::i16, 2) + static_swizzle3_const(glm::i16, 3) + static_swizzle3_const(glm::i16, 4) + static_swizzle3_const(glm::i32, 2) + static_swizzle3_const(glm::i32, 3) + static_swizzle3_const(glm::i32, 4) + static_swizzle3_const(glm::i64, 2) + static_swizzle3_const(glm::i64, 3) + static_swizzle3_const(glm::i64, 4) + + static_swizzle3_const(glm::u8, 2) + static_swizzle3_const(glm::u8, 3) + static_swizzle3_const(glm::u8, 4) + static_swizzle3_const(glm::u16, 2) + static_swizzle3_const(glm::u16, 3) + static_swizzle3_const(glm::u16, 4) + static_swizzle3_const(glm::u32, 2) + static_swizzle3_const(glm::u32, 3) + static_swizzle3_const(glm::u32, 4) + static_swizzle3_const(glm::u64, 2) + static_swizzle3_const(glm::u64, 3) + static_swizzle3_const(glm::u64, 4) + + static_swizzle4_const(glm::f16, 2) + static_swizzle4_const(glm::f16, 3) + static_swizzle4_const(glm::f16, 4) + static_swizzle4_const(glm::f32, 2) + static_swizzle4_const(glm::f32, 3) + static_swizzle4_const(glm::f32, 4) + static_swizzle4_const(glm::f64, 2) + static_swizzle4_const(glm::f64, 3) + static_swizzle4_const(glm::f64, 4) + + static_swizzle4_const(glm::i8, 2) + static_swizzle4_const(glm::i8, 3) + static_swizzle4_const(glm::i8, 4) + static_swizzle4_const(glm::i16, 2) + static_swizzle4_const(glm::i16, 3) + static_swizzle4_const(glm::i16, 4) + static_swizzle4_const(glm::i32, 2) + static_swizzle4_const(glm::i32, 3) + static_swizzle4_const(glm::i32, 4) + static_swizzle4_const(glm::i64, 2) + static_swizzle4_const(glm::i64, 3) + static_swizzle4_const(glm::i64, 4) + + static_swizzle4_const(glm::u8, 2) + static_swizzle4_const(glm::u8, 3) + static_swizzle4_const(glm::u8, 4) + static_swizzle4_const(glm::u16, 2) + static_swizzle4_const(glm::u16, 3) + static_swizzle4_const(glm::u16, 4) + static_swizzle4_const(glm::u32, 2) + static_swizzle4_const(glm::u32, 3) + static_swizzle4_const(glm::u32, 4) + static_swizzle4_const(glm::u64, 2) + static_swizzle4_const(glm::u64, 3) + static_swizzle4_const(glm::u64, 4) + +# define static_swizzle2_ref(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER glm::detail::tref2 swizzle(detail::tvec##SIZE & v) \ + {return glm::detail::tref2(v[x], v[y]);} + +# define static_swizzle3_ref(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER glm::detail::tref3 swizzle(detail::tvec##SIZE & v) \ + {return glm::detail::tref3(v[x], v[y], v[z]);} + +# define static_swizzle4_ref(TYPE, SIZE) \ + template \ + GLM_FUNC_QUALIFIER glm::detail::tref4 swizzle(detail::tvec##SIZE & v) \ + {return glm::detail::tref4(v[x], v[y], v[z], v[w]);} + + static_swizzle2_ref(glm::f16, 2) + static_swizzle2_ref(glm::f16, 3) + static_swizzle2_ref(glm::f16, 4) + static_swizzle2_ref(glm::f32, 2) + static_swizzle2_ref(glm::f32, 3) + static_swizzle2_ref(glm::f32, 4) + static_swizzle2_ref(glm::f64, 2) + static_swizzle2_ref(glm::f64, 3) + static_swizzle2_ref(glm::f64, 4) + + static_swizzle2_ref(glm::i8, 2) + static_swizzle2_ref(glm::i8, 3) + static_swizzle2_ref(glm::i8, 4) + static_swizzle2_ref(glm::i16, 2) + static_swizzle2_ref(glm::i16, 3) + static_swizzle2_ref(glm::i16, 4) + static_swizzle2_ref(glm::i32, 2) + static_swizzle2_ref(glm::i32, 3) + static_swizzle2_ref(glm::i32, 4) + static_swizzle2_ref(glm::i64, 2) + static_swizzle2_ref(glm::i64, 3) + static_swizzle2_ref(glm::i64, 4) + + static_swizzle2_ref(glm::u8, 2) + static_swizzle2_ref(glm::u8, 3) + static_swizzle2_ref(glm::u8, 4) + static_swizzle2_ref(glm::u16, 2) + static_swizzle2_ref(glm::u16, 3) + static_swizzle2_ref(glm::u16, 4) + static_swizzle2_ref(glm::u32, 2) + static_swizzle2_ref(glm::u32, 3) + static_swizzle2_ref(glm::u32, 4) + static_swizzle2_ref(glm::u64, 2) + static_swizzle2_ref(glm::u64, 3) + static_swizzle2_ref(glm::u64, 4) + + static_swizzle3_ref(glm::f16, 3) + static_swizzle3_ref(glm::f16, 4) + static_swizzle3_ref(glm::f32, 3) + static_swizzle3_ref(glm::f32, 4) + static_swizzle3_ref(glm::f64, 3) + static_swizzle3_ref(glm::f64, 4) + + static_swizzle3_ref(glm::i8, 3) + static_swizzle3_ref(glm::i8, 4) + static_swizzle3_ref(glm::i16, 3) + static_swizzle3_ref(glm::i16, 4) + static_swizzle3_ref(glm::i32, 3) + static_swizzle3_ref(glm::i32, 4) + static_swizzle3_ref(glm::i64, 3) + static_swizzle3_ref(glm::i64, 4) + + static_swizzle3_ref(glm::u8, 3) + static_swizzle3_ref(glm::u8, 4) + static_swizzle3_ref(glm::u16, 3) + static_swizzle3_ref(glm::u16, 4) + static_swizzle3_ref(glm::u32, 3) + static_swizzle3_ref(glm::u32, 4) + static_swizzle3_ref(glm::u64, 3) + static_swizzle3_ref(glm::u64, 4) + + static_swizzle4_ref(glm::f16, 4) + static_swizzle4_ref(glm::f32, 4) + static_swizzle4_ref(glm::f64, 4) + + static_swizzle4_ref(glm::i8, 4) + static_swizzle4_ref(glm::i16, 4) + static_swizzle4_ref(glm::i32, 4) + static_swizzle4_ref(glm::i64, 4) + + static_swizzle4_ref(glm::u8, 4) + static_swizzle4_ref(glm::u16, 4) + static_swizzle4_ref(glm::u32, 4) + static_swizzle4_ref(glm::u64, 4) + + /// @} +}//namespace glm + +#include "swizzle.inl" + +#endif//GLM_GTC_swizzle diff --git a/src/libraries/glm/gtc/swizzle.inl b/src/libraries/glm/gtc/swizzle.inl new file mode 100755 index 0000000..1efa7d9 --- /dev/null +++ b/src/libraries/glm/gtc/swizzle.inl @@ -0,0 +1,116 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_swizzle +/// @file glm/gtc/swizzle.inl +/// @date 2011-01-15 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template class vecType> + GLM_FUNC_QUALIFIER T swizzle + ( + vecType const & v, + comp x + ) + { + assert(int(x) < int(vecType::value_size)); + return v[x]; + } + + template class vecType> + GLM_FUNC_QUALIFIER detail::tvec2 swizzle + ( + vecType const & v, + comp x, comp y + ) + { + return detail::tvec2( + v[x], + v[y]); + } + + template class vecType> + GLM_FUNC_QUALIFIER detail::tvec3 swizzle + ( + vecType const & v, + comp x, comp y, comp z + ) + { + return detail::tvec3( + v[x], + v[y], + v[z]); + } + + template class vecType> + GLM_FUNC_QUALIFIER detail::tvec4 swizzle + ( + vecType const & v, + comp x, comp y, comp z, comp w + ) + { + return detail::tvec4(v[x], v[y], v[z], v[w]); + } + + template + GLM_FUNC_QUALIFIER T& swizzle + ( + detail::tvec4 & v, + comp x + ) + { + return v[x]; + } + + template + GLM_FUNC_QUALIFIER detail::tref2 swizzle + ( + detail::tvec4 & v, + comp x, comp y + ) + { + return detail::tref2(v[x], v[y]); + } + + template + GLM_FUNC_QUALIFIER detail::tref3 swizzle + ( + detail::tvec4 & v, + comp x, comp y, comp z + ) + { + return detail::tref3(v[x], v[y], v[z]); + } + + template + GLM_FUNC_QUALIFIER detail::tref4 swizzle + ( + detail::tvec4 & v, + comp x, comp y, comp z, comp w + ) + { + return detail::tref4(v[x], v[y], v[z], v[w]); + } +}//namespace glm diff --git a/src/libraries/glm/gtc/type_precision.hpp b/src/libraries/glm/gtc/type_precision.hpp new file mode 100755 index 0000000..270b51a --- /dev/null +++ b/src/libraries/glm/gtc/type_precision.hpp @@ -0,0 +1,669 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_type_precision +/// @file glm/gtc/type_precision.hpp +/// @date 2009-06-04 / 2011-12-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtc_type_precision GLM_GTC_type_precision +/// @ingroup gtc +/// +/// @brief Defines specific C++-based precision types. +/// +/// @ref core_precision defines types based on GLSL's precision qualifiers. This +/// extension defines types based on explicitly-sized C++ data types. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_type_precision +#define GLM_GTC_type_precision GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_type_precision extension included") +#endif + +namespace glm +{ + /////////////////////////// + // Signed int vector types + + /// @addtogroup gtc_type_precision + /// @{ + + /// 8 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int8 int8; + + /// 16 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int16 int16; + + /// 32 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int32 int32; + + /// 64 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int64 int64; + + + /// 8 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int8 int8_t; + + /// 16 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int16 int16_t; + + /// 32 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int32 int32_t; + + /// 64 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int64 int64_t; + + + /// 8 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int8 i8; + + /// 16 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int16 i16; + + /// 32 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int32 i32; + + /// 64 bit signed integer type. + /// @see gtc_type_precision + typedef detail::int64 i64; + + + /// 8 bit signed integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 i8vec1; + + /// 8 bit signed integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 i8vec2; + + /// 8 bit signed integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 i8vec3; + + /// 8 bit signed integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 i8vec4; + + + /// 16 bit signed integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 i16vec1; + + /// 16 bit signed integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 i16vec2; + + /// 16 bit signed integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 i16vec3; + + /// 16 bit signed integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 i16vec4; + + + /// 32 bit signed integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 i32vec1; + + /// 32 bit signed integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 i32vec2; + + /// 32 bit signed integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 i32vec3; + + /// 32 bit signed integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 i32vec4; + + + /// 64 bit signed integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 i64vec1; + + /// 64 bit signed integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 i64vec2; + + /// 64 bit signed integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 i64vec3; + + /// 64 bit signed integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 i64vec4; + + + ///////////////////////////// + // Unsigned int vector types + + /// 8 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint8 uint8; + + /// 16 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint16 uint16; + + /// 32 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint32 uint32; + + /// 64 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint64 uint64; + + + /// 8 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint8 uint8_t; + + /// 16 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint16 uint16_t; + + /// 32 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint32 uint32_t; + + /// 64 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint64 uint64_t; + + + /// 8 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint8 u8; + + /// 16 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint16 u16; + + /// 32 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint32 u32; + + /// 64 bit unsigned integer type. + /// @see gtc_type_precision + typedef detail::uint64 u64; + + + /// 8 bit unsigned integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 u8vec1; + + /// 8 bit unsigned integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 u8vec2; + + /// 8 bit unsigned integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 u8vec3; + + /// 8 bit unsigned integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 u8vec4; + + + /// 16 bit unsigned integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 u16vec1; + + /// 16 bit unsigned integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 u16vec2; + + /// 16 bit unsigned integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 u16vec3; + + /// 16 bit unsigned integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 u16vec4; + + + /// 32 bit unsigned integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 u32vec1; + + /// 32 bit unsigned integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 u32vec2; + + /// 32 bit unsigned integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 u32vec3; + + /// 32 bit unsigned integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 u32vec4; + + + /// 64 bit unsigned integer scalar type. + /// @see gtc_type_precision + typedef detail::tvec1 u64vec1; + + /// 64 bit unsigned integer vector of 2 components type. + /// @see gtc_type_precision + typedef detail::tvec2 u64vec2; + + /// 64 bit unsigned integer vector of 3 components type. + /// @see gtc_type_precision + typedef detail::tvec3 u64vec3; + + /// 64 bit unsigned integer vector of 4 components type. + /// @see gtc_type_precision + typedef detail::tvec4 u64vec4; + + + ////////////////////// + // Float vector types + + /// 16 bit half-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float16 float16; + + /// 32 bit single-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float32 float32; + + /// 64 bit double-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float64 float64; + + + /// 16 bit half-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float16 float16_t; + + /// 32 bit single-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float32 float32_t; + + /// 64 bit double-precision floating-point scalar. + /// @see gtc_type_precision + typedef detail::float64 float64_t; + + + /// 16 bit half-precision floating-point scalar. + /// @see gtc_type_precision + typedef float16 f16; + + /// 32 bit single-precision floating-point scalar. + /// @see gtc_type_precision + typedef float32 f32; + + /// 64 bit double-precision floating-point scalar. + /// @see gtc_type_precision + typedef float64 f64; + + + /// Single-precision floating-point vector of 1 component. + /// @see gtc_type_precision + typedef detail::tvec1 fvec1; + + /// Single-precision floating-point vector of 2 components. + /// @see gtc_type_precision + typedef detail::tvec2 fvec2; + + /// Single-precision floating-point vector of 3 components. + /// @see gtc_type_precision + typedef detail::tvec3 fvec3; + + /// Single-precision floating-point vector of 4 components. + /// @see gtc_type_precision + typedef detail::tvec4 fvec4; + + + /// Half-precision floating-point vector of 1 component. + /// @see gtc_type_precision + typedef detail::tvec1 f16vec1; + + /// Half-precision floating-point vector of 2 components. + /// @see gtc_type_precision + typedef detail::tvec2 f16vec2; + + /// Half-precision floating-point vector of 3 components. + /// @see gtc_type_precision + typedef detail::tvec3 f16vec3; + + /// Half-precision floating-point vector of 4 components. + /// @see gtc_type_precision + typedef detail::tvec4 f16vec4; + + + /// Single-precision floating-point vector of 1 component. + /// @see gtc_type_precision + typedef detail::tvec1 f32vec1; + + /// Single-precision floating-point vector of 2 components. + /// @see gtc_type_precision + typedef detail::tvec2 f32vec2; + + /// Single-precision floating-point vector of 3 components. + /// @see gtc_type_precision + typedef detail::tvec3 f32vec3; + + /// Single-precision floating-point vector of 4 components. + /// @see gtc_type_precision + typedef detail::tvec4 f32vec4; + + + /// Double-precision floating-point vector of 1 component. + /// @see gtc_type_precision + typedef detail::tvec1 f64vec1; + + /// Double-precision floating-point vector of 2 components. + /// @see gtc_type_precision + typedef detail::tvec2 f64vec2; + + /// Double-precision floating-point vector of 3 components. + /// @see gtc_type_precision + typedef detail::tvec3 f64vec3; + + /// Double-precision floating-point vector of 4 components. + /// @see gtc_type_precision + typedef detail::tvec4 f64vec4; + + + ////////////////////// + // Float matrix types + + /// Single-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef detail::tmat1x1 fmat1; + + /// Single-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 fmat2; + + /// Single-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 fmat3; + + /// Single-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 fmat4; + + + /// Single-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef f32 fmat1x1; + + /// Single-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 fmat2x2; + + /// Single-precision floating-point 2x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x3 fmat2x3; + + /// Single-precision floating-point 2x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x4 fmat2x4; + + /// Single-precision floating-point 3x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x2 fmat3x2; + + /// Single-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 fmat3x3; + + /// Single-precision floating-point 3x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x4 fmat3x4; + + /// Single-precision floating-point 4x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x2 fmat4x2; + + /// Single-precision floating-point 4x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x3 fmat4x3; + + /// Single-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 fmat4x4; + + + /// Half-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef detail::tmat1x1 f16mat1; + + /// Half-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f16mat2; + + /// Half-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f16mat3; + + /// Half-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f16mat4; + + + /// Half-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef f16 f16mat1x1; + + /// Half-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f16mat2x2; + + /// Half-precision floating-point 2x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x3 f16mat2x3; + + /// Half-precision floating-point 2x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x4 f16mat2x4; + + /// Half-precision floating-point 3x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x2 f16mat3x2; + + /// Half-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f16mat3x3; + + /// Half-precision floating-point 3x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x4 f16mat3x4; + + /// Half-precision floating-point 4x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x2 f16mat4x2; + + /// Half-precision floating-point 4x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x3 f16mat4x3; + + /// Half-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f16mat4x4; + + + /// Single-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef detail::tmat1x1 f32mat1; + + /// Single-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f32mat2; + + /// Single-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f32mat3; + + /// Single-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f32mat4; + + + /// Single-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef f32 f32mat1x1; + + /// Single-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f32mat2x2; + + /// Single-precision floating-point 2x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x3 f32mat2x3; + + /// Single-precision floating-point 2x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x4 f32mat2x4; + + /// Single-precision floating-point 3x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x2 f32mat3x2; + + /// Single-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f32mat3x3; + + /// Single-precision floating-point 3x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x4 f32mat3x4; + + /// Single-precision floating-point 4x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x2 f32mat4x2; + + /// Single-precision floating-point 4x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x3 f32mat4x3; + + /// Single-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f32mat4x4; + + + /// Double-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef detail::tmat1x1 f64mat1; + + /// Double-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f64mat2; + + /// Double-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f64mat3; + + /// Double-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f64mat4; + + + /// Double-precision floating-point 1x1 matrix. + /// @see gtc_type_precision + //typedef f64 f64mat1x1; + + /// Double-precision floating-point 2x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x2 f64mat2x2; + + /// Double-precision floating-point 2x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x3 f64mat2x3; + + /// Double-precision floating-point 2x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat2x4 f64mat2x4; + + /// Double-precision floating-point 3x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x2 f64mat3x2; + + /// Double-precision floating-point 3x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x3 f64mat3x3; + + /// Double-precision floating-point 3x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat3x4 f64mat3x4; + + /// Double-precision floating-point 4x2 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x2 f64mat4x2; + + /// Double-precision floating-point 4x3 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x3 f64mat4x3; + + /// Double-precision floating-point 4x4 matrix. + /// @see gtc_type_precision + typedef detail::tmat4x4 f64mat4x4; + + + ////////////////////////// + // Quaternion types + + /// Half-precision floating-point quaternion. + /// @see gtc_type_precision + typedef detail::tquat f16quat; + + /// Single-precision floating-point quaternion. + /// @see gtc_type_precision + typedef detail::tquat f32quat; + + /// Double-precision floating-point quaternion. + /// @see gtc_type_precision + typedef detail::tquat f64quat; + + /// @} +}//namespace glm + +#include "type_precision.inl" + +#endif//GLM_GTC_type_precision diff --git a/src/libraries/glm/gtc/type_precision.inl b/src/libraries/glm/gtc/type_precision.inl new file mode 100755 index 0000000..ea5b2fa --- /dev/null +++ b/src/libraries/glm/gtc/type_precision.inl @@ -0,0 +1,32 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_swizzle +/// @file glm/gtc/swizzle.inl +/// @date 2009-06-14 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +} diff --git a/src/libraries/glm/gtc/type_ptr.hpp b/src/libraries/glm/gtc/type_ptr.hpp new file mode 100755 index 0000000..2946e93 --- /dev/null +++ b/src/libraries/glm/gtc/type_ptr.hpp @@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_type_ptr +/// @file glm/gtc/type_ptr.hpp +/// @date 2009-05-06 / 2011-06-05 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtc_type_ptr GLM_GTC_type_ptr +/// @ingroup gtc +/// +/// @brief Handles the interaction between pointers and vector, matrix types. +/// +/// This extension defines an overloaded function, glm::value_ptr, which +/// takes any of the \ref core_template "core template types". It returns +/// a pointer to the memory layout of the object. Matrix types store their values +/// in column-major order. +/// +/// This is useful for uploading data to matrices or copying data to buffer objects. +/// +/// Example: +/// @code +/// #include +/// #include +/// +/// glm::vec3 aVector(3); +/// glm::mat4 someMatrix(1.0); +/// +/// glUniform3fv(uniformLoc, 1, glm::value_ptr(aVector)); +/// glUniformMatrix4fv(uniformMatrixLoc, 1, GL_FALSE, glm::value_ptr(someMatrix)); +/// @endcode +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_type_ptr +#define GLM_GTC_type_ptr GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" +#include + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_type_ptr extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_type_ptr + /// @{ + + /// Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + typename genType::value_type const * value_ptr(genType const & vec); + + /// Build a vector from a pointer. + /// @see gtc_type_ptr + template + detail::tvec2 make_vec2(T const * const ptr); + + /// Build a vector from a pointer. + /// @see gtc_type_ptr + template + detail::tvec3 make_vec3(T const * const ptr); + + /// Build a vector from a pointer. + /// @see gtc_type_ptr + template + detail::tvec4 make_vec4(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat2x2 make_mat2x2(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat2x3 make_mat2x3(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat2x4 make_mat2x4(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat3x2 make_mat3x2(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat3x3 make_mat3x3(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat3x4 make_mat3x4(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat4x2 make_mat4x2( + T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat4x3 make_mat4x3(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat4x4 make_mat4x4(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat2x2 make_mat2(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat3x3 make_mat3(T const * const ptr); + + /// Build a matrix from a pointer. + /// @see gtc_type_ptr + template + detail::tmat4x4 make_mat4(T const * const ptr); + + /// Build a quaternion from a pointer. + /// @see gtc_type_ptr + template + detail::tquat make_quat(T const * const ptr); + + /// @} +}//namespace glm + +#include "type_ptr.inl" + +#endif//GLM_GTC_type_ptr + diff --git a/src/libraries/glm/gtc/type_ptr.inl b/src/libraries/glm/gtc/type_ptr.inl new file mode 100755 index 0000000..f1638d2 --- /dev/null +++ b/src/libraries/glm/gtc/type_ptr.inl @@ -0,0 +1,462 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_type_ptr +/// @file glm/gtc/type_ptr.inl +/// @date 2011-06-15 / 2011-12-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + /// @addtogroup gtc_type_ptr + /// @{ + + /// Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tvec2 const & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tvec2 & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tvec3 const & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tvec3 & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tvec4 const & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + //! From GLM_GTC_type_ptr extension. + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tvec4 & vec + ) + { + return &(vec.x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat2x2 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat2x2 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat3x3 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat3x3 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat4x4 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + //! From GLM_GTC_type_ptr extension. + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat4x4 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat2x3 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat2x3 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat3x2 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat3x2 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat2x4 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat2x4 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat4x2 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat4x2 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat3x4 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr + ( + detail::tmat3x4 & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tmat4x3 const & mat + ) + { + return &(mat[0].x); + } + + //! Return the constant address to the data of the input parameter. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T const * value_ptr + ( + detail::tquat const & q + ) + { + return &(q[0]); + } + + //! Get the address of the matrix content. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER T * value_ptr(detail::tmat4x3 & mat) + { + return &(mat[0].x); + } + + //! Build a vector from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tvec2 make_vec2(T const * const ptr) + { + detail::tvec2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2)); + return Result; + } + + //! Build a vector from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tvec3 make_vec3(T const * const ptr) + { + detail::tvec3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3)); + return Result; + } + + //! Build a vector from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tvec4 make_vec4(T const * const ptr) + { + detail::tvec4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat2x2 make_mat2x2(T const * const ptr) + { + detail::tmat2x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat2x3 make_mat2x3(T const * const ptr) + { + detail::tmat2x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat2x4 make_mat2x4(T const * const ptr) + { + detail::tmat2x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat3x2 make_mat3x2(T const * const ptr) + { + detail::tmat3x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat3x3 make_mat3x3(T const * const ptr) + { + detail::tmat3x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat3x4 make_mat3x4(T const * const ptr) + { + detail::tmat3x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat4x2 make_mat4x2(T const * const ptr) + { + detail::tmat4x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat4x3 make_mat4x3(T const * const ptr) + { + detail::tmat4x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat4x4 make_mat4x4(T const * const ptr) + { + detail::tmat4x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4)); + return Result; + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat2x2 make_mat2(T const * const ptr) + { + return make_mat2x2(ptr); + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat3x3 make_mat3(T const * const ptr) + { + return make_mat3x3(ptr); + } + + //! Build a matrix from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tmat4x4 make_mat4(T const * const ptr) + { + return make_mat4x4(ptr); + } + + //! Build a quaternion from a pointer. + /// @see gtc_type_ptr + template + GLM_FUNC_QUALIFIER detail::tquat make_quat(T const * const ptr) + { + detail::tquat Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tquat)); + return Result; + } + + /// @} +}//namespace glm + diff --git a/src/libraries/glm/gtc/ulp.hpp b/src/libraries/glm/gtc/ulp.hpp new file mode 100755 index 0000000..5aa8905 --- /dev/null +++ b/src/libraries/glm/gtc/ulp.hpp @@ -0,0 +1,90 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_ulp +/// @file glm/gtc/ulp.hpp +/// @date 2011-02-21 / 2011-12-12 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtc_ulp GLM_GTC_ulp +/// @ingroup gtc +/// +/// @brief Allow the measurement of the accuracy of a function against a reference +/// implementation. This extension works on floating-point data and provide results +/// in ULP. +/// need to be included to use these features. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_ulp +#define GLM_GTC_ulp GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_ulp extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_ulp + /// @{ + + /// Return the next ULP value(s) after the input value(s). + /// @see gtc_ulp + template + genType next_float(genType const & x); + + /// Return the previous ULP value(s) before the input value(s). + /// @see gtc_ulp + template + genType prev_float(genType const & x); + + /// Return the value(s) ULP distance after the input value(s). + /// @see gtc_ulp + template + genType next_float(genType const & x, uint const & Distance); + + /// Return the value(s) ULP distance before the input value(s). + /// @see gtc_ulp + template + genType prev_float(genType const & x, uint const & Distance); + + /// Return the distance in the number of ULP between 2 scalars. + /// @see gtc_ulp + template + uint float_distance(T const & x, T const & y); + + /// Return the distance in the number of ULP between 2 vectors. + /// @see gtc_ulp + template class vecType> + vecType float_distance(vecType const & x, vecType const & y); + + /// @} +}// namespace glm + +#include "ulp.inl" + +#endif//GLM_GTC_ulp + diff --git a/src/libraries/glm/gtc/ulp.inl b/src/libraries/glm/gtc/ulp.inl new file mode 100755 index 0000000..2875c68 --- /dev/null +++ b/src/libraries/glm/gtc/ulp.inl @@ -0,0 +1,314 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtc_ulp +/// @file glm/gtc/ulp.inl +/// @date 2011-03-07 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// +/// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/// +/// Developed at SunPro, a Sun Microsystems, Inc. business. +/// Permission to use, copy, modify, and distribute this +/// software is freely granted, provided that this notice +/// is preserved. +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +#pragma warning(push) +#pragma warning(disable : 4127) + +typedef union +{ + float value; + /* FIXME: Assumes 32 bit int. */ + unsigned int word; +} ieee_float_shape_type; + +typedef union +{ + double value; + struct + { + glm::detail::int32 lsw; + glm::detail::int32 msw; + } parts; +} ieee_double_shape_type; + +#define GLM_EXTRACT_WORDS(ix0,ix1,d) \ + do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ + } while (0) + +#define GLM_GET_FLOAT_WORD(i,d) \ + do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ + } while (0) + +#define GLM_SET_FLOAT_WORD(d,i) \ + do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ + } while (0) + +#define GLM_INSERT_WORDS(d,ix0,ix1) \ + do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ + } while (0) + +namespace glm{ +namespace detail +{ + GLM_FUNC_QUALIFIER float nextafterf(float x, float y) + { + volatile float t; + glm::detail::int32 hx, hy, ix, iy; + + GLM_GET_FLOAT_WORD(hx, x); + GLM_GET_FLOAT_WORD(hy, y); + ix = hx&0x7fffffff; // |x| + iy = hy&0x7fffffff; // |y| + + if((ix>0x7f800000) || // x is nan + (iy>0x7f800000)) // y is nan + return x+y; + if(x==y) return y; // x=y, return y + if(ix==0) { // x == 0 + GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal + t = x*x; + if(t==x) return t; else return x; // raise underflow flag + } + if(hx>=0) { // x > 0 + if(hx>hy) { // x > y, x -= ulp + hx -= 1; + } else { // x < y, x += ulp + hx += 1; + } + } else { // x < 0 + if(hy>=0||hx>hy){ // x < y, x -= ulp + hx -= 1; + } else { // x > y, x += ulp + hx += 1; + } + } + hy = hx&0x7f800000; + if(hy>=0x7f800000) return x+x; // overflow + if(hy<0x00800000) { // underflow + t = x*x; + if(t!=x) { // raise underflow flag + GLM_SET_FLOAT_WORD(y,hx); + return y; + } + } + GLM_SET_FLOAT_WORD(x,hx); + return x; + } + + GLM_FUNC_QUALIFIER double nextafter(double x, double y) + { + volatile double t; + glm::detail::int32 hx, hy, ix, iy; + glm::detail::uint32 lx, ly; + + GLM_EXTRACT_WORDS(hx, lx, x); + GLM_EXTRACT_WORDS(hy, ly, y); + ix = hx & 0x7fffffff; // |x| + iy = hy & 0x7fffffff; // |y| + + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan + ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan + return x+y; + if(x==y) return y; // x=y, return y + if((ix|lx)==0) { // x == 0 + GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal + t = x*x; + if(t==x) return t; else return x; // raise underflow flag + } + if(hx>=0) { // x > 0 + if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp + if(lx==0) hx -= 1; + lx -= 1; + } else { // x < y, x += ulp + lx += 1; + if(lx==0) hx += 1; + } + } else { // x < 0 + if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){// x < y, x -= ulp + if(lx==0) hx -= 1; + lx -= 1; + } else { // x > y, x += ulp + lx += 1; + if(lx==0) hx += 1; + } + } + hy = hx&0x7ff00000; + if(hy>=0x7ff00000) return x+x; // overflow + if(hy<0x00100000) { // underflow + t = x*x; + if(t!=x) { // raise underflow flag + GLM_INSERT_WORDS(y,hx,lx); + return y; + } + } + GLM_INSERT_WORDS(x,hx,lx); + return x; + } +}//namespace detail +}//namespace glm + +#pragma warning(pop) + +#if((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) +# define GLM_NEXT_AFTER_FLT(x, toward) glm::detail::nextafterf((x), (toward)) +# define GLM_NEXT_AFTER_DBL(x, toward) _nextafter((x), (toward)) +#else +# define GLM_NEXT_AFTER_FLT(x, toward) nextafterf((x), (toward)) +# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward)) +#endif + +namespace glm +{ + GLM_FUNC_QUALIFIER float next_float(float const & x) + { + return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::max()); + } + + GLM_FUNC_QUALIFIER double next_float(double const & x) + { + return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::max()); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType next_float(vecType const & x) + { + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = next_float(x[i]); + return Result; + } + + GLM_FUNC_QUALIFIER float prev_float(float const & x) + { + return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::min()); + } + + GLM_FUNC_QUALIFIER double prev_float(double const & x) + { + return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::min()); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x) + { + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = prev_float(x[i]); + return Result; + } + + template + GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps) + { + T temp = x; + for(std::size_t i = 0; i < ulps; ++i) + temp = next_float(temp); + return temp; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType next_float(vecType const & x, vecType const & ulps) + { + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = next_float(x[i], ulps[i]); + return Result; + } + + template + GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps) + { + T temp = x; + for(std::size_t i = 0; i < ulps; ++i) + temp = prev_float(temp); + return temp; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x, vecType const & ulps) + { + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = prev_float(x[i], ulps[i]); + return Result; + } + + template + GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y) + { + uint ulp = 0; + + if(x < y) + { + T temp = x; + while(temp != y && ulp < std::numeric_limits::max()) + { + ++ulp; + temp = next_float(temp); + } + } + else if(y < x) + { + T temp = y; + while(temp != x && ulp < std::numeric_limits::max()) + { + ++ulp; + temp = next_float(temp); + } + } + else // == + { + + } + + return ulp; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType float_distance(vecType const & x, vecType const & y) + { + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = float_distance(x[i], y[i]); + return Result; + } +}//namespace glm -- cgit v1.2.3