parameterize number of dimensions of vector in tvec<D, T, P>

- specializes for 1, 2, 3 and 4-dimensional vector types
  which are then aliased as tvec1, tvec2, tvec3 and tvec4
- requires C++11 aliases; breaks compatability with C++03
- tested on:
  - clang-3.5.2, clang-3.8.0
  - gcc 4.8.5, gcc 5.4.1, gcc 6.2.0

TODO:
- still uses template template parameters - most can probably be removed
- some definitions might now be de-duplicated
This commit is contained in:
John McFarlane
2016-12-28 16:59:01 -08:00
parent 06f084063f
commit 506a487d24
94 changed files with 3453 additions and 3484 deletions

View File

@@ -50,8 +50,8 @@ namespace glm
/// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
///
/// @see gtc_bitfield
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> bitfieldRotateRight(vecType<D, T, P> const & In, int Shift);
/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
///
@@ -62,8 +62,8 @@ namespace glm
/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
///
/// @see gtc_bitfield
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> bitfieldRotateLeft(vecType<T, P> const & In, int Shift);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> bitfieldRotateLeft(vecType<D, T, P> const & In, int Shift);
/// Set to 1 a range of bits.
///
@@ -74,8 +74,8 @@ namespace glm
/// Set to 1 a range of bits.
///
/// @see gtc_bitfield
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> bitfieldFillOne(vecType<T, P> const & Value, int FirstBit, int BitCount);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> bitfieldFillOne(vecType<D, T, P> const & Value, int FirstBit, int BitCount);
/// Set to 0 a range of bits.
///
@@ -86,8 +86,8 @@ namespace glm
/// Set to 0 a range of bits.
///
/// @see gtc_bitfield
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> bitfieldFillZero(vecType<T, P> const & Value, int FirstBit, int BitCount);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> bitfieldFillZero(vecType<D, T, P> const & Value, int FirstBit, int BitCount);
/// Interleaves the bits of x and y.
/// The first bit is the first bit of x followed by the first bit of y.

View File

@@ -230,12 +230,12 @@ namespace detail
return Bits >= sizeof(genIUType) * 8 ? ~static_cast<genIUType>(0) : (static_cast<genIUType>(1) << Bits) - static_cast<genIUType>(1);
}
template <typename T, precision P, template <typename, precision> class vecIUType>
GLM_FUNC_QUALIFIER vecIUType<T, P> mask(vecIUType<T, P> const& v)
template <int D, typename T, precision P, template <int, typename, precision> class vecIUType>
GLM_FUNC_QUALIFIER vecIUType<D, T, P> mask(vecIUType<D, T, P> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'mask' accepts only integer values");
return detail::functor1<T, T, P, vecIUType>::call(mask, v);
return detail::functor1<D, T, T, P>::call(mask, v);
}
template <typename genIType>
@@ -247,8 +247,8 @@ namespace detail
return (In << static_cast<genIType>(Shift)) | (In >> static_cast<genIType>(BitSize - Shift));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldRotateRight(vecType<D, T, P> const & In, int Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateRight' accepts only integer values");
@@ -265,8 +265,8 @@ namespace detail
return (In >> static_cast<genIType>(Shift)) | (In << static_cast<genIType>(BitSize - Shift));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateLeft(vecType<T, P> const& In, int Shift)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldRotateLeft(vecType<D, T, P> const& In, int Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateLeft' accepts only integer values");
@@ -280,8 +280,8 @@ namespace detail
return Value | static_cast<genIUType>(mask(BitCount) << FirstBit);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldFillOne(vecType<T, P> const& Value, int FirstBit, int BitCount)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldFillOne(vecType<D, T, P> const& Value, int FirstBit, int BitCount)
{
return Value | static_cast<T>(mask(BitCount) << FirstBit);
}
@@ -292,8 +292,8 @@ namespace detail
return Value & static_cast<genIUType>(~(mask(BitCount) << FirstBit));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldFillZero(vecType<T, P> const& Value, int FirstBit, int BitCount)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldFillZero(vecType<D, T, P> const& Value, int FirstBit, int BitCount)
{
return Value & static_cast<T>(~(mask(BitCount) << FirstBit));
}

View File

@@ -32,23 +32,23 @@ namespace glm
/// Convert a linear color to sRGB color using a standard gamma correction.
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> convertLinearToSRGB(vecType<D, T, P> const & ColorLinear);
/// Convert a linear color to sRGB color using a custom gamma correction.
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> const & ColorLinear, T Gamma);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> convertLinearToSRGB(vecType<D, T, P> const & ColorLinear, T Gamma);
/// Convert a sRGB color to linear color using a standard gamma correction.
/// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> convertSRGBToLinear(vecType<D, T, P> const & ColorSRGB);
/// Convert a sRGB color to linear color using a custom gamma correction.
// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> convertSRGBToLinear(vecType<D, T, P> const & ColorSRGB, T Gamma);
/// @}
} //namespace glm

View File

@@ -4,55 +4,55 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType>
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
struct compute_rgbToSrgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorRGB, T GammaCorrection)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const& ColorRGB, T GammaCorrection)
{
vecType<T, P> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
vecType<D, T, P> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
return mix(
pow(ClampedColor, vecType<T, P>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
pow(ClampedColor, vecType<D, T, P>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
ClampedColor * static_cast<T>(12.92),
lessThan(ClampedColor, vecType<T, P>(static_cast<T>(0.0031308))));
lessThan(ClampedColor, vecType<D, T, P>(static_cast<T>(0.0031308))));
}
};
template <typename T, precision P>
struct compute_rgbToSrgb<T, P, tvec4>
struct compute_rgbToSrgb<4, T, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorRGB, T GammaCorrection)
{
return tvec4<T, P>(compute_rgbToSrgb<T, P, tvec3>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.a);
return tvec4<T, P>(compute_rgbToSrgb<3, T, P, tvec>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.a);
}
};
template <typename T, precision P, template <typename, precision> class vecType>
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
struct compute_srgbToRgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorSRGB, T Gamma)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const& ColorSRGB, T Gamma)
{
return mix(
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<T, P>(Gamma)),
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<D, T, P>(Gamma)),
ColorSRGB * static_cast<T>(0.07739938080495356037151702786378),
lessThanEqual(ColorSRGB, vecType<T, P>(static_cast<T>(0.04045))));
lessThanEqual(ColorSRGB, vecType<D, T, P>(static_cast<T>(0.04045))));
}
};
template <typename T, precision P>
struct compute_srgbToRgb<T, P, tvec4>
struct compute_srgbToRgb<4, T, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorSRGB, T Gamma)
{
return tvec4<T, P>(compute_srgbToRgb<T, P, tvec3>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.a);
return tvec4<T, P>(compute_srgbToRgb<3, T, P, tvec>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.a);
}
};
}//namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> convertLinearToSRGB(vecType<D, T, P> const& ColorLinear)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
return detail::compute_rgbToSrgb<D, T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
}
// Based on Ian Taylor http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html
@@ -65,21 +65,21 @@ namespace detail
return 0.662002687f * S1 + 0.684122060f * S2 - 0.323583601f * S3 - 0.0225411470f * ColorLinear;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear, T Gamma)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> convertLinearToSRGB(vecType<D, T, P> const& ColorLinear, T Gamma)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
return detail::compute_rgbToSrgb<D, T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> convertSRGBToLinear(vecType<D, T, P> const& ColorSRGB)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
return detail::compute_srgbToRgb<D, T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB, T Gamma)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> convertSRGBToLinear(vecType<D, T, P> const& ColorSRGB, T Gamma)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
return detail::compute_srgbToRgb<D, T, P, vecType>::call(ColorSRGB, Gamma);
}
}//namespace glm

View File

@@ -30,10 +30,10 @@ namespace glm
/// True if this expression is satisfied.
///
/// @see gtc_epsilon
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<bool, P> epsilonEqual(
vecType<T, P> const & x,
vecType<T, P> const & y,
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, bool, P> epsilonEqual(
vecType<D, T, P> const & x,
vecType<D, T, P> const & y,
T const & epsilon);
/// Returns the component-wise comparison of |x - y| < epsilon.

View File

@@ -55,48 +55,48 @@ namespace glm
return abs(x - y) >= epsilon;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> epsilonEqual
(
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<D, T, P> const & x,
vecType<D, T, P> const & y,
T const & epsilon
)
{
return lessThan(abs(x - y), vecType<T, P>(epsilon));
return lessThan(abs(x - y), vecType<D, T, P>(epsilon));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> epsilonEqual
(
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<T, P> const & epsilon
vecType<D, T, P> const & x,
vecType<D, T, P> const & y,
vecType<D, T, P> const & epsilon
)
{
return lessThan(abs(x - y), vecType<T, P>(epsilon));
return lessThan(abs(x - y), vecType<D, T, P>(epsilon));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> epsilonNotEqual
(
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<D, T, P> const & x,
vecType<D, T, P> const & y,
T const & epsilon
)
{
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
return greaterThanEqual(abs(x - y), vecType<D, T, P>(epsilon));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> epsilonNotEqual
(
vecType<T, P> const & x,
vecType<T, P> const & y,
vecType<T, P> const & epsilon
vecType<D, T, P> const & x,
vecType<D, T, P> const & y,
vecType<D, T, P> const & epsilon
)
{
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
return greaterThanEqual(abs(x - y), vecType<D, T, P>(epsilon));
}
template <typename T, precision P>

View File

@@ -55,8 +55,8 @@ namespace glm
/// @see gtc_integer
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, T y);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> mod(vecType<D, T, P> const & x, T y);
/// Modulus. Returns x % y
/// for each component in x using the floating point value y.
@@ -67,8 +67,8 @@ namespace glm
/// @see gtc_integer
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, vecType<T, P> const & y);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> mod(vecType<D, T, P> const & x, vecType<D, T, P> const & y);
/// Returns a value equal to the nearest integer to x.
/// The fraction 0.5 will round in a direction chosen by the
@@ -80,8 +80,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<int, P> iround(vecType<T, P> const & x);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, int, P> iround(vecType<D, T, P> const & x);
/// Returns a value equal to the nearest integer to x.
/// The fraction 0.5 will round in a direction chosen by the
@@ -93,8 +93,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<uint, P> uround(vecType<T, P> const & x);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, uint, P> uround(vecType<D, T, P> const & x);
/// @}
} //namespace glm

View File

@@ -4,14 +4,14 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType, bool Aligned>
struct compute_log2<T, P, vecType, false, Aligned>
template <int D, typename T, precision P, template <int, typename, precision> class vecType, bool Aligned>
struct compute_log2<D, T, P, vecType, false, Aligned>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & vec)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & vec)
{
//Equivalent to return findMSB(vec); but save one function call in ASM with VC
//return findMSB(vec);
return vecType<T, P>(detail::compute_findMSB_vec<T, P, vecType, sizeof(T) * 8>::call(vec));
return vecType<D, T, P>(detail::compute_findMSB_vec<D, T, P, vecType, sizeof(T) * 8>::call(vec));
}
};
@@ -42,13 +42,13 @@ namespace detail
return static_cast<int>(x + static_cast<genType>(0.5));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<int, P> iround(vecType<T, P> const& x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, int, P> iround(vecType<D, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'iround' only accept floating-point inputs");
assert(all(lessThanEqual(vecType<T, P>(0), x)));
assert(all(lessThanEqual(vecType<D, T, P>(0), x)));
return vecType<int, P>(x + static_cast<T>(0.5));
return vecType<D, int, P>(x + static_cast<T>(0.5));
}
template <typename genType>
@@ -60,12 +60,12 @@ namespace detail
return static_cast<uint>(x + static_cast<genType>(0.5));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint, P> uround(vecType<T, P> const& x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, uint, P> uround(vecType<D, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'uround' only accept floating-point inputs");
assert(all(lessThanEqual(vecType<T, P>(0), x)));
assert(all(lessThanEqual(vecType<D, T, P>(0), x)));
return vecType<uint, P>(x + static_cast<T>(0.5));
return vecType<D, uint, P>(x + static_cast<T>(0.5));
}
}//namespace glm

View File

@@ -37,22 +37,22 @@ namespace glm
/// Classic perlin noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
template <int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p);
vecType<D, T, P> const & p);
/// Periodic perlin noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
template <int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_DECL T perlin(
vecType<T, P> const & p,
vecType<T, P> const & rep);
vecType<D, T, P> const & p,
vecType<D, T, P> const & rep);
/// Simplex noise.
/// @see gtc_noise
template <typename T, precision P, template<typename, precision> class vecType>
template <int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_DECL T simplex(
vecType<T, P> const & p);
vecType<D, T, P> const & p);
/// @}
}//namespace glm

View File

@@ -477,7 +477,7 @@ namespace glm
/// @see gtc_packing
/// @see tvec3<T, P> unpackRGBM(tvec4<T, P> const & p)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <typename T, precision P>
template <int D, typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> packRGBM(tvec3<T, P> const & rgb);
/// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
@@ -487,7 +487,7 @@ namespace glm
/// @see gtc_packing
/// @see tvec4<T, P> packRGBM(tvec3<float, P> const & v)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <typename T, precision P>
template <int D, typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> unpackRGBM(tvec4<T, P> const & rgbm);
/// Returns an unsigned integer vector obtained by converting the components of a floating-point vector
@@ -496,48 +496,48 @@ namespace glm
/// the forth component specifies the 16 most-significant bits.
///
/// @see gtc_packing
/// @see vecType<float, P> unpackHalf(vecType<uint16, P> const & p)
/// @see vecType<D, float, P> unpackHalf(vecType<D, uint16, P> const & p)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<uint16, P> packHalf(vecType<float, P> const & v);
template <int D, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, uint16, P> packHalf(vecType<D, float, P> const & v);
/// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
/// The first component of the vector is obtained from the 16 least-significant bits of v;
/// the forth component is obtained from the 16 most-significant bits of v.
///
/// @see gtc_packing
/// @see vecType<uint16, P> packHalf(vecType<float, P> const & v)
/// @see vecType<D, uint16, P> packHalf(vecType<D, float, P> const & v)
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<float, P> unpackHalf(vecType<uint16, P> const & p);
template <int D, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, float, P> unpackHalf(vecType<D, uint16, P> const & p);
/// Convert each component of the normalized floating-point vector into unsigned integer values.
///
/// @see gtc_packing
/// @see vecType<floatType, P> unpackUnorm(vecType<intType, P> const & p);
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<uintType, P> packUnorm(vecType<floatType, P> const & v);
/// @see vecType<D, floatType, P> unpackUnorm(vecType<D, intType, P> const & p);
template <int D, typename uintType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, uintType, P> packUnorm(vecType<D, floatType, P> const & v);
/// Convert each unsigned integer components of a vector to normalized floating-point values.
///
/// @see gtc_packing
/// @see vecType<intType, P> packUnorm(vecType<floatType, P> const & v)
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<floatType, P> unpackUnorm(vecType<uintType, P> const & v);
/// @see vecType<D, intType, P> packUnorm(vecType<D, floatType, P> const & v)
template <int D, typename uintType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, floatType, P> unpackUnorm(vecType<D, uintType, P> const & v);
/// Convert each component of the normalized floating-point vector into signed integer values.
///
/// @see gtc_packing
/// @see vecType<floatType, P> unpackSnorm(vecType<intType, P> const & p);
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<intType, P> packSnorm(vecType<floatType, P> const & v);
/// @see vecType<D, floatType, P> unpackSnorm(vecType<D, intType, P> const & p);
template <int D, typename intType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, intType, P> packSnorm(vecType<D, floatType, P> const & v);
/// Convert each signed integer components of a vector to normalized floating-point values.
///
/// @see gtc_packing
/// @see vecType<intType, P> packSnorm(vecType<floatType, P> const & v)
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<floatType, P> unpackSnorm(vecType<intType, P> const & v);
/// @see vecType<D, intType, P> packSnorm(vecType<D, floatType, P> const & v)
template <int D, typename intType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, floatType, P> unpackSnorm(vecType<D, intType, P> const & v);
/// Convert each component of the normalized floating-point vector into unsigned integer values.
///

View File

@@ -270,14 +270,14 @@ namespace detail
uint32 pack;
};
template <precision P, template <typename, precision> class vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_half
{};
template <precision P>
struct compute_half<P, tvec1>
struct compute_half<1, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec1<uint16, P> pack(tvec1<float, P> const & v)
GLM_FUNC_QUALIFIER static tvec<1, uint16, P> pack(tvec<1, float, P> const & v)
{
int16 const Unpack(detail::toFloat16(v.x));
u16vec1 Packed(uninitialize);
@@ -285,68 +285,68 @@ namespace detail
return Packed;
}
GLM_FUNC_QUALIFIER static tvec1<float, P> unpack(tvec1<uint16, P> const & v)
GLM_FUNC_QUALIFIER static tvec<1, float, P> unpack(tvec<1, uint16, P> const & v)
{
i16vec1 Unpack(uninitialize);
memcpy(&Unpack, &v, sizeof(Unpack));
return tvec1<float, P>(detail::toFloat32(v.x));
return tvec<1, float, P>(detail::toFloat32(v.x));
}
};
template <precision P>
struct compute_half<P, tvec2>
struct compute_half<2, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec2<uint16, P> pack(tvec2<float, P> const & v)
GLM_FUNC_QUALIFIER static tvec<2, uint16, P> pack(tvec<2, float, P> const & v)
{
tvec2<int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y));
tvec<2, int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y));
u16vec2 Packed(uninitialize);
memcpy(&Packed, &Unpack, sizeof(Packed));
return Packed;
}
GLM_FUNC_QUALIFIER static tvec2<float, P> unpack(tvec2<uint16, P> const & v)
GLM_FUNC_QUALIFIER static tvec<2, float, P> unpack(tvec<2, uint16, P> const & v)
{
i16vec2 Unpack(uninitialize);
memcpy(&Unpack, &v, sizeof(Unpack));
return tvec2<float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y));
return tvec<2, float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y));
}
};
template <precision P>
struct compute_half<P, tvec3>
struct compute_half<3, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec3<uint16, P> pack(tvec3<float, P> const & v)
GLM_FUNC_QUALIFIER static tvec<3, uint16, P> pack(tvec<3, float, P> const & v)
{
tvec3<int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z));
tvec<3, int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z));
u16vec3 Packed(uninitialize);
memcpy(&Packed, &Unpack, sizeof(Packed));
return Packed;
}
GLM_FUNC_QUALIFIER static tvec3<float, P> unpack(tvec3<uint16, P> const & v)
GLM_FUNC_QUALIFIER static tvec<3, float, P> unpack(tvec<3, uint16, P> const & v)
{
i16vec3 Unpack(uninitialize);
memcpy(&Unpack, &v, sizeof(Unpack));
return tvec3<float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z));
return tvec<3, float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z));
}
};
template <precision P>
struct compute_half<P, tvec4>
struct compute_half<4, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec4<uint16, P> pack(tvec4<float, P> const & v)
GLM_FUNC_QUALIFIER static tvec<4, uint16, P> pack(tvec<4, float, P> const & v)
{
tvec4<int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w));
tvec<4, int16, P> const Unpack(detail::toFloat16(v.x), detail::toFloat16(v.y), detail::toFloat16(v.z), detail::toFloat16(v.w));
u16vec4 Packed(uninitialize);
memcpy(&Packed, &Unpack, sizeof(Packed));
return Packed;
}
GLM_FUNC_QUALIFIER static tvec4<float, P> unpack(tvec4<uint16, P> const & v)
GLM_FUNC_QUALIFIER static tvec<4, float, P> unpack(tvec<4, uint16, P> const & v)
{
i16vec4 Unpack(uninitialize);
memcpy(&Unpack, &v, sizeof(Unpack));
return tvec4<float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z), detail::toFloat32(v.w));
return tvec<4, float, P>(detail::toFloat32(v.x), detail::toFloat32(v.y), detail::toFloat32(v.z), detail::toFloat32(v.w));
}
};
}//namespace detail
@@ -641,66 +641,66 @@ namespace detail
// Based on Brian Karis http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> packRGBM(tvec3<T, P> const & rgb)
GLM_FUNC_QUALIFIER tvec<4, T, P> packRGBM(tvec<3, T, P> const & rgb)
{
tvec3<T, P> const Color(rgb * static_cast<T>(1.0 / 6.0));
tvec<3, T, P> const Color(rgb * static_cast<T>(1.0 / 6.0));
T Alpha = clamp(max(max(Color.x, Color.y), max(Color.z, static_cast<T>(1e-6))), static_cast<T>(0), static_cast<T>(1));
Alpha = ceil(Alpha * static_cast<T>(255.0)) / static_cast<T>(255.0);
return tvec4<T, P>(Color / Alpha, Alpha);
return tvec<4, T, P>(Color / Alpha, Alpha);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> unpackRGBM(tvec4<T, P> const & rgbm)
GLM_FUNC_QUALIFIER tvec<3, T, P> unpackRGBM(tvec<4, T, P> const & rgbm)
{
return tvec3<T, P>(rgbm.x, rgbm.y, rgbm.z) * rgbm.w * static_cast<T>(6);
return tvec<3, T, P>(rgbm.x, rgbm.y, rgbm.z) * rgbm.w * static_cast<T>(6);
}
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint16, P> packHalf(vecType<float, P> const & v)
template <int D, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, uint16, P> packHalf(vecType<D, float, P> const & v)
{
return detail::compute_half<P, vecType>::pack(v);
return detail::compute_half<D, P, vecType>::pack(v);
}
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<float, P> unpackHalf(vecType<uint16, P> const & v)
template <int D, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, float, P> unpackHalf(vecType<D, uint16, P> const & v)
{
return detail::compute_half<P, vecType>::unpack(v);
return detail::compute_half<D, P, vecType>::unpack(v);
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uintType, P> packUnorm(vecType<floatType, P> const & v)
template <int D, typename uintType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, uintType, P> packUnorm(vecType<D, floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<uintType, P>(round(clamp(v, static_cast<floatType>(0), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<uintType>::max())));
return vecType<D, uintType, P>(round(clamp(v, static_cast<floatType>(0), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<uintType>::max())));
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> unpackUnorm(vecType<uintType, P> const & v)
template <int D, typename uintType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, floatType, P> unpackUnorm(vecType<D, uintType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<float, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<uintType>::max()));
return vecType<D, float, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<uintType>::max()));
}
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<intType, P> packSnorm(vecType<floatType, P> const & v)
template <int D, typename intType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, intType, P> packSnorm(vecType<D, floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<intType, P>(round(clamp(v , static_cast<floatType>(-1), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<intType>::max())));
return vecType<D, intType, P>(round(clamp(v , static_cast<floatType>(-1), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<intType>::max())));
}
template <typename intType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> unpackSnorm(vecType<intType, P> const & v)
template <int D, typename intType, typename floatType, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, floatType, P> unpackSnorm(vecType<D, intType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<intType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return clamp(vecType<floatType, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<intType>::max())), static_cast<floatType>(-1), static_cast<floatType>(1));
return clamp(vecType<D, floatType, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<intType>::max())), static_cast<floatType>(-1), static_cast<floatType>(1));
}
GLM_FUNC_QUALIFIER uint8 packUnorm2x4(vec2 const & v)

View File

@@ -190,8 +190,8 @@ namespace glm
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
///
/// @see gtc_quaternion
template <typename T, precision P, template <typename, precision> class quatType>
GLM_FUNC_DECL T dot(quatType<T, P> const & x, quatType<T, P> const & y);
template <typename T, precision P>
GLM_FUNC_DECL T dot(tquat<T, P> const & x, tquat<T, P> const & y);
/// Spherical linear interpolation of two quaternions.
/// The interpolation is oriented and the rotation is performed at constant speed.

View File

@@ -10,11 +10,11 @@ namespace glm{
namespace detail
{
template <typename T, precision P, bool Aligned>
struct compute_dot<tquat, T, P, Aligned>
struct compute_dot<tquat<T, P>, T, Aligned>
{
static GLM_FUNC_QUALIFIER T call(tquat<T, P> const& x, tquat<T, P> const& y)
static GLM_FUNC_QUALIFIER T call(tquat<T, P> const& a, tquat<T, P> const& b)
{
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
tvec4<T, P> tmp(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
}
};
@@ -154,7 +154,7 @@ namespace detail
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & u, tvec3<T, P> const & v)
{
tvec3<T, P> const LocalW(cross(u, v));
T Dot = detail::compute_dot<tvec3, T, P, detail::is_aligned<P>::value>::call(u, v);
T Dot = detail::compute_dot<tvec<3, T, P>, T, detail::is_aligned<P>::value>::call(u, v);
tquat<T, P> q(T(1) + Dot, LocalW.x, LocalW.y, LocalW.z);
*this = normalize(q);

View File

@@ -62,7 +62,7 @@ namespace detail
*/
template <precision P>
struct compute_dot<tquat, float, P, true>
struct compute_dot<tquat<float, P>, float, true>
{
static GLM_FUNC_QUALIFIER float call(tquat<float, P> const& x, tquat<float, P> const& y)
{

View File

@@ -44,10 +44,10 @@ namespace glm
/// @tparam T Value type. Currently supported: float or double.
/// @tparam vecType A vertor type: tvec1, tvec2, tvec3, tvec4 or compatible
/// @see gtc_random
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> linearRand(
vecType<T, P> const & Min,
vecType<T, P> const & Max);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> linearRand(
vecType<D, T, P> const & Min,
vecType<D, T, P> const & Max);
/// Generate random numbers in the interval [Min, Max], according a gaussian distribution
///

View File

@@ -10,14 +10,14 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <class, precision> class vecType>
template <int D, typename T, precision P, template <int, class, precision> class vecType>
struct compute_rand
{
GLM_FUNC_QUALIFIER static vecType<T, P> call();
GLM_FUNC_QUALIFIER static vecType<D, T, P> call();
};
template <precision P>
struct compute_rand<uint8, P, tvec1>
struct compute_rand<1, uint8, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec1<uint8, P> call()
{
@@ -27,7 +27,7 @@ namespace detail
};
template <precision P>
struct compute_rand<uint8, P, tvec2>
struct compute_rand<2, uint8, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec2<uint8, P> call()
{
@@ -38,7 +38,7 @@ namespace detail
};
template <precision P>
struct compute_rand<uint8, P, tvec3>
struct compute_rand<3, uint8, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec3<uint8, P> call()
{
@@ -50,7 +50,7 @@ namespace detail
};
template <precision P>
struct compute_rand<uint8, P, tvec4>
struct compute_rand<4, uint8, P, tvec>
{
GLM_FUNC_QUALIFIER static tvec4<uint8, P> call()
{
@@ -62,195 +62,195 @@ namespace detail
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint16, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_rand<D, uint16, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint16, P> call()
GLM_FUNC_QUALIFIER static vecType<D, uint16, P> call()
{
return
(vecType<uint16, P>(compute_rand<uint8, P, vecType>::call()) << static_cast<uint16>(8)) |
(vecType<uint16, P>(compute_rand<uint8, P, vecType>::call()) << static_cast<uint16>(0));
(vecType<D, uint16, P>(compute_rand<D, uint8, P, vecType>::call()) << static_cast<uint16>(8)) |
(vecType<D, uint16, P>(compute_rand<D, uint8, P, vecType>::call()) << static_cast<uint16>(0));
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint32, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_rand<D, uint32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint32, P> call()
GLM_FUNC_QUALIFIER static vecType<D, uint32, P> call()
{
return
(vecType<uint32, P>(compute_rand<uint16, P, vecType>::call()) << static_cast<uint32>(16)) |
(vecType<uint32, P>(compute_rand<uint16, P, vecType>::call()) << static_cast<uint32>(0));
(vecType<D, uint32, P>(compute_rand<D, uint16, P, vecType>::call()) << static_cast<uint32>(16)) |
(vecType<D, uint32, P>(compute_rand<D, uint16, P, vecType>::call()) << static_cast<uint32>(0));
}
};
template <precision P, template <class, precision> class vecType>
struct compute_rand<uint64, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_rand<D, uint64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint64, P> call()
GLM_FUNC_QUALIFIER static vecType<D, uint64, P> call()
{
return
(vecType<uint64, P>(compute_rand<uint32, P, vecType>::call()) << static_cast<uint64>(32)) |
(vecType<uint64, P>(compute_rand<uint32, P, vecType>::call()) << static_cast<uint64>(0));
(vecType<D, uint64, P>(compute_rand<D, uint32, P, vecType>::call()) << static_cast<uint64>(32)) |
(vecType<D, uint64, P>(compute_rand<D, uint32, P, vecType>::call()) << static_cast<uint64>(0));
}
};
template <typename T, precision P, template <class, precision> class vecType>
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & Min, vecType<T, P> const & Max);
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & Min, vecType<D, T, P> const & Max);
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int8, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, int8, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int8, P> call(vecType<int8, P> const & Min, vecType<int8, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, int8, P> call(vecType<D, int8, P> const & Min, vecType<D, int8, P> const & Max)
{
return (vecType<int8, P>(compute_rand<uint8, P, vecType>::call() % vecType<uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
return (vecType<D, int8, P>(compute_rand<D, uint8, P, vecType>::call() % vecType<D, uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint8, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, uint8, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint8, P> call(vecType<uint8, P> const & Min, vecType<uint8, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, uint8, P> call(vecType<D, uint8, P> const & Min, vecType<D, uint8, P> const & Max)
{
return (compute_rand<uint8, P, vecType>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
return (compute_rand<D, uint8, P, vecType>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int16, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, int16, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int16, P> call(vecType<int16, P> const & Min, vecType<int16, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, int16, P> call(vecType<D, int16, P> const & Min, vecType<D, int16, P> const & Max)
{
return (vecType<int16, P>(compute_rand<uint16, P, vecType>::call() % vecType<uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
return (vecType<D, int16, P>(compute_rand<D, uint16, P, vecType>::call() % vecType<D, uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint16, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, uint16, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint16, P> call(vecType<uint16, P> const & Min, vecType<uint16, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, uint16, P> call(vecType<D, uint16, P> const & Min, vecType<D, uint16, P> const & Max)
{
return (compute_rand<uint16, P, vecType>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
return (compute_rand<D, uint16, P, vecType>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int32, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, int32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int32, P> call(vecType<int32, P> const & Min, vecType<int32, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, int32, P> call(vecType<D, int32, P> const & Min, vecType<D, int32, P> const & Max)
{
return (vecType<int32, P>(compute_rand<uint32, P, vecType>::call() % vecType<uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
return (vecType<D, int32, P>(compute_rand<D, uint32, P, vecType>::call() % vecType<D, uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint32, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, uint32, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint32, P> call(vecType<uint32, P> const & Min, vecType<uint32, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, uint32, P> call(vecType<D, uint32, P> const & Min, vecType<D, uint32, P> const & Max)
{
return (compute_rand<uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
return (compute_rand<D, uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<int64, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, int64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<int64, P> call(vecType<int64, P> const & Min, vecType<int64, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, int64, P> call(vecType<D, int64, P> const & Min, vecType<D, int64, P> const & Max)
{
return (vecType<int64, P>(compute_rand<uint64, P, vecType>::call() % vecType<uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
return (vecType<D, int64, P>(compute_rand<D, uint64, P, vecType>::call() % vecType<D, uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
}
};
template <precision P, template <class, precision> class vecType>
struct compute_linearRand<uint64, P, vecType>
template <int D, precision P, template <int, typename, precision> class vecType>
struct compute_linearRand<D, uint64, P, vecType>
{
GLM_FUNC_QUALIFIER static vecType<uint64, P> call(vecType<uint64, P> const & Min, vecType<uint64, P> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, uint64, P> call(vecType<D, uint64, P> const & Min, vecType<D, uint64, P> const & Max)
{
return (compute_rand<uint64, P, vecType>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
return (compute_rand<D, uint64, P, vecType>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, lowp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, float, lowp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, lowp> call(vecType<float, lowp> const & Min, vecType<float, lowp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, float, lowp> call(vecType<D, float, lowp> const & Min, vecType<D, float, lowp> const & Max)
{
return vecType<float, lowp>(compute_rand<uint8, lowp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
return vecType<D, float, lowp>(compute_rand<D, uint8, lowp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, mediump, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, float, mediump, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, mediump> call(vecType<float, mediump> const & Min, vecType<float, mediump> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, float, mediump> call(vecType<D, float, mediump> const & Min, vecType<D, float, mediump> const & Max)
{
return vecType<float, mediump>(compute_rand<uint16, mediump, vecType>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
return vecType<D, float, mediump>(compute_rand<D, uint16, mediump, vecType>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<float, highp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, float, highp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<float, highp> call(vecType<float, highp> const & Min, vecType<float, highp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, float, highp> call(vecType<D, float, highp> const & Min, vecType<D, float, highp> const & Max)
{
return vecType<float, highp>(compute_rand<uint32, highp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vecType<D, float, highp>(compute_rand<D, uint32, highp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<double, lowp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, double, lowp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<double, lowp> call(vecType<double, lowp> const & Min, vecType<double, lowp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, double, lowp> call(vecType<D, double, lowp> const & Min, vecType<D, double, lowp> const & Max)
{
return vecType<double, lowp>(compute_rand<uint16, lowp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
return vecType<D, double, lowp>(compute_rand<D, uint16, lowp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<double, mediump, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, double, mediump, vecType>
{
GLM_FUNC_QUALIFIER static vecType<double, mediump> call(vecType<double, mediump> const & Min, vecType<double, mediump> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, double, mediump> call(vecType<D, double, mediump> const & Min, vecType<D, double, mediump> const & Max)
{
return vecType<double, mediump>(compute_rand<uint32, mediump, vecType>::call()) / static_cast<double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vecType<D, double, mediump>(compute_rand<D, uint32, mediump, vecType>::call()) / static_cast<double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<double, highp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, double, highp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<double, highp> call(vecType<double, highp> const & Min, vecType<double, highp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, double, highp> call(vecType<D, double, highp> const & Min, vecType<D, double, highp> const & Max)
{
return vecType<double, highp>(compute_rand<uint64, highp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vecType<D, double, highp>(compute_rand<D, uint64, highp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<long double, lowp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, long double, lowp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<long double, lowp> call(vecType<long double, lowp> const & Min, vecType<long double, lowp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, long double, lowp> call(vecType<D, long double, lowp> const & Min, vecType<D, long double, lowp> const & Max)
{
return vecType<long double, lowp>(compute_rand<uint32, lowp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vecType<D, long double, lowp>(compute_rand<D, uint32, lowp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<long double, mediump, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, long double, mediump, vecType>
{
GLM_FUNC_QUALIFIER static vecType<long double, mediump> call(vecType<long double, mediump> const & Min, vecType<long double, mediump> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, long double, mediump> call(vecType<D, long double, mediump> const & Min, vecType<D, long double, mediump> const & Max)
{
return vecType<long double, mediump>(compute_rand<uint64, mediump, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vecType<D, long double, mediump>(compute_rand<D, uint64, mediump, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
template <template <class, precision> class vecType>
struct compute_linearRand<long double, highp, vecType>
template <int D, template <int, typename, precision> class vecType>
struct compute_linearRand<D, long double, highp, vecType>
{
GLM_FUNC_QUALIFIER static vecType<long double, highp> call(vecType<long double, highp> const & Min, vecType<long double, highp> const & Max)
GLM_FUNC_QUALIFIER static vecType<D, long double, highp> call(vecType<D, long double, highp> const & Min, vecType<D, long double, highp> const & Max)
{
return vecType<long double, highp>(compute_rand<uint64, highp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vecType<D, long double, highp>(compute_rand<D, uint64, highp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
}//namespace detail
@@ -258,15 +258,15 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType linearRand(genType Min, genType Max)
{
return detail::compute_linearRand<genType, highp, tvec1>::call(
return detail::compute_linearRand<1, genType, highp, tvec>::call(
tvec1<genType, highp>(Min),
tvec1<genType, highp>(Max)).x;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> linearRand(vecType<T, P> const & Min, vecType<T, P> const & Max)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> linearRand(vecType<D, T, P> const & Min, vecType<D, T, P> const & Max)
{
return detail::compute_linearRand<T, P, vecType>::call(Min, Max);
return detail::compute_linearRand<D, T, P, vecType>::call(Min, Max);
}
template <typename genType>
@@ -285,10 +285,10 @@ namespace detail
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> gaussRand(vecType<T, P> const & Mean, vecType<T, P> const & Deviation)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> gaussRand(vecType<D, T, P> const & Mean, vecType<D, T, P> const & Deviation)
{
return detail::functor2<T, P, vecType>::call(gaussRand, Mean, Deviation);
return detail::functor2<D, T, P>::call(gaussRand, Mean, Deviation);
}
template <typename T>

View File

@@ -14,11 +14,11 @@ namespace glm
return genType(1) / glm::cos(angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> sec(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> sec(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sec' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(sec, x);
return detail::functor1<D, T, T, P>::call(sec, x);
}
// csc
@@ -29,11 +29,11 @@ namespace glm
return genType(1) / glm::sin(angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> csc(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> csc(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csc' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(csc, x);
return detail::functor1<D, T, T, P>::call(csc, x);
}
// cot
@@ -46,11 +46,11 @@ namespace glm
return glm::tan(pi_over_2 - angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> cot(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> cot(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cot' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(cot, x);
return detail::functor1<D, T, T, P>::call(cot, x);
}
// asec
@@ -61,11 +61,11 @@ namespace glm
return acos(genType(1) / x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> asec(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> asec(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asec' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(asec, x);
return detail::functor1<D, T, T, P>::call(asec, x);
}
// acsc
@@ -76,11 +76,11 @@ namespace glm
return asin(genType(1) / x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acsc(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> acsc(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsc' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(acsc, x);
return detail::functor1<D, T, T, P>::call(acsc, x);
}
// acot
@@ -93,11 +93,11 @@ namespace glm
return pi_over_2 - atan(x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acot(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> acot(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acot' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(acot, x);
return detail::functor1<D, T, T, P>::call(acot, x);
}
// sech
@@ -108,11 +108,11 @@ namespace glm
return genType(1) / glm::cosh(angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> sech(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> sech(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sech' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(sech, x);
return detail::functor1<D, T, T, P>::call(sech, x);
}
// csch
@@ -123,11 +123,11 @@ namespace glm
return genType(1) / glm::sinh(angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> csch(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> csch(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csch' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(csch, x);
return detail::functor1<D, T, T, P>::call(csch, x);
}
// coth
@@ -138,11 +138,11 @@ namespace glm
return glm::cosh(angle) / glm::sinh(angle);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> coth(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> coth(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'coth' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(coth, x);
return detail::functor1<D, T, T, P>::call(coth, x);
}
// asech
@@ -153,11 +153,11 @@ namespace glm
return acosh(genType(1) / x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> asech(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> asech(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asech' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(asech, x);
return detail::functor1<D, T, T, P>::call(asech, x);
}
// acsch
@@ -168,11 +168,11 @@ namespace glm
return acsch(genType(1) / x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acsch(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> acsch(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsch' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(acsch, x);
return detail::functor1<D, T, T, P>::call(acsch, x);
}
// acoth
@@ -183,10 +183,10 @@ namespace glm
return atanh(genType(1) / x);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> acoth(vecType<T, P> const & x)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> acoth(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acoth' only accept floating-point inputs");
return detail::functor1<T, T, P, vecType>::call(acoth, x);
return detail::functor1<D, T, T, P>::call(acoth, x);
}
}//namespace glm

View File

@@ -39,8 +39,8 @@ namespace glm
/// Return true if the value is a power of two number.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<bool, P> isPowerOfTwo(vecType<T, P> const & value);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, bool, P> isPowerOfTwo(vecType<D, T, P> const & value);
/// Return the power of two number which value is just higher the input value,
/// round up to a power of two.
@@ -53,8 +53,8 @@ namespace glm
/// round up to a power of two.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & value);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> ceilPowerOfTwo(vecType<D, T, P> const & value);
/// Return the power of two number which value is just lower the input value,
/// round down to a power of two.
@@ -67,8 +67,8 @@ namespace glm
/// round down to a power of two.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> floorPowerOfTwo(vecType<T, P> const & value);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> floorPowerOfTwo(vecType<D, T, P> const & value);
/// Return the power of two number which value is the closet to the input value.
///
@@ -79,8 +79,8 @@ namespace glm
/// Return the power of two number which value is the closet to the input value.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> roundPowerOfTwo(vecType<T, P> const & value);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> roundPowerOfTwo(vecType<D, T, P> const & value);
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
@@ -91,14 +91,14 @@ namespace glm
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, T Multiple);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, bool, P> isMultiple(vecType<D, T, P> const & Value, T Multiple);
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, vecType<T, P> const & Multiple);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, bool, P> isMultiple(vecType<D, T, P> const & Value, vecType<D, T, P> const & Multiple);
/// Higher multiple number of Source.
///
@@ -117,8 +117,8 @@ namespace glm
/// @param Multiple Must be a null or positive value
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> ceilMultiple(vecType<D, T, P> const & Source, vecType<D, T, P> const & Multiple);
/// Lower multiple number of Source.
///
@@ -139,10 +139,10 @@ namespace glm
/// @param Multiple Must be a null or positive value
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> floorMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> floorMultiple(
vecType<D, T, P> const & Source,
vecType<D, T, P> const & Multiple);
/// Lower multiple number of Source.
///
@@ -163,10 +163,10 @@ namespace glm
/// @param Multiple Must be a null or positive value
///
/// @see gtc_round
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> roundMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_DECL vecType<D, T, P> roundMultiple(
vecType<D, T, P> const & Source,
vecType<D, T, P> const & Multiple);
/// @}
} //namespace glm

View File

@@ -6,62 +6,62 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
template <int D, typename T, precision P, template <int, typename, precision> class vecType, bool compute = false>
struct compute_ceilShift
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T)
{
return v;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilShift<T, P, vecType, true>
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
struct compute_ceilShift<D, T, P, vecType, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Shift)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T Shift)
{
return v | (v >> Shift);
}
};
template <typename T, precision P, template <typename, precision> class vecType, bool isSigned = true>
template <int D, typename T, precision P, template <int, typename, precision> class vecType, bool isSigned = true>
struct compute_ceilPowerOfTwo
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<T, P> const Sign(sign(x));
vecType<D, T, P> const Sign(sign(x));
vecType<T, P> v(abs(x));
vecType<D, T, P> v(abs(x));
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 8>::call(v, 32);
return (v + static_cast<T>(1)) * Sign;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilPowerOfTwo<T, P, vecType, false>
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
struct compute_ceilPowerOfTwo<D, T, P, vecType, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<T, P> v(x);
vecType<D, T, P> v(x);
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<D, T, P, vecType, sizeof(T) >= 8>::call(v, 32);
return v + static_cast<T>(1);
}
};
@@ -219,11 +219,11 @@ namespace detail
return !(Result & (Result - 1));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> isPowerOfTwo(vecType<T, P> const & Value)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> isPowerOfTwo(vecType<D, T, P> const & Value)
{
vecType<T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vecType<T, P>(0));
vecType<D, T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vecType<D, T, P>(0));
}
//////////////////
@@ -232,13 +232,13 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo(genType value)
{
return detail::compute_ceilPowerOfTwo<genType, defaultp, tvec1, std::numeric_limits<genType>::is_signed>::call(tvec1<genType, defaultp>(value)).x;
return detail::compute_ceilPowerOfTwo<1, genType, defaultp, tvec, std::numeric_limits<genType>::is_signed>::call(tvec1<genType, defaultp>(value)).x;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & v)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> ceilPowerOfTwo(vecType<D, T, P> const & v)
{
return detail::compute_ceilPowerOfTwo<T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
return detail::compute_ceilPowerOfTwo<D, T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
}
///////////////////
@@ -250,10 +250,10 @@ namespace detail
return isPowerOfTwo(value) ? value : static_cast<genType>(1) << findMSB(value);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> floorPowerOfTwo(vecType<T, P> const & v)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> floorPowerOfTwo(vecType<D, T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(floorPowerOfTwo, v);
return detail::functor1<D, T, T, P>::call(floorPowerOfTwo, v);
}
///////////////////
@@ -270,10 +270,10 @@ namespace detail
return (next - value) < (value - prev) ? next : prev;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> roundPowerOfTwo(vecType<T, P> const & v)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> roundPowerOfTwo(vecType<D, T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(roundPowerOfTwo, v);
return detail::functor1<D, T, T, P>::call(roundPowerOfTwo, v);
}
////////////////
@@ -285,16 +285,16 @@ namespace detail
return isMultiple(tvec1<genType>(Value), tvec1<genType>(Multiple)).x;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> isMultiple(vecType<T, P> const & Value, T Multiple)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> isMultiple(vecType<D, T, P> const & Value, T Multiple)
{
return (Value % Multiple) == vecType<T, P>(0);
return (Value % Multiple) == vecType<D, T, P>(0);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> isMultiple(vecType<T, P> const & Value, vecType<T, P> const & Multiple)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, bool, P> isMultiple(vecType<D, T, P> const & Value, vecType<D, T, P> const & Multiple)
{
return (Value % Multiple) == vecType<T, P>(0);
return (Value % Multiple) == vecType<D, T, P>(0);
}
//////////////////////
@@ -306,10 +306,10 @@ namespace detail
return detail::compute_ceilMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> ceilMultiple(vecType<D, T, P> const & Source, vecType<D, T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(ceilMultiple, Source, Multiple);
return detail::functor2<D, T, P>::call(ceilMultiple, Source, Multiple);
}
//////////////////////
@@ -321,10 +321,10 @@ namespace detail
return detail::compute_floorMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> floorMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> floorMultiple(vecType<D, T, P> const & Source, vecType<D, T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(floorMultiple, Source, Multiple);
return detail::functor2<D, T, P>::call(floorMultiple, Source, Multiple);
}
//////////////////////
@@ -336,9 +336,9 @@ namespace detail
return detail::compute_roundMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> roundMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> roundMultiple(vecType<D, T, P> const & Source, vecType<D, T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(roundMultiple, Source, Multiple);
return detail::functor2<D, T, P>::call(roundMultiple, Source, Multiple);
}
}//namespace glm

View File

@@ -25,10 +25,6 @@
namespace glm
{
template <typename T, precision P> struct tvec1;
template <typename T, precision P> struct tvec2;
template <typename T, precision P> struct tvec3;
template <typename T, precision P> struct tvec4;
/// @addtogroup gtc_type_aligned
/// @{

View File

@@ -54,8 +54,8 @@ namespace glm
/// Return the distance in the number of ULP between 2 vectors.
/// @see gtc_ulp
template<typename T, template<typename> class vecType>
GLM_FUNC_DECL vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y);
template<typename T, template<int, typename> class vecType>
GLM_FUNC_DECL vecType<2, uint> float_distance(vecType<2, T> const & x, vecType<2, T> const & y);
/// @}
}// namespace glm

View File

@@ -199,10 +199,10 @@ namespace glm
# endif
}
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x)
template<int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> next_float(vecType<D, T, P> const & x)
{
vecType<T, P> Result(uninitialize);
vecType<D, T, P> Result(uninitialize);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = next_float(x[i]);
return Result;
@@ -234,10 +234,10 @@ namespace glm
# endif
}
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x)
template<int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> prev_float(vecType<D, T, P> const & x)
{
vecType<T, P> Result(uninitialize);
vecType<D, T, P> Result(uninitialize);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = prev_float(x[i]);
return Result;
@@ -252,10 +252,10 @@ namespace glm
return temp;
}
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> next_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
template<int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> next_float(vecType<D, T, P> const & x, vecType<D, uint, P> const & ulps)
{
vecType<T, P> Result(uninitialize);
vecType<D, T, P> Result(uninitialize);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = next_float(x[i], ulps[i]);
return Result;
@@ -270,10 +270,10 @@ namespace glm
return temp;
}
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> prev_float(vecType<T, P> const & x, vecType<uint, P> const & ulps)
template<int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> prev_float(vecType<D, T, P> const & x, vecType<D, uint, P> const & ulps)
{
vecType<T, P> Result(uninitialize);
vecType<D, T, P> Result(uninitialize);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = prev_float(x[i], ulps[i]);
return Result;
@@ -310,10 +310,10 @@ namespace glm
return ulp;
}
template<typename T, precision P, template<typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint, P> float_distance(vecType<T, P> const & x, vecType<T, P> const & y)
template<int D, typename T, precision P, template<int, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, uint, P> float_distance(vecType<D, T, P> const & x, vecType<D, T, P> const & y)
{
vecType<uint, P> Result(uninitialize);
vecType<D, uint, P> Result(uninitialize);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = float_distance(x[i], y[i]);
return Result;