Added compScale
This commit is contained in:
parent
678d393b99
commit
26590ecb0b
@ -60,6 +60,12 @@ namespace glm
|
||||
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<floatType, P> compNormalize(vecType<T, P> const & v);
|
||||
|
||||
/// Convert a normalized float vector to an integer vector.
|
||||
/// If the parameter value type is already a floating precision type, the value is passed through.
|
||||
/// @see gtx_component_wise
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> compScale(vecType<floatType, P> const & v)
|
||||
|
||||
/// Add all vector components together.
|
||||
/// @see gtx_component_wise
|
||||
template <typename genType>
|
||||
|
@ -67,6 +67,39 @@ namespace detail
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
|
||||
struct compute_compScale
|
||||
{};
|
||||
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||
struct compute_compScale<T, floatType, P, vecType, true, true>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
|
||||
{
|
||||
floatType const Min = static_cast<floatType>(std::numeric_limits<T>::min());
|
||||
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max());
|
||||
return (vecType<floatType, P>(v) + Min) * (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||
struct compute_compScale<T, floatType, P, vecType, true, false>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
|
||||
{
|
||||
return vecType<T, P>(vecType<floatType, P>(v) * static_cast<floatType>(std::numeric_limits<T>::max()));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||
struct compute_compScale<T, floatType, P, vecType, false, true>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
|
||||
@ -77,6 +110,14 @@ namespace detail
|
||||
return detail::compute_compNormalize<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
|
||||
}
|
||||
|
||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> compScale(vecType<floatType, P> const & v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compScale' accepts only floating-point types for 'floatType' template parameter");
|
||||
|
||||
return detail::compute_compScale<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER T compAdd(vecType<T, P> const & v)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
||||
|
||||
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX
|
||||
##### Improvements:
|
||||
- Added compNormalize function to GTX_component_wise
|
||||
- Added compNormalize and compScale functions to GTX_component_wise
|
||||
|
||||
##### Fixes:
|
||||
- Fixed GTC_round floorMultiple/ceilMultiple #412
|
||||
|
Loading…
Reference in New Issue
Block a user