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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-09-18 13:54:56 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-09-18 13:54:56 +0300
commit4c1ee477070083f12bf802e551b14179e0c4579a (patch)
treed4b34ab42495a5ba76804c940cc9876cbaca8b44 /source/blender/blenlib
parent9068c0743e0840cea5bbf07cd1bad7d662ab5a07 (diff)
parentc622533fa01a9f478d5116ca68ad299081ae22b4 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 6574c001a23..5ae2b1a70a7 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -194,6 +194,17 @@ MINLINE int divide_round_i(int a, int b)
}
/**
+ * Integer division that floors negative result.
+ * \note This works like Python's int division.
+ */
+MINLINE int divide_floor_i(int a, int b)
+{
+ int d = a / b;
+ int r = a % b; /* Optimizes into a single division. */
+ return r ? d - ((a < 0) ^ (b < 0)) : d;
+}
+
+/**
* modulo that handles negative numbers, works the same as Python's.
*/
MINLINE int mod_i(int i, int n)