Multi-objects: Select similar edge SIMEDGE_FACE_ANGLE

I'm not sure why the original implementation was only checking for equal
comparison but I'm doing the same here. It is a one line change if we
want to support LT/GT anyways.

Also "technically" we should compare the angles in the worldspace, since
different scales will result in different angles. Added as a TODO but
honestly I think this is overkill.
This commit is contained in:
Dalai Felinto 2018-09-21 13:57:33 -03:00
parent 35f659aeb4
commit e406a9f305
1 changed files with 23 additions and 2 deletions

View File

@ -258,7 +258,8 @@ static float edge_length_squared_worldspace_get(Object *ob, BMEdge *edge) {
return len_squared_v3v3(v1, v2);
}
/* wrap the above function but do selection flushing edge to face */
/* Note/TODO(dfelinto) technically SIMEDGE_FACE_ANGLE should compare the angles in world space.
* Although doable this is overkill - at least for the initial multi-objects implementation. */
static int similar_edge_select_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
@ -270,7 +271,6 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
const int compare = RNA_enum_get(op->ptr, "compare");
if (ELEM(type,
SIMEDGE_FACE_ANGLE,
SIMEDGE_CREASE,
SIMEDGE_BEVEL,
SIMEDGE_SEAM,
@ -304,6 +304,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
GSet *gset = NULL;
switch (type) {
case SIMEDGE_FACE_ANGLE:
case SIMEDGE_LENGTH:
case SIMEDGE_DIR:
tree = BLI_kdtree_new(tot_edges_selected_all);
@ -346,6 +347,15 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
BLI_kdtree_insert(tree, tree_index++, dummy);
break;
}
case SIMEDGE_FACE_ANGLE:
{
if (BM_edge_face_count_at_most(edge, 2) == 2) {
float angle = BM_edge_calc_face_angle(edge);
float dummy[3] = {angle, 0.0f, 0.0f};
BLI_kdtree_insert(tree, tree_index++, dummy);
}
break;
}
}
}
}
@ -407,6 +417,17 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
}
break;
}
case SIMEDGE_FACE_ANGLE:
{
if (BM_edge_face_count_at_most(edge, 2) == 2) {
float angle = BM_edge_calc_face_angle(edge);
if (select_similar_compare_float_tree(tree, angle, thresh, SIM_CMP_EQ)) {
BM_edge_select_set(bm, edge, true);
changed = true;
}
}
break;
}
}
}
}