[Bf-blender-cvs] [0ff485b6bac] master: Cleanup: Move modifier.c to C++

Hans Goudey noreply at git.blender.org
Thu Sep 29 23:58:24 CEST 2022


Commit: 0ff485b6bac274c26605da56995ad6a3a63dd8e5
Author: Hans Goudey
Date:   Thu Sep 29 16:43:09 2022 -0500
Branches: master
https://developer.blender.org/rB0ff485b6bac274c26605da56995ad6a3a63dd8e5

Cleanup: Move modifier.c to C++

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

M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/BKE_collision.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/cloth.c
R087	source/blender/blenkernel/intern/modifier.c	source/blender/blenkernel/intern/modifier.cc
M	source/blender/modifiers/MOD_modifiertypes.h

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

diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index f5ffd1190b1..2ef81b754cc 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -218,7 +218,7 @@ int cloth_bvh_collision(struct Depsgraph *depsgraph,
 /* -------------------------------------------------------------------- */
 /* cloth.c */
 
-/* Needed for modifier.c */
+/* Needed for modifier.cc */
 /** Frees all. */
 void cloth_free_modifier_extern(struct ClothModifierData *clmd);
 /** Frees all. */
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index 291d76df4c8..c390d0a8802 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -85,7 +85,7 @@ typedef struct FaceCollPair {
 /////////////////////////////////////////////////
 
 /////////////////////////////////////////////////
-// used in modifier.c from collision.c
+// used in modifier.cc from collision.c
 /////////////////////////////////////////////////
 
 struct BVHTree *bvhtree_build_from_mvert(const struct MVert *mvert,
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index ff6f279b9c6..40f86f9673f 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -214,7 +214,7 @@ set(SRC
   intern/mesh_tessellate.cc
   intern/mesh_validate.cc
   intern/mesh_wrapper.cc
-  intern/modifier.c
+  intern/modifier.cc
   intern/movieclip.c
   intern/multires.c
   intern/multires_reshape.c
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index e85e19f04c9..08c36177600 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -57,7 +57,7 @@ typedef struct BendSpringRef {
 
 /******************************************************************************
  *
- * External interface called by modifier.c clothModifier functions.
+ * External interface called by modifier.cc clothModifier functions.
  *
  ******************************************************************************/
 
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.cc
similarity index 87%
rename from source/blender/blenkernel/intern/modifier.c
rename to source/blender/blenkernel/intern/modifier.cc
index ba84b27bf31..7270f19a882 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.cc
@@ -10,12 +10,12 @@
 /* Allow using deprecated functionality for .blend file I/O. */
 #define DNA_DEPRECATED_ALLOW
 
-#include <float.h>
-#include <math.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cfloat>
+#include <cmath>
+#include <cstdarg>
+#include <cstddef>
+#include <cstdlib>
+#include <cstring>
 
 #include "MEM_guardedalloc.h"
 
@@ -73,7 +73,7 @@
 #include "CLG_log.h"
 
 static CLG_LogRef LOG = {"bke.modifier"};
-static ModifierTypeInfo *modifier_types[NUM_MODIFIER_TYPES] = {NULL};
+static ModifierTypeInfo *modifier_types[NUM_MODIFIER_TYPES] = {nullptr};
 static VirtualModifierData virtualModifierCommonData;
 
 void BKE_modifier_init(void)
@@ -113,7 +113,7 @@ const ModifierTypeInfo *BKE_modifier_get_info(ModifierType type)
     return modifier_types[type];
   }
 
-  return NULL;
+  return nullptr;
 }
 
 void BKE_modifier_type_panel_id(ModifierType type, char *r_idname)
@@ -131,10 +131,10 @@ void BKE_modifier_panel_expand(ModifierData *md)
 
 /***/
 
-static ModifierData *modifier_allocate_and_init(int type)
+static ModifierData *modifier_allocate_and_init(ModifierType type)
 {
   const ModifierTypeInfo *mti = BKE_modifier_get_info(type);
-  ModifierData *md = MEM_callocN(mti->structSize, mti->structName);
+  ModifierData *md = static_cast<ModifierData *>(MEM_callocN(mti->structSize, mti->structName));
 
   /* NOTE: this name must be made unique later. */
   BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
@@ -158,7 +158,7 @@ static ModifierData *modifier_allocate_and_init(int type)
 
 ModifierData *BKE_modifier_new(int type)
 {
-  ModifierData *md = modifier_allocate_and_init(type);
+  ModifierData *md = modifier_allocate_and_init(ModifierType(type));
 
   BKE_modifier_session_uuid_generate(md);
 
@@ -171,18 +171,18 @@ static void modifier_free_data_id_us_cb(void *UNUSED(userData),
                                         int cb_flag)
 {
   ID *id = *idpoin;
-  if (id != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
+  if (id != nullptr && (cb_flag & IDWALK_CB_USER) != 0) {
     id_us_min(id);
   }
 }
 
 void BKE_modifier_free_ex(ModifierData *md, const int flag)
 {
-  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+  const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
   if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
     if (mti->foreachIDLink) {
-      mti->foreachIDLink(md, NULL, modifier_free_data_id_us_cb, NULL);
+      mti->foreachIDLink(md, nullptr, modifier_free_data_id_us_cb, nullptr);
     }
   }
 
@@ -207,10 +207,10 @@ void BKE_modifier_remove_from_list(Object *ob, ModifierData *md)
 
   if (md->flag & eModifierFlag_Active) {
     /* Prefer the previous modifier but use the next if this modifier is the first in the list. */
-    if (md->next != NULL) {
+    if (md->next != nullptr) {
       BKE_object_modifier_set_active(ob, md->next);
     }
-    else if (md->prev != NULL) {
+    else if (md->prev != nullptr) {
       BKE_object_modifier_set_active(ob, md->prev);
     }
   }
@@ -226,7 +226,7 @@ void BKE_modifier_session_uuid_generate(ModifierData *md)
 bool BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
 {
   if (modifiers && md) {
-    const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+    const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
     return BLI_uniquename(
         modifiers, md, DATA_(mti->name), '.', offsetof(ModifierData, name), sizeof(md->name));
@@ -236,14 +236,14 @@ bool BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
 
 bool BKE_modifier_depends_ontime(Scene *scene, ModifierData *md)
 {
-  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+  const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
   return mti->dependsOnTime && mti->dependsOnTime(scene, md);
 }
 
 bool BKE_modifier_supports_mapping(ModifierData *md)
 {
-  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+  const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
   return (mti->type == eModifierTypeType_OnlyDeform ||
           (mti->flags & eModifierTypeFlag_SupportsMapping));
@@ -251,7 +251,7 @@ bool BKE_modifier_supports_mapping(ModifierData *md)
 
 bool BKE_modifier_is_preview(ModifierData *md)
 {
-  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+  const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
   /* Constructive modifiers are highly likely to also modify data like vgroups or vcol! */
   if (!((mti->flags & eModifierTypeFlag_UsesPreview) ||
@@ -273,12 +273,13 @@ ModifierData *BKE_modifiers_findby_type(const Object *ob, ModifierType type)
       return md;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 ModifierData *BKE_modifiers_findby_name(const Object *ob, const char *name)
 {
-  return BLI_findstring(&(ob->modifiers), name, offsetof(ModifierData, name));
+  return static_cast<ModifierData *>(
+      BLI_findstring(&(ob->modifiers), name, offsetof(ModifierData, name)));
 }
 
 ModifierData *BKE_modifiers_findby_session_uuid(const Object *ob, const SessionUUID *session_uuid)
@@ -288,7 +289,7 @@ ModifierData *BKE_modifiers_findby_session_uuid(const Object *ob, const SessionU
       return md;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void BKE_modifiers_clear_errors(Object *ob)
@@ -296,7 +297,7 @@ void BKE_modifiers_clear_errors(Object *ob)
   LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
     if (md->error) {
       MEM_freeN(md->error);
-      md->error = NULL;
+      md->error = nullptr;
     }
   }
 }
@@ -304,7 +305,7 @@ void BKE_modifiers_clear_errors(Object *ob)
 void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *userData)
 {
   LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
-    const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+    const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
     if (mti->foreachIDLink) {
       mti->foreachIDLink(md, ob, walk, userData);
@@ -315,7 +316,7 @@ void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *userData)
 void BKE_modifiers_foreach_tex_link(Object *ob, TexWalkFunc walk, void *userData)
 {
   LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
-    const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+    const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
 
     if (mti->foreachTexLink) {
       mti->foreachTexLink(md, ob, walk, userData);
@@ -325,7 +326,7 @@ void BKE_modifiers_foreach_tex_link(Object *ob, TexWalkFunc walk, void *userData
 
 ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag)
 {
-  ModifierData *md_dst = modifier_allocate_and_init(md->type);
+  ModifierData *md_dst = modifier_allocate_and_init(ModifierType(md->type));
 
   BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name));
   BKE_modifier_copydata_ex(md, md_dst, flag);
@@ -337,7 +338,7 @@ void BKE_modifier_copydata_generic(const ModifierData *md_src,
                                    ModifierData *md_dst,
                                    const int UNUSED(flag))
 {
-  const ModifierTypeInfo *mti = BKE_modifier_get_info(md_src->type);
+  const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md_src->type));
 
   /* md_dst may have already be fully initialized with some extra allocated data,
    * we need to free it now to avoid memleak. */
@@ -352,7 +353,7 @@ void BKE_modifier_copydata_generic(const ModifierData *md_src,
   memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
 
   /* Runtime fields are never to be pr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list