[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18883] branches/bmesh/blender/source/ blender: edge subdivide now spits out inner elements from fully-subdivided faces, and non-inner split edges/verts, so proper selection can be moved to the tools code.

Joseph Eagar joeedh at gmail.com
Mon Feb 9 08:08:38 CET 2009


Revision: 18883
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18883
Author:   joeedh
Date:     2009-02-09 08:08:35 +0100 (Mon, 09 Feb 2009)

Log Message:
-----------
edge subdivide now spits out inner elements from fully-subdivided faces, and non-inner split edges/verts, so proper selection can be moved to the tools code.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
    branches/bmesh/blender/source/blender/editors/mesh/editmesh_loop.c

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2009-02-09 06:36:59 UTC (rev 18882)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2009-02-09 07:08:35 UTC (rev 18883)
@@ -178,7 +178,6 @@
 	BMOP_ESUBDIVIDE_NUMCUTS,
 	BMOP_ESUBDIVIDE_FLAG, //beauty flag in esubdivide
 	BMOP_ESUBDIVIDE_RADIUS,
-	BMOP_ESUBDIVIDE_SELACTION,
 
 	BMOP_ESUBDIVIDE_CUSTOMFILL_FACEMAP,
 	BMOP_ESUBDIVIDE_PERCENT_EDGEMAP,
@@ -189,11 +188,7 @@
 
 	/*new edges and vertices from splitting original edges,
 	  doesn't include edges creating by connecting verts.*/
-	BMOP_ESUBDIVIDE_SPLIT_MULTOUT,
-	
-	/*edges created by connecting verts, except for those created
-	  by fully-filled faces (e.g. fully selected faces).*/
-	BMOP_ESUBDIVIDE_CONNECT_MULTOUT,
+	BMOP_ESUBDIVIDE_SPLIT_MULTOUT,	
 	BMOP_ESUBDIVIDE_TOTSLOT,
 };
 /*

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2009-02-09 06:36:59 UTC (rev 18882)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2009-02-09 07:08:35 UTC (rev 18883)
@@ -38,12 +38,10 @@
 	 BMOP_OPSLOT_INT,
 	 BMOP_OPSLOT_INT,
 	 BMOP_OPSLOT_FLT,
-	 BMOP_OPSLOT_INT,
 	 BMOP_OPSLOT_MAPPING,
 	 BMOP_OPSLOT_MAPPING,
 	 BMOP_OPSLOT_PNT_BUF,
 	 BMOP_OPSLOT_PNT_BUF,
-	 BMOP_OPSLOT_PNT_BUF,
 	 },
 	esubdivide_exec,
 	BMOP_ESUBDIVIDE_TOTSLOT,

Modified: branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c	2009-02-09 06:36:59 UTC (rev 18882)
+++ branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c	2009-02-09 07:08:35 UTC (rev 18883)
@@ -19,14 +19,18 @@
 #include <string.h>
 #include <math.h>
 
+/*flags for all elements share a common bitfield space*/
 #define SUBD_SPLIT	1
 
 #define EDGE_PERCENT	2
 
 /*I don't think new faces are flagged, currently, but
   better safe than sorry.*/
-#define FACE_NEW	2
-#define FACE_CUSTOMFILL	4
+#define FACE_NEW	4
+#define FACE_CUSTOMFILL	8
+#define ELE_INNER	16
+#define ELE_SPLIT	32
+#define ELE_CONNECT	64
 
 /*stuff for the flag paramter.  note that
   what used to live in "beauty" and
@@ -116,7 +120,7 @@
 //	float co[3];
 	
 	ev = BM_Split_Edge(bm, edge->v1, edge, out, percent, 1);
-	if (params->flag & SELTYPE_INNER) BM_Select_Vert(bm, ev, 1);
+	BMO_SetFlag(bm, ev, ELE_INNER);
 
 	/* offset for smooth or sphere or fractal */
 	alter_co(ev->co, edge, params, percent, vsta, vend);
@@ -170,6 +174,9 @@
 		                     &newe, vsta, vend);
 		BMO_SetFlag(bm, v, SUBD_SPLIT);
 		BMO_SetFlag(bm, eed, SUBD_SPLIT);
+
+		BMO_SetFlag(bm, v, ELE_SPLIT);
+		BMO_SetFlag(bm, eed, ELE_SPLIT);
 	}
 }
 
@@ -363,10 +370,9 @@
 		b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1);
 		
 		e = BM_Connect_Verts(bm, verts[a], verts[b], &nf);
-		if (params->flag & SELTYPE_INNER) {
-			BM_Select_Edge(bm, e, 1);
-			BM_Select_Face(bm, nf, 1);
-		}
+		BMO_SetFlag(bm, e, ELE_INNER);
+		BMO_SetFlag(bm, nf, ELE_INNER);
+
 		
 		v1 = lines[(i+1)*s] = verts[a];
 		v2 = lines[(i+1)*s + s-1] = verts[b];
@@ -374,9 +380,7 @@
 		for (a=0; a<numcuts; a++) {
 			v = subdivideedgenum(bm, e, a, numcuts, params, &ne,
 			                     v1, v2);
-			if (params->flag & SELTYPE_INNER) {
-				BM_Select_Edge(bm, ne, 1);
-			}
+			BMO_SetFlag(bm, ne, ELE_INNER);
 			lines[(i+1)*s+a+1] = v;
 		}
 	}
@@ -386,10 +390,8 @@
 			a = i*s + j;
 			b = (i-1)*s + j;
 			e = BM_Connect_Verts(bm, lines[a], lines[b], &nf);
-			if (params->flag & SELTYPE_INNER) {
-				BM_Select_Edge(bm, e, 1);
-				BM_Select_Face(bm, nf, 1);
-			}
+			BMO_SetFlag(bm, e, ELE_INNER);
+			BMO_SetFlag(bm, nf, ELE_INNER);
 		}
 	}
 
@@ -488,10 +490,8 @@
 		b = numcuts + numcuts - i;
 		e = BM_Connect_Verts(bm, verts[a], verts[b], &nf);
 		
-		if (params->flag & SELTYPE_INNER) {
-			BM_Select_Edge(bm, e, 1);
-			BM_Select_Face(bm, nf, 1);
-		}
+		BMO_SetFlag(bm, e, ELE_INNER);
+		BMO_SetFlag(bm, nf, ELE_INNER);
 
 		lines[i+1][0] = verts[a];
 		lines[i+1][1+i] = verts[b];
@@ -501,9 +501,7 @@
 			                     verts[a], verts[b]);
 			lines[i+1][j+1] = v;
 
-			if (params->flag & SELTYPE_INNER) {
-				BM_Select_Edge(bm, ne, 1);
-			}
+			BMO_SetFlag(bm, ne, ELE_INNER);
 		}
 	}
 	
@@ -521,17 +519,15 @@
 		for (j=0; j<i; j++) {
 			e= BM_Connect_Verts(bm, lines[i][j], lines[i+1][j+1],
 				           &nf);
-			if (params->flag & SELTYPE_INNER) {
-				BM_Select_Edge(bm, e, 1);
-				BM_Select_Face(bm, nf, 1);
-			}
 
+			BMO_SetFlag(bm, e, ELE_INNER);
+			BMO_SetFlag(bm, nf, ELE_INNER);
+
 			e= BM_Connect_Verts(bm,lines[i][j+1],lines[i+1][j+1],
 				           &nf);
-			if (params->flag & SELTYPE_INNER) {
-				BM_Select_Edge(bm, e, 1);
-				BM_Select_Face(bm, nf, 1);
-			}
+
+			BMO_SetFlag(bm, e, ELE_INNER);
+			BMO_SetFlag(bm, nf, ELE_INNER);
 		}
 	}
 
@@ -587,7 +583,7 @@
 	subd_facedata *facedata = NULL;
 	V_DECLARE(facedata);
 	float rad;
-	int i, j, matched, a, b, numcuts, flag, selaction;
+	int i, j, matched, a, b, numcuts, flag;
 	
 	BMO_Flag_Buffer(bmesh, op, BMOP_ESUBDIVIDE_EDGES, SUBD_SPLIT);
 	
@@ -595,9 +591,6 @@
 	flag = BMO_GetSlot(op, BMOP_ESUBDIVIDE_FLAG)->data.i;
 	rad = BMO_GetSlot(op, BMOP_ESUBDIVIDE_RADIUS)->data.f;
 
-	selaction = BMO_GetSlot(op, BMOP_ESUBDIVIDE_SELACTION)->data.i;
-	if (selaction == SUBDIV_SELECT_INNER) flag |= SELTYPE_INNER;
-
 	einput = BMO_GetSlot(op, BMOP_ESUBDIVIDE_EDGES);
 	/*first go through and tag edges*/
 	for (i=0; i<einput->len; i++) {
@@ -740,6 +733,11 @@
 	if (facedata) V_FREE(facedata);
 	if (edges) V_FREE(edges);
 	if (verts) V_FREE(verts);
+
+	BMO_Flag_To_Slot(bmesh, op, BMOP_ESUBDIVIDE_INNER_MULTOUT,
+		         ELE_INNER, BM_ALL);
+	BMO_Flag_To_Slot(bmesh, op, BMOP_ESUBDIVIDE_SPLIT_MULTOUT,
+		         ELE_SPLIT, BM_ALL);
 }
 
 /*editmesh-emulating function*/
@@ -752,10 +750,21 @@
 	BMO_Set_Int(&op, BMOP_ESUBDIVIDE_NUMCUTS, numcuts);
 	BMO_Set_Int(&op, BMOP_ESUBDIVIDE_FLAG, flag);
 	BMO_Set_Float(&op, BMOP_ESUBDIVIDE_RADIUS, rad);
-	BMO_Set_Int(&op, BMOP_ESUBDIVIDE_SELACTION, seltype);
 	BMO_HeaderFlag_To_Slot(bm, &op, BMOP_ESUBDIVIDE_EDGES, selflag, BM_EDGE);
 	
 	BMO_Exec_Op(bm, &op);
+
+	if (seltype == SUBDIV_SELECT_INNER) {
+		BMOpSlot *einput;
+		BMHeader *ele;
+		int i;
+		
+		einput = BMO_GetSlot(&op, BMOP_ESUBDIVIDE_INNER_MULTOUT);
+		for (i=0; i<einput->len; i++) {
+			ele = ((BMHeader**)einput->data.p)[i];
+			BM_Select(bm, ele, 1);
+		}
+	}
 	BMO_Finish_Op(bm, &op);
 }
 

Modified: branches/bmesh/blender/source/blender/editors/mesh/editmesh_loop.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editmesh_loop.c	2009-02-09 06:36:59 UTC (rev 18882)
+++ branches/bmesh/blender/source/blender/editors/mesh/editmesh_loop.c	2009-02-09 07:08:35 UTC (rev 18883)
@@ -851,7 +851,6 @@
 	if (mode == KNIFE_MIDPOINT) numcuts = 1;
 	BMO_Set_Int(&bmop, BMOP_ESUBDIVIDE_FLAG, flag);
 	BMO_Set_Float(&bmop, BMOP_ESUBDIVIDE_RADIUS, 0);
-	BMO_Set_Int(&bmop, BMOP_ESUBDIVIDE_SELACTION, SUBDIV_SELECT_ORIG);
 	
 	BMO_Exec_Op(bm, &bmop);
 	BMO_Finish_Op(bm, &bmop);





More information about the Bf-blender-cvs mailing list