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-05 14:12:00 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-05 14:12:00 +0400
commit96c668b1dd8c5b30796e10f068b8f7d082aef10c (patch)
tree387eb38664f7628cd72de17001310ccde96d6f9d
parentc84b18790d220d9468aa817e78c16088bb0de57d (diff)
add positive_mod() utility function.
-rw-r--r--source/blender/blenlib/BLI_math_base.h1
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c5
-rw-r--r--source/blender/bmesh/operators/bmo_bridge.c3
3 files changed, 7 insertions, 2 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);
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 9381fabacf2..fa46e353b48 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -273,8 +273,7 @@ static void bridge_loop_pair(BMesh *bm,
if (twist_offset != 0) {
const int len_b = BM_edgeloop_length_get(el_store_b);
ListBase *lb_b = BM_edgeloop_verts_get(el_store_b);
- const int offset = twist_offset % len_b;
- LinkData *el_b = BLI_rfindlink(lb_b, (offset < 0) ? (offset + len_b) : offset);
+ LinkData *el_b = BLI_rfindlink(lb_b, positive_mod(twist_offset, len_b));
BLI_rotatelist(lb_b, el_b);
}
}