diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-05 14:12:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-05 14:12:00 +0400 |
commit | 96c668b1dd8c5b30796e10f068b8f7d082aef10c (patch) | |
tree | 387eb38664f7628cd72de17001310ccde96d6f9d /source/blender/blenlib/intern/math_base_inline.c | |
parent | c84b18790d220d9468aa817e78c16088bb0de57d (diff) |
add positive_mod() utility function.
Diffstat (limited to 'source/blender/blenlib/intern/math_base_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_base_inline.c | 5 |
1 files changed, 5 insertions, 0 deletions
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); |