diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-06 00:54:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-06 00:54:32 +0400 |
commit | 3b72f1824cf06216c70101ee0d29004cc6dc632d (patch) | |
tree | 56981fdefd7a0de0d37e4feab3acaea7c1b744ef /source/blender/blenlib/intern/math_base_inline.c | |
parent | f6b37f34ec2593b12b67046cf032acc202e2fa54 (diff) |
rename positive_mod to mod_i, make it work with nagative numbers (matching pythons modulo), and use in a few more places.
allow mesh-checker-deselect to have a negative offset.
Diffstat (limited to 'source/blender/blenlib/intern/math_base_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_base_inline.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index f68970b832d..e6509db1c5e 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -153,9 +153,12 @@ MINLINE int divide_round_i(int a, int b) return (2 * a + b) / (2 * b); } -MINLINE int positive_mod(int i, int n) +/** + * modulo that handles negative numbers, works the same as Python's. + */ +MINLINE int mod_i(int i, int n) { - return ((i = i % n) < 0) ? i + n : i; + return (i % n + n) % n; } MINLINE unsigned int highest_order_bit_i(unsigned int n) |