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:
authorCampbell Barton <ideasman42@gmail.com>2013-09-06 00:54:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-06 00:54:32 +0400
commit3b72f1824cf06216c70101ee0d29004cc6dc632d (patch)
tree56981fdefd7a0de0d37e4feab3acaea7c1b744ef /source/blender/blenlib/intern/math_base_inline.c
parentf6b37f34ec2593b12b67046cf032acc202e2fa54 (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.c7
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)