diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Utility.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Utility.h index 7d243c79..915c20ab 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Utility.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Utility.h @@ -32,6 +32,19 @@ namespace PolyVox { POLYVOX_API uint8_t logBase2(uint32_t uInput); POLYVOX_API bool isPowerOf2(uint32_t uInput); + + int32_t roundTowardsNegInf(float r); + int32_t roundToInteger(float r); + + inline int32_t roundTowardsNegInf(float r) + { + return (r > 0.0) ? static_cast(r) : static_cast(r - 1.0f); + } + + inline int32_t roundToNearestInteger(float r) + { + return (r > 0.0) ? static_cast(r + 0.5f) : static_cast(r - 0.5f); + } } #endif