[Bf-blender-cvs] [406a98aff89] master: Cleanup: Move eight modifier files to C++

Hans Goudey noreply at git.blender.org
Thu Oct 6 23:08:40 CEST 2022


Commit: 406a98aff893570eef1f2d217b87a5997a7a60d6
Author: Hans Goudey
Date:   Thu Oct 6 16:05:56 2022 -0500
Branches: master
https://developer.blender.org/rB406a98aff893570eef1f2d217b87a5997a7a60d6

Cleanup: Move eight modifier files to C++

In preparation for moving mesh runtime data to C++.

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

M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
R088	source/blender/modifiers/intern/MOD_multires.c	source/blender/modifiers/intern/MOD_multires.cc
R089	source/blender/modifiers/intern/MOD_util.c	source/blender/modifiers/intern/MOD_util.cc
R087	source/blender/modifiers/intern/MOD_uvproject.c	source/blender/modifiers/intern/MOD_uvproject.cc
R086	source/blender/modifiers/intern/MOD_uvwarp.c	source/blender/modifiers/intern/MOD_uvwarp.cc
R081	source/blender/modifiers/intern/MOD_weighted_normal.c	source/blender/modifiers/intern/MOD_weighted_normal.cc
M	source/blender/modifiers/intern/MOD_weightvg_util.h
R088	source/blender/modifiers/intern/MOD_weightvgedit.c	source/blender/modifiers/intern/MOD_weightvgedit.cc
R087	source/blender/modifiers/intern/MOD_weightvgmix.c	source/blender/modifiers/intern/MOD_weightvgmix.cc
R085	source/blender/modifiers/intern/MOD_weightvgproximity.c	source/blender/modifiers/intern/MOD_weightvgproximity.cc

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

diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 90ae3c8093c..e3a88e61cbd 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -63,7 +63,7 @@ set(SRC
   intern/MOD_meshdeform.c
   intern/MOD_meshsequencecache.cc
   intern/MOD_mirror.c
-  intern/MOD_multires.c
+  intern/MOD_multires.cc
   intern/MOD_nodes.cc
   intern/MOD_none.c
   intern/MOD_normal_edit.cc
@@ -86,18 +86,18 @@ set(SRC
   intern/MOD_surfacedeform.c
   intern/MOD_triangulate.c
   intern/MOD_ui_common.c
-  intern/MOD_util.c
-  intern/MOD_uvproject.c
-  intern/MOD_uvwarp.c
+  intern/MOD_util.cc
+  intern/MOD_uvproject.cc
+  intern/MOD_uvwarp.cc
   intern/MOD_volume_displace.cc
   intern/MOD_volume_to_mesh.cc
   intern/MOD_warp.c
   intern/MOD_wave.cc
-  intern/MOD_weighted_normal.c
+  intern/MOD_weighted_normal.cc
   intern/MOD_weightvg_util.c
-  intern/MOD_weightvgedit.c
-  intern/MOD_weightvgmix.c
-  intern/MOD_weightvgproximity.c
+  intern/MOD_weightvgedit.cc
+  intern/MOD_weightvgmix.cc
+  intern/MOD_weightvgproximity.cc
   intern/MOD_weld.cc
   intern/MOD_wireframe.c
 
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 70d6cb9ff76..62b496017c4 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -76,7 +76,7 @@ extern ModifierTypeInfo modifierType_MeshToVolume;
 extern ModifierTypeInfo modifierType_VolumeDisplace;
 extern ModifierTypeInfo modifierType_VolumeToMesh;
 
-/* MOD_util.c */
+/* MOD_util.cc */
 
 /**
  * Only called by `BKE_modifier.h/modifier.cc`
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.cc
similarity index 88%
rename from source/blender/modifiers/intern/MOD_multires.c
rename to source/blender/modifiers/intern/MOD_multires.cc
index 87108836a90..6342ff384a4 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.cc
@@ -5,7 +5,7 @@
  * \ingroup modifiers
  */
 
-#include <stddef.h>
+#include <cstddef>
 
 #include "MEM_guardedalloc.h"
 
@@ -45,10 +45,10 @@
 #include "MOD_modifiertypes.h"
 #include "MOD_ui_common.h"
 
-typedef struct MultiresRuntimeData {
+struct MultiresRuntimeData {
   /* Cached subdivision surface descriptor, with topology and settings. */
   struct Subdiv *subdiv;
-} MultiresRuntimeData;
+};
 
 static void initData(ModifierData *md)
 {
@@ -87,11 +87,11 @@ static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int
 
 static void freeRuntimeData(void *runtime_data_v)
 {
-  if (runtime_data_v == NULL) {
+  if (runtime_data_v == nullptr) {
     return;
   }
   MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)runtime_data_v;
-  if (runtime_data->subdiv != NULL) {
+  if (runtime_data->subdiv != nullptr) {
     BKE_subdiv_free(runtime_data->subdiv);
   }
   MEM_freeN(runtime_data);
@@ -106,8 +106,9 @@ static void freeData(ModifierData *md)
 static MultiresRuntimeData *multires_ensure_runtime(MultiresModifierData *mmd)
 {
   MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)mmd->modifier.runtime;
-  if (runtime_data == NULL) {
-    runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+  if (runtime_data == nullptr) {
+    runtime_data = static_cast<MultiresRuntimeData *>(
+        MEM_callocN(sizeof(*runtime_data), __func__));
     mmd->modifier.runtime = runtime_data;
   }
   return runtime_data;
@@ -189,8 +190,8 @@ static Mesh *multires_as_ccg(MultiresModifierData *mmd,
   /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
    * this pointer. Not sure if it's needed, but might have a second look
    * on the ownership model here. */
-  MultiresRuntimeData *runtime_data = mmd->modifier.runtime;
-  runtime_data->subdiv = NULL;
+  MultiresRuntimeData *runtime_data = static_cast<MultiresRuntimeData *>(mmd->modifier.runtime);
+  runtime_data->subdiv = nullptr;
 
   return result;
 }
@@ -210,7 +211,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
   }
   MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
   Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
-  if (subdiv == NULL) {
+  if (subdiv == nullptr) {
     /* Happens on bad topology, ut also on empty input mesh. */
     return result;
   }
@@ -235,7 +236,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
      * stroke: i.e. when exiting blender right after stroke is done.
      * Annoying and not so much black-boxed as far as sculpting goes, and
      * surely there is a better way of solving this. */
-    if (ctx->object->sculpt != NULL) {
+    if (ctx->object->sculpt != nullptr) {
       SculptSession *sculpt_session = ctx->object->sculpt;
       sculpt_session->subdiv_ccg = result->runtime.subdiv_ccg;
       sculpt_session->multires.active = true;
@@ -243,9 +244,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
       sculpt_session->multires.level = mmd->sculptlvl;
       sculpt_session->totvert = mesh->totvert;
       sculpt_session->totpoly = mesh->totpoly;
-      sculpt_session->mvert = NULL;
-      sculpt_session->mpoly = NULL;
-      sculpt_session->mloop = NULL;
+      sculpt_session->mvert = nullptr;
+      sculpt_session->mpoly = nullptr;
+      sculpt_session->mloop = nullptr;
     }
     // BKE_subdiv_stats_print(&subdiv->stats);
   }
@@ -260,8 +261,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
     result = multires_as_mesh(mmd, ctx, mesh, subdiv);
 
     if (use_clnors) {
-      float(*lnors)[3] = CustomData_get_layer(&result->ldata, CD_NORMAL);
-      BLI_assert(lnors != NULL);
+      float(*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&result->ldata, CD_NORMAL));
+      BLI_assert(lnors != nullptr);
       BKE_mesh_set_custom_normals(result, lnors);
       CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
       CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
@@ -306,7 +307,7 @@ static void deformMatrices(ModifierData *md,
 
   MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
   Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
-  if (subdiv == NULL) {
+  if (subdiv == nullptr) {
     /* Happens on bad topology, ut also on empty input mesh. */
     return;
   }
@@ -322,7 +323,7 @@ static void panel_draw(const bContext *C, Panel *panel)
   uiLayout *col;
   uiLayout *layout = panel->layout;
 
-  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
 
   uiLayoutSetPropSep(layout, true);
 
@@ -337,7 +338,7 @@ static void panel_draw(const bContext *C, Panel *panel)
   uiItemR(col, ptr, "use_sculpt_base_mesh", 0, IFACE_("Sculpt Base Mesh"), ICON_NONE);
   UI_block_lock_clear(block);
 
-  uiItemR(layout, ptr, "show_only_control_edges", 0, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "show_only_control_edges", 0, nullptr, ICON_NONE);
 
   modifier_panel_end(layout, ptr);
 }
@@ -370,7 +371,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
               "OBJECT_OT_multires_subdivide",
               IFACE_("Subdivide"),
               ICON_NONE,
-              NULL,
+              nullptr,
               WM_OP_EXEC_DEFAULT,
               0,
               &op_ptr);
@@ -382,7 +383,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
               "OBJECT_OT_multires_subdivide",
               IFACE_("Simple"),
               ICON_NONE,
-              NULL,
+              nullptr,
               WM_OP_EXEC_DEFAULT,
               0,
               &op_ptr);
@@ -392,7 +393,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
               "OBJECT_OT_multires_subdivide",
               IFACE_("Linear"),
               ICON_NONE,
-              NULL,
+              nullptr,
               WM_OP_EXEC_DEFAULT,
               0,
               &op_ptr);
@@ -425,7 +426,7 @@ static void generate_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiLayout *col, *row;
   uiLayout *layout = panel->layout;
 
-  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
   MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
 
   bool is_external = RNA_boolean_get(ptr, "is_external");
@@ -441,7 +442,7 @@ static void generate_panel_draw(const bContext *UNUSED(C), Panel *panel)
     uiItemO(row, IFACE_("Pack External"), ICON_NONE, "OBJECT_OT_multires_external_pack");
     uiLayoutSetPropSep(col, true);
     row = uiLayoutRow(col, false);
-    uiItemR(row, ptr, "filepath", 0, NULL, ICON_NONE);
+    uiItemR(row, ptr, "filepath", 0, nullptr, ICON_NONE);
   }
   else {
     uiItemO(col, IFACE_("Save External..."), ICON_NONE, "OBJECT_OT_multires_external_save");
@@ -453,7 +454,7 @@ static void advanced_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiLayout *col;
   uiLayout *layout = panel->layout;
 
-  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
 
   bool has_displacement = RNA_int_get(ptr, "total_levels") != 0;
 
@@ -461,27 +462,27 @@ static void advanced_panel_draw(const bContext *UNUSED(C), Panel *panel)
 
   uiLayoutSetActive(layout, !has_displacement);
 
-  uiItemR(layout, ptr, "quality", 0, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "quality", 0, nullptr, ICON_NONE);
 
   col = uiLayoutColumn(layout, false);
   uiLayoutSetActive(col, true);
-  uiItemR(col, ptr, "uv_smooth", 0, NULL, ICON_NONE);
-  uiItemR(col, ptr, "boundary_smooth", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "uv_smooth", 0, nullptr, ICON_NONE);
+  uiItemR(col, ptr, "boundary_smooth", 0, nullptr, ICON_NONE);
 
-  uiItemR(layout, ptr, "use_creases", 0, NULL, ICON_NONE);
-  uiItemR(layout, ptr, "use_custom_normals", 0, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "use_creases", 0, nu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list