mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 19:34:36 +00:00
Adding constexpr for sign(vec) and sign(genFIType)
This commit is contained in:
parent
c8ca18942b
commit
3b546eb011
@ -51,7 +51,7 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign 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>
|
/// @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<length_t L, typename T, qualifier Q>
|
template<length_t L, typename T, qualifier Q>
|
||||||
GLM_FUNC_DECL vec<L, T, Q> sign(vec<L, T, Q> const& x);
|
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> sign(vec<L, T, Q> const& x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer that is less then or equal to x.
|
/// Returns a value equal to the nearest integer that is less then or equal to x.
|
||||||
///
|
///
|
||||||
|
@ -143,7 +143,7 @@ namespace detail
|
|||||||
template<length_t L, typename T, qualifier Q, bool isFloat, bool Aligned>
|
template<length_t L, typename T, qualifier Q, bool isFloat, bool Aligned>
|
||||||
struct compute_sign
|
struct compute_sign
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||||
{
|
{
|
||||||
return vec<L, T, Q>(glm::lessThan(vec<L, T, Q>(0), x)) - vec<L, T, Q>(glm::lessThan(x, vec<L, T, Q>(0)));
|
return vec<L, T, Q>(glm::lessThan(vec<L, T, Q>(0), x)) - vec<L, T, Q>(glm::lessThan(x, vec<L, T, Q>(0)));
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace detail
|
|||||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||||
struct compute_sign<L, T, Q, false, Aligned>
|
struct compute_sign<L, T, Q, false, Aligned>
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||||
{
|
{
|
||||||
T const Shift(static_cast<T>(sizeof(T) * 8 - 1));
|
T const Shift(static_cast<T>(sizeof(T) * 8 - 1));
|
||||||
vec<L, T, Q> const y(vec<L, typename detail::make_unsigned<T>::type, Q>(-x) >> typename detail::make_unsigned<T>::type(Shift));
|
vec<L, T, Q> const y(vec<L, typename detail::make_unsigned<T>::type, Q>(-x) >> typename detail::make_unsigned<T>::type(Shift));
|
||||||
@ -281,7 +281,7 @@ namespace detail
|
|||||||
// sign
|
// sign
|
||||||
// fast and works for any type
|
// fast and works for any type
|
||||||
template<typename genFIType>
|
template<typename genFIType>
|
||||||
GLM_FUNC_QUALIFIER genFIType sign(genFIType x)
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genFIType sign(genFIType x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(
|
||||||
std::numeric_limits<genFIType>::is_iec559 || (std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer),
|
std::numeric_limits<genFIType>::is_iec559 || (std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer),
|
||||||
@ -292,7 +292,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<length_t L, typename T, qualifier Q>
|
template<length_t L, typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sign(vec<L, T, Q> const& x)
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> sign(vec<L, T, Q> const& x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(
|
||||||
std::numeric_limits<T>::is_iec559 || (std::numeric_limits<T>::is_signed && std::numeric_limits<T>::is_integer),
|
std::numeric_limits<T>::is_iec559 || (std::numeric_limits<T>::is_signed && std::numeric_limits<T>::is_integer),
|
||||||
|
Loading…
Reference in New Issue
Block a user