[Bf-blender-cvs] [3e8a8184193] master: Cleanup: use const for 'clnors' argument where possible

Campbell Barton noreply at git.blender.org
Sun Apr 5 09:13:06 CEST 2020


Commit: 3e8a81841931f2cdbe8349a2c7ce0f6b3a486c79
Author: Campbell Barton
Date:   Sun Apr 5 17:12:10 2020 +1000
Branches: master
https://developer.blender.org/rB3e8a81841931f2cdbe8349a2c7ce0f6b3a486c79

Cleanup: use const for 'clnors' argument where possible

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

M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/bmesh/intern/bmesh_mesh.c

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

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 0b3650fd40a..17fd7b18bab 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1012,7 +1012,7 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops,
 static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
 {
   MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
-  short(*clnors_data)[2] = common_data->clnors_data;
+  const short(*clnors_data)[2] = common_data->clnors_data;
 
   const MVert *mverts = common_data->mverts;
   const MEdge *medges = common_data->medges;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 933223c3337..b65d563d441 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -676,7 +676,7 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
                                        const float (*fnos)[3],
                                        float (*r_lnos)[3],
                                        MLoopNorSpaceArray *r_lnors_spacearr,
-                                       short (*clnors_data)[2],
+                                       const short (*clnors_data)[2],
                                        const int cd_loop_clnors_offset,
                                        const bool do_rebuild)
 {
@@ -786,8 +786,9 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
           BKE_lnor_space_add_loop(r_lnors_spacearr, lnor_space, l_curr_index, l_curr, true);
 
           if (has_clnors) {
-            short(*clnor)[2] = clnors_data ? &clnors_data[l_curr_index] :
-                                             BM_ELEM_CD_GET_VOID_P(l_curr, cd_loop_clnors_offset);
+            const short(*clnor)[2] = clnors_data ? &clnors_data[l_curr_index] :
+                                                   (const void *)BM_ELEM_CD_GET_VOID_P(
+                                                       l_curr, cd_loop_clnors_offset);
             BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor, r_lnos[l_curr_index]);
           }
         }
@@ -820,7 +821,7 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
 
         /* We validate clnors data on the fly - cheapest way to do! */
         int clnors_avg[2] = {0, 0};
-        short(*clnor_ref)[2] = NULL;
+        const short(*clnor_ref)[2] = NULL;
         int clnors_nbr = 0;
         bool clnors_invalid = false;
 
@@ -886,9 +887,9 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
 
             if (has_clnors) {
               /* Accumulate all clnors, if they are not all equal we have to fix that! */
-              short(*clnor)[2] = clnors_data ?
-                                     &clnors_data[lfan_pivot_index] :
-                                     BM_ELEM_CD_GET_VOID_P(lfan_pivot, cd_loop_clnors_offset);
+              const short(*clnor)[2] = clnors_data ? &clnors_data[lfan_pivot_index] :
+                                                     (const void *)BM_ELEM_CD_GET_VOID_P(
+                                                         lfan_pivot, cd_loop_clnors_offset);
               if (clnors_nbr) {
                 clnors_invalid |= ((*clnor_ref)[0] != (*clnor)[0] ||
                                    (*clnor_ref)[1] != (*clnor)[1]);
@@ -1049,7 +1050,7 @@ void BM_mesh_loop_normals_update(BMesh *bm,
                                  const float split_angle,
                                  float (*r_lnos)[3],
                                  MLoopNorSpaceArray *r_lnors_spacearr,
-                                 short (*clnors_data)[2],
+                                 const short (*clnors_data)[2],
                                  const int cd_loop_clnors_offset)
 {
   const bool has_clnors = clnors_data || (cd_loop_clnors_offset != -1);



More information about the Bf-blender-cvs mailing list