[Bf-blender-cvs] [2a2ae9c3fa] master: BMesh: remove BM_face_create_ngon_vcloud

Campbell Barton noreply at git.blender.org
Thu Jan 19 20:08:15 CET 2017


Commit: 2a2ae9c3fa680b84b9fef3c29f10739a5c3da7a5
Author: Campbell Barton
Date:   Fri Jan 20 06:06:06 2017 +1100
Branches: master
https://developer.blender.org/rB2a2ae9c3fa680b84b9fef3c29f10739a5c3da7a5

BMesh: remove BM_face_create_ngon_vcloud

Instead, add BM_verts_sort_radial_plane
and use regular creation API.

===================================================================

M	source/blender/bmesh/intern/bmesh_construct.c
M	source/blender/bmesh/intern/bmesh_construct.h
M	source/blender/bmesh/operators/bmo_create.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index af7ef01da7..e46a31cb2e 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -387,15 +387,11 @@ BMFace *BM_face_create_ngon_verts(
  *
  * \note Since this is a vcloud there is no direction.
  */
-BMFace *BM_face_create_ngon_vcloud(
-        BMesh *bm, BMVert **vert_arr, int len,
-        const BMFace *f_example, const eBMCreateFlag create_flag)
+void BM_verts_sort_radial_plane(BMVert **vert_arr, int len)
 {
 	struct SortIntByFloat *vang = BLI_array_alloca(vang, len);
 	BMVert **vert_arr_map = BLI_array_alloca(vert_arr_map, len);
 
-	BMFace *f;
-
 	float totv_inv = 1.0f / (float)len;
 	int i = 0;
 
@@ -472,6 +468,7 @@ BMFace *BM_face_create_ngon_vcloud(
 	for (i = 0; i < len; i++) {
 		vang[i].sort_value = angle_signed_on_axis_v3v3v3_v3(far, cent, vert_arr[i]->co, nor);
 		vang[i].data = i;
+		vert_arr_map[i] = vert_arr[i];
 	}
 
 	/* sort by angle and magic! - we have our ngon */
@@ -479,14 +476,9 @@ BMFace *BM_face_create_ngon_vcloud(
 
 	/* --- */
 
-	/* create edges and find the winding (if faces are attached to any existing edges) */
 	for (i = 0; i < len; i++) {
-		vert_arr_map[i] = vert_arr[vang[i].data];
+		vert_arr[i] = vert_arr_map[vang[i].data];
 	}
-
-	f = BM_face_create_ngon_verts(bm, vert_arr_map, len, f_example, create_flag, true, true);
-
-	return f;
 }
 
 /*************************************************************/
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index 9c6483de42..a52a17cd2f 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -34,6 +34,9 @@ bool BM_verts_from_edges(BMVert **vert_arr, BMEdge **edge_arr, const int len);
 bool BM_edges_from_verts(BMEdge **edge_arr, BMVert **vert_arr, const int len);
 void BM_edges_from_verts_ensure(BMesh *bm, BMEdge **edge_arr, BMVert **vert_arr, const int len);
 
+/* sort before creation */
+void    BM_verts_sort_radial_plane(BMVert **vert_arr, int len);
+
 BMFace *BM_face_create_quad_tri(
         BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
         const BMFace *f_example, const eBMCreateFlag create_flag);
@@ -50,10 +53,6 @@ BMFace *BM_face_create_ngon_verts(
         const BMFace *f_example, const eBMCreateFlag create_flag,
         const bool calc_winding, const bool create_edges);
 
-BMFace *BM_face_create_ngon_vcloud(
-        BMesh *bm, BMVert **vert_arr, int len,
-        const BMFace *f_example, const eBMCreateFlag create_flag);
-
 void BM_elem_attrs_copy_ex(
         BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
         const char hflag_mask);
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 7b8cb36ab5..a980baf862 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -290,7 +290,11 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
 		BMFace *f;
 
 		BMO_iter_as_array(op->slots_in, "geom", BM_VERT, (void **)vert_arr, totv);
-		f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, NULL, BM_CREATE_NO_DOUBLE);
+
+		BM_verts_sort_radial_plane(vert_arr, totv);
+
+		/* create edges and find the winding (if faces are attached to any existing edges) */
+		f = BM_face_create_ngon_verts(bm, vert_arr, totv, NULL, BM_CREATE_NO_DOUBLE, true, true);
 
 		if (f) {
 			BMO_face_flag_enable(bm, f, ELE_OUT);




More information about the Bf-blender-cvs mailing list