Merged changes in the trunk up to revision 51853.
[blender-staging.git] / source / blender / editors / mesh / editmesh_select.c
index 99eee19f66d431d700b4c1e5253f3069b4d61d3e..3e985a9779cd3fd2a2f1aa6fb76f99872a212e1d 100644 (file)
@@ -671,6 +671,13 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
 }
 
 /* ****************  SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */
+static EnumPropertyItem prop_similar_compare_types[] = {
+       {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""},
+       {SIM_CMP_GT, "GREATER", 0, "Greater", ""},
+       {SIM_CMP_LT, "LESS", 0, "Less", ""},
+
+       {0, NULL, 0, NULL, NULL}
+};
 
 static EnumPropertyItem prop_similar_types[] = {
        {SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""},
@@ -691,6 +698,7 @@ static EnumPropertyItem prop_similar_types[] = {
        {SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""},
        {SIMFACE_IMAGE, "IMAGE", 0, "Image", ""},
        {SIMFACE_AREA, "AREA", 0, "Area", ""},
+       {SIMFACE_SIDES, "SIDES", 0, "Polygon Sides", ""},
        {SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""},
        {SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""},
        {SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""},
@@ -708,11 +716,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
        BMOperator bmop;
 
        /* get the type from RNA */
-       int type = RNA_enum_get(op->ptr, "type");
-       float thresh = RNA_float_get(op->ptr, "threshold");
+       const int type = RNA_enum_get(op->ptr, "type");
+       const float thresh = RNA_float_get(op->ptr, "threshold");
+       const int compare = RNA_enum_get(op->ptr, "compare");
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_op_init(em, &bmop, op, "similar_faces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_op_init(em, &bmop, op,
+                    "similar_faces faces=%hf type=%i thresh=%f compare=%i",
+                    BM_ELEM_SELECT, type, thresh, compare);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -746,11 +757,14 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
        BMOperator bmop;
 
        /* get the type from RNA */
-       int type = RNA_enum_get(op->ptr, "type");
-       float thresh = RNA_float_get(op->ptr, "threshold");
+       const int type = RNA_enum_get(op->ptr, "type");
+       const float thresh = RNA_float_get(op->ptr, "threshold");
+       const int compare = RNA_enum_get(op->ptr, "compare");
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_op_init(em, &bmop, op, "similar_edges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_op_init(em, &bmop, op,
+                    "similar_edges edges=%he type=%i thresh=%f compare=%i",
+                    BM_ELEM_SELECT, type, thresh, compare);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -787,11 +801,14 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
        BMEditMesh *em = BMEdit_FromObject(ob);
        BMOperator bmop;
        /* get the type from RNA */
-       int type = RNA_enum_get(op->ptr, "type");
+       const int type = RNA_enum_get(op->ptr, "type");
        float thresh = RNA_float_get(op->ptr, "threshold");
+       const int compare = RNA_enum_get(op->ptr, "compare");
 
        /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
-       EDBM_op_init(em, &bmop, op, "similar_verts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh);
+       EDBM_op_init(em, &bmop, op,
+                    "similar_verts verts=%hv type=%i thresh=%f compare=%i",
+                    BM_ELEM_SELECT, type, thresh, compare);
 
        /* execute the operator */
        BMO_op_exec(em->bm, &bmop);
@@ -820,7 +837,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
        ToolSettings *ts = CTX_data_tool_settings(C);
        PropertyRNA *prop = RNA_struct_find_property(op->ptr, "threshold");
 
-       int type = RNA_enum_get(op->ptr, "type");
+       const int type = RNA_enum_get(op->ptr, "type");
 
        if (!RNA_property_is_set(op->ptr, prop)) {
                RNA_property_float_set(op->ptr, prop, ts->select_thresh);
@@ -831,7 +848,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
 
        if      (type < 100) return similar_vert_select_exec(C, op);
        else if (type < 200) return similar_edge_select_exec(C, op);
-       else return similar_face_select_exec(C, op);
+       else                 return similar_face_select_exec(C, op);
 }
 
 static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop),
@@ -895,7 +912,9 @@ void MESH_OT_select_similar(wmOperatorType *ot)
        prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", "");
        RNA_def_enum_funcs(prop, select_similar_type_itemf);
 
-       RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.01, 1.0);
+       RNA_def_enum(ot->srna, "compare", prop_similar_compare_types, SIM_CMP_EQ, "Compare", "");
+
+       RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.0, 1.0);
 }
 
 /* ***************************************************** */
@@ -2299,9 +2318,9 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
 void MESH_OT_select_nth(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Select Nth";
+       ot->name = "Checker Deselect";
        ot->idname = "MESH_OT_select_nth";
-       ot->description = "Select every Nth element starting from a selected vertex, edge or face";
+       ot->description = "Deselect every Nth element starting from a selected vertex, edge or face";
 
        /* api callbacks */
        ot->exec = edbm_select_nth_exec;