[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54173] trunk/blender/source/blender: Correct fix for r54164, the testcase I was using worked but different edge slide examples didn't.

Campbell Barton ideasman42 at gmail.com
Tue Jan 29 04:25:52 CET 2013


Revision: 54173
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54173
Author:   campbellbarton
Date:     2013-01-29 03:25:47 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
Correct fix for r54164, the testcase I was using worked but different edge slide examples didn't.

Edge slide needed to check for concave ngons too.

add BM_loop_is_convex() and expose to python too.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54164

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_queries.c
    trunk/blender/source/blender/bmesh/intern/bmesh_queries.h
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_queries.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_queries.c	2013-01-29 03:12:49 UTC (rev 54172)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_queries.c	2013-01-29 03:25:47 UTC (rev 54173)
@@ -1007,6 +1007,22 @@
 }
 
 /**
+ * Check if the loop is convex or concave
+ * (depends on face normal)
+ */
+bool BM_loop_is_convex(BMLoop *l)
+{
+	float e_dir_prev[3];
+	float e_dir_next[3];
+	float l_no[3];
+
+	sub_v3_v3v3(e_dir_prev, l->prev->v->co, l->v->co);
+	sub_v3_v3v3(e_dir_next, l->next->v->co, l->v->co);
+	cross_v3_v3v3(l_no, e_dir_next, e_dir_prev);
+	return dot_v3v3(l_no, l->f->no) > 0.0f;
+}
+
+/**
  * Calculates the angle between the previous and next loops
  * (angle at this loops face corner).
  *
@@ -1034,7 +1050,7 @@
 	                  l->v->co,
 	                  l->next->v->co) != 0.0f)
 	{
-		return;
+		/* pass */
 	}
 	else {
 		copy_v3_v3(r_normal, l->f->no);

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_queries.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_queries.h	2013-01-29 03:12:49 UTC (rev 54172)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_queries.h	2013-01-29 03:25:47 UTC (rev 54173)
@@ -62,6 +62,8 @@
 bool    BM_edge_is_manifold(BMEdge *e);
 bool    BM_edge_is_boundary(BMEdge *e);
 
+bool    BM_loop_is_convex(BMLoop *l);
+
 float   BM_loop_calc_face_angle(BMLoop *l);
 void    BM_loop_calc_face_normal(BMLoop *l, float r_normal[3]);
 void    BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3]);

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2013-01-29 03:12:49 UTC (rev 54172)
+++ trunk/blender/source/blender/editors/transform/transform.c	2013-01-29 03:25:47 UTC (rev 54173)
@@ -4932,7 +4932,7 @@
 				/* check if we need to flip
 				 * (compare the normal defines by the edges with the face normal) */
 				cross_v3_v3v3(tvec, e_dir_prev, e_dir_next);
-				if (dot_v3v3(tvec, l->f->no) > 0.0f) {
+				if ((dot_v3v3(tvec, l->f->no) < 0.0f) == BM_loop_is_convex(l)) {
 					negate_v3(vec_accum);
 				}
 			}

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2013-01-29 03:12:49 UTC (rev 54172)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2013-01-29 03:25:47 UTC (rev 54173)
@@ -559,6 +559,15 @@
 	return BPy_BMLoop_CreatePyObject(self->bm, self->l->radial_prev);
 }
 
+PyDoc_STRVAR(bpy_bm_is_convex_doc,
+"True when this loop is at the convex corner of a face, depends on a valid face normal (read-only).\n\n:type: :class:`BMLoop`"
+);
+static PyObject *bpy_bm_is_convex_get(BPy_BMLoop *self)
+{
+	BPY_BM_CHECK_OBJ(self);
+	return PyBool_FromLong(BM_loop_is_convex(self->l));
+}
+
 /* ElemSeq
  * ^^^^^^^ */
 
@@ -721,7 +730,8 @@
 	{(char *)"link_loop_radial_prev", (getter)bpy_bmloop_link_loop_radial_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_radial_prev_doc, NULL},
 
 	/* readonly checks */
-	{(char *)"is_valid",   (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
+	{(char *)"is_convex",  (getter)bpy_bm_is_convex_get, (setter)NULL, (char *)bpy_bm_is_convex_doc, NULL},
+	{(char *)"is_valid",   (getter)bpy_bm_is_valid_get,  (setter)NULL, (char *)bpy_bm_is_valid_doc,  NULL},
 
 	{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };




More information about the Bf-blender-cvs mailing list