[Bf-blender-cvs] [8803c5ca5d8] master: Cleanup: use sections for editmesh tools/select

Campbell Barton noreply at git.blender.org
Wed Mar 14 07:48:35 CET 2018


Commit: 8803c5ca5d8a99d97529ce2c170a268b52335997
Author: Campbell Barton
Date:   Wed Mar 14 17:25:23 2018 +1100
Branches: master
https://developer.blender.org/rB8803c5ca5d8a99d97529ce2c170a268b52335997

Cleanup: use sections for editmesh tools/select

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

M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/mesh/editmesh_tools.c

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

diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 7d20f7a5665..c84ba93ec0d 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -73,7 +73,9 @@
 /* use bmesh operator flags for a few operators */
 #define BMO_ELE_TAG 1
 
-/* ****************************** MIRROR **************** */
+/* -------------------------------------------------------------------- */
+/** \name Select Mirror
+ * \{ */
 
 void EDBM_select_mirrored(
         BMEditMesh *em, const int axis, const bool extend,
@@ -166,21 +168,34 @@ void EDBM_select_mirrored(
 	*r_totfail = totfail;
 }
 
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Auto-Merge
+ *
+ * Used after transform operations.
+ * \{ */
+
 void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag)
 {
 	bool ok;
 	BMEditMesh *em = BKE_editmesh_from_object(obedit);
 
-	ok = BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS,
-	                  "automerge verts=%hv dist=%f",
-	                  hflag, scene->toolsettings->doublimit);
+	ok = BMO_op_callf(
+	        em->bm, BMO_FLAG_DEFAULTS,
+	        "automerge verts=%hv dist=%f",
+	        hflag, scene->toolsettings->doublimit);
 
 	if (LIKELY(ok) && update) {
 		EDBM_update_generic(em, true, true);
 	}
 }
 
-/* ****************************** SELECTION ROUTINES **************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Back-Buffer OpenGL Selection
+ * \{ */
 
 unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0;    /* set in drawobject.c ... for colorindices */
 
@@ -199,21 +214,21 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma
 	struct ImBuf *buf;
 	unsigned int *dr;
 	int a;
-	
+
 	if (vc->obedit == NULL || !V3D_IS_ZBUF(vc->v3d)) {
 		return false;
 	}
-	
+
 	buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
 	if ((buf == NULL) || (bm_vertoffs == 0)) {
 		return false;
 	}
 
 	dr = buf->rect;
-	
+
 	/* build selection lookup */
 	selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
-	
+
 	a = (xmax - xmin + 1) * (ymax - ymin + 1);
 	while (a--) {
 		if (*dr > 0 && *dr <= bm_vertoffs) {
@@ -263,9 +278,9 @@ static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
 
 /* mcords is a polygon mask
  * - grab backbuffer,
- * - draw with black in backbuffer, 
+ * - draw with black in backbuffer,
  * - grab again and compare
- * returns 'OK' 
+ * returns 'OK'
  */
 bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
 {
@@ -273,7 +288,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
 	struct ImBuf *buf;
 	int a;
 	struct LassoMaskData lasso_mask_data;
-	
+
 	/* method in use for face selecting too */
 	if (vc->obedit == NULL) {
 		if (!BKE_paint_select_elem_test(vc->obact)) {
@@ -302,7 +317,7 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
 
 	/* build selection lookup */
 	selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
-	
+
 	a = (xmax - xmin + 1) * (ymax - ymin + 1);
 	while (a--) {
 		if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) {
@@ -323,7 +338,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
 	unsigned int *dr;
 	short xmin, ymin, xmax, ymax, xc, yc;
 	int radsq;
-	
+
 	/* method in use for face selecting too */
 	if (vc->obedit == NULL) {
 		if (!BKE_paint_select_elem_test(vc->obact)) {
@@ -342,7 +357,7 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
 	}
 
 	dr = buf->rect;
-	
+
 	/* build selection lookup */
 	selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
 	radsq = rads * rads;
@@ -358,12 +373,12 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
 
 	IMB_freeImBuf(buf);
 	return true;
-	
+
 }
 
+/** \} */
 
 /* -------------------------------------------------------------------- */
-
 /** \name Find Nearest Vert/Edge/Face
  *
  * \note Screen-space manhatten distances are used here,
@@ -445,14 +460,14 @@ BMVert *EDBM_vert_find_nearest_ex(
 		float dist_test;
 		unsigned int index;
 		BMVert *eve;
-		
+
 		/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
 		ED_view3d_backbuf_validate(vc);
 
 		index = ED_view3d_backbuf_sample_rect(
 		        vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
 		eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
-		
+
 		if (eve) {
 			if (dist_test < *r_dist) {
 				*r_dist = dist_test;
@@ -811,7 +826,7 @@ BMFace *EDBM_face_find_nearest_ex(
 
 		index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
 		efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
-		
+
 		if (r_efa_zbuf) {
 			*r_efa_zbuf = efa;
 		}
@@ -889,8 +904,8 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
 #undef FIND_NEAR_CYCLE_THRESHOLD_MIN
 
 
-/* best distance based on screen coords. 
- * use em->selectmode to define how to use 
+/* best distance based on screen coords.
+ * use em->selectmode to define how to use
  * selected vertices and edges get disadvantage
  * return 1 if found one
  */
@@ -906,7 +921,7 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
 	float dist = dist_init;
 	BMFace *efa_zbuf = NULL;
 	BMEdge *eed_zbuf = NULL;
-	
+
 	BMVert *eve = NULL;
 	BMEdge *eed = NULL;
 	BMFace *efa = NULL;
@@ -968,8 +983,10 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Select Similar (Vert/Edge/Face) Operator
+ * \{ */
 
-/* ****************  SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */
 static const EnumPropertyItem prop_similar_compare_types[] = {
 	{SIM_CMP_EQ, "EQUAL", 0, "Equal", ""},
 	{SIM_CMP_GT, "GREATER", 0, "Greater", ""},
@@ -1046,7 +1063,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
 	EDBM_update_generic(em, false, false);
 
 	return OPERATOR_FINISHED;
-}	
+}
 
 /* ***************************************************** */
 
@@ -1152,8 +1169,9 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
 	else                 return similar_face_select_exec(C, op);
 }
 
-static const EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop),
-                                                   bool *r_free)
+static const EnumPropertyItem *select_similar_type_itemf(
+        bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop),
+        bool *r_free)
 {
 	Object *obedit;
 
@@ -1205,15 +1223,15 @@ void MESH_OT_select_similar(wmOperatorType *ot)
 	ot->name = "Select Similar";
 	ot->idname = "MESH_OT_select_similar";
 	ot->description = "Select similar vertices, edges or faces by property types";
-	
+
 	/* api callbacks */
 	ot->invoke = WM_menu_invoke;
 	ot->exec = edbm_select_similar_exec;
 	ot->poll = ED_operator_editmesh;
-	
+
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-	
+
 	/* properties */
 	prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", "");
 	RNA_def_enum_funcs(prop, select_similar_type_itemf);
@@ -1223,9 +1241,11 @@ void MESH_OT_select_similar(wmOperatorType *ot)
 	RNA_def_float(ot->srna, "threshold", 0.0f, 0.0f, 1.0f, "Threshold", "", 0.0f, 1.0f);
 }
 
+/** \} */
 
 /* -------------------------------------------------------------------- */
-/* Select Similar Regions */
+/** \name Select Similar Region Operator
+ * \{ */
 
 static int edbm_select_similar_region_exec(bContext *C, wmOperator *op)
 {
@@ -1246,9 +1266,10 @@ static int edbm_select_similar_region_exec(bContext *C, wmOperator *op)
 	}
 
 	groups_array = MEM_mallocN(sizeof(*groups_array) * bm->totfacesel, __func__);
-	group_tot = BM_mesh_calc_face_groups(bm, groups_array, &group_index,
-	                                     NULL, NULL,
-	                                     BM_ELEM_SELECT, BM_VERT);
+	group_tot = BM_mesh_calc_face_groups(
+	        bm, groups_array, &group_index,
+	        NULL, NULL,
+	        BM_ELEM_SELECT, BM_VERT);
 
 	BM_mesh_elem_table_ensure(bm, BM_FACE);
 
@@ -1313,8 +1334,11 @@ void MESH_OT_select_similar_region(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/** \} */
 
-/* ****************  Mode Select *************** */
+/* -------------------------------------------------------------------- */
+/** \name Select Mode Vert/Edge/Face Operator
+ * \{ */
 
 static int edbm_select_mode_exec(bContext *C, wmOperator *op)
 {
@@ -1385,12 +1409,15 @@ void MESH_OT_select_mode(wmOperatorType *ot)
 	RNA_def_enum(ot->srna, "action", actions_items, 2, "Action", "Selection action to execute");
 }
 
-/* ***************************************************** */
+/** \} */
 
-/* ****************  LOOP SELECTS *************** */
+/* -------------------------------------------------------------------- */
+/** \name Select Loop (Non Modal) Operator
+ * \{ */
 
-static void walker_select_count(BMEditMesh *em, int walkercode, void *start, const bool select, const bool select_mix,
-                                int *r_totsel, int *r_totunsel)
+static void walker_select_count(
+        BMEditMesh *em, int walkercode, void *start, const bool select, const bool select_mix,
+        int *r_totsel, int *r_totunsel)
 {
 	BMesh *bm = em->bm;
 	BMElem *ele;
@@ -1445,7 +1472,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
 	BMEdge **edarray;
 	int edindex;
 	const bool is_ring = RNA_boolean_get(op->ptr, "ring");
-	
+
 	BMIter iter;
 	int totedgesel = 0;
 
@@ -1454,17 +1481,17 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
 			totedgesel++;
 		}
 	}
-	
+
 	edarray = MEM_mallocN(sizeof(BMEdge *) * totedgesel, "edge array");
 	edindex = 0;
-	
+
 	BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
 		if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
 			edarray[edindex] = eed;
 			edindex++;
 		}
 	}
-	
+
 	if (is_r

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list