Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-08-24 00:12:53 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-08-24 17:17:00 +0300
commit00ab0b039995db7dfae6284d1ed1f7f034420366 (patch)
treea791bbc4181a49ed51aef8ba89e8b332c1bb1ad4
parentedbe334ae91504f49ad13a09b480804f929e65a4 (diff)
MESH_OT_select_axis: cleanup (use enum instead of hardcoded values)
-rw-r--r--source/blender/editors/mesh/editmesh_select.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index bbdb0a904a9..fdf6ac5685f 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -4330,6 +4330,18 @@ void MESH_OT_select_ungrouped(wmOperatorType *ot)
/** \name Select Axis Operator
* \{ */
+enum {
+ SELECT_AXIS_POSITIVE = 0,
+ SELECT_AXIS_NEGATIVE = 1,
+ SELECT_AXIS_ALIGNED = 2,
+};
+
+enum {
+ SELECT_AXIS_X = 0,
+ SELECT_AXIS_Y = 1,
+ SELECT_AXIS_Z = 2,
+};
+
/* BMESH_TODO - some way to select on an arbitrary axis */
static int edbm_select_axis_exec(bContext *C, wmOperator *op)
{
@@ -4338,7 +4350,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
BMesh *bm = em->bm;
BMVert *v_act = BM_mesh_active_vert_get(bm);
const int axis = RNA_enum_get(op->ptr, "axis");
- const int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */
+ const int mode = RNA_enum_get(op->ptr, "mode");
if (v_act == NULL) {
BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)");
@@ -4350,23 +4362,25 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
const float limit = RNA_float_get(op->ptr, "threshold");
float value = v_act->co[axis];
- if (mode == 0)
+ if (mode == SELECT_AXIS_NEGATIVE) {
value -= limit;
- else if (mode == 1)
+ }
+ else if (mode == SELECT_AXIS_POSITIVE) {
value += limit;
+ }
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
switch (mode) {
- case -1: /* aligned */
+ case SELECT_AXIS_ALIGNED:
if (fabsf(v->co[axis] - value) < limit)
BM_vert_select_set(bm, v, true);
break;
- case 0: /* neg */
+ case SELECT_AXIS_NEGATIVE:
if (v->co[axis] > value)
BM_vert_select_set(bm, v, true);
break;
- case 1: /* pos */
+ case SELECT_AXIS_POSITIVE:
if (v->co[axis] < value)
BM_vert_select_set(bm, v, true);
break;
@@ -4384,16 +4398,16 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
void MESH_OT_select_axis(wmOperatorType *ot)
{
static const EnumPropertyItem axis_mode_items[] = {
- {0, "POSITIVE", 0, "Positive Axis", ""},
- {1, "NEGATIVE", 0, "Negative Axis", ""},
- {-1, "ALIGNED", 0, "Aligned Axis", ""},
+ {SELECT_AXIS_POSITIVE, "POSITIVE", 0, "Positive Axis", ""},
+ {SELECT_AXIS_NEGATIVE, "NEGATIVE", 0, "Negative Axis", ""},
+ {SELECT_AXIS_ALIGNED, "ALIGNED", 0, "Aligned Axis", ""},
{0, NULL, 0, NULL, NULL}
};
static const EnumPropertyItem axis_items_xyz[] = {
- {0, "X_AXIS", 0, "X Axis", ""},
- {1, "Y_AXIS", 0, "Y Axis", ""},
- {2, "Z_AXIS", 0, "Z Axis", ""},
+ {SELECT_AXIS_X, "X_AXIS", 0, "X Axis", ""},
+ {SELECT_AXIS_Y, "Y_AXIS", 0, "Y Axis", ""},
+ {SELECT_AXIS_Z, "Z_AXIS", 0, "Z Axis", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -4410,8 +4424,8 @@ void MESH_OT_select_axis(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting");
- RNA_def_enum(ot->srna, "axis", axis_items_xyz, 0, "Axis", "Select the axis to compare each vertex on");
+ RNA_def_enum(ot->srna, "mode", axis_mode_items, SELECT_AXIS_NEGATIVE, "Axis Mode", "Axis side to use when selecting");
+ RNA_def_enum(ot->srna, "axis", axis_items_xyz, SELECT_AXIS_X, "Axis", "Select the axis to compare each vertex on");
RNA_def_float(ot->srna, "threshold", 0.0001f, 0.000001f, 50.0f, "Threshold", "", 0.00001f, 10.0f);
}