diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_base.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_base_inline.c | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 69dbd3253f0..86aabf76350 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -222,6 +222,7 @@ MINLINE int power_of_2_max_i(int n); MINLINE int power_of_2_min_i(int n); MINLINE int divide_round_i(int a, int b); +MINLINE int positive_mod(int i, int n); MINLINE float shell_angle_to_dist(const float angle); diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 955a3406cbb..f68970b832d 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -153,6 +153,11 @@ MINLINE int divide_round_i(int a, int b) return (2 * a + b) / (2 * b); } +MINLINE int positive_mod(int i, int n) +{ + return ((i = i % n) < 0) ? i + n : i; +} + MINLINE unsigned int highest_order_bit_i(unsigned int n) { n |= (n >> 1); |