[Bf-blender-cvs] [55e1ef2c232] refactor-mesh-corner-normals-lazy: More progress, reverting unnecessary changes

Hans Goudey noreply at git.blender.org
Wed Dec 14 16:42:22 CET 2022


Commit: 55e1ef2c232f0c1a19ee4b659004f61f80ff0b14
Author: Hans Goudey
Date:   Wed Dec 14 09:40:41 2022 -0600
Branches: refactor-mesh-corner-normals-lazy
https://developer.blender.org/rB55e1ef2c232f0c1a19ee4b659004f61f80ff0b14

More progress, reverting unnecessary changes

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

M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/intern/DerivedMesh.cc
M	source/blender/blenkernel/intern/data_transfer.cc
M	source/blender/blenkernel/intern/mesh.cc
M	source/blender/blenkernel/intern/mesh_normals.cc
M	source/blender/blenkernel/intern/mesh_wrapper.cc
M	source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh.hh
M	source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M	source/blender/modifiers/intern/MOD_displace.cc
M	source/blender/modifiers/intern/MOD_triangulate.cc
M	source/blender/render/intern/multires_bake.cc

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

diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 846250bd098..c75fac7452f 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -410,8 +410,6 @@ float (*BKE_mesh_vertex_normals_for_write(struct Mesh *mesh))[3];
  */
 float (*BKE_mesh_poly_normals_for_write(struct Mesh *mesh))[3];
 
-float (*BKE_mesh_corner_normals_for_write(struct Mesh *mesh))[3];
-
 /**
  * Mark the mesh's vertex normals non-dirty, for when they are calculated or assigned manually.
  */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index d13f30b1898..88cdbdce963 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -559,8 +559,6 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
        * which deals with drawing differently. */
       BKE_mesh_ensure_normals_for_display(mesh_final);
     }
-
-
   }
 }
 
diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc
index cc914599005..382736ae502 100644
--- a/source/blender/blenkernel/intern/data_transfer.cc
+++ b/source/blender/blenkernel/intern/data_transfer.cc
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2014 Blender Foundation. All rights reserved. */
 
 /** \file
  * \ingroup bke
@@ -269,18 +271,19 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
     const float split_angle_dst = me_dst->smoothresh;
 
     /* This should be ensured by cddata_masks we pass to code generating/giving us me_src now. */
-    BLI_assert(CustomData_get_layer(&me_src->ldata, CD_NORMAL) != NULL);
+    BLI_assert(CustomData_get_layer(&me_src->ldata, CD_NORMAL) != nullptr);
     (void)me_src;
 
     float(*loop_nors_dst)[3];
-    short(*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
+    short(*custom_nors_dst)[2] = static_cast<short(*)[2]>(
+        CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL));
 
     /* Cache loop nors into a temp CDLayer. */
-    loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
-    const bool do_loop_nors_dst = (loop_nors_dst == NULL);
+    loop_nors_dst = static_cast<float(*)[3]>(CustomData_get_layer(ldata_dst, CD_NORMAL));
+    const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
     if (do_loop_nors_dst) {
-      loop_nors_dst = CustomData_add_layer(
-          ldata_dst, CD_NORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
+      loop_nors_dst = static_cast<float(*)[3]>(
+          CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, nullptr, num_loops_dst));
       CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
     }
     if (dirty_nors_dst || do_loop_nors_dst) {
@@ -297,8 +300,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
                                   num_polys_dst,
                                   use_split_nors_dst,
                                   split_angle_dst,
-                                  NULL,
-                                  NULL,
+                                  nullptr,
+                                  nullptr,
                                   custom_nors_dst);
     }
   }
@@ -328,12 +331,14 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
     CustomData *ldata_dst = &me_dst->ldata;
 
     const float(*poly_nors_dst)[3] = BKE_mesh_poly_normals_ensure(me_dst);
-    float(*loop_nors_dst)[3] = CustomData_get_layer(ldata_dst, CD_NORMAL);
-    short(*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
+    float(*loop_nors_dst)[3] = static_cast<float(*)[3]>(
+        CustomData_get_layer(ldata_dst, CD_NORMAL));
+    short(*custom_nors_dst)[2] = static_cast<short(*)[2]>(
+        CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL));
 
     if (!custom_nors_dst) {
-      custom_nors_dst = CustomData_add_layer(
-          ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
+      custom_nors_dst = static_cast<short(*)[2]>(CustomData_add_layer(
+          ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, num_loops_dst));
     }
 
     /* Note loop_nors_dst contains our custom normals as transferred from source... */
@@ -362,7 +367,7 @@ static MeshRemapIslandsCalc data_transfer_get_loop_islands_generator(const int c
     default:
       break;
   }
-  return NULL;
+  return nullptr;
 }
 
 float data_transfer_interp_float_do(const int mix_mode,
@@ -420,9 +425,9 @@ void data_transfer_layersmapping_add_item(ListBase *r_map,
                                           cd_datatransfer_interp interp,
                                           void *interp_data)
 {
-  CustomDataTransferLayerMap *item = MEM_mallocN(sizeof(*item), __func__);
+  CustomDataTransferLayerMap *item = MEM_new<CustomDataTransferLayerMap>(__func__);
 
-  BLI_assert(data_dst != NULL);
+  BLI_assert(data_dst != nullptr);
 
   item->data_type = cddata_type;
   item->mix_mode = mix_mode;
@@ -485,7 +490,7 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map,
  * \note
  * All those layer mapping handlers return false *only* if they were given invalid parameters.
  * This means that even if they do nothing, they will return true if all given parameters were OK.
- * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers
+ * Also, r_map may be nullptr, in which case they will 'only' create/delete destination layers
  * according to given parameters.
  */
 static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map,
@@ -506,10 +511,10 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
                                                                  void *interp_data)
 {
   const void *data_src;
-  void *data_dst = NULL;
+  void *data_dst = nullptr;
   int idx_src = num_layers_src;
   int idx_dst, tot_dst = CustomData_number_of_layers(cd_dst, cddata_type);
-  bool *data_dst_to_delete = NULL;
+  bool *data_dst_to_delete = nullptr;
 
   if (!use_layers_src) {
     /* No source at all, we can only delete all dest if requested... */
@@ -536,7 +541,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
         if (use_create) {
           /* Create as much data layers as necessary! */
           for (; idx_dst < idx_src; idx_dst++) {
-            CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+            CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
           }
         }
         else {
@@ -579,9 +584,9 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
     case DT_LAYERS_NAME_DST:
       if (use_delete) {
         if (tot_dst) {
-          data_dst_to_delete = MEM_mallocN(sizeof(*data_dst_to_delete) * (size_t)tot_dst,
-                                           __func__);
-          memset(data_dst_to_delete, true, sizeof(*data_dst_to_delete) * (size_t)tot_dst);
+          data_dst_to_delete = static_cast<bool *>(
+              MEM_mallocN(sizeof(*data_dst_to_delete) * size_t(tot_dst), __func__));
+          memset(data_dst_to_delete, true, sizeof(*data_dst_to_delete) * size_t(tot_dst));
         }
       }
 
@@ -598,7 +603,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
         if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
           if (use_create) {
             CustomData_add_layer_named(
-                cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
+                cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
             idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
           }
           else {
@@ -671,7 +676,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
 {
   int idx_src, idx_dst;
   const void *data_src;
-  void *data_dst = NULL;
+  void *data_dst = nullptr;
 
   if (CustomData_layertype_is_singleton(cddata_type)) {
     if (!(data_src = CustomData_get_layer(cd_src, cddata_type))) {
@@ -686,7 +691,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
       if (!use_create) {
         return true;
       }
-      data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+      data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
     }
     else if (use_dupref_dst && r_map) {
       /* If dest is a evaluated mesh (from modifier),
@@ -739,7 +744,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
         if (!use_create) {
           return true;
         }
-        data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+        data_dst = CustomData_add_layer(
+            cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
       }
       else {
         /* If dest is a evaluated mesh (from modifier),
@@ -762,7 +768,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
         }
         /* Create as much data layers as necessary! */
         for (; num <= idx_dst; num++) {
-          CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+          CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
         }
       }
       /* If dest is a evaluated mesh (from modifier),
@@ -781,7 +787,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
         if (!use_create) {
           return true;
         }
-        CustomData_add_layer_named(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
+        CustomData_add_layer_named(
+            cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
         idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
       }
       /* If dest is a evaluated mesh (from modifier),
@@ -816,9 +823,9 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
   }
   else if (fromlayers == DT_LAYERS_ALL_SRC) {
     int 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list