[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59821] trunk/blender/source/blender: add positive_mod() utility function.

Campbell Barton ideasman42 at gmail.com
Thu Sep 5 12:12:01 CEST 2013


Revision: 59821
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59821
Author:   campbellbarton
Date:     2013-09-05 10:12:00 +0000 (Thu, 05 Sep 2013)
Log Message:
-----------
add positive_mod() utility function.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_base.h
    trunk/blender/source/blender/blenlib/intern/math_base_inline.c
    trunk/blender/source/blender/bmesh/operators/bmo_bridge.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_base.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_base.h	2013-09-05 09:39:38 UTC (rev 59820)
+++ trunk/blender/source/blender/blenlib/BLI_math_base.h	2013-09-05 10:12:00 UTC (rev 59821)
@@ -222,6 +222,7 @@
 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);
 

Modified: trunk/blender/source/blender/blenlib/intern/math_base_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_base_inline.c	2013-09-05 09:39:38 UTC (rev 59820)
+++ trunk/blender/source/blender/blenlib/intern/math_base_inline.c	2013-09-05 10:12:00 UTC (rev 59821)
@@ -153,6 +153,11 @@
 	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);

Modified: trunk/blender/source/blender/bmesh/operators/bmo_bridge.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_bridge.c	2013-09-05 09:39:38 UTC (rev 59820)
+++ trunk/blender/source/blender/bmesh/operators/bmo_bridge.c	2013-09-05 10:12:00 UTC (rev 59821)
@@ -273,8 +273,7 @@
 		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);
 		}
 	}




More information about the Bf-blender-cvs mailing list