Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-05-18 18:03:19 +0300
committerSergey Sharybin <sergey@blender.org>2022-05-18 18:03:19 +0300
commitb712dbe5de2dcba3338f42b74b75388453d52d23 (patch)
treece1939518256c3580002245d272efe79491f47ac /source/blender/blenlib
parent708547ab06519ce741a091a20777cd5b1bf27120 (diff)
parentc56103356f642041f76c0be84772a40f1caad9df (diff)
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_base.hh12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_math_base.hh b/source/blender/blenlib/BLI_math_base.hh
index 81f5343056e..034c6968c94 100644
--- a/source/blender/blenlib/BLI_math_base.hh
+++ b/source/blender/blenlib/BLI_math_base.hh
@@ -108,12 +108,20 @@ template<typename T,
BLI_ENABLE_IF((is_math_float_type<FactorT>))>
inline T interpolate(const T &a, const T &b, const FactorT &t)
{
- return a * (1 - t) + b * t;
+ auto result = a * (1 - t) + b * t;
+ if constexpr (std::is_integral_v<T> && std::is_floating_point_v<FactorT>) {
+ result = std::round(result);
+ }
+ return result;
}
template<typename T> inline T midpoint(const T &a, const T &b)
{
- return (a + b) * T(0.5);
+ auto result = (a + b) * T(0.5);
+ if constexpr (std::is_integral_v<T>) {
+ result = std::round(result);
+ }
+ return result;
}
} // namespace blender::math