Commit: d29dd5916f7d3cfb21cacb003df5796051c93301
Author: Bastien Montagne
Date:   Tue Mar 19 11:10:30 2019 +0100
Branches: master
https://developer.blender.org/rBd29dd5916f7d3cfb21cacb003df5796051c93301

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).

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

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

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

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;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to