Commit: d1596dc1709701e731fd4943918d2990c7efbee2
Author: Bastien Montagne
Date:   Fri Mar 2 13:52:10 2018 +0100
Branches: soc-2017-normal-tools
https://developer.blender.org/rBd1596dc1709701e731fd4943918d2990c7efbee2

Cleanup: renaming mostly, plus some const qualifiers etc.

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

M       source/blender/bmesh/intern/bmesh_mesh.c
M       source/blender/bmesh/intern/bmesh_mesh.h
M       source/blender/editors/mesh/editmesh_tools.c
M       source/blender/editors/transform/transform.c

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

diff --git a/source/blender/bmesh/intern/bmesh_mesh.c 
b/source/blender/bmesh/intern/bmesh_mesh.c
index ab6ac9edef4..99582089bde 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1330,7 +1330,7 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, 
BLI_bitmap *loops)
        return totloopsel;
 }
 
-static void InitTransDataNormal(BMesh *bm, BMLoopNorEditData *tld, BMVert *v, 
BMLoop *l, const int offset)
+static void loop_normal_editdata_init(BMesh *bm, BMLoopNorEditData *lnor_ed, 
BMVert *v, BMLoop *l, const int offset)
 {
        BLI_assert(bm->lnor_spacearr != NULL);
        BLI_assert(bm->lnor_spacearr->lspacearr != NULL);
@@ -1338,25 +1338,25 @@ static void InitTransDataNormal(BMesh *bm, 
BMLoopNorEditData *tld, BMVert *v, BM
        const int l_index = BM_elem_index_get(l);
        short *clnors_data = BM_ELEM_CD_GET_VOID_P(l, offset);
 
-       tld->loop_index = l_index;
-       tld->loop = l;
+       lnor_ed->loop_index = l_index;
+       lnor_ed->loop = l;
 
        float custom_normal[3];
        
BKE_lnor_space_custom_data_to_normal(bm->lnor_spacearr->lspacearr[l_index], 
clnors_data, custom_normal);
 
-       tld->clnors_data = clnors_data;
-       copy_v3_v3(tld->nloc, custom_normal);
-       copy_v3_v3(tld->niloc, custom_normal);
+       lnor_ed->clnors_data = clnors_data;
+       copy_v3_v3(lnor_ed->nloc, custom_normal);
+       copy_v3_v3(lnor_ed->niloc, custom_normal);
 
        if (v) {
-               tld->loc = v->co;
+               lnor_ed->loc = v->co;
        }
        else {
-               tld->loc = NULL;
+               lnor_ed->loc = NULL;
        }
 }
 
-BMLoopNorEditDataArray *BM_loop_normal_editdata_init(BMesh *bm)
+BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm)
 {
        BMLoop *l;
        BMVert *v;
@@ -1369,8 +1369,8 @@ BMLoopNorEditDataArray 
*BM_loop_normal_editdata_init(BMesh *bm)
 
        BLI_assert(bm->spacearr_dirty == 0);
 
-       BMLoopNorEditDataArray *ld = MEM_mallocN(sizeof(*ld), __func__);
-       ld->lidx_to_lnor_editdata = 
MEM_callocN(sizeof(*ld->lidx_to_lnor_editdata) * bm->totloop, __func__);
+       BMLoopNorEditDataArray *lnors_ed_arr = 
MEM_mallocN(sizeof(*lnors_ed_arr), __func__);
+       lnors_ed_arr->lidx_to_lnor_editdata = 
MEM_callocN(sizeof(*lnors_ed_arr->lidx_to_lnor_editdata) * bm->totloop, 
__func__);
 
        if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) {
                BM_data_layer_add(bm, &bm->ldata, CD_CUSTOMLOOPNORMAL);
@@ -1386,45 +1386,45 @@ BMLoopNorEditDataArray 
*BM_loop_normal_editdata_init(BMesh *bm)
        }
 
        if (totloopsel) {
-               BMLoopNorEditData *tld = ld->lnor_editdata = 
MEM_mallocN(sizeof(*tld) * totloopsel, __func__);
+               BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata = 
MEM_mallocN(sizeof(*lnor_ed) * totloopsel, __func__);
 
                BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) {
                        BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) {
                                if (BLI_BITMAP_TEST(loops, 
BM_elem_index_get(l))) {
-                                       InitTransDataNormal(bm, tld, v, l, 
cd_custom_normal_offset);
-                                       
ld->lidx_to_lnor_editdata[BM_elem_index_get(l)] = tld;
-                                       tld++;
+                                       loop_normal_editdata_init(bm, lnor_ed, 
v, l, cd_custom_normal_offset);
+                                       
lnors_ed_arr->lidx_to_lnor_editdata[BM_elem_index_get(l)] = lnor_ed;
+                                       lnor_ed++;
                                }
                        }
                }
-               ld->totloop = totloopsel;
+               lnors_ed_arr->totloop = totloopsel;
        }
        else {  /* If multiple selection modes are inactive OR no such loop is 
found, fall back to editing all loops. */
                totloopsel = BM_total_loop_select(bm);
-               BMLoopNorEditData *tld = ld->lnor_editdata = 
MEM_mallocN(sizeof(*tld) * totloopsel, __func__);
+               BMLoopNorEditData *tld = lnors_ed_arr->lnor_editdata = 
MEM_mallocN(sizeof(*tld) * totloopsel, __func__);
 
                BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) {
                        if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
                                BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) {
-                                       InitTransDataNormal(bm, tld, v, l, 
cd_custom_normal_offset);
-                                       
ld->lidx_to_lnor_editdata[BM_elem_index_get(l)] = tld;
+                                       loop_normal_editdata_init(bm, tld, v, 
l, cd_custom_normal_offset);
+                                       
lnors_ed_arr->lidx_to_lnor_editdata[BM_elem_index_get(l)] = tld;
                                        tld++;
                                }
                        }
                }
-               ld->totloop = totloopsel;
+               lnors_ed_arr->totloop = totloopsel;
        }
 
        MEM_freeN(loops);
-       ld->cd_custom_normal_offset = cd_custom_normal_offset;
-       return ld;
+       lnors_ed_arr->cd_custom_normal_offset = cd_custom_normal_offset;
+       return lnors_ed_arr;
 }
 
-void BM_loop_normal_editdata_free(BMLoopNorEditDataArray *ld)
+void BM_loop_normal_editdata_array_free(BMLoopNorEditDataArray *lnors_ed_arr)
 {
-       MEM_SAFE_FREE(ld->lnor_editdata);
-       MEM_SAFE_FREE(ld->lidx_to_lnor_editdata);
-       MEM_freeN(ld);
+       MEM_SAFE_FREE(lnors_ed_arr->lnor_editdata);
+       MEM_SAFE_FREE(lnors_ed_arr->lidx_to_lnor_editdata);
+       MEM_freeN(lnors_ed_arr);
 }
 
 int BM_total_loop_select(BMesh *bm)
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h 
b/source/blender/bmesh/intern/bmesh_mesh.h
index 98439c8b4a1..51f58a7f44c 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -64,12 +64,10 @@ void BM_lnorspace_err(BMesh *bm);
 #endif
 
 /* Loop Generics */
-struct BMLoopNorEditDataArray *BM_loop_normal_editdata_init(BMesh *bm);
-void BM_loop_normal_editdata_free(struct BMLoopNorEditDataArray *ld);
+struct BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm);
+void BM_loop_normal_editdata_array_free(struct BMLoopNorEditDataArray 
*lnors_ed_arr);
 int BM_total_loop_select(BMesh *bm);
 
-bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr);
-
 
 void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle);
 
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index 9fc89ba7f42..79adba36302 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -5995,34 +5995,34 @@ void MESH_OT_mark_freestyle_face(wmOperatorType *ot)
 #endif
 
 /* Initialize loop normal data */
-static int init_point_normals(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
+static int point_normals_init(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
 {
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
        BMesh *bm = em->bm;
 
        BKE_editmesh_lnorspace_update(em);
-       BMLoopNorEditDataArray *ld = BM_loop_normal_editdata_init(bm);
+       BMLoopNorEditDataArray *lnors_ed_arr = 
BM_loop_normal_editdata_array_init(bm);
 
-       ld->funcdata = NULL;
-       op->customdata = ld;
+       lnors_ed_arr->funcdata = NULL;
+       op->customdata = lnors_ed_arr;
 
-       return ld->totloop;
+       return lnors_ed_arr->totloop;
 }
 
-static void apply_point_normals(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event), float target[3])
+static void point_normals_apply(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event), float target[3])
 {
        Object *obedit = CTX_data_edit_object(C);
        BMesh *bm = BKE_editmesh_from_object(obedit)->bm;
-       BMLoopNorEditDataArray *ld = op->customdata;
-       BMLoopNorEditData *tld = ld->lnor_editdata;
+       BMLoopNorEditDataArray *lnors_ed_arr = op->customdata;
 
-       const bool point_away = RNA_boolean_get(op->ptr, "point_away");
-       const bool spherize = RNA_boolean_get(op->ptr, "spherize");
-       const bool align = RNA_boolean_get(op->ptr, "align");
-       float zero[3] = { 0.0f }, center[3];
+       const bool do_point_away = RNA_boolean_get(op->ptr, "point_away");
+       const bool do_spherize = RNA_boolean_get(op->ptr, "spherize");
+       const bool do_align = RNA_boolean_get(op->ptr, "align");
+       const float null_vec[3] = { 0.0f };
+       float center[3];
 
-       if (align) {
+       if (do_align) {
                BMVert *v;
                BMIter viter;
                int i = 0;
@@ -6036,40 +6036,42 @@ static void apply_point_normals(bContext *C, wmOperator 
*op, const wmEvent *UNUS
                mul_v3_fl(center, 1.0f / (float)i);
        }
 
-       for (int i = 0; i < ld->totloop; i++, tld++) {
-               if (spherize) {
-                       float strength = RNA_float_get(op->ptr, "strength");
+       BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata;
+       for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
+               if (do_spherize) {
+                       const float strength = RNA_float_get(op->ptr, 
"strength");
                        float spherized_normal[3] = { 0.0f };
 
-                       sub_v3_v3v3(spherized_normal, target, tld->loc);
+                       sub_v3_v3v3(spherized_normal, target, lnor_ed->loc);
                        sub_v3_v3(spherized_normal, obedit->loc);
                        mul_v3_fl(spherized_normal, strength);
-                       mul_v3_fl(tld->nloc, 1.0f - strength);
-                       sub_v3_v3(tld->nloc, spherized_normal);
+                       mul_v3_fl(lnor_ed->nloc, 1.0f - strength);
+                       sub_v3_v3(lnor_ed->nloc, spherized_normal);
                }
-               else if (align) {
-                       sub_v3_v3v3(tld->nloc, target, center);
-                       sub_v3_v3(tld->nloc, obedit->loc);
+               else if (do_align) {
+                       sub_v3_v3v3(lnor_ed->nloc, target, center);
+                       sub_v3_v3(lnor_ed->nloc, obedit->loc);
                }
                else {
-                       sub_v3_v3v3(tld->nloc, target, tld->loc);
-                       sub_v3_v3(tld->nloc, obedit->loc);
+                       sub_v3_v3v3(lnor_ed->nloc, target, lnor_ed->loc);
+                       sub_v3_v3(lnor_ed->nloc, obedit->loc);
                }
 
-               if (point_away) {
-                       negate_v3(tld->nloc);
+               if (do_point_away) {
+                       negate_v3(lnor_ed->nloc);
                }
-               if (tld->loop_index != -1 && !compare_v3v3(tld->nloc, zero, 
1e-4f)) {
-                       normalize_v3(tld->nloc);
-                       
BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index],
 tld->nloc, tld->clnors_data);
+               if (lnor_ed->loop_index != -1 && !compare_v3v3(lnor_ed->nloc, 
null_vec, 1e-4f)) {
+                       normalize_v3(lnor_ed->nloc);
+                       BKE_lnor_space_custom_normal_to_data(
+                                   
bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, 
lnor_ed->clnors_data);
                }
        }
 }
 
 static void point_normals_free(bContext *C, wmOperator *op)
 {
-       BMLoopNorEditDataArray *ld = op->customdata;
-       BM_loop_normal_editdata_free(ld);
+       BMLoopNorEditDataArray *lnors_ed_arr = op->customdata;
+       BM_loop_normal_editdata_array_free(lnors_ed_arr);
        op->customdata = NULL;
        ED_area_headerprint(CTX_wm_area(C), NULL);
 }
@@ -6101,7 +6103,7 @@ static int point_normals_mouse(bContext *C, wmOperator 
*op, const wmEvent *event
 
        ED_view3d_win_to_3d_int(v3d, ar, center, event->mval, target);
 
-       apply_point_normals(C, op, event, target);
+       point_normals_apply(C, op, event, target);
        EDBM_update_generic(em, true, false);
 
        if (event->type == LEFTMOUSE) {
@@ -6110,11 +6112,14 @@ static int point_normals_mouse(bContext *C, wmOperator 
*op, const wmEvent *event
                return OPERATOR_FINI

@@ 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