[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43883] branches/bmesh/blender/source/ blender: Bring BME_bevel code back (stage 1), porting it from the old BKE_bmesh to the new BMesh methods and data structures , and turns on compilation of this again.

Andrew Wiggin ender79bl at gmail.com
Sat Feb 4 15:23:08 CET 2012


Revision: 43883
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43883
Author:   ender79
Date:     2012-02-04 14:23:07 +0000 (Sat, 04 Feb 2012)
Log Message:
-----------
Bring BME_bevel code back (stage 1), porting it from the old BKE_bmesh to the new BMesh methods and data structures, and turns on compilation of this again. This makes the code work but isn't using it to do the bevel modifier just yet - that's coming next.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h
    branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt
    branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h	2012-02-04 14:22:05 UTC (rev 43882)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_bmesh.h	2012-02-04 14:23:07 UTC (rev 43883)
@@ -44,6 +44,7 @@
 #include "BLI_editVert.h"
 #include "BKE_DerivedMesh.h"
 //XXX #include "transform.h"
+#include "bmesh.h"
 
 /*forward declerations*/
 struct BME_Vert;
@@ -214,8 +215,8 @@
 #define BME_BEVEL_DIST			(1<<12) /* same as above */
 
 typedef struct BME_TransData {
-	BME_Mesh *bm; /* the bmesh the vert belongs to */
-	BME_Vert *v;  /* pointer to the vert this tdata applies to */
+	BMesh *bm; /* the bmesh the vert belongs to */
+	BMVert *v;  /* pointer to the vert this tdata applies to */
 	float co[3];  /* the original coordinate */
 	float org[3]; /* the origin */
 	float vec[3]; /* a directional vector; always, always normalize! */
@@ -236,7 +237,7 @@
 } BME_TransData_Head;
 
 typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
-	BME_Mesh *bm;
+	BMesh *bm;
 	BME_TransData_Head *td;
 	struct TransInfo *Trans; /* a pointer to the global Trans struct */
 	int imval[2]; /* for restoring original mouse co when initTransform() is called multiple times */
@@ -244,10 +245,10 @@
 	int res;
 } BME_Glob;
 
-struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BME_Vert *v);
+struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v);
 void BME_free_transdata(struct BME_TransData_Head *td);
 float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *td);
-struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
+struct BMesh *BME_bevel(struct BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
 
 /*CONVERSION FUNCTIONS*/
 struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em);

Modified: branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt	2012-02-04 14:22:05 UTC (rev 43882)
+++ branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt	2012-02-04 14:23:07 UTC (rev 43883)
@@ -105,6 +105,7 @@
 	intern/bmesh_walkers_impl.c
 	intern/bmesh_walkers_private.h
 	intern/bmesh_inline.c
+	tools/BME_bevel.c
 	bmesh_error.h
 	bmesh_queries.h
 	bmesh.h

Modified: branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c	2012-02-04 14:22:05 UTC (rev 43882)
+++ branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c	2012-02-04 14:23:07 UTC (rev 43883)
@@ -1,5 +1,3 @@
-#if 0
-
 /*
  *	Functions for changing the topology of a mesh.
  *
@@ -38,15 +36,15 @@
 #include "DNA_mesh_types.h"
 
 #include "BKE_utildefines.h"
+#include "BKE_tessmesh.h"
 #include "BKE_bmesh.h"
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
+#include "BLI_ghash.h"
 
-#include "MTC_matrixops.h"
-#include "MTC_vectorops.h"
+#include "bmesh.h"
+#include "bmesh_private.h"
 
-#include "blendef.h"
-
 /* ------- Bevel code starts here -------- */
 
 BME_TransData_Head *BME_init_transdata(int bufsize)
@@ -54,8 +52,8 @@
 	BME_TransData_Head *td;
 
 	td = MEM_callocN(sizeof(BME_TransData_Head), "BM transdata header");
-	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp);
-	td->ma = BLI_memarena_new(bufsize);
+	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "BME_init_transdata gh");
+	td->ma = BLI_memarena_new(bufsize, "BME_TransData arena");
 	BLI_memarena_use_calloc(td->ma);
 
 	return td;
@@ -127,15 +125,53 @@
 	return BLI_memarena_alloc(td->ma, sizeof(float));
 }
 
-static int BME_bevel_is_split_vert(BMLoop *l)
+/* BM_Dissolve_Disk is a real mess, and crashes bevel if called instead of this.
+   The drawback, though, is that this code doesn't merge customdata. */
+static int BME_Bevel_Dissolve_Disk(BMesh *bm, BMVert *v)
 {
+	BMIter iter;
+	BMEdge *e, *elast;
+	BMLoop *l1, *l2;
+
+	if (BM_Nonmanifold_Vert(bm, v)) {
+		return 0;
+	}
+
+	BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+		if (BM_Edge_FaceCount(e) != 2) {
+			return 0;
+		}
+	}
+
+	if (BM_Vert_EdgeCount(v) > 2) {
+		while (BM_Vert_EdgeCount(v) > 2) {
+			e = v->e;
+			l1 = e->l;
+			l2 = l1->radial_next;
+			bmesh_jfke(bm, l1->f, l2->f, e);
+		}
+
+		e = v->e;
+		elast = bmesh_disk_nextedge(e, v);
+		bmesh_jekv(bm, e, v);
+
+		l1 = elast->l;
+		l2 = l1->radial_next;
+		bmesh_jfke(bm, l1->f, l2->f, elast);
+	}
+
+	return 1;
+}
+
+static int BME_bevel_is_split_vert(BMesh *bm, BMLoop *l)
+{
 	/* look for verts that have already been added to the edge when
 	 * beveling other polys; this can be determined by testing the
 	 * vert and the edges around it for originality
 	 */
-	if ((l->v->tflag1 & BME_BEVEL_ORIG)==0
-			&& (l->e->tflag1 & BME_BEVEL_ORIG)
-			&& (l->prev->e->tflag1 & BME_BEVEL_ORIG))
+	if (!BMO_TestFlag(bm, l->v, BME_BEVEL_ORIG)
+		 && BMO_TestFlag(bm, l->e, BME_BEVEL_ORIG)
+		 && BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG))
 	{
 		return 1;
 	}
@@ -185,7 +221,7 @@
  * vec2 is the direction of projection (pointing away from vec1)
  * up_vec is used for orientation (expected to be normalized)
  * returns the length of the projected vector that lies along vec1 */
-static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td)
+static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td))
 {
 	float factor, vec3[3], tmp[3],c1,c2;
 
@@ -258,8 +294,8 @@
 		//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
 		//BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
 		BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
-		sv->tflag1 |= BME_BEVEL_BEVEL;
-		ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
+		BMO_SetFlag(bm, sv, BME_BEVEL_BEVEL);
+		BMO_SetFlag(bm, ne, BME_BEVEL_ORIG); /* mark edge as original, even though it isn't */
 		BME_bevel_get_vec(vec1,v1,v,td);
 		BME_bevel_get_vec(vec2,v2,v,td);
 		cross_v3_v3v3(t_up_vec,vec1,vec2);
@@ -287,7 +323,7 @@
 			return NULL;
 		}
 
-		if (BME_bevel_is_split_vert(lv1)) {
+		if (BME_bevel_is_split_vert(bm, lv1)) {
 			is_split_vert = 1;
 			sv = v1;
 			if (forward) v1 = l->next->next->v;
@@ -301,11 +337,11 @@
 			//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
 			//BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
 			BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
-			sv->tflag1 |= BME_BEVEL_BEVEL;
-			ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
+			BMO_SetFlag(bm, sv, BME_BEVEL_BEVEL);
+			BMO_SetFlag(bm, ne, BME_BEVEL_ORIG); /* mark edge as original, even though it isn't */
 		}
 
-		if (BME_bevel_is_split_vert(lv2)) {
+		if (BME_bevel_is_split_vert(bm, lv2)) {
 			if (forward) v2 = lv2->prev->v;
 			else v2 = lv2->next->v;
 		}
@@ -346,7 +382,7 @@
 		}
 	}
 
-	dis = (v1->tflag1 & BME_BEVEL_ORIG)? len/3 : len/2;
+	dis = BMO_TestFlag(bm, v1, BME_BEVEL_ORIG)? len/3 : len/2;
 	if (is_edge || dis > maxfactor*value) {
 		dis = maxfactor*value;
 	}
@@ -414,7 +450,8 @@
 	return max;
 }
 
-static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int options, BME_TransData_Head *td)
+#if 0 /* UNUSED */
+static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int UNUSED(options), BME_TransData_Head *td)
 {
 	BMVert *ov1, *ov2, *v1, *v2;
 
@@ -423,9 +460,9 @@
 
 	/* split the edges */
 	v1 = BME_bevel_split_edge(bm,v,ov1,NULL,NULL,value,td);
-	v1->tflag1 |= BME_BEVEL_NONMAN;
+	BMO_SetFlag(bm, v1, BME_BEVEL_NONMAN);
 	v2 = BME_bevel_split_edge(bm,v,ov2,NULL,NULL,value,td);
-	v2->tflag1 |= BME_BEVEL_NONMAN;
+	BMO_SetFlag(bm, v2, BME_BEVEL_NONMAN);
 
 	if (value > 0.5) {
 		BME_bevel_set_max(v1,ov1,value,td);
@@ -434,37 +471,37 @@
 
 	/* remove the original vert */
 	if (res) {
-		bmesh_jekv;
+		/*bmesh_jekv;*/
 
 		//void BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, int calcnorm){
 		//hrm, why is there a fac here? it just removes a vert
-		BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE);
-		//bmesh_jekv(bm,v->e,v);
+		BM_Collapse_Vert_Edges(bm, v->e, v);
 	}
 
 	return v1;
 }
+#endif
 
-static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, float *up_vec, BME_TransData_Head *td)
+static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td)
 {
 	BMVert *v1, *v2, *kv;
 	BMLoop *kl=NULL, *nl;
-	BMEdge *e;
-	BMFace *f;
+	BMEdge *e, *ke, *se;
+	BMFace *f, *jf;
 
 	f = l->f;
 	e = l->e;
 
-	if ((l->e->tflag1 & BME_BEVEL_BEVEL) == 0
-		&& ((l->v->tflag1 & BME_BEVEL_BEVEL) || (l->next->v->tflag1 & BME_BEVEL_BEVEL)))
-	{ /* sanity check */
+	/* sanity check */
+	if (!BMO_TestFlag(bm, l->e, BME_BEVEL_BEVEL)
+	    && (BMO_TestFlag(bm, l->v, BME_BEVEL_BEVEL) || BMO_TestFlag(bm, l->next->v, BME_BEVEL_BEVEL))) {
 		return l;
 	}
 
 	/* checks and operations for prev edge */
 	/* first, check to see if this edge was inset previously */
-	if ((l->prev->e->tflag1 & BME_BEVEL_ORIG) == 0
-		&& (l->v->tflag1 & BME_BEVEL_NONMAN) == 0) {
+	if (!BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG)
+	    && !BMO_TestFlag(bm, l->v, BME_BEVEL_NONMAN)) {
 		kl = l->prev->radial_next;
 		if (kl->v == l->v) kl = kl->prev;
 		else kl = kl->next;
@@ -474,7 +511,7 @@
 		kv = NULL;
 	}
 	/* get/make the first vert to be used in SFME */
-	if (l->v->tflag1 & BME_BEVEL_NONMAN){
+	if (BMO_TestFlag(bm, l->v, BME_BEVEL_NONMAN)) {
 		v1 = l->v;
 	}
 	else { /* we'll need to split the previous edge */
@@ -482,27 +519,35 @@
 	}
 	/* if we need to clean up geometry... */
 	if (kv) {
-		l = l->next;
+		se = l->next->e;
+		jf = NULL;
 		if (kl->v == kv) {
 			BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
-			bmesh_jfke(bm, kl->prev->radial_next->f,kl->f,kl->prev->e);
-			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0, TRUE);
-			//BME_JEKV(bm,kl->e,kv);
-			
+			ke = kl->e;
+			/* BMESH-TODO: jfke doesn't handle customdata */
+			jf = bmesh_jfke(bm,kl->prev->radial_next->f,kl->f,kl->prev->e);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list