Fixed build

This commit is contained in:
Christophe Riccio
2014-11-13 00:08:13 +01:00
parent 2df3bf71cc
commit a604ebdaa5
7 changed files with 278 additions and 450 deletions

View File

@@ -55,58 +55,6 @@ namespace glm
/// @addtogroup gtc_integer
/// @{
/// Return true if the value is a power of two number.
///
/// @see gtc_integer
template <typename genIUType>
GLM_FUNC_DECL bool isPowerOfTwo(genIUType Value);
/// Return true if the value is a power of two number.
///
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<bool, P> isPowerOfTwo(vecType<T, P> const & value);
/// Return the power of two number which value is just higher the input value,
/// round up to a power of two.
///
/// @see gtc_integer
template <typename genIUType>
GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType Value);
/// Return the power of two number which value is just higher the input value,
/// round up to a power of two.
///
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & value);
/// Return the power of two number which value is just lower the input value,
/// round down to a power of two.
///
/// @see gtc_integer
template <typename genIUType>
GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType Value);
/// Return the power of two number which value is just lower the input value,
/// round down to a power of two.
///
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> floorPowerOfTwo(vecType<T, P> const & value);
/// Return the power of two number which value is the closet to the input value.
///
/// @see gtc_integer
template <typename genIUType>
GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType Value);
/// Return the power of two number which value is the closet to the input value.
///
/// @see gtc_integer
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> roundPowerOfTwo(vecType<T, P> const & value);
/// @}
} //namespace glm

View File

@@ -29,131 +29,8 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
struct compute_ceilShift
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T)
{
return v;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilShift<T, P, vecType, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Shift)
{
return v | (v >> Shift);
}
};
template <typename T, precision P, template <typename, precision> class vecType, bool isSigned = true>
struct compute_ceilPowerOfTwo
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<T, P> const Sign(sign(x));
vecType<T, P> v(abs(x));
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
return (v + static_cast<T>(1)) * Sign;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_ceilPowerOfTwo<T, P, vecType, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<T, P> v(x);
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<T, P, vecType, sizeof(T) >= 8>::call(v, 32);
return v + static_cast<T>(1);
}
};
}//namespace detail
////////////////
// isPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType Value)
{
genType const Result = glm::abs(Value);
return !(Result & (Result - 1));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> isPowerOfTwo(vecType<T, P> const & Value)
{
vecType<T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vecType<T, P>(0));
}
//////////////////
// ceilPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo(genType value)
{
return detail::compute_ceilPowerOfTwo<genType, defaultp, tvec1, std::numeric_limits<genType>::is_signed>::call(tvec1<genType, defaultp>(value)).x;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & v)
{
return detail::compute_ceilPowerOfTwo<T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
}
///////////////////
// floorPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER genType floorPowerOfTwo(genType value)
{
return isPowerOfTwo(value) ? value : highestBitValue(value);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> floorPowerOfTwo(vecType<T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(floorPowerOfTwo, v);
}
///////////////////
// roundPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER genType roundPowerOfTwo(genType value)
{
if(isPowerOfTwo(value))
return value;
genType const prev = highestBitValue(value);
genType const next = prev << 1;
return (next - value) < (value - prev) ? next : prev;
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> roundPowerOfTwo(vecType<T, P> const & v)
{
return detail::functor1<T, T, P, vecType>::call(roundPowerOfTwo, v);
}
}//namespace glm

View File

@@ -289,8 +289,8 @@ namespace detail
///////////////////
// roundPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER genType roundPowerOfTwo(genType value)
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType roundPowerOfTwo(genIUType value)
{
if(isPowerOfTwo(value))
return value;