From 35bfe1702c3754af17f440c7ee7cb0e9abb8fa9d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 16 Jul 2020 10:46:18 +0200 Subject: BLI: add safe_powf function The same function is also used by cycles. --- source/blender/blenlib/intern/math_base_inline.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/blenlib/intern/math_base_inline.c') diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 1b388dcf11f..26dc4d35c80 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -70,6 +70,13 @@ MINLINE float pow7f(float x) { return pow2f(pow3f(x)) * x; } +MINLINE float safe_powf(float base, float exponent) +{ + if (UNLIKELY(base < 0.0f && exponent != (int)exponent)) { + return 0.0f; + } + return powf(base, exponent); +} MINLINE float sqrt3f(float f) { -- cgit v1.2.3