Commit: b19b250d55010b90875142f57a4c7535f12fbb79
Author: Bastien Montagne
Date:   Tue Mar 6 12:20:29 2018 +0100
Branches: soc-2017-normal-tools
https://developer.blender.org/rBb19b250d55010b90875142f57a4c7535f12fbb79

Try to fix naming of new editnormals ops, and some optimizations.

Some operators were using just 'normals', others 'lopp normals', others
'custom normals'... For now, decided to tick to just 'normals', should
we decide this is too confusing with vnors, I'd rather go to 'custom
normals'.

Also did some cleanup/simplification/optimization in split/merge normals code.

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/editors/mesh/editmesh_tools.c
M       source/blender/editors/mesh/mesh_intern.h
M       source/blender/editors/mesh/mesh_ops.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 5d05d465873..f333b16f709 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -457,7 +457,7 @@ class VIEW3D_PT_tools_normal(View3DPanel, Panel):
         col.operator("mesh.flip_normals", text="Flip Direction")
 
         layout.separator()
-        layout.label(text="Split Normals:")
+        layout.label(text="Custom Normals:")
 
         col = layout.column(align=True)
         col.operator("mesh.set_normals_from_faces", text="Set From Faces")
@@ -465,28 +465,28 @@ class VIEW3D_PT_tools_normal(View3DPanel, Panel):
         col.operator("mesh.point_normals", text="Point To...")
 
         row = layout.row(align=True)
-        row.operator("mesh.merge_loop_normals", text="Merge")
-        row.operator("mesh.split_loop_normals", text="Split")
+        row.operator("mesh.merge_normals", text="Merge")
+        row.operator("mesh.split_normals", text="Split")
 
         col = layout.column(align=True)
-        col.operator_menu_enum("mesh.average_loop_normals", "average_type")
+        col.operator_menu_enum("mesh.average_normals", "average_type")
 
         col = layout.column(align=True)
         col.label(text="Normal Vector:")
         col.prop(toolsettings, "normal_vector", text="")
 
         row = col.row(align=True)
-        row.operator("mesh.custom_normal_tools", text="Copy").mode = 'COPY'
-        row.operator("mesh.custom_normal_tools", text="Paste").mode = 'PASTE'
+        row.operator("mesh.normals_tools", text="Copy").mode = 'COPY'
+        row.operator("mesh.normals_tools", text="Paste").mode = 'PASTE'
 
         row = col.row(align=True)
-        row.operator("mesh.custom_normal_tools", text="Multiply").mode = 
'MULTIPLY'
-        row.operator("mesh.custom_normal_tools", text="Add").mode = 'ADD'
+        row.operator("mesh.normals_tools", text="Multiply").mode = 'MULTIPLY'
+        row.operator("mesh.normals_tools", text="Add").mode = 'ADD'
 
-        col.operator("mesh.custom_normal_tools", text="Reset").mode = 'RESET'
+        col.operator("mesh.normals_tools", text="Reset").mode = 'RESET'
 
         col = layout.column(align=True)
-        col.operator("mesh.smoothen_custom_normals", text="Smoothen")
+        col.operator("mesh.smoothen_normals", text="Smoothen")
 
         col = layout.column(align=True)
         col.label(text="Face Strength:")
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index d2e805c5a1b..93497bdebfb 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6460,8 +6460,8 @@ static void edbm_point_normals_ui(bContext *C, wmOperator 
*op)
 void MESH_OT_point_normals(struct wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Point normals to Target";
-       ot->description = "Point selected normals to specified Target";
+       ot->name = "Point Normals to Target";
+       ot->description = "Point selected custom normals to specified Target";
        ot->idname = "MESH_OT_point_normals";
 
        /* api callbacks */
@@ -6495,7 +6495,7 @@ void MESH_OT_point_normals(struct wmOperatorType *ot)
 
 /********************** Split/Merge Loop Normals **********************/
 
-static void custom_loops_tag(BMesh *bm, const bool do_edges)
+static void normals_splitmerge_loops_edges_tag(BMesh *bm, const bool do_edges)
 {
        BMFace *f;
        BMEdge *e;
@@ -6530,19 +6530,15 @@ static void custom_loops_tag(BMesh *bm, const bool 
do_edges)
        bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
 }
 
-static void loop_normal_merge(bContext *C, BMLoopNorEditDataArray 
*lnors_ed_arr)
+static void normals_merge(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
-       BMesh *bm = em->bm;
-
        BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata;
 
        BLI_SMALLSTACK_DECLARE(clnors, short *);
 
        BLI_assert(bm->lnor_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR);
 
-       custom_loops_tag(bm, false);
+       normals_splitmerge_loops_edges_tag(bm, false);
 
        for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
                if (BM_elem_flag_test(lnor_ed->loop, BM_ELEM_TAG)) {
@@ -6566,33 +6562,25 @@ static void loop_normal_merge(bContext *C, 
BMLoopNorEditDataArray *lnors_ed_arr)
                                BLI_SMALLSTACK_PUSH(clnors, 
lnor_ed_tmp->clnors_data);
                                BM_elem_flag_enable(l, BM_ELEM_TAG);
                        }
-                       if (len_squared_v3(avg_normal) < 1e-4f) {  /* If avg 
normal is nearly 0, set clnor to default value. */
-                               while ((clnors_data = 
BLI_SMALLSTACK_POP(clnors))) {
-                                       copy_v2_v2_short(clnors_data, 
(short[2]){0, 0});
-                               }
+                       if (normalize_v3(avg_normal) < 1e-4f) {  /* If avg 
normal is nearly 0, set clnor to default value. */
+                               zero_v3(avg_normal);
                        }
-                       else {
-                               normalize_v3(avg_normal);  /* Else set all 
clnors to this avg. */
-                               while ((clnors_data = 
BLI_SMALLSTACK_POP(clnors))) {
-                                       
BKE_lnor_space_custom_normal_to_data(lnor_space, avg_normal, clnors_data);
-                               }
+                       while ((clnors_data = BLI_SMALLSTACK_POP(clnors))) {
+                               
BKE_lnor_space_custom_normal_to_data(lnor_space, avg_normal, clnors_data);
                        }
                }
        }
 }
 
-static void loop_normla_split(bContext *C)
+static void normals_split(BMesh *bm)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
-       BMesh *bm = em->bm;
        BMFace *f;
        BMLoop *l, *l_curr, *l_first;
        BMIter fiter;
 
        BLI_assert(bm->lnor_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR);
 
-       custom_loops_tag(bm, true);
+       normals_splitmerge_loops_edges_tag(bm, true);
 
        const int cd_clnors_offset = CustomData_get_offset(&bm->ldata, 
CD_CUSTOMLOOPNORMAL);
        BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
@@ -6646,7 +6634,7 @@ static void loop_normla_split(bContext *C)
        }
 }
 
-static int loop_normals_split_merge(bContext *C, const bool do_merge)
+static int normals_split_merge(bContext *C, const bool do_merge)
 {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6674,10 +6662,10 @@ static int loop_normals_split_merge(bContext *C, const 
bool do_merge)
        BKE_editmesh_lnorspace_update(em);
 
        if (do_merge) {
-               loop_normal_merge(C, lnors_ed_arr);
+               normals_merge(bm, lnors_ed_arr);
        }
        else {
-               loop_normla_split(C);
+               normals_split(bm);
        }
 
        if (lnors_ed_arr) {
@@ -6689,40 +6677,40 @@ static int loop_normals_split_merge(bContext *C, const 
bool do_merge)
        return OPERATOR_FINISHED;
 }
 
-static int edbm_merge_loop_normals_exec(bContext *C, wmOperator *UNUSED(op))
+static int edbm_merge_normals_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       return loop_normals_split_merge(C, true);
+       return normals_split_merge(C, true);
 }
 
-void MESH_OT_merge_loop_normals(struct wmOperatorType *ot)
+void MESH_OT_merge_normals(struct wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Merge Loop Normals";
-       ot->description = "Merge loop normals of selected vertices";
-       ot->idname = "MESH_OT_merge_loop_normals";
+       ot->name = "Merge Normals";
+       ot->description = "Merge custom normals of selected vertices";
+       ot->idname = "MESH_OT_merge_normals";
 
        /* api callbacks */
-       ot->exec = edbm_merge_loop_normals_exec;
+       ot->exec = edbm_merge_normals_exec;
        ot->poll = ED_operator_editmesh_auto_smooth;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-static int edbm_split_loop_normals_exec(bContext *C, wmOperator *UNUSED(op))
+static int edbm_split_normals_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       return loop_normals_split_merge(C, false);
+       return normals_split_merge(C, false);
 }
 
-void MESH_OT_split_loop_normals(struct wmOperatorType *ot)
+void MESH_OT_split_normals(struct wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Split Loop Normals";
-       ot->description = "Split loop normals of selected vertices";
-       ot->idname = "MESH_OT_split_loop_normals";
+       ot->name = "Split Normals";
+       ot->description = "Split custom normals of selected vertices";
+       ot->idname = "MESH_OT_split_normals";
 
        /* api callbacks */
-       ot->exec = edbm_split_loop_normals_exec;
+       ot->exec = edbm_split_normals_exec;
        ot->poll = ED_operator_editmesh_auto_smooth;
 
        /* flags */
@@ -6744,7 +6732,7 @@ static EnumPropertyItem average_method_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-static int edbm_average_loop_normals_exec(bContext *C, wmOperator *op)
+static int edbm_average_normals_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6772,7 +6760,7 @@ static int edbm_average_loop_normals_exec(bContext *C, 
wmOperator *op)
                weight = (weight - 1) * 25;
        }
 
-       custom_loops_tag(bm, true);
+       normals_splitmerge_loops_edges_tag(bm, true);
 
        Heap *loop_weight = BLI_heap_new();
 
@@ -6866,7 +6854,7 @@ static int edbm_average_loop_normals_exec(bContext *C, 
wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static bool average_loop_normals_draw_check_prop(PointerRNA *ptr, PropertyRNA 
*prop)
+static bool average_normals_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
 {
        const char *prop_id = RNA_property_identifier(prop);
        const int average_type = RNA_enum_get(ptr, "average_type");
@@ -6883,7 +6871,7 @@ static bool 
average_loop_normals_draw_check_prop(PointerRNA *ptr, PropertyRNA *p
        return true;
 }
 
-static void edbm_average_loop_normals_ui(bContext *C, wmOperator *op)
+static void edbm_average_normals_ui(bContext *C, wmOperator *op)
 {
        uiLayout *layout = op->layout;
        wmWindowManager *wm = CTX_wm_manager(C);
@@ -6892,30 +6880,32 @@ static void edbm_average_loop_normals_ui(bContext *C, 
wmOperator *op)
        RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
 
        /* Main auto-draw call */
-       uiDefAutoButsRNA(layout, &ptr, average_loop_normals_draw_check_prop, 
'\0');
+       uiDefAutoButsRNA(layout, &ptr, average_normals_draw_check_prop, '\0');
 }
 
-void MESH_OT_average_loop_normals(struct wmOperatorType *ot)
+void MESH_OT_average_normals(struct wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Average";
-       ot->description = "Average loop normals of selected vertices";
-       ot->i

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to