[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50531] branches/soc-2012-sushi/source/ blender/bmesh/operators/bmo_bevel.c: Fix for round bevel when even number of segments.

Howard Trickey howard.trickey at gmail.com
Tue Sep 11 14:30:30 CEST 2012


Revision: 50531
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50531
Author:   howardt
Date:     2012-09-11 12:30:30 +0000 (Tue, 11 Sep 2012)
Log Message:
-----------
Fix for round bevel when even number of segments.

Modified Paths:
--------------
    branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_bevel.c

Modified: branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_bevel.c
===================================================================
--- branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_bevel.c	2012-09-11 12:19:43 UTC (rev 50530)
+++ branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_bevel.c	2012-09-11 12:30:30 UTC (rev 50531)
@@ -120,6 +120,7 @@
 	float h[3];
 
 } SurfaceEdgeData;
+#include "bevdebug.c"
 
 BMVert* bevel_create_unique_vertex(BMesh *bm, BevelParams *bp, float co[3]);
 
@@ -1414,7 +1415,7 @@
 	}
 }
 
-int check_dublicated_vertex(BMVert **vv, int count, BMVert *v)
+int check_duplicated_vertex(BMVert **vv, int count, BMVert *v)
 {
 	int result =0, i;
 	for (i = 0; i< count; i++) {
@@ -1424,6 +1425,25 @@
 	return result;
 }
 
+void merge_verts_at_center(BMesh *bm, BMOperator *op, BMVert **verts, int totv)
+{
+	int i;
+	float cent[3] = {0.0f, 0.0f, 0.0f};
+
+	if (totv <= 1)
+		return;
+
+	for (i = 0; i < totv; i++) {
+		add_v3_v3(cent, verts[i]->co);
+		BMO_elem_flag_enable(bm, verts[i], VERT_OLD);
+	}
+	mul_v3_fl(cent, 1.0f/totv);
+	BMO_op_callf(bm, op->flag, "pointmerge verts=%fv merge_co=%v", VERT_OLD, cent);
+
+	/* after merge, only the first vert remains; remove the flag from it */
+	BMO_elem_flag_disable(bm, verts[0], VERT_OLD);
+}
+
 void bevel_build_rings(BMesh *bm, BMOperator *op, BevelParams* bp, AdditionalVert *av)
 {
 	BMEdge *e, *firstE;
@@ -1459,25 +1479,25 @@
 
 		} while (e != firstE);
 		if (i != 0) {
+			if (i == bp->seg/2) { /*DEBUG*/int j; printf("bevel_build_rings i=%d, ", i); dump_e(e); printf("\n");
+				for (j=0; j < BLI_array_count(segmentList); j++) dump_sdata(segmentList[j], "segment"); }
 			updatSurfaceEdgeItems(segmentList, newSegmentsList, BLI_array_count(segmentList));
 			BLI_array_empty(newSegmentsList);
 		}
 	}
 
-	if (bp->seg % 2 != 0) {
-		for(i = 0; i < BLI_array_count(segmentList); i++) {
-			if (!check_dublicated_vertex(nGonList,BLI_array_count(nGonList), segmentList[i]->a))
-				BLI_array_append(nGonList, segmentList[i]->a);
-			if (!check_dublicated_vertex(nGonList,BLI_array_count(nGonList), segmentList[i]->b))
-				BLI_array_append(nGonList, segmentList[i]->b);
-		}
-		if (BLI_array_count(nGonList) > 2)
+	for(i = 0; i < BLI_array_count(segmentList); i++) {
+		if (!check_duplicated_vertex(nGonList,BLI_array_count(nGonList), segmentList[i]->a))
+			BLI_array_append(nGonList, segmentList[i]->a);
+		if (!check_duplicated_vertex(nGonList,BLI_array_count(nGonList), segmentList[i]->b))
+			BLI_array_append(nGonList, segmentList[i]->b);
+	}
+	if (BLI_array_count(nGonList) > 2) {
+		if (bp->seg % 2 != 0)
 			BM_face_create_ngon_vcloud(bm, nGonList, BLI_array_count(nGonList), 1);
+		else
+			merge_verts_at_center(bm, op, nGonList, BLI_array_count(nGonList));
 	}
-
-
-	firstE = find_first_edge(bm, op, av->v);
-	e = firstE;
 }
 
 void bevel_build_polygons_around_vertex(BMesh *bm, BevelParams *bp, BMOperator *op, BMVert *v)




More information about the Bf-blender-cvs mailing list