windows compilation fix

metadata
Wenzel Jakob 2014-08-03 00:07:50 +02:00
parent 48730364a4
commit a5c574f98d
1 changed files with 14 additions and 2 deletions

View File

@ -103,10 +103,22 @@ template <typename Scalar> inline int floorToInt(Scalar value) { return (int) st
template <typename Scalar> inline int ceilToInt(Scalar value) { return (int) std::ceil(value); } template <typename Scalar> inline int ceilToInt(Scalar value) { return (int) std::ceil(value); }
/// Integer round function (single precision) /// Integer round function (single precision)
inline int roundToInt(float value) { return (int) ::roundf(value); } inline int roundToInt(float value) {
#if defined(__MSVC__)
return (int) (value < 0.0f ? std::ceil(value - 0.5f) : std::floor(value + 0.5f));
#else
return (int) ::roundf(value);
#endif
}
/// Integer round function (double precision) /// Integer round function (double precision)
inline int roundToInt(double value) { return (int) ::round(value); } inline int roundToInt(double value) {
#if defined(__MSVC__)
return (int) (value < 0.0f ? std::ceil(value - 0.5f) : std::floor(value + 0.5f));
#else
return (int) ::round(value);
#endif
}
/// Base-2 logarithm (32-bit integer version) /// Base-2 logarithm (32-bit integer version)
extern MTS_EXPORT_CORE int log2i(uint32_t value); extern MTS_EXPORT_CORE int log2i(uint32_t value);