diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-19 13:10:30 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-19 14:31:50 +0300 |
commit | d29dd5916f7d3cfb21cacb003df5796051c93301 (patch) | |
tree | 00bef1305cefb021fd05b926f379e505caaa9bbd /source/blender/editors/mesh | |
parent | a73afc7eebfea1e60e94ae334a4dc4c3fce57467 (diff) |
Minor cleanup/refactor of EditMesh custom normals copy code.
Do not compute temp helper data when we do not need it (even though in
that case it was totally cheap to compute).
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 9a58608081f..5b2cb97aff1 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -8000,16 +8000,10 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op) switch (mode) { case EDBM_CLNOR_TOOLS_COPY: if (bm->totfacesel != 1 && lnors_ed_arr->totloop != 1 && bm->totvertsel != 1) { - BKE_report(op->reports, RPT_ERROR, "Can only copy custom normal, vertex normal or face normal"); + BKE_report(op->reports, RPT_ERROR, "Can only copy one custom normal, vertex normal or face normal"); BM_loop_normal_editdata_array_free(lnors_ed_arr); return OPERATOR_CANCELLED; } - bool join = true; - for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) { - if (!compare_v3v3(lnors_ed_arr->lnor_editdata->nloc, lnor_ed->nloc, 1e-4f)) { - join = false; - } - } if (lnors_ed_arr->totloop == 1) { copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc); } @@ -8022,8 +8016,18 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op) } } } - else if (join) { - copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc); + else { + /* 'Vertex' normal, i.e. common set of loop normals on the same vertex, + * only if they are all the same. */ + bool are_same_lnors = true; + for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) { + if (!compare_v3v3(lnors_ed_arr->lnor_editdata->nloc, lnor_ed->nloc, 1e-4f)) { + are_same_lnors = false; + } + } + if (are_same_lnors) { + copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc); + } } break; |