From 730b11034f8b0e96102c659ccaa312c963589a6f Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 4 May 2023 18:35:37 +0200 Subject: [PATCH] Cleanup: Move remaining modifier files to C++ See #103343 Pull Request: https://projects.blender.org/blender/blender/pulls/107626 --- .../blender/blenkernel/intern/mesh_mirror.cc | 2 +- source/blender/blenkernel/intern/modifier.cc | 2 +- source/blender/bmesh/tools/bmesh_wireframe.h | 8 ++ source/blender/modifiers/CMakeLists.txt | 64 ++++----- ...D_modifiertypes.h => MOD_modifiertypes.hh} | 8 -- .../{MOD_armature.c => MOD_armature.cc} | 72 +++++----- source/blender/modifiers/intern/MOD_array.cc | 4 +- .../intern/{MOD_bevel.c => MOD_bevel.cc} | 111 ++++++++------- .../blender/modifiers/intern/MOD_boolean.cc | 4 +- source/blender/modifiers/intern/MOD_build.cc | 4 +- .../intern/{MOD_cast.c => MOD_cast.cc} | 88 ++++++------ .../intern/{MOD_cloth.c => MOD_cloth.cc} | 78 ++++++----- .../{MOD_collision.c => MOD_collision.cc} | 82 +++++------ .../modifiers/intern/MOD_correctivesmooth.cc | 6 +- .../intern/{MOD_curve.c => MOD_curve.cc} | 54 ++++---- .../modifiers/intern/MOD_datatransfer.cc | 4 +- .../{MOD_decimate.c => MOD_decimate.cc} | 85 ++++++------ .../blender/modifiers/intern/MOD_displace.cc | 4 +- ...MOD_dynamicpaint.c => MOD_dynamicpaint.cc} | 52 +++---- .../{MOD_edgesplit.c => MOD_edgesplit.cc} | 70 +++++----- .../blender/modifiers/intern/MOD_explode.cc | 4 +- .../intern/{MOD_fluid.c => MOD_fluid.cc} | 50 +++---- .../intern/{MOD_hook.c => MOD_hook.cc} | 116 ++++++++-------- .../modifiers/intern/MOD_laplaciandeform.cc | 4 +- .../modifiers/intern/MOD_laplaciansmooth.cc | 4 +- .../intern/{MOD_lattice.c => MOD_lattice.cc} | 55 ++++---- source/blender/modifiers/intern/MOD_mask.cc | 4 +- .../modifiers/intern/MOD_mesh_to_volume.cc | 4 +- .../{MOD_meshcache.c => MOD_meshcache.cc} | 123 ++++++++--------- ...D_meshcache_mdd.c => MOD_meshcache_mdd.cc} | 22 +-- ...D_meshcache_pc2.c => MOD_meshcache_pc2.cc} | 18 +-- ...meshcache_util.c => MOD_meshcache_util.cc} | 4 +- ...meshcache_util.h => MOD_meshcache_util.hh} | 0 .../{MOD_meshdeform.c => MOD_meshdeform.cc} | 117 ++++++++-------- .../modifiers/intern/MOD_meshsequencecache.cc | 4 +- source/blender/modifiers/intern/MOD_mirror.cc | 4 +- .../blender/modifiers/intern/MOD_multires.cc | 4 +- source/blender/modifiers/intern/MOD_nodes.cc | 4 +- source/blender/modifiers/intern/MOD_none.c | 61 -------- source/blender/modifiers/intern/MOD_none.cc | 56 ++++++++ .../modifiers/intern/MOD_normal_edit.cc | 4 +- source/blender/modifiers/intern/MOD_ocean.cc | 4 +- .../modifiers/intern/MOD_particleinstance.cc | 4 +- .../modifiers/intern/MOD_particlesystem.cc | 4 +- source/blender/modifiers/intern/MOD_remesh.cc | 4 +- source/blender/modifiers/intern/MOD_screw.cc | 4 +- .../{MOD_shapekey.c => MOD_shapekey.cc} | 53 +++---- .../{MOD_shrinkwrap.c => MOD_shrinkwrap.cc} | 92 ++++++------- ...MOD_simpledeform.c => MOD_simpledeform.cc} | 130 +++++++++--------- source/blender/modifiers/intern/MOD_skin.cc | 4 +- source/blender/modifiers/intern/MOD_smooth.cc | 6 +- .../{MOD_softbody.c => MOD_softbody.cc} | 52 +++---- .../blender/modifiers/intern/MOD_solidify.cc | 4 +- .../modifiers/intern/MOD_solidify_extrude.cc | 4 +- .../intern/MOD_solidify_nonmanifold.cc | 4 +- .../blender/modifiers/intern/MOD_subsurf.cc | 4 +- .../intern/{MOD_surface.c => MOD_surface.cc} | 70 +++++----- .../modifiers/intern/MOD_surfacedeform.cc | 4 +- .../modifiers/intern/MOD_triangulate.cc | 4 +- .../{MOD_ui_common.c => MOD_ui_common.cc} | 36 ++--- .../blender/modifiers/intern/MOD_ui_common.h | 66 --------- .../blender/modifiers/intern/MOD_ui_common.hh | 56 ++++++++ source/blender/modifiers/intern/MOD_util.cc | 4 +- source/blender/modifiers/intern/MOD_util.h | 60 -------- source/blender/modifiers/intern/MOD_util.hh | 49 +++++++ .../blender/modifiers/intern/MOD_uvproject.cc | 4 +- source/blender/modifiers/intern/MOD_uvwarp.cc | 4 +- .../modifiers/intern/MOD_volume_displace.cc | 4 +- .../modifiers/intern/MOD_volume_to_mesh.cc | 4 +- .../intern/{MOD_warp.c => MOD_warp.cc} | 98 +++++++------ source/blender/modifiers/intern/MOD_wave.cc | 6 +- .../modifiers/intern/MOD_weighted_normal.cc | 6 +- ...D_weightvg_util.c => MOD_weightvg_util.cc} | 33 ++--- ...D_weightvg_util.h => MOD_weightvg_util.hh} | 24 +--- .../modifiers/intern/MOD_weightvgedit.cc | 8 +- .../modifiers/intern/MOD_weightvgmix.cc | 8 +- .../modifiers/intern/MOD_weightvgproximity.cc | 8 +- source/blender/modifiers/intern/MOD_weld.cc | 4 +- .../{MOD_wireframe.c => MOD_wireframe.cc} | 74 +++++----- 79 files changed, 1216 insertions(+), 1255 deletions(-) rename source/blender/modifiers/{MOD_modifiertypes.h => MOD_modifiertypes.hh} (97%) rename source/blender/modifiers/intern/{MOD_armature.c => MOD_armature.cc} (84%) rename source/blender/modifiers/intern/{MOD_bevel.c => MOD_bevel.cc} (80%) rename source/blender/modifiers/intern/{MOD_cast.c => MOD_cast.cc} (88%) rename source/blender/modifiers/intern/{MOD_cloth.c => MOD_cloth.cc} (81%) rename source/blender/modifiers/intern/{MOD_collision.c => MOD_collision.cc} (79%) rename source/blender/modifiers/intern/{MOD_curve.c => MOD_curve.cc} (85%) rename source/blender/modifiers/intern/{MOD_decimate.c => MOD_decimate.cc} (77%) rename source/blender/modifiers/intern/{MOD_dynamicpaint.c => MOD_dynamicpaint.cc} (83%) rename source/blender/modifiers/intern/{MOD_edgesplit.c => MOD_edgesplit.cc} (74%) rename source/blender/modifiers/intern/{MOD_fluid.c => MOD_fluid.cc} (89%) rename source/blender/modifiers/intern/{MOD_hook.c => MOD_hook.cc} (82%) rename source/blender/modifiers/intern/{MOD_lattice.c => MOD_lattice.cc} (81%) rename source/blender/modifiers/intern/{MOD_meshcache.c => MOD_meshcache.cc} (79%) rename source/blender/modifiers/intern/{MOD_meshcache_mdd.c => MOD_meshcache_mdd.cc} (94%) rename source/blender/modifiers/intern/{MOD_meshcache_pc2.c => MOD_meshcache_pc2.cc} (96%) rename source/blender/modifiers/intern/{MOD_meshcache_util.c => MOD_meshcache_util.cc} (95%) rename source/blender/modifiers/intern/{MOD_meshcache_util.h => MOD_meshcache_util.hh} (100%) rename source/blender/modifiers/intern/{MOD_meshdeform.c => MOD_meshdeform.cc} (85%) delete mode 100644 source/blender/modifiers/intern/MOD_none.c create mode 100644 source/blender/modifiers/intern/MOD_none.cc rename source/blender/modifiers/intern/{MOD_shapekey.c => MOD_shapekey.cc} (73%) rename source/blender/modifiers/intern/{MOD_shrinkwrap.c => MOD_shrinkwrap.cc} (78%) rename source/blender/modifiers/intern/{MOD_simpledeform.c => MOD_simpledeform.cc} (83%) rename source/blender/modifiers/intern/{MOD_softbody.c => MOD_softbody.cc} (73%) rename source/blender/modifiers/intern/{MOD_surface.c => MOD_surface.cc} (75%) rename source/blender/modifiers/intern/{MOD_ui_common.c => MOD_ui_common.cc} (95%) delete mode 100644 source/blender/modifiers/intern/MOD_ui_common.h create mode 100644 source/blender/modifiers/intern/MOD_ui_common.hh delete mode 100644 source/blender/modifiers/intern/MOD_util.h create mode 100644 source/blender/modifiers/intern/MOD_util.hh rename source/blender/modifiers/intern/{MOD_warp.c => MOD_warp.cc} (84%) rename source/blender/modifiers/intern/{MOD_weightvg_util.c => MOD_weightvg_util.cc} (93%) rename source/blender/modifiers/intern/{MOD_weightvg_util.h => MOD_weightvg_util.hh} (87%) rename source/blender/modifiers/intern/{MOD_wireframe.c => MOD_wireframe.cc} (72%) diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index dbcef51eb8d..6308a582767 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -24,7 +24,7 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mmd, const Mesh *mesh, diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index 8c94f6067d1..d5f3565744c 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -68,7 +68,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" #include "BLO_read_write.h" diff --git a/source/blender/bmesh/tools/bmesh_wireframe.h b/source/blender/bmesh/tools/bmesh_wireframe.h index a5f1da8b3e9..30324a87317 100644 --- a/source/blender/bmesh/tools/bmesh_wireframe.h +++ b/source/blender/bmesh/tools/bmesh_wireframe.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /** * \param defgrp_index: Vertex group index, -1 for no vertex groups. * @@ -29,3 +33,7 @@ void BM_mesh_wireframe(BMesh *bm, short mat_offset, short mat_max, bool use_tag); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 4358ebc2093..506e4ed6065 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -33,81 +33,81 @@ set(INC_SYS ) set(SRC - intern/MOD_armature.c + intern/MOD_armature.cc intern/MOD_array.cc - intern/MOD_bevel.c + intern/MOD_bevel.cc intern/MOD_boolean.cc intern/MOD_build.cc - intern/MOD_cast.c - intern/MOD_cloth.c - intern/MOD_collision.c + intern/MOD_cast.cc + intern/MOD_cloth.cc + intern/MOD_collision.cc intern/MOD_correctivesmooth.cc - intern/MOD_curve.c + intern/MOD_curve.cc intern/MOD_datatransfer.cc - intern/MOD_decimate.c + intern/MOD_decimate.cc intern/MOD_displace.cc - intern/MOD_dynamicpaint.c - intern/MOD_edgesplit.c + intern/MOD_dynamicpaint.cc + intern/MOD_edgesplit.cc intern/MOD_explode.cc - intern/MOD_fluid.c - intern/MOD_hook.c + intern/MOD_fluid.cc + intern/MOD_hook.cc intern/MOD_laplaciandeform.cc intern/MOD_laplaciansmooth.cc - intern/MOD_lattice.c + intern/MOD_lattice.cc intern/MOD_mask.cc intern/MOD_mesh_to_volume.cc - intern/MOD_meshcache.c - intern/MOD_meshcache_mdd.c - intern/MOD_meshcache_pc2.c - intern/MOD_meshcache_util.c - intern/MOD_meshdeform.c + intern/MOD_meshcache.cc + intern/MOD_meshcache_mdd.cc + intern/MOD_meshcache_pc2.cc + intern/MOD_meshcache_util.cc + intern/MOD_meshdeform.cc intern/MOD_meshsequencecache.cc intern/MOD_mirror.cc intern/MOD_multires.cc intern/MOD_nodes.cc - intern/MOD_none.c + intern/MOD_none.cc intern/MOD_normal_edit.cc intern/MOD_ocean.cc intern/MOD_particleinstance.cc intern/MOD_particlesystem.cc intern/MOD_remesh.cc intern/MOD_screw.cc - intern/MOD_shapekey.c - intern/MOD_shrinkwrap.c - intern/MOD_simpledeform.c + intern/MOD_shapekey.cc + intern/MOD_shrinkwrap.cc + intern/MOD_simpledeform.cc intern/MOD_skin.cc intern/MOD_smooth.cc - intern/MOD_softbody.c + intern/MOD_softbody.cc intern/MOD_solidify.cc intern/MOD_solidify_extrude.cc intern/MOD_solidify_nonmanifold.cc intern/MOD_subsurf.cc - intern/MOD_surface.c + intern/MOD_surface.cc intern/MOD_surfacedeform.cc intern/MOD_triangulate.cc - intern/MOD_ui_common.c + intern/MOD_ui_common.cc 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_warp.cc intern/MOD_wave.cc intern/MOD_weighted_normal.cc - intern/MOD_weightvg_util.c + intern/MOD_weightvg_util.cc intern/MOD_weightvgedit.cc intern/MOD_weightvgmix.cc intern/MOD_weightvgproximity.cc intern/MOD_weld.cc - intern/MOD_wireframe.c + intern/MOD_wireframe.cc - MOD_modifiertypes.h + MOD_modifiertypes.hh MOD_nodes.h - intern/MOD_meshcache_util.h + intern/MOD_meshcache_util.hh intern/MOD_solidify_util.hh - intern/MOD_ui_common.h - intern/MOD_util.h - intern/MOD_weightvg_util.h + intern/MOD_ui_common.hh + intern/MOD_util.hh + intern/MOD_weightvg_util.hh ) set(LIB diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.hh similarity index 97% rename from source/blender/modifiers/MOD_modifiertypes.h rename to source/blender/modifiers/MOD_modifiertypes.hh index 62b496017c4..6df6fd8586f 100644 --- a/source/blender/modifiers/MOD_modifiertypes.h +++ b/source/blender/modifiers/MOD_modifiertypes.hh @@ -8,10 +8,6 @@ #include "BKE_modifier.h" -#ifdef __cplusplus -extern "C" { -#endif - /* ****************** Type structures for all modifiers ****************** */ extern ModifierTypeInfo modifierType_None; @@ -82,7 +78,3 @@ extern ModifierTypeInfo modifierType_VolumeToMesh; * Only called by `BKE_modifier.h/modifier.cc` */ void modifier_type_init(ModifierTypeInfo *types[]); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.cc similarity index 84% rename from source/blender/modifiers/intern/MOD_armature.c rename to source/blender/modifiers/intern/MOD_armature.cc index c1feae20ffe..4b629d032da 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_listbase.h" #include "BLI_utildefines.h" @@ -42,8 +42,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -62,18 +62,16 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla ArmatureModifierData *tamd = (ArmatureModifierData *)target; BKE_modifier_copydata_generic(md, target, flag); - tamd->vert_coords_prev = NULL; + tamd->vert_coords_prev = nullptr; } -static void requiredDataMask(ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks) +static void requiredDataMask(ModifierData * /*md*/, CustomData_MeshMasks *r_cddata_masks) { /* ask for vertexgroups */ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT; } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { ArmatureModifierData *amd = (ArmatureModifierData *)md; @@ -95,10 +93,10 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - if (amd->object != NULL) { + if (amd->object != nullptr) { /* If not using envelopes, * create relations to individual bones for more rigging flexibility. */ - if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) && + if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != nullptr) && ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL_LEGACY)) { /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */ @@ -106,7 +104,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte /* Enumerate groups that match existing bones. */ const ListBase *defbase = BKE_object_defgroup_list(ctx->object); LISTBASE_FOREACH (bDeformGroup *, dg, defbase) { - if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != NULL) { + if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != nullptr) { /* Can't check BONE_NO_DEFORM because it can be animated. */ DEG_add_bone_relation( ctx->node, amd->object, dg->name, DEG_OB_COMP_BONE, "Armature Modifier"); @@ -137,7 +135,7 @@ static void deformVerts(ModifierData *md, BKE_armature_deform_coords_with_mesh(amd->object, ctx->object, vertexCos, - NULL, + nullptr, verts_num, amd->deformflag, amd->vert_coords_prev, @@ -150,12 +148,12 @@ static void deformVerts(ModifierData *md, static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *em, + BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], int verts_num) { - if (mesh != NULL) { + if (mesh != nullptr) { deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -167,7 +165,7 @@ static void deformVertsEM(ModifierData *md, BKE_armature_deform_coords_with_editmesh(amd->object, ctx->object, vertexCos, - NULL, + nullptr, verts_num, amd->deformflag, amd->vert_coords_prev, @@ -180,8 +178,8 @@ static void deformVertsEM(ModifierData *md, static void deformMatricesEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *em, - Mesh *UNUSED(mesh), + BMEditMesh *em, + Mesh * /*mesh*/, float (*vertexCos)[3], float (*defMats)[3][3], int verts_num) @@ -194,7 +192,7 @@ static void deformMatricesEM(ModifierData *md, defMats, verts_num, amd->deformflag, - NULL, + nullptr, amd->defgrp_name, em); } @@ -207,7 +205,7 @@ static void deformMatrices(ModifierData *md, int verts_num) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); BKE_armature_deform_coords_with_mesh(amd->object, ctx->object, @@ -215,16 +213,16 @@ static void deformMatrices(ModifierData *md, defMats, verts_num, amd->deformflag, - NULL, + nullptr, amd->defgrp_name, mesh_src); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; @@ -234,12 +232,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_deform_preserve_volume", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_multi_modifier", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_deform_preserve_volume", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "use_multi_modifier", 0, nullptr, ICON_NONE); col = uiLayoutColumnWithHeading(layout, true, IFACE_("Bind To")); uiItemR(col, ptr, "use_vertex_groups", 0, IFACE_("Vertex Groups"), ICON_NONE); @@ -253,11 +251,11 @@ static void panelRegister(ARegionType *region_type) modifier_panel_register(region_type, eModifierType_Armature, panel_draw); } -static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) +static void blendRead(BlendDataReader * /*reader*/, ModifierData *md) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - amd->vert_coords_prev = NULL; + amd->vert_coords_prev = nullptr; } ModifierTypeInfo modifierType_Armature = { @@ -276,20 +274,20 @@ ModifierTypeInfo modifierType_Armature = { /*deformMatrices*/ deformMatrices, /*deformVertsEM*/ deformVertsEM, /*deformMatricesEM*/ deformMatricesEM, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, + /*blendWrite*/ nullptr, /*blendRead*/ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index bac187b4f79..419b1ae1f88 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -42,8 +42,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.cc similarity index 80% rename from source/blender/modifiers/intern/MOD_bevel.c rename to source/blender/modifiers/intern/MOD_bevel.cc index 25bfc5f21d4..31202a9f915 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.cc @@ -34,8 +34,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "BLO_read_write.h" @@ -90,7 +90,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * BMVert *v; float weight, weight2; int vgroup = -1; - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; BevelModifierData *bmd = (BevelModifierData *)md; const float threshold = cosf(bmd->bevel_angle + 0.000000175f); const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK); @@ -108,20 +108,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * const float spread = bmd->spread; const bool invert_vgroup = (bmd->flags & MOD_BEVEL_INVERT_VGROUP) != 0; - bm = BKE_mesh_to_bmesh_ex(mesh, - &(struct BMeshCreateParams){0}, - &(struct BMeshFromMeshParams){ - .calc_face_normal = true, - .calc_vert_normal = true, - .add_key_index = false, - .use_shapekey = false, - .active_shapekey = 0, - /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead - * (also for other modifiers cases)? */ - .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, - .emask = CD_MASK_ORIGINDEX, - .pmask = CD_MASK_ORIGINDEX}, - }); + BMeshCreateParams create_params{}; + BMeshFromMeshParams convert_params{}; + convert_params.calc_face_normal = true; + convert_params.calc_vert_normal = true; + convert_params.add_key_index = false; + convert_params.use_shapekey = false; + convert_params.active_shapekey = 0; + convert_params.cd_mask_extra.vmask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.emask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.pmask = CD_MASK_ORIGINDEX; + + bm = BKE_mesh_to_bmesh_ex(mesh, &create_params, &convert_params); if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) { MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup); @@ -223,17 +221,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * bmd->custom_profile, bmd->vmesh_method); - result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); + result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh); /* Make sure we never alloc'd these. */ - BLI_assert(bm->vtoolflagpool == NULL && bm->etoolflagpool == NULL && bm->ftoolflagpool == NULL); + BLI_assert(bm->vtoolflagpool == nullptr && bm->etoolflagpool == nullptr && + bm->ftoolflagpool == nullptr); BM_mesh_free(bm); return result; } -static bool dependsOnNormals(ModifierData *UNUSED(md)) +static bool dependsOnNormals(ModifierData * /*md*/) { return true; } @@ -244,13 +243,13 @@ static void freeData(ModifierData *md) BKE_curveprofile_free(bmd->custom_profile); } -static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { BevelModifierData *bmd = (BevelModifierData *)md; return (bmd->value == 0.0f); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *col, *sub; uiLayout *layout = panel->layout; @@ -260,51 +259,51 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; - uiItemR(layout, ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "affect", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "offset_type", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "offset_type", 0, nullptr, ICON_NONE); if (RNA_enum_get(ptr, "offset_type") == BEVEL_AMT_PERCENT) { - uiItemR(col, ptr, "width_pct", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "width_pct", 0, nullptr, ICON_NONE); } else { uiItemR(col, ptr, "width", 0, IFACE_("Amount"), ICON_NONE); } - uiItemR(layout, ptr, "segments", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "segments", 0, nullptr, ICON_NONE); uiItemS(layout); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "limit_method", 0, nullptr, ICON_NONE); int limit_method = RNA_enum_get(ptr, "limit_method"); if (limit_method == MOD_BEVEL_ANGLE) { sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, edge_bevel); - uiItemR(col, ptr, "angle_limit", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "angle_limit", 0, nullptr, ICON_NONE); } else if (limit_method == MOD_BEVEL_VGROUP) { - modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); } modifier_panel_end(layout, ptr); } -static void profile_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void profile_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); int profile_type = RNA_enum_get(ptr, "profile_type"); int miter_inner = RNA_enum_get(ptr, "miter_inner"); int miter_outer = RNA_enum_get(ptr, "miter_outer"); bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; - uiItemR(layout, ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "profile_type", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -331,12 +330,12 @@ static void profile_panel_draw(const bContext *UNUSED(C), Panel *panel) } } -static void geometry_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void geometry_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; @@ -351,53 +350,53 @@ static void geometry_panel_draw(const bContext *UNUSED(C), Panel *panel) if (RNA_enum_get(ptr, "miter_inner") == BEVEL_MITER_ARC) { row = uiLayoutRow(layout, false); uiLayoutSetActive(row, edge_bevel); - uiItemR(row, ptr, "spread", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "spread", 0, nullptr, ICON_NONE); } uiItemS(layout); row = uiLayoutRow(layout, false); uiLayoutSetActive(row, edge_bevel); uiItemR(row, ptr, "vmesh_method", 0, IFACE_("Intersections"), ICON_NONE); - uiItemR(layout, ptr, "use_clamp_overlap", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_clamp_overlap", 0, nullptr, ICON_NONE); row = uiLayoutRow(layout, false); uiLayoutSetActive(row, edge_bevel); - uiItemR(row, ptr, "loop_slide", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "loop_slide", 0, nullptr, ICON_NONE); } -static void shading_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void shading_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); bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "harden_normals", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "harden_normals", 0, nullptr, ICON_NONE); col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark")); uiLayoutSetActive(col, edge_bevel); uiItemR(col, ptr, "mark_seam", 0, IFACE_("Seam"), ICON_NONE); uiItemR(col, ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE); - uiItemR(layout, ptr, "material", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "face_strength_mode", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "material", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "face_strength_mode", 0, nullptr, ICON_NONE); } static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Bevel, panel_draw); modifier_subpanel_register( - region_type, "profile", "Profile", NULL, profile_panel_draw, panel_type); + region_type, "profile", "Profile", nullptr, profile_panel_draw, panel_type); modifier_subpanel_register( - region_type, "geometry", "Geometry", NULL, geometry_panel_draw, panel_type); + region_type, "geometry", "Geometry", nullptr, geometry_panel_draw, panel_type); modifier_subpanel_register( - region_type, "shading", "Shading", NULL, shading_panel_draw, panel_type); + region_type, "shading", "Shading", nullptr, shading_panel_draw, panel_type); } -static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md) +static void blendWrite(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) { const BevelModifierData *bmd = (const BevelModifierData *)md; @@ -428,22 +427,22 @@ ModifierTypeInfo modifierType_Bevel = { eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_AcceptsCVs, /*icon*/ ICON_MOD_BEVEL, /*copyData*/ copyData, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, /*isDisabled*/ isDisabled, - /*updateDepsgraph*/ NULL, - /*dependsOnTime*/ NULL, + /*updateDepsgraph*/ nullptr, + /*dependsOnTime*/ nullptr, /*dependsOnNormals*/ dependsOnNormals, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*uiPanel*/ panelRegister, /*blendWrite*/ blendWrite, /*blendRead*/ blendRead, diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc index 083484b2a4d..f6b8e18bf89 100644 --- a/source/blender/modifiers/intern/MOD_boolean.cc +++ b/source/blender/modifiers/intern/MOD_boolean.cc @@ -43,8 +43,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "DEG_depsgraph_query.h" diff --git a/source/blender/modifiers/intern/MOD_build.cc b/source/blender/modifiers/intern/MOD_build.cc index 613fa786119..9a064ddc51b 100644 --- a/source/blender/modifiers/intern/MOD_build.cc +++ b/source/blender/modifiers/intern/MOD_build.cc @@ -36,8 +36,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static void initData(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.cc similarity index 88% rename from source/blender/modifiers/intern/MOD_cast.c rename to source/blender/modifiers/intern/MOD_cast.cc index 600f64556ae..042d4feb55a 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.cc @@ -36,8 +36,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -48,9 +48,7 @@ static void initData(ModifierData *md) MEMCPY_STRUCT_AFTER(cmd, DNA_struct_default_get(CastModifierData), modifier); } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { CastModifierData *cmd = (CastModifierData *)md; short flag; @@ -84,23 +82,23 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { CastModifierData *cmd = (CastModifierData *)md; - if (cmd->object != NULL) { + if (cmd->object != nullptr) { DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); DEG_add_depends_on_transform_relation(ctx->node, "Cast Modifier"); } } static void sphere_do(CastModifierData *cmd, - const ModifierEvalContext *UNUSED(ctx), + const ModifierEvalContext * /*ctx*/, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0; - Object *ctrl_ob = NULL; + Object *ctrl_ob = nullptr; int i, defgrp_index; bool has_radius = false; @@ -232,17 +230,17 @@ static void sphere_do(CastModifierData *cmd, } static void cuboid_do(CastModifierData *cmd, - const ModifierEvalContext *UNUSED(ctx), + const ModifierEvalContext * /*ctx*/, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; int defgrp_index; const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0; - Object *ctrl_ob = NULL; + Object *ctrl_ob = nullptr; int i; bool has_radius = false; @@ -463,11 +461,11 @@ static void deformVerts(ModifierData *md, int verts_num) { CastModifierData *cmd = (CastModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && cmd->defgrp_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } if (cmd->type == MOD_CAST_TYPE_CUBOID) { @@ -477,23 +475,23 @@ static void deformVerts(ModifierData *md, sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, + BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int verts_num) { CastModifierData *cmd = (CastModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (cmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); } if (mesh && BKE_mesh_wrapper_type(mesh) == ME_WRAPPER_TYPE_MDATA) { @@ -501,7 +499,7 @@ static void deformVertsEM(ModifierData *md, } /* TODO(@ideasman42): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } @@ -512,12 +510,12 @@ static void deformVertsEM(ModifierData *md, sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; @@ -530,23 +528,23 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "cast_type", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "cast_type", 0, nullptr, ICON_NONE); row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis")); - uiItemR(row, ptr, "use_x", toggles_flag, NULL, ICON_NONE); - uiItemR(row, ptr, "use_y", toggles_flag, NULL, ICON_NONE); - uiItemR(row, ptr, "use_z", toggles_flag, NULL, ICON_NONE); + uiItemR(row, ptr, "use_x", toggles_flag, nullptr, ICON_NONE); + uiItemR(row, ptr, "use_y", toggles_flag, nullptr, ICON_NONE); + uiItemR(row, ptr, "use_z", toggles_flag, nullptr, ICON_NONE); - uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "radius", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_radius_as_size", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "factor", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "radius", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "size", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "use_radius_as_size", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); - uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE); if (!RNA_pointer_is_null(&cast_object_ptr)) { - uiItemR(layout, ptr, "use_transform", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_transform", 0, nullptr, ICON_NONE); } modifier_panel_end(layout, ptr); @@ -570,23 +568,23 @@ ModifierTypeInfo modifierType_Cast = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.cc similarity index 81% rename from source/blender/modifiers/intern/MOD_cloth.c rename to source/blender/modifiers/intern/MOD_cloth.cc index 7fbe7b78141..1d76cd21026 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -45,8 +45,8 @@ #include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -66,7 +66,7 @@ static void initData(ModifierData *md) } if (!clmd->sim_parms->effector_weights) { - clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL); + clmd->sim_parms->effector_weights = BKE_effector_add_weights(nullptr); } if (clmd->point_cache) { @@ -93,13 +93,13 @@ static void deformVerts(ModifierData *md, } } - if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false); + if (mesh == nullptr) { + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, nullptr, nullptr, verts_num, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices * and get_mesh() would return 'mesh' directly. */ - mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); + mesh_src = (Mesh *)BKE_id_copy_ex(nullptr, (ID *)mesh, nullptr, LIB_ID_COPY_LOCALIZE); } /* TODO(sergey): For now it actually duplicates logic from DerivedMesh.cc @@ -108,16 +108,16 @@ static void deformVerts(ModifierData *md, * * Also hopefully new cloth system will arrive soon.. */ - if (mesh == NULL && clmd->sim_parms->shapekey_rest) { + if (mesh == nullptr && clmd->sim_parms->shapekey_rest) { KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ctx->object), clmd->sim_parms->shapekey_rest); - if (kb && kb->data != NULL) { + if (kb && kb->data != nullptr) { float(*layerorco)[3]; - if (!(layerorco = CustomData_get_layer_for_write( - &mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert))) + if (!(layerorco = static_cast(CustomData_get_layer_for_write( + &mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert)))) { - layerorco = CustomData_add_layer( - &mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, mesh_src->totvert); + layerorco = static_cast(CustomData_add_layer( + &mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, mesh_src->totvert)); } memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num); @@ -128,19 +128,19 @@ static void deformVerts(ModifierData *md, clothModifier_do(clmd, ctx->depsgraph, scene, ctx->object, mesh_src, vertexCos); - BKE_id_free(NULL, mesh_src); + BKE_id_free(nullptr, mesh_src); } static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { ClothModifierData *clmd = (ClothModifierData *)md; - if (clmd != NULL) { + if (clmd != nullptr) { if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) { DEG_add_collision_relations(ctx->node, ctx->object, clmd->coll_parms->group, eModifierType_Collision, - NULL, + nullptr, "Cloth Collision"); } DEG_add_forcefield_relations( @@ -188,20 +188,22 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla else { const int clmd_point_cache_index = BLI_findindex(&clmd->ptcaches, clmd->point_cache); BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches, flag); - tclmd->point_cache = BLI_findlink(&tclmd->ptcaches, clmd_point_cache_index); + tclmd->point_cache = static_cast( + BLI_findlink(&tclmd->ptcaches, clmd_point_cache_index)); } - tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); + tclmd->sim_parms = static_cast(MEM_dupallocN(clmd->sim_parms)); if (clmd->sim_parms->effector_weights) { - tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights); + tclmd->sim_parms->effector_weights = static_cast( + MEM_dupallocN(clmd->sim_parms->effector_weights)); } - tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->clothObject = NULL; - tclmd->hairdata = NULL; - tclmd->solver_result = NULL; + tclmd->coll_parms = static_cast(MEM_dupallocN(clmd->coll_parms)); + tclmd->clothObject = nullptr; + tclmd->hairdata = nullptr; + tclmd->solver_result = nullptr; } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime( Scene * /*scene*/, ModifierData * /*md*/) { return true; } @@ -233,7 +235,7 @@ static void freeData(ModifierData *md) else { BKE_ptcache_free_list(&clmd->ptcaches); } - clmd->point_cache = NULL; + clmd->point_cache = nullptr; if (clmd->hairdata) { MEM_freeN(clmd->hairdata); @@ -258,11 +260,11 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -287,23 +289,23 @@ ModifierTypeInfo modifierType_Cloth = { /*copyData*/ copyData, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, - /*isDisabled*/ NULL, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.cc similarity index 79% rename from source/blender/modifiers/intern/MOD_collision.c rename to source/blender/modifiers/intern/MOD_collision.cc index 9674200ad17..db7e5dcb9d4 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.cc @@ -38,9 +38,9 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "BLO_read_write.h" @@ -62,7 +62,7 @@ static void freeData(ModifierData *md) if (collmd) { /* Seriously? */ if (collmd->bvhtree) { BLI_bvhtree_free(collmd->bvhtree); - collmd->bvhtree = NULL; + collmd->bvhtree = nullptr; } MEM_SAFE_FREE(collmd->x); @@ -80,7 +80,7 @@ static void freeData(ModifierData *md) } } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime( Scene * /*scene*/, ModifierData * /*md*/) { return true; } @@ -105,13 +105,13 @@ static void deformVerts(ModifierData *md, return; } - if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, verts_num, false); + if (mesh == nullptr) { + mesh_src = MOD_deform_mesh_eval_get(ob, nullptr, nullptr, nullptr, verts_num, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices * and get_mesh() would return 'mesh' directly. */ - mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); + mesh_src = (Mesh *)BKE_id_copy_ex(nullptr, (ID *)mesh, nullptr, LIB_ID_COPY_LOCALIZE); } if (mesh_src) { @@ -144,24 +144,26 @@ static void deformVerts(ModifierData *md, if (collmd->time_xnew == -1000) { /* first time */ - collmd->x = MEM_dupallocN(BKE_mesh_vert_positions(mesh_src)); /* frame start position */ + collmd->x = static_cast( + MEM_dupallocN(BKE_mesh_vert_positions(mesh_src))); /* frame start position */ for (uint i = 0; i < mvert_num; i++) { /* we save global positions */ mul_m4_v3(ob->object_to_world, collmd->x[i]); } - collmd->xnew = MEM_dupallocN(collmd->x); /* Frame end position. */ - collmd->current_x = MEM_dupallocN(collmd->x); /* Inter-frame. */ - collmd->current_xnew = MEM_dupallocN(collmd->x); /* Inter-frame. */ - collmd->current_v = MEM_dupallocN(collmd->x); /* Inter-frame. */ + collmd->xnew = static_cast(MEM_dupallocN(collmd->x)); /* Frame end position. */ + collmd->current_x = static_cast(MEM_dupallocN(collmd->x)); /* Inter-frame. */ + collmd->current_xnew = static_cast(MEM_dupallocN(collmd->x)); /* Inter-frame. */ + collmd->current_v = static_cast(MEM_dupallocN(collmd->x)); /* Inter-frame. */ collmd->mvert_num = mvert_num; { const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh_src); collmd->tri_num = BKE_mesh_runtime_looptri_len(mesh_src); - MVertTri *tri = MEM_mallocN(sizeof(*tri) * collmd->tri_num, __func__); + MVertTri *tri = static_cast( + MEM_mallocN(sizeof(*tri) * collmd->tri_num, __func__)); BKE_mesh_runtime_verttri_from_looptri( tri, BKE_mesh_corner_verts(mesh_src), looptri, collmd->tri_num); collmd->tri = tri; @@ -228,21 +230,21 @@ static void deformVerts(ModifierData *md, } } - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx) +static void updateDepsgraph(ModifierData * /*md*/, const ModifierUpdateDepsgraphContext *ctx) { DEG_add_depends_on_transform_relation(ctx->node, "Collision Modifier"); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -254,7 +256,7 @@ static void panelRegister(ARegionType *region_type) modifier_panel_register(region_type, eModifierType_Collision, panel_draw); } -static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) +static void blendRead(BlendDataReader * /*reader*/, ModifierData *md) { CollisionModifierData *collmd = (CollisionModifierData *)md; #if 0 @@ -269,17 +271,17 @@ static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) collmd->current_v = MEM_calloc_arrayN(collmd->mvert_num, sizeof(float[3]), "current_v"); #endif - collmd->x = NULL; - collmd->xnew = NULL; - collmd->current_x = NULL; - collmd->current_xnew = NULL; - collmd->current_v = NULL; + collmd->x = nullptr; + collmd->xnew = nullptr; + collmd->current_x = nullptr; + collmd->current_xnew = nullptr; + collmd->current_v = nullptr; collmd->time_x = collmd->time_xnew = -1000; collmd->mvert_num = 0; collmd->tri_num = 0; collmd->is_static = false; - collmd->bvhtree = NULL; - collmd->tri = NULL; + collmd->bvhtree = nullptr; + collmd->tri = nullptr; } ModifierTypeInfo modifierType_Collision = { @@ -291,26 +293,26 @@ ModifierTypeInfo modifierType_Collision = { /*flags*/ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_Single, /*icon*/ ICON_MOD_PHYSICS, - /*copyData*/ NULL, + /*copyData*/ nullptr, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, - /*requiredDataMask*/ NULL, + /*requiredDataMask*/ nullptr, /*freeData*/ freeData, - /*isDisabled*/ NULL, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, + /*blendWrite*/ nullptr, /*blendRead*/ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.cc b/source/blender/modifiers/intern/MOD_correctivesmooth.cc index 24aa50ee5c9..dfaf75521c6 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.cc +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.cc @@ -36,9 +36,9 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "BLO_read_write.h" diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.cc similarity index 85% rename from source/blender/modifiers/intern/MOD_curve.c rename to source/blender/modifiers/intern/MOD_curve.cc index 111191e0bae..a57b5d8ca10 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -38,9 +38,9 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -61,7 +61,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma } } -static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { CurveModifierData *cmd = (CurveModifierData *)md; @@ -83,7 +83,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { CurveModifierData *cmd = (CurveModifierData *)md; - if (cmd->object != NULL) { + if (cmd->object != nullptr) { /* TODO(sergey): Need to do the same eval_flags trick for path * as happening in legacy depsgraph callback. */ @@ -105,14 +105,14 @@ static void deformVerts(ModifierData *md, int verts_num) { CurveModifierData *cmd = (CurveModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && cmd->name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; int defgrp_index = -1; MOD_get_vgroup(ctx->object, mesh_src, cmd->name, &dvert, &defgrp_index); @@ -128,8 +128,8 @@ static void deformVerts(ModifierData *md, cmd->flag, cmd->defaxis - 1); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } @@ -140,7 +140,7 @@ static void deformVertsEM(ModifierData *md, float (*vertexCos)[3], int verts_num) { - if (mesh != NULL) { + if (mesh != nullptr) { deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -171,14 +171,14 @@ static void deformVertsEM(ModifierData *md, ctx->object, vertexCos, verts_num, - NULL, + nullptr, defgrp_index, cmd->flag, cmd->defaxis - 1); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; @@ -188,9 +188,9 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); uiItemR(layout, ptr, "object", 0, IFACE_("Curve Object"), ICON_NONE); - uiItemR(layout, ptr, "deform_axis", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "deform_axis", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); modifier_panel_end(layout, ptr); } @@ -213,23 +213,23 @@ ModifierTypeInfo modifierType_Curve = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.cc b/source/blender/modifiers/intern/MOD_datatransfer.cc index 96b79b56d18..d96b9b7d6ba 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.cc +++ b/source/blender/modifiers/intern/MOD_datatransfer.cc @@ -39,8 +39,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" /************************************** * Modifiers functions. * diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.cc similarity index 77% rename from source/blender/modifiers/intern/MOD_decimate.c rename to source/blender/modifiers/intern/MOD_decimate.cc index 338fc803d94..b2ad6ed55b4 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.cc @@ -42,8 +42,8 @@ # include "PIL_time_utildefines.h" #endif -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -87,11 +87,11 @@ static void updateFaceCount(const ModifierEvalContext *ctx, static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData) { DecimateModifierData *dmd = (DecimateModifierData *)md; - Mesh *mesh = meshData, *result = NULL; + Mesh *mesh = meshData, *result = nullptr; BMesh *bm; bool calc_vert_normal; bool calc_face_normal; - float *vweights = NULL; + float *vweights = nullptr; #ifdef USE_TIMEIT TIMEIT_START(decim); @@ -142,7 +142,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * const uint vert_tot = mesh->totvert; uint i; - vweights = MEM_malloc_arrayN(vert_tot, sizeof(float), __func__); + vweights = static_cast(MEM_malloc_arrayN(vert_tot, sizeof(float), __func__)); if (dmd->flag & MOD_DECIM_FLAG_INVERT_VGROUP) { for (i = 0; i < vert_tot; i++) { @@ -158,15 +158,15 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } } - bm = BKE_mesh_to_bmesh_ex(mesh, - &(struct BMeshCreateParams){0}, - &(struct BMeshFromMeshParams){ - .calc_face_normal = calc_face_normal, - .calc_vert_normal = calc_vert_normal, - .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, - .emask = CD_MASK_ORIGINDEX, - .pmask = CD_MASK_ORIGINDEX}, - }); + BMeshCreateParams create_params{}; + BMeshFromMeshParams convert_params{}; + convert_params.calc_face_normal = calc_face_normal; + convert_params.calc_vert_normal = calc_vert_normal; + convert_params.cd_mask_extra.vmask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.emask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.pmask = CD_MASK_ORIGINDEX; + + bm = BKE_mesh_to_bmesh_ex(mesh, &create_params, &convert_params); switch (dmd->mode) { case MOD_DECIM_MODE_COLLAPSE: { @@ -200,9 +200,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * updateFaceCount(ctx, dmd, bm->totface); /* make sure we never alloc'd these */ - BLI_assert(bm->vtoolflagpool == NULL && bm->etoolflagpool == NULL && bm->ftoolflagpool == NULL); + BLI_assert(bm->vtoolflagpool == nullptr && bm->etoolflagpool == nullptr && + bm->ftoolflagpool == nullptr); - result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); + result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh); BM_mesh_free(bm); @@ -213,7 +214,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * return result; } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *sub, *row; uiLayout *layout = panel->layout; @@ -225,12 +226,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) char count_info[64]; snprintf(count_info, 32, TIP_("Face Count: %d"), RNA_int_get(ptr, "face_count")); - uiItemR(layout, ptr, "decimate_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "decimate_type", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); if (decimate_type == MOD_DECIM_MODE_COLLAPSE) { - uiItemR(layout, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "ratio", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); row = uiLayoutRowWithHeading(layout, true, IFACE_("Symmetry")); uiLayoutSetPropDecorate(row, false); @@ -238,25 +239,25 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(sub, ptr, "use_symmetry", 0, "", ICON_NONE); sub = uiLayoutRow(sub, true); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_symmetry")); - uiItemR(sub, ptr, "symmetry_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(sub, ptr, "symmetry_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemDecoratorR(row, ptr, "symmetry_axis", 0); - uiItemR(layout, ptr, "use_collapse_triangulate", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_collapse_triangulate", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); sub = uiLayoutRow(layout, true); bool has_vertex_group = RNA_string_length(ptr, "vertex_group") != 0; uiLayoutSetActive(sub, has_vertex_group); - uiItemR(sub, ptr, "vertex_group_factor", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "vertex_group_factor", 0, nullptr, ICON_NONE); } else if (decimate_type == MOD_DECIM_MODE_UNSUBDIV) { - uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "iterations", 0, nullptr, ICON_NONE); } else { /* decimate_type == MOD_DECIM_MODE_DISSOLVE. */ - uiItemR(layout, ptr, "angle_limit", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "angle_limit", 0, nullptr, ICON_NONE); uiLayout *col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "delimit", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_dissolve_boundaries", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "delimit", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "use_dissolve_boundaries", 0, nullptr, ICON_NONE); } uiItemL(layout, count_info, ICON_NONE); @@ -279,24 +280,24 @@ ModifierTypeInfo modifierType_Decimate = { /*copyData*/ BKE_modifier_copydata_generic, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, - /*isDisabled*/ NULL, - /*updateDepsgraph*/ NULL, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, + /*updateDepsgraph*/ nullptr, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_displace.cc b/source/blender/modifiers/intern/MOD_displace.cc index 497a917194f..5448d551c56 100644 --- a/source/blender/modifiers/intern/MOD_displace.cc +++ b/source/blender/modifiers/intern/MOD_displace.cc @@ -43,8 +43,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "RE_texture.h" diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.cc similarity index 83% rename from source/blender/modifiers/intern/MOD_dynamicpaint.c rename to source/blender/modifiers/intern/MOD_dynamicpaint.cc index 0bbb08fdba9..b5829480761 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.cc @@ -4,8 +4,8 @@ * \ingroup modifiers */ -#include -#include +#include +#include #include "BLI_listbase.h" #include "BLI_utildefines.h" @@ -39,8 +39,8 @@ #include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static void initData(ModifierData *md) { @@ -61,7 +61,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla static void freeRuntimeData(void *runtime_data_v) { - if (runtime_data_v == NULL) { + if (runtime_data_v == nullptr) { return; } DynamicPaintRuntime *runtime_data = (DynamicPaintRuntime *)runtime_data_v; @@ -79,7 +79,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; if (pmd->canvas) { - DynamicPaintSurface *surface = pmd->canvas->surfaces.first; + DynamicPaintSurface *surface = static_cast(pmd->canvas->surfaces.first); for (; surface; surface = surface->next) { /* UVs: #CD_PROP_FLOAT2. */ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ || @@ -113,17 +113,17 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * return mesh; } -static bool is_brush_cb(Object *UNUSED(ob), ModifierData *md) +static bool is_brush_cb(Object * /*ob*/, ModifierData *md) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - return (pmd->brush != NULL && pmd->type == MOD_DYNAMICPAINT_TYPE_BRUSH); + return (pmd->brush != nullptr && pmd->type == MOD_DYNAMICPAINT_TYPE_BRUSH); } static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; /* Add relation from canvases to all brush objects. */ - if (pmd->canvas != NULL && pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) { + if (pmd->canvas != nullptr && pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) { LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) { if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { DEG_add_forcefield_relations( @@ -142,7 +142,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*md*/) { return true; } @@ -152,7 +152,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; if (pmd->canvas) { - DynamicPaintSurface *surface = pmd->canvas->surfaces.first; + DynamicPaintSurface *surface = static_cast(pmd->canvas->surfaces.first); for (; surface; surface = surface->next) { walk(userData, ob, (ID **)&surface->brush_group, IDWALK_CB_NOP); @@ -164,19 +164,19 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u } } -static void foreachTexLink(ModifierData *UNUSED(md), - Object *UNUSED(ob), - TexWalkFunc UNUSED(walk), - void *UNUSED(userData)) +static void foreachTexLink(ModifierData * /*md*/, + Object * /*ob*/, + TexWalkFunc /*walk*/, + void * /*userData*/) { // walk(userData, ob, md, ""); /* re-enable when possible */ } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -201,24 +201,24 @@ ModifierTypeInfo modifierType_DynamicPaint = { /*copyData*/ copyData, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, - /*isDisabled*/ NULL, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, /*foreachTexLink*/ foreachTexLink, /*freeRuntimeData*/ freeRuntimeData, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.cc similarity index 74% rename from source/blender/modifiers/intern/MOD_edgesplit.c rename to source/blender/modifiers/intern/MOD_edgesplit.cc index 45f7e568e13..4c00f5b86f7 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.cc @@ -35,8 +35,8 @@ #include "bmesh.h" #include "bmesh_tools.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" /* For edge split modifier node. */ Mesh *doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd); @@ -49,22 +49,22 @@ Mesh *doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd) BMEdge *e; const float threshold = cosf(emd->split_angle + 0.000000175f); const bool do_split_angle = (emd->flags & MOD_EDGESPLIT_FROMANGLE) != 0 && - emd->split_angle < (float)M_PI; + emd->split_angle < float(M_PI); const bool do_split_all = do_split_angle && emd->split_angle < FLT_EPSILON; const bool calc_face_normals = do_split_angle && !do_split_all; - bm = BKE_mesh_to_bmesh_ex(mesh, - &(struct BMeshCreateParams){0}, - &(struct BMeshFromMeshParams){ - .calc_face_normal = calc_face_normals, - .calc_vert_normal = false, - .add_key_index = false, - .use_shapekey = false, - .active_shapekey = 0, - .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, - .emask = CD_MASK_ORIGINDEX, - .pmask = CD_MASK_ORIGINDEX}, - }); + BMeshCreateParams create_params{}; + BMeshFromMeshParams convert_params{}; + convert_params.calc_face_normal = calc_face_normals; + convert_params.calc_vert_normal = false; + convert_params.add_key_index = false; + convert_params.use_shapekey = false; + convert_params.active_shapekey = 0; + convert_params.cd_mask_extra.vmask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.emask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.pmask = CD_MASK_ORIGINDEX; + + bm = BKE_mesh_to_bmesh_ex(mesh, &create_params, &convert_params); if (do_split_angle) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -100,7 +100,7 @@ Mesh *doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd) /* Uncomment for troubleshooting. */ // BM_mesh_validate(bm); - result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); + result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh); BM_mesh_free(bm); return result; @@ -115,7 +115,7 @@ static void initData(ModifierData *md) MEMCPY_STRUCT_AFTER(emd, DNA_struct_default_get(EdgeSplitModifierData), modifier); } -static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh) +static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, Mesh *mesh) { Mesh *result; EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md; @@ -129,12 +129,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx) return result; } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row, *sub; 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); @@ -167,24 +167,24 @@ ModifierTypeInfo modifierType_EdgeSplit = { /*copyData*/ BKE_modifier_copydata_generic, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, - /*requiredDataMask*/ NULL, - /*freeData*/ NULL, - /*isDisabled*/ NULL, - /*updateDepsgraph*/ NULL, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*requiredDataMask*/ nullptr, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, + /*updateDepsgraph*/ nullptr, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_explode.cc b/source/blender/modifiers/intern/MOD_explode.cc index cd6ea92bc39..02320582465 100644 --- a/source/blender/modifiers/intern/MOD_explode.cc +++ b/source/blender/modifiers/intern/MOD_explode.cc @@ -46,8 +46,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static void initData(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_fluid.c b/source/blender/modifiers/intern/MOD_fluid.cc similarity index 89% rename from source/blender/modifiers/intern/MOD_fluid.c rename to source/blender/modifiers/intern/MOD_fluid.cc index bdb6071142f..645503f136f 100644 --- a/source/blender/modifiers/intern/MOD_fluid.c +++ b/source/blender/modifiers/intern/MOD_fluid.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "MEM_guardedalloc.h" @@ -40,16 +40,16 @@ #include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static void initData(ModifierData *md) { FluidModifierData *fmd = (FluidModifierData *)md; - fmd->domain = NULL; - fmd->flow = NULL; - fmd->effector = NULL; + fmd->domain = nullptr; + fmd->flow = nullptr; + fmd->effector = nullptr; fmd->type = 0; fmd->time = -1; } @@ -96,14 +96,14 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma } } -typedef struct FluidIsolationData { +struct FluidIsolationData { Depsgraph *depsgraph; Object *object; Mesh *mesh; FluidModifierData *fmd; Mesh *result; -} FluidIsolationData; +}; #ifdef WITH_FLUID static void fluid_modifier_do_isolated(void *userdata) @@ -149,18 +149,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #endif /* WITH_FLUID */ } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*md*/) { return true; } -static bool is_flow_cb(Object *UNUSED(ob), ModifierData *md) +static bool is_flow_cb(Object * /*ob*/, ModifierData *md) { FluidModifierData *fmd = (FluidModifierData *)md; return (fmd->type & MOD_FLUID_TYPE_FLOW) && fmd->flow; } -static bool is_coll_cb(Object *UNUSED(ob), ModifierData *md) +static bool is_coll_cb(Object * /*ob*/, ModifierData *md) { FluidModifierData *fmd = (FluidModifierData *)md; return (fmd->type & MOD_FLUID_TYPE_EFFEC) && fmd->effector; @@ -190,7 +190,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte PFIELD_FLUIDFLOW, "Fluid Force Field"); - if (fmd->domain->guide_parent != NULL) { + if (fmd->domain->guide_parent != nullptr) { DEG_add_object_relation( ctx->node, fmd->domain->guide_parent, DEG_OB_COMP_TRANSFORM, "Fluid Guiding Object"); DEG_add_object_relation( @@ -222,11 +222,11 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -249,24 +249,24 @@ ModifierTypeInfo modifierType_Fluid = { /*copyData*/ copyData, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, - /*isDisabled*/ NULL, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.cc similarity index 82% rename from source/blender/modifiers/intern/MOD_hook.c rename to source/blender/modifiers/intern/MOD_hook.cc index 723be5a6165..457cc311a42 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.cc @@ -42,8 +42,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -65,7 +65,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla thmd->curfalloff = BKE_curvemapping_copy(hmd->curfalloff); - thmd->indexar = MEM_dupallocN(hmd->indexar); + thmd->indexar = static_cast(MEM_dupallocN(hmd->indexar)); } static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks) @@ -76,7 +76,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma if (hmd->name[0] != '\0') { r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT; } - if (hmd->indexar != NULL) { + if (hmd->indexar != nullptr) { /* TODO: check which origindex are actually needed? */ r_cddata_masks->vmask |= CD_MASK_ORIGINDEX; r_cddata_masks->emask |= CD_MASK_ORIGINDEX; @@ -93,9 +93,7 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(hmd->indexar); } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { HookModifierData *hmd = (HookModifierData *)md; @@ -112,7 +110,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { HookModifierData *hmd = (HookModifierData *)md; - if (hmd->object != NULL) { + if (hmd->object != nullptr) { if (hmd->subtarget[0]) { DEG_add_bone_relation( ctx->node, hmd->object, hmd->subtarget, DEG_OB_COMP_BONE, "Hook Modifier"); @@ -128,11 +126,11 @@ struct HookData_cb { /** * When anything other than -1, use deform groups. - * This is not the same as checking `dvert` for NULL when we have edit-meshes. + * This is not the same as checking `dvert` for nullptr when we have edit-meshes. */ int defgrp_index; - struct CurveMapping *curfalloff; + CurveMapping *curfalloff; char falloff_type; float falloff; @@ -164,7 +162,7 @@ static BLI_bitmap *hook_index_array_to_bitmap(HookModifierData *hmd, const int v return indexar_used; } -static float hook_falloff(const struct HookData_cb *hd, const float len_sq) +static float hook_falloff(const HookData_cb *hd, const float len_sq) { BLI_assert(hd->falloff_sq); if (len_sq > hd->falloff_sq) { @@ -230,7 +228,7 @@ static float hook_falloff(const struct HookData_cb *hd, const float len_sq) } } -static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv) +static void hook_co_apply(HookData_cb *hd, int j, const MDeformVert *dv) { float *co = hd->vertexCos[j]; float fac; @@ -254,7 +252,7 @@ static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv) } if (fac) { - if (dv != NULL) { + if (dv != nullptr) { fac *= hd->invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, hd->defgrp_index) : BKE_defvert_find_weight(dv, hd->defgrp_index); } @@ -268,7 +266,7 @@ static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv) } static void deformVerts_do(HookModifierData *hmd, - const ModifierEvalContext *UNUSED(ctx), + const ModifierEvalContext * /*ctx*/, Object *ob, Mesh *mesh, BMEditMesh *em, @@ -280,10 +278,10 @@ static void deformVerts_do(HookModifierData *hmd, float dmat[4][4]; int i, *index_pt; const MDeformVert *dvert; - struct HookData_cb hd; + HookData_cb hd; const bool invert_vgroup = (hmd->flag & MOD_HOOK_INVERT_VGROUP) != 0; - if (hmd->curfalloff == NULL) { + if (hmd->curfalloff == nullptr) { /* should never happen, but bad lib linking could cause it */ hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } @@ -300,7 +298,7 @@ static void deformVerts_do(HookModifierData *hmd, if (hd.defgrp_index != -1) { /* Edit-mesh. */ - if (em != NULL) { + if (em != nullptr) { cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); if (cd_dvert_offset == -1) { hd.defgrp_index = -1; @@ -308,7 +306,7 @@ static void deformVerts_do(HookModifierData *hmd, } else { /* Regular mesh. */ - if (dvert == NULL) { + if (dvert == nullptr) { hd.defgrp_index = -1; } } @@ -362,10 +360,12 @@ static void deformVerts_do(HookModifierData *hmd, else if (hmd->indexar) { /* vertex indices? */ const int *origindex_ar; /* if mesh is present and has original index data, use it */ - if (mesh && (origindex_ar = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))) { + if (mesh && (origindex_ar = static_cast( + CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)))) + { int verts_orig_num = verts_num; if (ob->type == OB_MESH) { - const Mesh *me_orig = ob->data; + const Mesh *me_orig = static_cast(ob->data); verts_orig_num = me_orig->totvert; } BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_orig_num); @@ -373,20 +373,21 @@ static void deformVerts_do(HookModifierData *hmd, int i_orig = origindex_ar[i]; BLI_assert(i_orig < verts_orig_num); if (BLI_BITMAP_TEST(indexar_used, i_orig)) { - hook_co_apply(&hd, i, dvert ? &dvert[i] : NULL); + hook_co_apply(&hd, i, dvert ? &dvert[i] : nullptr); } } MEM_freeN(indexar_used); } else { /* missing mesh or ORIGINDEX */ - if ((em != NULL) && (hd.defgrp_index != -1)) { + if ((em != nullptr) && (hd.defgrp_index != -1)) { BLI_assert(em->bm->totvert == verts_num); BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_num); BMIter iter; BMVert *v; BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (BLI_BITMAP_TEST(indexar_used, i)) { - const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset); + const MDeformVert *dv = static_cast( + BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset)); hook_co_apply(&hd, i, dv); } } @@ -396,24 +397,25 @@ static void deformVerts_do(HookModifierData *hmd, for (i = 0, index_pt = hmd->indexar; i < hmd->indexar_num; i++, index_pt++) { const int j = *index_pt; if (j < verts_num) { - hook_co_apply(&hd, j, dvert ? &dvert[j] : NULL); + hook_co_apply(&hd, j, dvert ? &dvert[j] : nullptr); } } } } } else if (hd.defgrp_index != -1) { /* vertex group hook */ - if (em != NULL) { + if (em != nullptr) { BLI_assert(em->bm->totvert == verts_num); BMIter iter; BMVert *v; BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) { - const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset); + const MDeformVert *dv = static_cast( + BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset)); hook_co_apply(&hd, i, dv); } } else { - BLI_assert(dvert != NULL); + BLI_assert(dvert != nullptr); for (i = 0; i < verts_num; i++) { hook_co_apply(&hd, i, &dvert[i]); } @@ -421,35 +423,35 @@ static void deformVerts_do(HookModifierData *hmd, } } -static void deformVerts(struct ModifierData *md, - const struct ModifierEvalContext *ctx, - struct Mesh *mesh, +static void deformVerts(ModifierData *md, + const ModifierEvalContext *ctx, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { HookModifierData *hmd = (HookModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); - deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, verts_num); + deformVerts_do(hmd, ctx, ctx->object, mesh_src, nullptr, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void deformVertsEM(struct ModifierData *md, - const struct ModifierEvalContext *ctx, - struct BMEditMesh *editData, - struct Mesh *mesh, +static void deformVertsEM(ModifierData *md, + const ModifierEvalContext *ctx, + BMEditMesh *editData, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { HookModifierData *hmd = (HookModifierData *)md; - deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? NULL : editData, vertexCos, verts_num); + deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? nullptr : editData, vertexCos, verts_num); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row, *col; uiLayout *layout = panel->layout; @@ -462,7 +464,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "object", 0, nullptr, ICON_NONE); if (!RNA_pointer_is_null(&hook_object_ptr) && RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) { @@ -470,9 +472,9 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemPointerR( col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); } - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); - uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); if (RNA_enum_get(&ob_ptr, "mode") == OB_MODE_EDIT) { row = uiLayoutRow(layout, true); @@ -486,12 +488,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) modifier_panel_end(layout, ptr); } -static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void falloff_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); bool use_falloff = RNA_enum_get(ptr, "falloff_type") != eWarp_Falloff_None; @@ -501,9 +503,9 @@ static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel) row = uiLayoutRow(layout, false); uiLayoutSetActive(row, use_falloff); - uiItemR(row, ptr, "falloff_radius", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "falloff_radius", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "use_falloff_uniform", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_falloff_uniform", 0, nullptr, ICON_NONE); if (RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) { uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false); @@ -514,10 +516,10 @@ static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Hook, panel_draw); modifier_subpanel_register( - region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type); + region_type, "falloff", "Falloff", nullptr, falloff_panel_draw, panel_type); } -static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md) +static void blendWrite(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) { const HookModifierData *hmd = (const HookModifierData *)md; @@ -554,22 +556,22 @@ ModifierTypeInfo modifierType_Hook = { /*copyData*/ copyData, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, /*blendWrite*/ blendWrite, /*blendRead*/ blendRead, diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.cc b/source/blender/modifiers/intern/MOD_laplaciandeform.cc index bbc3feb05c0..2eb99885c1e 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.cc +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.cc @@ -39,8 +39,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "eigen_capi.h" diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc index 7a2ba55acf5..9beaa8744a7 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc @@ -34,8 +34,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "eigen_capi.h" diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.cc similarity index 81% rename from source/blender/modifiers/intern/MOD_lattice.c rename to source/blender/modifiers/intern/MOD_lattice.cc index 086a5ed3fd5..328e17960cd 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -35,8 +35,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -67,9 +67,7 @@ static bool is_disabled(LatticeModifierData *lmd) return !lmd->object || lmd->object->type != OB_LATTICE; } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(userRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { LatticeModifierData *lmd = (LatticeModifierData *)md; return is_disabled(lmd); @@ -96,13 +94,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, - struct Mesh *mesh, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { LatticeModifierData *lmd = (LatticeModifierData *)md; - struct Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ @@ -115,19 +112,19 @@ static void deformVerts(ModifierData *md, lmd->strength, mesh_src); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *em, - struct Mesh *mesh, + BMEditMesh *em, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { - if (mesh != NULL) { + if (mesh != nullptr) { deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -140,7 +137,7 @@ static void deformVertsEM(ModifierData *md, lmd->object, ctx->object, vertexCos, verts_num, lmd->flag, lmd->name, lmd->strength, em); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; @@ -149,11 +146,11 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); - uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); modifier_panel_end(layout, ptr); } @@ -176,23 +173,23 @@ ModifierTypeInfo modifierType_Lattice = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index b0553b51d15..aea5ce125c1 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -42,8 +42,8 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "BLI_array.hh" #include "BLI_listbase_wrapper.hh" diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index ca4c9b84858..cd4c97a5fb1 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -34,8 +34,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "BLI_index_range.hh" #include "BLI_math_matrix_types.hh" diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.cc similarity index 79% rename from source/blender/modifiers/intern/MOD_meshcache.c rename to source/blender/modifiers/intern/MOD_meshcache.cc index c7da6711138..450d2fd53f9 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.cc @@ -4,7 +4,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -40,10 +40,10 @@ #include "MEM_guardedalloc.h" -#include "MOD_meshcache_util.h" /* utility functions */ -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_meshcache_util.hh" /* utility functions */ +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -54,15 +54,13 @@ static void initData(ModifierData *md) MEMCPY_STRUCT_AFTER(mcmd, DNA_struct_default_get(MeshCacheModifierData), modifier); } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md) +static bool dependsOnTime(Scene * /*scene*/, ModifierData *md) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; return (mcmd->play_mode == MOD_MESHCACHE_PLAY_CFEA); } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; @@ -84,15 +82,15 @@ static void meshcache_do(MeshCacheModifierData *mcmd, float(*vertexCos_Store)[3] = (use_factor || influence_group_index != -1 || (mcmd->deform_mode == MOD_MESHCACHE_DEFORM_INTEGRATE)) ? - MEM_malloc_arrayN( - verts_num, sizeof(*vertexCos_Store), __func__) : - NULL; + static_cast(MEM_malloc_arrayN( + verts_num, sizeof(*vertexCos_Store), __func__)) : + nullptr; float(*vertexCos)[3] = vertexCos_Store ? vertexCos_Store : vertexCos_Real; const float fps = FPS; char filepath[FILE_MAX]; - const char *err_str = NULL; + const char *err_str = nullptr; bool ok; float time; @@ -163,7 +161,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, /* -------------------------------------------------------------------- */ /* tricky shape key integration (slow!) */ if (mcmd->deform_mode == MOD_MESHCACHE_DEFORM_INTEGRATE) { - Mesh *me = ob->data; + Mesh *me = static_cast(ob->data); /* we could support any object type */ if (UNLIKELY(ob->type != OB_MESH)) { @@ -176,7 +174,8 @@ static void meshcache_do(MeshCacheModifierData *mcmd, BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' requires faces"); } else { - float(*vertexCos_New)[3] = MEM_malloc_arrayN(verts_num, sizeof(*vertexCos_New), __func__); + float(*vertexCos_New)[3] = static_cast( + MEM_malloc_arrayN(verts_num, sizeof(*vertexCos_New), __func__)); BKE_mesh_calc_relative_deform( BKE_mesh_poly_offsets(me), @@ -244,7 +243,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, const float global_offset = (mcmd->flag & MOD_MESHCACHE_INVERT_VERTEX_GROUP) ? mcmd->factor : 0.0f; - if (BKE_mesh_deform_verts(mesh) != NULL) { + if (BKE_mesh_deform_verts(mesh) != nullptr) { for (int i = 0; i < verts_num; i++) { /* For each vertex, compute its blending factor between the mesh cache (for `fac = 0`) * and the former position of the vertex (for `fac = 1`). */ @@ -280,22 +279,22 @@ static void deformVerts(ModifierData *md, MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, + BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int verts_num) @@ -303,24 +302,24 @@ static void deformVertsEM(ModifierData *md, MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); } - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; @@ -329,62 +328,62 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "cache_format", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "filepath", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "cache_format", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "filepath", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "factor", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(layout, ptr, "deform_mode", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "interpolation", 0, NULL, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + uiItemR(layout, ptr, "factor", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); + uiItemR(layout, ptr, "deform_mode", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "interpolation", 0, nullptr, ICON_NONE); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); modifier_panel_end(layout, ptr); } -static void time_remapping_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void time_remapping_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); - uiItemR(layout, ptr, "time_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "time_mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "play_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "play_mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); if (RNA_enum_get(ptr, "play_mode") == MOD_MESHCACHE_PLAY_CFEA) { - uiItemR(layout, ptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "frame_scale", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "frame_start", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "frame_scale", 0, nullptr, ICON_NONE); } else { /* play_mode == MOD_MESHCACHE_PLAY_EVAL */ int time_mode = RNA_enum_get(ptr, "time_mode"); if (time_mode == MOD_MESHCACHE_TIME_FRAME) { - uiItemR(layout, ptr, "eval_frame", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_frame", 0, nullptr, ICON_NONE); } else if (time_mode == MOD_MESHCACHE_TIME_SECONDS) { - uiItemR(layout, ptr, "eval_time", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_time", 0, nullptr, ICON_NONE); } else { /* time_mode == MOD_MESHCACHE_TIME_FACTOR */ - uiItemR(layout, ptr, "eval_factor", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_factor", 0, nullptr, ICON_NONE); } } } -static void axis_mapping_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void axis_mapping_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); col = uiLayoutColumn(layout, true); uiLayoutSetRedAlert(col, RNA_enum_get(ptr, "forward_axis") == RNA_enum_get(ptr, "up_axis")); - uiItemR(col, ptr, "forward_axis", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "up_axis", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "forward_axis", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "up_axis", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "flip_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } static void panelRegister(ARegionType *region_type) @@ -394,11 +393,11 @@ static void panelRegister(ARegionType *region_type) modifier_subpanel_register(region_type, "time_remapping", "Time Remapping", - NULL, + nullptr, time_remapping_panel_draw, panel_type); modifier_subpanel_register( - region_type, "axis_mapping", "Axis Mapping", NULL, axis_mapping_panel_draw, panel_type); + region_type, "axis_mapping", "Axis Mapping", nullptr, axis_mapping_panel_draw, panel_type); } ModifierTypeInfo modifierType_MeshCache = { @@ -414,23 +413,23 @@ ModifierTypeInfo modifierType_MeshCache = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, - /*requiredDataMask*/ NULL, - /*freeData*/ NULL, + /*requiredDataMask*/ nullptr, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, - /*updateDepsgraph*/ NULL, + /*updateDepsgraph*/ nullptr, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.cc similarity index 94% rename from source/blender/modifiers/intern/MOD_meshcache_mdd.c rename to source/blender/modifiers/intern/MOD_meshcache_mdd.cc index 305bba63998..95d699dbdf2 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c +++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.cc @@ -4,9 +4,9 @@ * \ingroup modifiers */ -#include -#include -#include +#include +#include +#include #include "BLI_utildefines.h" @@ -21,12 +21,12 @@ #include "DNA_modifier_types.h" -#include "MOD_meshcache_util.h" /* own include */ +#include "MOD_meshcache_util.hh" /* own include */ -typedef struct MDDHead { +struct MDDHead { int frame_tot; int verts_tot; -} MDDHead; /* frames, verts */ +}; /* frames, verts */ static bool meshcache_read_mdd_head(FILE *fp, const int verts_tot, @@ -83,7 +83,7 @@ static bool meshcache_read_mdd_range(FILE *fp, static bool meshcache_read_mdd_range_from_time(FILE *fp, const int verts_tot, const float time, - const float UNUSED(fps), + const float /*fps*/, float *r_frame, const char **err_str) { @@ -123,10 +123,10 @@ static bool meshcache_read_mdd_range_from_time(FILE *fp, const float range = f_time - f_time_prev; if (range <= FRAME_SNAP_EPS) { - frame = (float)i; + frame = float(i); } else { - frame = (float)(i - 1) + ((time - f_time_prev) / range); + frame = float(i - 1) + ((time - f_time_prev) / range); } } @@ -269,7 +269,7 @@ bool MOD_meshcache_read_mdd_times(const char *filepath, FILE *fp = BLI_fopen(filepath, "rb"); bool ok; - if (fp == NULL) { + if (fp == nullptr) { *err_str = errno ? strerror(errno) : "Unknown error opening file"; return false; } @@ -296,7 +296,7 @@ bool MOD_meshcache_read_mdd_times(const char *filepath, return false; } - frame = CLAMPIS(time, 0.0f, 1.0f) * (float)mdd_head.frame_tot; + frame = CLAMPIS(time, 0.0f, 1.0f) * float(mdd_head.frame_tot); rewind(fp); break; } diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.cc similarity index 96% rename from source/blender/modifiers/intern/MOD_meshcache_pc2.c rename to source/blender/modifiers/intern/MOD_meshcache_pc2.cc index 8eb17475a50..11b7933f14b 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.cc @@ -4,9 +4,9 @@ * \ingroup modifiers */ -#include -#include -#include +#include +#include +#include #include "BLI_utildefines.h" @@ -21,16 +21,16 @@ #include "DNA_modifier_types.h" -#include "MOD_meshcache_util.h" /* own include */ +#include "MOD_meshcache_util.hh" /* own include */ -typedef struct PC2Head { +struct PC2Head { char header[12]; /* 'POINTCACHE2\0' */ int file_version; /* unused - should be 1 */ int verts_tot; float start; float sampling; int frame_tot; -} PC2Head; /* frames, verts */ +}; /* frames, verts */ static bool meshcache_read_pc2_head(FILE *fp, const int verts_tot, @@ -109,7 +109,7 @@ static bool meshcache_read_pc2_range_from_time(FILE *fp, frame = ((time / fps) - pc2_head.start) / pc2_head.sampling; if (frame >= pc2_head.frame_tot) { - frame = (float)(pc2_head.frame_tot - 1); + frame = float(pc2_head.frame_tot - 1); } else if (frame < 0.0f) { frame = 0.0f; @@ -238,7 +238,7 @@ bool MOD_meshcache_read_pc2_times(const char *filepath, FILE *fp = BLI_fopen(filepath, "rb"); bool ok; - if (fp == NULL) { + if (fp == nullptr) { *err_str = errno ? strerror(errno) : "Unknown error opening file"; return false; } @@ -265,7 +265,7 @@ bool MOD_meshcache_read_pc2_times(const char *filepath, return false; } - frame = CLAMPIS(time, 0.0f, 1.0f) * (float)pc2_head.frame_tot; + frame = CLAMPIS(time, 0.0f, 1.0f) * float(pc2_head.frame_tot); rewind(fp); break; } diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.c b/source/blender/modifiers/intern/MOD_meshcache_util.cc similarity index 95% rename from source/blender/modifiers/intern/MOD_meshcache_util.c rename to source/blender/modifiers/intern/MOD_meshcache_util.cc index d3cb21bfb6e..2b8e2106a42 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_util.c +++ b/source/blender/modifiers/intern/MOD_meshcache_util.cc @@ -10,7 +10,7 @@ #include "DNA_modifier_types.h" -#include "MOD_meshcache_util.h" +#include "MOD_meshcache_util.hh" void MOD_meshcache_calc_range(const float frame, const char interp, @@ -25,7 +25,7 @@ void MOD_meshcache_calc_range(const float frame, else { const float tframe = floorf(frame); const float range = frame - tframe; - r_index_range[0] = (int)tframe; + r_index_range[0] = int(tframe); if (range <= FRAME_SNAP_EPS) { /* we're close enough not to need blending */ r_index_range[1] = r_index_range[0]; diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.h b/source/blender/modifiers/intern/MOD_meshcache_util.hh similarity index 100% rename from source/blender/modifiers/intern/MOD_meshcache_util.h rename to source/blender/modifiers/intern/MOD_meshcache_util.hh diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.cc similarity index 85% rename from source/blender/modifiers/intern/MOD_meshdeform.c rename to source/blender/modifiers/intern/MOD_meshdeform.cc index 999c069f155..3d41afa3664 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.cc @@ -44,8 +44,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -94,28 +94,28 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla BKE_modifier_copydata_generic(md, target, flag); if (mmd->bindinfluences) { - tmmd->bindinfluences = MEM_dupallocN(mmd->bindinfluences); + tmmd->bindinfluences = static_cast(MEM_dupallocN(mmd->bindinfluences)); } if (mmd->bindoffsets) { - tmmd->bindoffsets = MEM_dupallocN(mmd->bindoffsets); + tmmd->bindoffsets = static_cast(MEM_dupallocN(mmd->bindoffsets)); } if (mmd->bindcagecos) { - tmmd->bindcagecos = MEM_dupallocN(mmd->bindcagecos); + tmmd->bindcagecos = static_cast(MEM_dupallocN(mmd->bindcagecos)); } if (mmd->dyngrid) { - tmmd->dyngrid = MEM_dupallocN(mmd->dyngrid); + tmmd->dyngrid = static_cast(MEM_dupallocN(mmd->dyngrid)); } if (mmd->dyninfluences) { - tmmd->dyninfluences = MEM_dupallocN(mmd->dyninfluences); + tmmd->dyninfluences = static_cast(MEM_dupallocN(mmd->dyninfluences)); } if (mmd->dynverts) { - tmmd->dynverts = MEM_dupallocN(mmd->dynverts); + tmmd->dynverts = static_cast(MEM_dupallocN(mmd->dynverts)); } if (mmd->bindweights) { - tmmd->bindweights = MEM_dupallocN(mmd->bindweights); /* deprecated */ + tmmd->bindweights = static_cast(MEM_dupallocN(mmd->bindweights)); /* deprecated */ } if (mmd->bindcos) { - tmmd->bindcos = MEM_dupallocN(mmd->bindcos); /* deprecated */ + tmmd->bindcos = static_cast(MEM_dupallocN(mmd->bindcos)); /* deprecated */ } } @@ -129,9 +129,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma } } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; @@ -153,7 +151,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - if (mmd->object != NULL) { + if (mmd->object != nullptr) { DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Mesh Deform Modifier"); DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_GEOMETRY, "Mesh Deform Modifier"); } @@ -179,7 +177,7 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 for (i = 0; i < 3; i++) { gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth * 0.5f) / mmd->dyncellwidth; - ivec[i] = (int)gridvec[i]; + ivec[i] = int(gridvec[i]); dvec[i] = gridvec[i] - ivec[i]; } @@ -250,7 +248,7 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 return totweight; } -typedef struct MeshdeformUserdata { +struct MeshdeformUserdata { /*const*/ MeshDeformModifierData *mmd; const MDeformVert *dvert; /*const*/ float (*dco)[3]; @@ -258,13 +256,13 @@ typedef struct MeshdeformUserdata { float (*vertexCos)[3]; float (*cagemat)[4]; float (*icagemat)[3]; -} MeshdeformUserdata; +}; static void meshdeform_vert_task(void *__restrict userdata, const int iter, - const TaskParallelTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict /*tls*/) { - MeshdeformUserdata *data = userdata; + MeshdeformUserdata *data = static_cast(userdata); /*const*/ MeshDeformModifierData *mmd = data->mmd; const MDeformVert *dvert = data->dvert; const int defgrp_index = data->defgrp_index; @@ -328,15 +326,15 @@ static void meshdeformModifier_do(ModifierData *md, Object *ob = ctx->object; Mesh *cagemesh; - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; - float(*dco)[3] = NULL, (*bindcagecos)[3]; + float(*dco)[3] = nullptr, (*bindcagecos)[3]; int a, cage_verts_num, defgrp_index; MeshdeformUserdata data; static int recursive_bind_sentinel = 0; - if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL)) { + if (mmd->object == nullptr || (mmd->bindcagecos == nullptr && mmd->bindfunc == nullptr)) { return; } @@ -352,7 +350,7 @@ static void meshdeformModifier_do(ModifierData *md, */ Object *ob_target = mmd->object; cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target); - if (cagemesh == NULL) { + if (cagemesh == nullptr) { BKE_modifier_set_error(ctx->object, md, "Cannot get mesh from cage object"); return; } @@ -392,7 +390,7 @@ static void meshdeformModifier_do(ModifierData *md, ob, md, "Cage vertices changed from %d to %d", mmd->cage_verts_num, cage_verts_num); goto finally; } - else if (mmd->bindcagecos == NULL) { + else if (mmd->bindcagecos == nullptr) { BKE_modifier_set_error(ob, md, "Bind data missing"); goto finally; } @@ -400,7 +398,7 @@ static void meshdeformModifier_do(ModifierData *md, /* We allocate 1 element extra to make it possible to * load the values to SSE registers, which are float4. */ - dco = MEM_calloc_arrayN((cage_verts_num + 1), sizeof(*dco), "MDefDco"); + dco = static_cast(MEM_calloc_arrayN((cage_verts_num + 1), sizeof(*dco), "MDefDco")); zero_v3(dco[cage_verts_num]); /* setup deformation data */ @@ -442,35 +440,36 @@ static void deformVerts(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ meshdeformModifier_do(md, ctx, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, + BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, nullptr, verts_num, false); /* TODO(@ideasman42): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } meshdeformModifier_do(md, ctx, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } @@ -502,9 +501,9 @@ void BKE_modifier_mdef_compact_influences(ModifierData *md) } /* allocate bind influences */ - mmd->bindinfluences = MEM_calloc_arrayN( - mmd->influences_num, sizeof(MDefInfluence), "MDefBindInfluence"); - mmd->bindoffsets = MEM_calloc_arrayN((verts_num + 1), sizeof(int), "MDefBindOffset"); + mmd->bindinfluences = static_cast( + MEM_calloc_arrayN(mmd->influences_num, sizeof(MDefInfluence), __func__)); + mmd->bindoffsets = static_cast(MEM_calloc_arrayN((verts_num + 1), sizeof(int), __func__)); /* write influences */ influences_num = 0; @@ -538,10 +537,10 @@ void BKE_modifier_mdef_compact_influences(ModifierData *md) /* free */ MEM_freeN(mmd->bindweights); - mmd->bindweights = NULL; + mmd->bindweights = nullptr; } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; @@ -555,14 +554,14 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) col = uiLayoutColumn(layout, true); uiLayoutSetEnabled(col, !is_bound); - uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "object", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); col = uiLayoutColumn(layout, false); uiLayoutSetEnabled(col, !is_bound); - uiItemR(col, ptr, "precision", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_dynamic_bind", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "precision", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "use_dynamic_bind", 0, nullptr, ICON_NONE); uiItemO(layout, is_bound ? IFACE_("Unbind") : IFACE_("Bind"), @@ -589,16 +588,16 @@ static void blendWrite(BlendWriter *writer, const ID *id_owner, const ModifierDa /* Modifier coming from linked data cannot be bound from an override, so we can remove all * binding data, can save a significant amount of memory. */ mmd.influences_num = 0; - mmd.bindinfluences = NULL; + mmd.bindinfluences = nullptr; mmd.verts_num = 0; - mmd.bindoffsets = NULL; + mmd.bindoffsets = nullptr; mmd.cage_verts_num = 0; - mmd.bindcagecos = NULL; + mmd.bindcagecos = nullptr; mmd.dyngridsize = 0; - mmd.dyngrid = NULL; + mmd.dyngrid = nullptr; mmd.influences_num = 0; - mmd.dyninfluences = NULL; - mmd.dynverts = NULL; + mmd.dyninfluences = nullptr; + mmd.dynverts = nullptr; } } @@ -609,12 +608,12 @@ static void blendWrite(BlendWriter *writer, const ID *id_owner, const ModifierDa BLO_write_struct_array(writer, MDefInfluence, mmd.influences_num, mmd.bindinfluences); /* NOTE: `bindoffset` is abusing `verts_num + 1` as its size, this becomes an incorrect value in - * case `verts_num == 0`, since `bindoffset` is then NULL, not a size 1 allocated array. */ + * case `verts_num == 0`, since `bindoffset` is then nullptr, not a size 1 allocated array. */ if (mmd.verts_num > 0) { BLO_write_int32_array(writer, mmd.verts_num + 1, mmd.bindoffsets); } else { - BLI_assert(mmd.bindoffsets == NULL); + BLI_assert(mmd.bindoffsets == nullptr); } BLO_write_float3_array(writer, mmd.cage_verts_num, mmd.bindcagecos); @@ -630,7 +629,7 @@ static void blendRead(BlendDataReader *reader, ModifierData *md) BLO_read_data_address(reader, &mmd->bindinfluences); /* NOTE: `bindoffset` is abusing `verts_num + 1` as its size, this becomes an incorrect value in - * case `verts_num == 0`, since `bindoffset` is then NULL, not a size 1 allocated array. */ + * case `verts_num == 0`, since `bindoffset` is then nullptr, not a size 1 allocated array. */ if (mmd->verts_num > 0) { BLO_read_int32_array(reader, mmd->verts_num + 1, &mmd->bindoffsets); } @@ -658,22 +657,22 @@ ModifierTypeInfo modifierType_MeshDeform = { /*copyData*/ copyData, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, /*freeData*/ freeData, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, /*blendWrite*/ blendWrite, /*blendRead*/ blendRead, diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc index adf33bd0071..6672ca4ba74 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc @@ -44,8 +44,8 @@ #include "GEO_mesh_primitive_cuboid.hh" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #if defined(WITH_USD) || defined(WITH_ALEMBIC) # include "BKE_global.h" diff --git a/source/blender/modifiers/intern/MOD_mirror.cc b/source/blender/modifiers/intern/MOD_mirror.cc index 63a293e4e59..4256b93808a 100644 --- a/source/blender/modifiers/intern/MOD_mirror.cc +++ b/source/blender/modifiers/intern/MOD_mirror.cc @@ -33,8 +33,8 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "GEO_mesh_merge_by_distance.hh" diff --git a/source/blender/modifiers/intern/MOD_multires.cc b/source/blender/modifiers/intern/MOD_multires.cc index 342dbe96f85..1d27dd5b792 100644 --- a/source/blender/modifiers/intern/MOD_multires.cc +++ b/source/blender/modifiers/intern/MOD_multires.cc @@ -42,8 +42,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" struct MultiresRuntimeData { /* Cached subdivision surface descriptor, with topology and settings. */ diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index d29918e4c81..3076c6299e6 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -75,9 +75,9 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" #include "MOD_nodes.h" -#include "MOD_ui_common.h" +#include "MOD_ui_common.hh" #include "ED_object.h" #include "ED_screen.h" diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c deleted file mode 100644 index 563db837d20..00000000000 --- a/source/blender/modifiers/intern/MOD_none.c +++ /dev/null @@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2005 Blender Foundation */ - -/** \file - * \ingroup modifiers - */ - -#include - -#include "BLI_utildefines.h" - -#include "MOD_modifiertypes.h" - -#include "UI_resources.h" - -#include "RNA_access.h" -#include "RNA_prototypes.h" - -/* We only need to define isDisabled; because it always returns 1, - * no other functions will be called - */ - -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *UNUSED(md), - bool UNUSED(userRenderParams)) -{ - return true; -} - -ModifierTypeInfo modifierType_None = { - /*name*/ "None", - /*structName*/ "ModifierData", - /*structSize*/ sizeof(ModifierData), - /*srna*/ &RNA_Modifier, - /*type*/ eModifierTypeType_None, - /*flags*/ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs, - /*icon*/ ICON_NONE, - - /*copyData*/ NULL, - - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, - - /*initData*/ NULL, - /*requiredDataMask*/ NULL, - /*freeData*/ NULL, - /*isDisabled*/ isDisabled, - /*updateDepsgraph*/ NULL, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, - /*panelRegister*/ NULL, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, -}; diff --git a/source/blender/modifiers/intern/MOD_none.cc b/source/blender/modifiers/intern/MOD_none.cc new file mode 100644 index 00000000000..3a776095747 --- /dev/null +++ b/source/blender/modifiers/intern/MOD_none.cc @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2005 Blender Foundation */ + +/** \file + * \ingroup modifiers + */ + +#include "BLI_utildefines.h" + +#include "MOD_modifiertypes.hh" + +#include "UI_resources.h" + +#include "RNA_prototypes.h" + +/* We only need to define isDisabled; because it always returns 1, + * no other functions will be called + */ + +static bool isDisabled(const Scene * /*scene*/, ModifierData * /*md*/, bool /*useRenderParams*/) +{ + return true; +} + +ModifierTypeInfo modifierType_None = { + /*name*/ "None", + /*structName*/ "ModifierData", + /*structSize*/ sizeof(ModifierData), + /*srna*/ &RNA_Modifier, + /*type*/ eModifierTypeType_None, + /*flags*/ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs, + /*icon*/ ICON_NONE, + + /*copyData*/ nullptr, + + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, + + /*initData*/ nullptr, + /*requiredDataMask*/ nullptr, + /*freeData*/ nullptr, + /*isDisabled*/ isDisabled, + /*updateDepsgraph*/ nullptr, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, + /*panelRegister*/ nullptr, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, +}; diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index 0ce2be95850..d128ab6137a 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -37,8 +37,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void generate_vert_coordinates(Mesh *mesh, Object *ob, diff --git a/source/blender/modifiers/intern/MOD_ocean.cc b/source/blender/modifiers/intern/MOD_ocean.cc index 06a78e81dfc..f09506fd3f0 100644 --- a/source/blender/modifiers/intern/MOD_ocean.cc +++ b/source/blender/modifiers/intern/MOD_ocean.cc @@ -41,8 +41,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #ifdef WITH_OCEANSIM static void init_cache_data(Object *ob, OceanModifierData *omd, const int resolution) diff --git a/source/blender/modifiers/intern/MOD_particleinstance.cc b/source/blender/modifiers/intern/MOD_particleinstance.cc index 4d5006542d7..cdae7dda5ee 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.cc +++ b/source/blender/modifiers/intern/MOD_particleinstance.cc @@ -40,8 +40,8 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static void initData(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_particlesystem.cc b/source/blender/modifiers/intern/MOD_particlesystem.cc index b042a1af8e9..f3a2fdd09ae 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.cc +++ b/source/blender/modifiers/intern/MOD_particlesystem.cc @@ -36,8 +36,8 @@ #include "BLO_read_write.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index 32589bae6e7..50d1c706310 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -32,8 +32,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include #include diff --git a/source/blender/modifiers/intern/MOD_screw.cc b/source/blender/modifiers/intern/MOD_screw.cc index dd4f6ce3971..cf6f0c02955 100644 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@ -40,8 +40,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "BLI_strict_flags.h" diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.cc similarity index 73% rename from source/blender/modifiers/intern/MOD_shapekey.c rename to source/blender/modifiers/intern/MOD_shapekey.cc index d9683dc3ed4..c60a32389de 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.cc @@ -21,13 +21,13 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" #include "UI_resources.h" -static void deformVerts(ModifierData *UNUSED(md), +static void deformVerts(ModifierData * /*md*/, const ModifierEvalContext *ctx, - Mesh *UNUSED(mesh), + Mesh * /*mesh*/, float (*vertexCos)[3], int verts_num) { @@ -35,8 +35,11 @@ static void deformVerts(ModifierData *UNUSED(md), if (key && key->block.first) { int deformedVerts_tot; - BKE_key_evaluate_object_ex( - ctx->object, &deformedVerts_tot, (float *)vertexCos, sizeof(*vertexCos) * verts_num, NULL); + BKE_key_evaluate_object_ex(ctx->object, + &deformedVerts_tot, + (float *)vertexCos, + sizeof(*vertexCos) * verts_num, + nullptr); } } @@ -73,7 +76,7 @@ static void deformMatrices(ModifierData *md, static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *UNUSED(editData), + BMEditMesh * /*editData*/, Mesh *mesh, float (*vertexCos)[3], int verts_num) @@ -85,10 +88,10 @@ static void deformVertsEM(ModifierData *md, } } -static void deformMatricesEM(ModifierData *UNUSED(md), +static void deformMatricesEM(ModifierData * /*md*/, const ModifierEvalContext *ctx, - struct BMEditMesh *UNUSED(editData), - Mesh *UNUSED(mesh), + BMEditMesh * /*editData*/, + Mesh * /*mesh*/, float (*vertexCos)[3], float (*defMats)[3][3], int verts_num) @@ -118,26 +121,26 @@ ModifierTypeInfo modifierType_ShapeKey = { eModifierTypeFlag_SupportsEditmode, /*icon*/ ICON_DOT, - /*copyData*/ NULL, + /*copyData*/ nullptr, /*deformVerts*/ deformVerts, /*deformMatrices*/ deformMatrices, /*deformVertsEM*/ deformVertsEM, /*deformMatricesEM*/ deformMatricesEM, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, - /*initData*/ NULL, - /*requiredDataMask*/ NULL, - /*freeData*/ NULL, - /*isDisabled*/ NULL, - /*updateDepsgraph*/ NULL, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, - /*panelRegister*/ NULL, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*initData*/ nullptr, + /*requiredDataMask*/ nullptr, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, + /*updateDepsgraph*/ nullptr, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, + /*panelRegister*/ nullptr, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.cc similarity index 78% rename from source/blender/modifiers/intern/MOD_shrinkwrap.c rename to source/blender/modifiers/intern/MOD_shrinkwrap.cc index 1341214be53..2b6d3403d31 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -34,8 +34,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static bool dependsOnNormals(ModifierData *md); @@ -58,9 +58,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma } } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(useRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; @@ -93,49 +91,49 @@ static void deformVerts(ModifierData *md, int verts_num) { ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md; - struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - Mesh *mesh_src = NULL; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + Mesh *mesh_src = nullptr; if (ELEM(ctx->object->type, OB_MESH, OB_LATTICE) || (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { /* mesh_src is needed for vgroups, but also used as ShrinkwrapCalcData.vert when projecting. * Avoid time-consuming mesh conversion for curves when not projecting. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; int defgrp_index = -1; MOD_get_vgroup(ctx->object, mesh_src, swmd->vgroup_name, &dvert, &defgrp_index); shrinkwrapModifier_deform( swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, + BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int verts_num) { ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md; - struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - Mesh *mesh_src = NULL; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + Mesh *mesh_src = nullptr; if ((swmd->vgroup_name[0] != '\0') || (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); } /* TODO(@ideasman42): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } - const MDeformVert *dvert = NULL; + const MDeformVert *dvert = nullptr; int defgrp_index = -1; if (swmd->vgroup_name[0] != '\0') { MOD_get_vgroup(ctx->object, mesh_src, swmd->vgroup_name, &dvert, &defgrp_index); @@ -144,8 +142,8 @@ static void deformVertsEM(ModifierData *md, shrinkwrapModifier_deform( swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } @@ -158,7 +156,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte mask.lmask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL; } - if (smd->target != NULL) { + if (smd->target != nullptr) { DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier"); DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier"); DEG_add_customdata_mask(ctx->node, smd->target, &mask); @@ -166,7 +164,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_special_eval_flag(ctx->node, &smd->target->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY); } } - if (smd->auxTarget != NULL) { + if (smd->auxTarget != nullptr) { DEG_add_object_relation( ctx->node, smd->auxTarget, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier"); DEG_add_object_relation( @@ -190,7 +188,7 @@ static bool dependsOnNormals(ModifierData *md) return false; } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row, *col; uiLayout *layout = panel->layout; @@ -203,44 +201,44 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) int wrap_method = RNA_enum_get(ptr, "wrap_method"); - uiItemR(layout, ptr, "wrap_method", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "wrap_method", 0, nullptr, ICON_NONE); if (ELEM(wrap_method, MOD_SHRINKWRAP_PROJECT, MOD_SHRINKWRAP_NEAREST_SURFACE, MOD_SHRINKWRAP_TARGET_PROJECT)) { - uiItemR(layout, ptr, "wrap_mode", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "wrap_mode", 0, nullptr, ICON_NONE); } if (wrap_method == MOD_SHRINKWRAP_PROJECT) { uiItemR(layout, ptr, "project_limit", 0, IFACE_("Limit"), ICON_NONE); - uiItemR(layout, ptr, "subsurf_levels", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "subsurf_levels", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, false); row = uiLayoutRowWithHeading(col, true, IFACE_("Axis")); - uiItemR(row, ptr, "use_project_x", toggles_flag, NULL, ICON_NONE); - uiItemR(row, ptr, "use_project_y", toggles_flag, NULL, ICON_NONE); - uiItemR(row, ptr, "use_project_z", toggles_flag, NULL, ICON_NONE); + uiItemR(row, ptr, "use_project_x", toggles_flag, nullptr, ICON_NONE); + uiItemR(row, ptr, "use_project_y", toggles_flag, nullptr, ICON_NONE); + uiItemR(row, ptr, "use_project_z", toggles_flag, nullptr, ICON_NONE); - uiItemR(col, ptr, "use_negative_direction", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_positive_direction", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_negative_direction", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "use_positive_direction", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "cull_face", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "cull_face", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_negative_direction") && RNA_enum_get(ptr, "cull_face") != 0); - uiItemR(col, ptr, "use_invert_cull", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_invert_cull", 0, nullptr, ICON_NONE); } - uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "target", 0, nullptr, ICON_NONE); if (wrap_method == MOD_SHRINKWRAP_PROJECT) { - uiItemR(layout, ptr, "auxiliary_target", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "auxiliary_target", 0, nullptr, ICON_NONE); } - uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); modifier_panel_end(layout, ptr); } @@ -264,23 +262,23 @@ ModifierTypeInfo modifierType_Shrinkwrap = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, + /*freeData*/ nullptr, /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, + /*dependsOnTime*/ nullptr, /*dependsOnNormals*/ dependsOnNormals, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.cc similarity index 83% rename from source/blender/modifiers/intern/MOD_simpledeform.c rename to source/blender/modifiers/intern/MOD_simpledeform.cc index d6fd2389da8..dff3a4cf8f0 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.cc @@ -34,8 +34,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #define BEND_EPS 0.000001f @@ -95,7 +95,7 @@ static void axis_limit(const int axis, const float limits[2], float co[3], float } static void simpleDeform_taper(const float factor, - const int UNUSED(axis), + const int /*axis*/, const float dcut[3], float r_co[3]) { @@ -110,7 +110,7 @@ static void simpleDeform_taper(const float factor, } static void simpleDeform_stretch(const float factor, - const int UNUSED(axis), + const int /*axis*/, const float dcut[3], float r_co[3]) { @@ -127,7 +127,7 @@ static void simpleDeform_stretch(const float factor, } static void simpleDeform_twist(const float factor, - const int UNUSED(axis), + const int /*axis*/, const float *dcut, float r_co[3]) { @@ -204,9 +204,9 @@ static void simpleDeform_bend(const float factor, static void simple_helper(void *__restrict userdata, const int iter, - const TaskParallelTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict /*tls*/) { - const struct DeformUserData *curr_deform_data = userdata; + const DeformUserData *curr_deform_data = static_cast(userdata); float weight = BKE_defvert_array_find_weight_safe( curr_deform_data->dvert, iter, curr_deform_data->vgroup); const uint *axis_map = axis_map_table[(curr_deform_data->mode != MOD_SIMPLEDEFORM_MODE_BEND) ? @@ -282,15 +282,15 @@ static void simple_helper(void *__restrict userdata, /* simple deform modifier */ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, - const ModifierEvalContext *UNUSED(ctx), - struct Object *ob, - struct Mesh *mesh, + const ModifierEvalContext * /*ctx*/, + Object *ob, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { int i; float smd_limit[2], smd_factor; - SpaceTransform *transf = NULL, tmp_transf; + SpaceTransform *transf = nullptr, tmp_transf; int vgroup; const MDeformVert *dvert; @@ -316,7 +316,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, /* Safe-check */ if (smd->origin == ob) { - smd->origin = NULL; /* No self references */ + smd->origin = nullptr; /* No self references */ } if (smd->limit[0] < 0.0f) { @@ -329,7 +329,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ /* Calculate matrix to convert between coordinate spaces. */ - if (smd->origin != NULL) { + if (smd->origin != nullptr) { transf = &tmp_transf; BLI_SPACE_TRANSFORM_SETUP(transf, ob, smd->origin); } @@ -382,20 +382,20 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, const bool invert_vgroup = (smd->flag & MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP) != 0; /* Build our data. */ - const struct DeformUserData deform_pool_data = { - .mode = smd->mode, - .smd_factor = smd_factor, - .deform_axis = deform_axis, - .transf = transf, - .vertexCos = vertexCos, - .invert_vgroup = invert_vgroup, - .lock_axis = lock_axis, - .vgroup = vgroup, - .smd_limit[0] = smd_limit[0], - .smd_limit[1] = smd_limit[1], - .dvert = dvert, - .limit_axis = limit_axis, - }; + DeformUserData deform_pool_data{}; + deform_pool_data.mode = smd->mode; + deform_pool_data.smd_factor = smd_factor; + deform_pool_data.deform_axis = deform_axis; + deform_pool_data.transf = transf; + deform_pool_data.vertexCos = vertexCos; + deform_pool_data.invert_vgroup = invert_vgroup; + deform_pool_data.lock_axis = lock_axis; + deform_pool_data.vgroup = vgroup; + deform_pool_data.smd_limit[0] = smd_limit[0]; + deform_pool_data.smd_limit[1] = smd_limit[1]; + deform_pool_data.dvert = dvert; + deform_pool_data.limit_axis = limit_axis; + /* Do deformation. */ TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); @@ -431,7 +431,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; - if (smd->origin != NULL) { + if (smd->origin != nullptr) { DEG_add_object_relation( ctx->node, smd->origin, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier"); DEG_add_depends_on_transform_relation(ctx->node, "SimpleDeform Modifier"); @@ -440,53 +440,53 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, - struct Mesh *mesh, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, - struct Mesh *mesh, + BMEditMesh *editData, + Mesh *mesh, float (*vertexCos)[3], int verts_num) { SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); } /* TODO(@ideasman42): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; @@ -497,24 +497,24 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) int deform_method = RNA_enum_get(ptr, "deform_method"); row = uiLayoutRow(layout, false); - uiItemR(row, ptr, "deform_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, ptr, "deform_method", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); if (ELEM(deform_method, MOD_SIMPLEDEFORM_MODE_TAPER, MOD_SIMPLEDEFORM_MODE_STRETCH)) { - uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "factor", 0, nullptr, ICON_NONE); } else { - uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "angle", 0, nullptr, ICON_NONE); } - uiItemR(layout, ptr, "origin", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "deform_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "origin", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "deform_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); modifier_panel_end(layout, ptr); } -static void restrictions_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void restrictions_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; @@ -527,7 +527,7 @@ static void restrictions_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "limits", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "limits", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); if (ELEM(deform_method, MOD_SIMPLEDEFORM_MODE_TAPER, @@ -538,17 +538,17 @@ static void restrictions_panel_draw(const bContext *UNUSED(C), Panel *panel) row = uiLayoutRowWithHeading(layout, true, IFACE_("Lock")); if (deform_axis != 0) { - uiItemR(row, ptr, "lock_x", toggles_flag, NULL, ICON_NONE); + uiItemR(row, ptr, "lock_x", toggles_flag, nullptr, ICON_NONE); } if (deform_axis != 1) { - uiItemR(row, ptr, "lock_y", toggles_flag, NULL, ICON_NONE); + uiItemR(row, ptr, "lock_y", toggles_flag, nullptr, ICON_NONE); } if (deform_axis != 2) { - uiItemR(row, ptr, "lock_z", toggles_flag, NULL, ICON_NONE); + uiItemR(row, ptr, "lock_z", toggles_flag, nullptr, ICON_NONE); } } - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); } static void panelRegister(ARegionType *region_type) @@ -556,7 +556,7 @@ static void panelRegister(ARegionType *region_type) PanelType *panel_type = modifier_panel_register( region_type, eModifierType_SimpleDeform, panel_draw); modifier_subpanel_register( - region_type, "restrictions", "Restrictions", NULL, restrictions_panel_draw, panel_type); + region_type, "restrictions", "Restrictions", nullptr, restrictions_panel_draw, panel_type); } ModifierTypeInfo modifierType_SimpleDeform = { @@ -574,23 +574,23 @@ ModifierTypeInfo modifierType_SimpleDeform = { /*copyData*/ BKE_modifier_copydata_generic, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, - /*isDisabled*/ NULL, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, - /*dependsOnTime*/ NULL, - /*dependsOnNormals*/ NULL, + /*dependsOnTime*/ nullptr, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_skin.cc b/source/blender/modifiers/intern/MOD_skin.cc index 5223acd2e39..f02dd705295 100644 --- a/source/blender/modifiers/intern/MOD_skin.cc +++ b/source/blender/modifiers/intern/MOD_skin.cc @@ -72,8 +72,8 @@ #include "WM_types.h" /* For skin mark clear operator UI. */ -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "bmesh.h" diff --git a/source/blender/modifiers/intern/MOD_smooth.cc b/source/blender/modifiers/intern/MOD_smooth.cc index 1b9aec8fcc1..156b3ea75b5 100644 --- a/source/blender/modifiers/intern/MOD_smooth.cc +++ b/source/blender/modifiers/intern/MOD_smooth.cc @@ -34,9 +34,9 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.cc similarity index 73% rename from source/blender/modifiers/intern/MOD_softbody.c rename to source/blender/modifiers/intern/MOD_softbody.cc index b46682beb46..79e76d76f5f 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.cc @@ -5,7 +5,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -33,12 +33,12 @@ #include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" -static void deformVerts(ModifierData *UNUSED(md), +static void deformVerts(ModifierData * /*md*/, const ModifierEvalContext *ctx, - Mesh *UNUSED(derivedData), + Mesh * /*mesh*/, float (*vertexCos)[3], int verts_num) { @@ -47,12 +47,12 @@ static void deformVerts(ModifierData *UNUSED(md), ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, verts_num); } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime( Scene * /*scene*/, ModifierData * /*md*/) { return true; } -static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx) +static void updateDepsgraph(ModifierData * /*md*/, const ModifierUpdateDepsgraphContext *ctx) { if (ctx->object->soft) { /* Actual code uses ccd_build_deflector_hash */ @@ -60,7 +60,7 @@ static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgr ctx->object, ctx->object->soft->collision_group, eModifierType_Collision, - NULL, + nullptr, "Softbody Collision"); DEG_add_forcefield_relations( ctx->node, ctx->object, ctx->object->soft->effector_weights, true, 0, "Softbody Field"); @@ -69,11 +69,11 @@ static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgr DEG_add_depends_on_transform_relation(ctx->node, "SoftBody Modifier"); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -96,26 +96,26 @@ ModifierTypeInfo modifierType_Softbody = { eModifierTypeFlag_UsesPointCache, /*icon*/ ICON_MOD_SOFT, - /*copyData*/ NULL, + /*copyData*/ nullptr, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, - /*initData*/ NULL, - /*requiredDataMask*/ NULL, - /*freeData*/ NULL, - /*isDisabled*/ NULL, + /*initData*/ nullptr, + /*requiredDataMask*/ nullptr, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, }; diff --git a/source/blender/modifiers/intern/MOD_solidify.cc b/source/blender/modifiers/intern/MOD_solidify.cc index f216bf9683e..5015a9a3d01 100644 --- a/source/blender/modifiers/intern/MOD_solidify.cc +++ b/source/blender/modifiers/intern/MOD_solidify.cc @@ -26,8 +26,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "MOD_solidify_util.hh" diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.cc b/source/blender/modifiers/intern/MOD_solidify_extrude.cc index ef4d87492fe..c1265abd349 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.cc +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.cc @@ -20,9 +20,9 @@ #include "BKE_mesh.hh" #include "BKE_particle.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" #include "MOD_solidify_util.hh" /* own include */ -#include "MOD_util.h" +#include "MOD_util.hh" /* -------------------------------------------------------------------- */ /** \name High Quality Normal Calculation Function diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc index 18dff6a4565..1d09cef61de 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc @@ -18,9 +18,9 @@ #include "BKE_mesh.hh" #include "BKE_particle.h" -#include "MOD_modifiertypes.h" +#include "MOD_modifiertypes.hh" #include "MOD_solidify_util.hh" /* Own include. */ -#include "MOD_util.h" +#include "MOD_util.hh" /* -------------------------------------------------------------------- */ /** \name Local Utilities diff --git a/source/blender/modifiers/intern/MOD_subsurf.cc b/source/blender/modifiers/intern/MOD_subsurf.cc index c2d9cfd65a6..b954d1f7c8e 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.cc +++ b/source/blender/modifiers/intern/MOD_subsurf.cc @@ -45,8 +45,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "BLO_read_write.h" diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.cc similarity index 75% rename from source/blender/modifiers/intern/MOD_surface.c rename to source/blender/modifiers/intern/MOD_surface.cc index c38ec66d28f..b1047fac671 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.cc @@ -33,9 +33,9 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "BLO_read_write.h" @@ -70,8 +70,8 @@ static void freeData(ModifierData *md) } if (surmd->runtime.mesh) { - BKE_id_free(NULL, surmd->runtime.mesh); - surmd->runtime.mesh = NULL; + BKE_id_free(nullptr, surmd->runtime.mesh); + surmd->runtime.mesh = nullptr; } MEM_SAFE_FREE(surmd->runtime.vert_positions_prev); @@ -80,7 +80,7 @@ static void freeData(ModifierData *md) } } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*md*/) { return true; } @@ -92,7 +92,7 @@ static void deformVerts(ModifierData *md, int verts_num) { SurfaceModifierData *surmd = (SurfaceModifierData *)md; - const int cfra = (int)DEG_get_ctime(ctx->depsgraph); + const int cfra = int(DEG_get_ctime(ctx->depsgraph)); /* Free mesh and BVH cache. */ if (surmd->runtime.bvhtree) { @@ -101,18 +101,19 @@ static void deformVerts(ModifierData *md, } if (surmd->runtime.mesh) { - BKE_id_free(NULL, surmd->runtime.mesh); - surmd->runtime.mesh = NULL; + BKE_id_free(nullptr, surmd->runtime.mesh); + surmd->runtime.mesh = nullptr; } if (mesh) { /* Not possible to use get_mesh() in this case as we'll modify its vertices * and get_mesh() would return 'mesh' directly. */ - surmd->runtime.mesh = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); + surmd->runtime.mesh = (Mesh *)BKE_id_copy_ex( + nullptr, (ID *)mesh, nullptr, LIB_ID_COPY_LOCALIZE); } else { surmd->runtime.mesh = MOD_deform_mesh_eval_get( - ctx->object, NULL, NULL, NULL, verts_num, false); + ctx->object, nullptr, nullptr, nullptr, verts_num, false); } if (!ctx->object->pd) { @@ -129,17 +130,17 @@ static void deformVerts(ModifierData *md, mesh_verts_num = surmd->runtime.mesh->totvert; if ((mesh_verts_num != surmd->runtime.verts_num) || - (surmd->runtime.vert_positions_prev == NULL) || (surmd->runtime.vert_velocities == NULL) || - (cfra != surmd->runtime.cfra_prev + 1)) + (surmd->runtime.vert_positions_prev == nullptr) || + (surmd->runtime.vert_velocities == nullptr) || (cfra != surmd->runtime.cfra_prev + 1)) { MEM_SAFE_FREE(surmd->runtime.vert_positions_prev); MEM_SAFE_FREE(surmd->runtime.vert_velocities); - surmd->runtime.vert_positions_prev = MEM_calloc_arrayN( - mesh_verts_num, sizeof(float[3]), __func__); - surmd->runtime.vert_velocities = MEM_calloc_arrayN( - mesh_verts_num, sizeof(float[3]), __func__); + surmd->runtime.vert_positions_prev = static_cast( + MEM_calloc_arrayN(mesh_verts_num, sizeof(float[3]), __func__)); + surmd->runtime.vert_velocities = static_cast( + MEM_calloc_arrayN(mesh_verts_num, sizeof(float[3]), __func__)); surmd->runtime.verts_num = mesh_verts_num; @@ -167,7 +168,8 @@ static void deformVerts(ModifierData *md, const bool has_poly = surmd->runtime.mesh->totpoly > 0; const bool has_edge = surmd->runtime.mesh->totedge > 0; if (has_poly || has_edge) { - surmd->runtime.bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); + surmd->runtime.bvhtree = static_cast( + MEM_callocN(sizeof(BVHTreeFromMesh), __func__)); if (has_poly) { BKE_bvhtree_from_mesh_get( @@ -181,11 +183,11 @@ static void deformVerts(ModifierData *md, } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiItemL(layout, TIP_("Settings are inside the Physics tab"), ICON_NONE); @@ -197,7 +199,7 @@ static void panelRegister(ARegionType *region_type) modifier_panel_register(region_type, eModifierType_Surface, panel_draw); } -static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) +static void blendRead(BlendDataReader * /*reader*/, ModifierData *md) { SurfaceModifierData *surmd = (SurfaceModifierData *)md; @@ -217,23 +219,23 @@ ModifierTypeInfo modifierType_Surface = { /*copyData*/ copyData, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, - /*requiredDataMask*/ NULL, + /*requiredDataMask*/ nullptr, /*freeData*/ freeData, - /*isDisabled*/ NULL, - /*updateDepsgraph*/ NULL, + /*isDisabled*/ nullptr, + /*updateDepsgraph*/ nullptr, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*dependsOnNormals*/ nullptr, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, + /*blendWrite*/ nullptr, /*blendRead*/ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.cc b/source/blender/modifiers/intern/MOD_surfacedeform.cc index 7313904faf2..33f147fbcb4 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.cc +++ b/source/blender/modifiers/intern/MOD_surfacedeform.cc @@ -43,8 +43,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" struct SDefAdjacency { SDefAdjacency *next; diff --git a/source/blender/modifiers/intern/MOD_triangulate.cc b/source/blender/modifiers/intern/MOD_triangulate.cc index 182132abffe..a3ea65cf7e1 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.cc +++ b/source/blender/modifiers/intern/MOD_triangulate.cc @@ -32,8 +32,8 @@ #include "bmesh.h" #include "bmesh_tools.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.cc similarity index 95% rename from source/blender/modifiers/intern/MOD_ui_common.c rename to source/blender/modifiers/intern/MOD_ui_common.cc index c12e3d88782..75452ce5ab9 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.c +++ b/source/blender/modifiers/intern/MOD_ui_common.cc @@ -33,18 +33,18 @@ #include "WM_api.h" #include "WM_types.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" /* Self include */ +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" /* Self include */ /** * Poll function so these modifier panels don't show for other object types with modifiers (only * grease pencil currently). */ -static bool modifier_ui_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool modifier_ui_poll(const bContext *C, PanelType * /*pt*/) { Object *ob = ED_object_active_context(C); - return (ob != NULL) && (ob->type != OB_GPENCIL_LEGACY); + return (ob != nullptr) && (ob->type != OB_GPENCIL_LEGACY); } /* -------------------------------------------------------------------- */ @@ -64,18 +64,18 @@ static void modifier_reorder(bContext *C, Panel *panel, int new_index) WM_operator_properties_create_ptr(&props_ptr, ot); RNA_string_set(&props_ptr, "modifier", md->name); RNA_int_set(&props_ptr, "index", new_index); - WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, NULL); + WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr); WM_operator_properties_free(&props_ptr); } -static short get_modifier_expand_flag(const bContext *UNUSED(C), Panel *panel) +static short get_modifier_expand_flag(const bContext * /*C*/, Panel *panel) { PointerRNA *md_ptr = UI_panel_custom_data_get(panel); ModifierData *md = (ModifierData *)md_ptr->data; return md->ui_expand_flag; } -static void set_modifier_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) +static void set_modifier_expand_flag(const bContext * /*C*/, Panel *panel, short expand_flag) { PointerRNA *md_ptr = UI_panel_custom_data_get(panel); ModifierData *md = (ModifierData *)md_ptr->data; @@ -90,7 +90,7 @@ static void set_modifier_expand_flag(const bContext *UNUSED(C), Panel *panel, sh void modifier_panel_end(uiLayout *layout, PointerRNA *ptr) { - ModifierData *md = ptr->data; + ModifierData *md = static_cast(ptr->data); if (md->error) { uiLayout *row = uiLayoutRow(layout, false); uiItemL(row, TIP_(md->error), ICON_ERROR); @@ -110,7 +110,7 @@ PointerRNA *modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ BLI_assert(!RNA_pointer_is_null(ptr)); BLI_assert(RNA_struct_is_a(ptr->type, &RNA_Modifier)); - if (r_ob_ptr != NULL) { + if (r_ob_ptr != nullptr) { RNA_pointer_create(ptr->owner_id, &RNA_Object, ptr->owner_id, r_ob_ptr); } @@ -133,7 +133,7 @@ void modifier_vgroup_ui(uiLayout *layout, uiLayout *row = uiLayoutRow(layout, true); uiItemPointerR(row, ptr, vgroup_prop, ob_ptr, "vertex_groups", text, ICON_NONE); - if (invert_vgroup_prop != NULL) { + if (invert_vgroup_prop != nullptr) { uiLayout *sub = uiLayoutRow(row, true); uiLayoutSetActive(sub, has_vertex_group); uiLayoutSetPropDecorate(sub, false); @@ -254,7 +254,7 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v) "OBJECT_OT_modifier_move_to_index", IFACE_("Move to First"), ICON_TRIA_UP, - NULL, + nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); @@ -269,7 +269,7 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v) "OBJECT_OT_modifier_move_to_index", IFACE_("Move to Last"), ICON_TRIA_DOWN, - NULL, + nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); @@ -281,9 +281,9 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v) if (md->type == eModifierType_Nodes) { uiItemFullO(layout, "OBJECT_OT_geometry_nodes_move_to_nodes", - NULL, + nullptr, ICON_NONE, - NULL, + nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); @@ -302,7 +302,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel) UI_panel_context_pointer_set(panel, "modifier", ptr); - const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); + const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); Scene *scene = CTX_data_scene(C); int index = BLI_findindex(&ob->modifiers, md); @@ -453,7 +453,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel) PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw) { - PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = MEM_cnew(__func__); BKE_modifier_type_panel_id(type, panel_type->idname); BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); @@ -484,7 +484,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type, PanelDrawFn draw, PanelType *parent) { - PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = MEM_cnew(__func__); BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_%s", parent->idname, name); BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME); @@ -497,7 +497,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type, panel_type->poll = modifier_ui_poll; panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; - BLI_assert(parent != NULL); + BLI_assert(parent != nullptr); BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); diff --git a/source/blender/modifiers/intern/MOD_ui_common.h b/source/blender/modifiers/intern/MOD_ui_common.h deleted file mode 100644 index 6548a897be9..00000000000 --- a/source/blender/modifiers/intern/MOD_ui_common.h +++ /dev/null @@ -1,66 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#pragma once - -/* so modifier types match their defines */ -#include "MOD_modifiertypes.h" - -#include "DEG_depsgraph_build.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct ARegionType; -struct PanelType; -struct bContext; -struct uiLayout; -typedef void (*PanelDrawFn)(const bContext *, struct Panel *); - -void modifier_panel_buttons(const struct bContext *C, struct Panel *panel); - -/** - * Helper function for modifier layouts to draw vertex group settings. - */ -void modifier_vgroup_ui(struct uiLayout *layout, - struct PointerRNA *ptr, - struct PointerRNA *ob_ptr, - const char *vgroup_prop, - const char *invert_vgroup_prop, - const char *text); - -/** - * Draw modifier error message. - */ -void modifier_panel_end(struct uiLayout *layout, PointerRNA *ptr); - -struct PointerRNA *modifier_panel_get_property_pointers(struct Panel *panel, - struct PointerRNA *r_ob_ptr); - -/** - * Create a panel in the context's region - */ -struct PanelType *modifier_panel_register(struct ARegionType *region_type, - ModifierType type, - PanelDrawFn draw); - -/** - * Add a child panel to the parent. - * - * \note To create the panel type's #PanelType.idname, - * it appends the \a name argument to the \a parent's `idname`. - */ -struct PanelType *modifier_subpanel_register(struct ARegionType *region_type, - const char *name, - const char *label, - PanelDrawFn draw_header, - PanelDrawFn draw, - struct PanelType *parent); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/modifiers/intern/MOD_ui_common.hh b/source/blender/modifiers/intern/MOD_ui_common.hh new file mode 100644 index 00000000000..8c935dc0521 --- /dev/null +++ b/source/blender/modifiers/intern/MOD_ui_common.hh @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup modifiers + */ + +#pragma once + +/* so modifier types match their defines */ +#include "MOD_modifiertypes.hh" + +#include "DEG_depsgraph_build.h" + +struct ARegionType; +struct Panel; +struct PanelType; +struct PointerRNA; +struct bContext; +struct uiLayout; + +using PanelDrawFn = void (*)(const bContext *, Panel *); + +/** + * Helper function for modifier layouts to draw vertex group settings. + */ +void modifier_vgroup_ui(uiLayout *layout, + PointerRNA *ptr, + PointerRNA *ob_ptr, + const char *vgroup_prop, + const char *invert_vgroup_prop, + const char *text); + +/** + * Draw modifier error message. + */ +void modifier_panel_end(uiLayout *layout, PointerRNA *ptr); + +PointerRNA *modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr); + +/** + * Create a panel in the context's region + */ +PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw); + +/** + * Add a child panel to the parent. + * + * \note To create the panel type's #PanelType.idname, + * it appends the \a name argument to the \a parent's `idname`. + */ +PanelType *modifier_subpanel_register(ARegionType *region_type, + const char *name, + const char *label, + PanelDrawFn draw_header, + PanelDrawFn draw, + PanelType *parent); diff --git a/source/blender/modifiers/intern/MOD_util.cc b/source/blender/modifiers/intern/MOD_util.cc index 1e544875a7d..844c00a3ee6 100644 --- a/source/blender/modifiers/intern/MOD_util.cc +++ b/source/blender/modifiers/intern/MOD_util.cc @@ -35,8 +35,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_modifiertypes.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_util.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h deleted file mode 100644 index 5f9bd97744b..00000000000 --- a/source/blender/modifiers/intern/MOD_util.h +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#pragma once - -/* so modifier types match their defines */ -#include "MOD_modifiertypes.h" - -#include "DEG_depsgraph_build.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct MDeformVert; -struct Mesh; -struct ModifierData; -struct ModifierEvalContext; -struct Object; - -void MOD_init_texture(struct MappingInfoModifierData *dmd, const struct ModifierEvalContext *ctx); -/** - * \param cos: may be NULL, in which case we use directly mesh vertices' coordinates. - */ -void MOD_get_texture_coords(struct MappingInfoModifierData *dmd, - const struct ModifierEvalContext *ctx, - struct Object *ob, - struct Mesh *mesh, - float (*cos)[3], - float (*r_texco)[3]); - -void MOD_previous_vcos_store(struct ModifierData *md, const float (*vert_coords)[3]); - -/** - * \returns a mesh if mesh == NULL, for deforming modifiers that need it. - */ -struct Mesh *MOD_deform_mesh_eval_get(struct Object *ob, - struct BMEditMesh *em, - struct Mesh *mesh, - const float (*vertexCos)[3], - int verts_num, - bool use_orco); - -void MOD_get_vgroup(struct Object *ob, - struct Mesh *mesh, - const char *name, - const struct MDeformVert **dvert, - int *defgrp_index); - -void MOD_depsgraph_update_object_bone_relation(struct DepsNodeHandle *node, - struct Object *object, - const char *bonename, - const char *description); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/modifiers/intern/MOD_util.hh b/source/blender/modifiers/intern/MOD_util.hh new file mode 100644 index 00000000000..71fb3fc7498 --- /dev/null +++ b/source/blender/modifiers/intern/MOD_util.hh @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup modifiers + */ + +#pragma once + +/* so modifier types match their defines */ +#include "MOD_modifiertypes.hh" + +#include "DEG_depsgraph_build.h" + +struct MDeformVert; +struct Mesh; +struct ModifierData; +struct ModifierEvalContext; +struct Object; + +void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx); +/** + * \param cos: may be null, in which case we use directly mesh vertices' coordinates. + */ +void MOD_get_texture_coords(MappingInfoModifierData *dmd, + const ModifierEvalContext *ctx, + Object *ob, + Mesh *mesh, + float (*cos)[3], + float (*r_texco)[3]); + +void MOD_previous_vcos_store(ModifierData *md, const float (*vert_coords)[3]); + +/** + * \returns a mesh if mesh == null, for deforming modifiers that need it. + */ +Mesh *MOD_deform_mesh_eval_get(Object *ob, + BMEditMesh *em, + Mesh *mesh, + const float (*vertexCos)[3], + int verts_num, + bool use_orco); + +void MOD_get_vgroup( + Object *ob, Mesh *mesh, const char *name, const MDeformVert **dvert, int *defgrp_index); + +void MOD_depsgraph_update_object_bone_relation(DepsNodeHandle *node, + Object *object, + const char *bonename, + const char *description); diff --git a/source/blender/modifiers/intern/MOD_uvproject.cc b/source/blender/modifiers/intern/MOD_uvproject.cc index 4cee9d70a4e..4f992a411f1 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.cc +++ b/source/blender/modifiers/intern/MOD_uvproject.cc @@ -34,8 +34,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/modifiers/intern/MOD_uvwarp.cc b/source/blender/modifiers/intern/MOD_uvwarp.cc index a1333ee013d..035ec251077 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.cc +++ b/source/blender/modifiers/intern/MOD_uvwarp.cc @@ -35,8 +35,8 @@ #include "DEG_depsgraph_query.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void uv_warp_from_mat4_pair(float uv_dst[2], const float uv_src[2], diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index 4982669c976..4d636d0218f 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -31,8 +31,8 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "RE_texture.h" diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index 9a0e8eabe0b..9e54119cf20 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -14,8 +14,8 @@ #include "BLT_translation.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.cc similarity index 84% rename from source/blender/modifiers/intern/MOD_warp.c rename to source/blender/modifiers/intern/MOD_warp.cc index 5d10f58c464..9e4db1bf985 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.cc @@ -4,7 +4,7 @@ * \ingroup modifiers */ -#include +#include #include "MEM_guardedalloc.h" @@ -46,8 +46,8 @@ #include "RE_texture.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" static void initData(ModifierData *md) { @@ -101,7 +101,7 @@ static void matrix_from_obj_pchan(float mat[4][4], } } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md) +static bool dependsOnTime(Scene * /*scene*/, ModifierData *md) { WarpModifierData *wmd = (WarpModifierData *)md; @@ -118,9 +118,7 @@ static void freeData(ModifierData *md) BKE_curvemapping_free(wmd->curfalloff); } -static bool isDisabled(const struct Scene *UNUSED(scene), - ModifierData *md, - bool UNUSED(userRenderParams)) +static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/) { WarpModifierData *wmd = (WarpModifierData *)md; @@ -147,7 +145,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte WarpModifierData *wmd = (WarpModifierData *)md; bool need_transform_relation = false; - if (wmd->object_from != NULL && wmd->object_to != NULL) { + if (wmd->object_from != nullptr && wmd->object_to != nullptr) { MOD_depsgraph_update_object_bone_relation( ctx->node, wmd->object_from, wmd->bone_from, "Warp Modifier"); MOD_depsgraph_update_object_bone_relation( @@ -155,10 +153,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte need_transform_relation = true; } - if (wmd->texture != NULL) { + if (wmd->texture != nullptr) { DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Warp Modifier"); - if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) { + if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != nullptr) { MOD_depsgraph_update_object_bone_relation( ctx->node, wmd->map_object, wmd->map_bone, "Warp Modifier"); need_transform_relation = true; @@ -194,20 +192,20 @@ static void warpModifier_do(WarpModifierData *wmd, float fac = 1.0f, weight; int i; int defgrp_index; - const MDeformVert *dvert, *dv = NULL; + const MDeformVert *dvert, *dv = nullptr; const bool invert_vgroup = (wmd->flag & MOD_WARP_INVERT_VGROUP) != 0; - float(*tex_co)[3] = NULL; + float(*tex_co)[3] = nullptr; if (!(wmd->object_from && wmd->object_to)) { return; } MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index); - if (dvert == NULL) { + if (dvert == nullptr) { defgrp_index = -1; } - if (wmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ + if (wmd->curfalloff == nullptr) { /* should never happen, but bad lib linking could cause it */ wmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } @@ -240,8 +238,8 @@ static void warpModifier_do(WarpModifierData *wmd, weight = strength; Tex *tex_target = wmd->texture; - if (mesh != NULL && tex_target != NULL) { - tex_co = MEM_malloc_arrayN(verts_num, sizeof(*tex_co), "warpModifier_do tex_co"); + if (mesh != nullptr && tex_target != nullptr) { + tex_co = static_cast(MEM_malloc_arrayN(verts_num, sizeof(*tex_co), __func__)); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); MOD_init_texture((MappingInfoModifierData *)wmd, ctx); @@ -299,7 +297,7 @@ static void warpModifier_do(WarpModifierData *wmd, fac *= weight; if (tex_co) { - struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); TexResult texres; BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false); fac *= texres.tin; @@ -343,48 +341,48 @@ static void deformVerts(ModifierData *md, int verts_num) { WarpModifierData *wmd = (WarpModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; - if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { + if (wmd->defgrp_name[0] != '\0' || wmd->texture != nullptr) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } warpModifier_do(wmd, ctx, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *em, + BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], int verts_num) { WarpModifierData *wmd = (WarpModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; - if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { + if (wmd->defgrp_name[0] != '\0' || wmd->texture != nullptr) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, nullptr, verts_num, false); } /* TODO(@ideasman42): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } warpModifier_do(wmd, ctx, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; @@ -395,7 +393,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "object_from", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "object_from", 0, nullptr, ICON_NONE); PointerRNA from_obj_ptr = RNA_pointer_get(ptr, "object_from"); if (!RNA_pointer_is_null(&from_obj_ptr) && RNA_enum_get(&from_obj_ptr, "type") == OB_ARMATURE) { @@ -404,36 +402,36 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) } col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "object_to", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "object_to", 0, nullptr, ICON_NONE); PointerRNA to_obj_ptr = RNA_pointer_get(ptr, "object_to"); if (!RNA_pointer_is_null(&to_obj_ptr) && RNA_enum_get(&to_obj_ptr, "type") == OB_ARMATURE) { PointerRNA to_obj_data_ptr = RNA_pointer_get(&to_obj_ptr, "data"); uiItemPointerR(col, ptr, "bone_to", &to_obj_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); } - uiItemR(layout, ptr, "use_volume_preserve", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_volume_preserve", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "strength", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "strength", 0, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); modifier_panel_end(layout, ptr); } -static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void falloff_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); bool use_falloff = (RNA_enum_get(ptr, "falloff_type") != eWarp_Falloff_None); uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "falloff_type", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "falloff_type", 0, nullptr, ICON_NONE); if (use_falloff) { - uiItemR(layout, ptr, "falloff_radius", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "falloff_radius", 0, nullptr, ICON_NONE); } if (use_falloff && RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) { @@ -451,7 +449,7 @@ static void texture_panel_draw(const bContext *C, Panel *panel) int texture_coords = RNA_enum_get(ptr, "texture_coords"); - uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); + uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr); uiLayoutSetPropSep(layout, true); @@ -475,7 +473,7 @@ static void texture_panel_draw(const bContext *C, Panel *panel) } else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); - uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); + uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE); } } @@ -483,12 +481,12 @@ static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Warp, panel_draw); modifier_subpanel_register( - region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type); + region_type, "falloff", "Falloff", nullptr, falloff_panel_draw, panel_type); modifier_subpanel_register( - region_type, "texture", "Texture", NULL, texture_panel_draw, panel_type); + region_type, "texture", "Texture", nullptr, texture_panel_draw, panel_type); } -static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md) +static void blendWrite(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) { const WarpModifierData *wmd = (const WarpModifierData *)md; @@ -521,11 +519,11 @@ ModifierTypeInfo modifierType_Warp = { /*copyData*/ copyData, /*deformVerts*/ deformVerts, - /*deformMatrices*/ NULL, + /*deformMatrices*/ nullptr, /*deformVertsEM*/ deformVertsEM, - /*deformMatricesEM*/ NULL, - /*modifyMesh*/ NULL, - /*modifyGeometrySet*/ NULL, + /*deformMatricesEM*/ nullptr, + /*modifyMesh*/ nullptr, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, @@ -533,10 +531,10 @@ ModifierTypeInfo modifierType_Warp = { /*isDisabled*/ isDisabled, /*updateDepsgraph*/ updateDepsgraph, /*dependsOnTime*/ dependsOnTime, - /*dependsOnNormals*/ NULL, + /*dependsOnNormals*/ nullptr, /*foreachIDLink*/ foreachIDLink, /*foreachTexLink*/ foreachTexLink, - /*freeRuntimeData*/ NULL, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, /*blendWrite*/ blendWrite, /*blendRead*/ blendRead, diff --git a/source/blender/modifiers/intern/MOD_wave.cc b/source/blender/modifiers/intern/MOD_wave.cc index d66d4beb452..9cc50fb13e8 100644 --- a/source/blender/modifiers/intern/MOD_wave.cc +++ b/source/blender/modifiers/intern/MOD_wave.cc @@ -40,9 +40,9 @@ #include "RE_texture.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc index fb25d6eb3d2..efa96443076 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.cc +++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc @@ -33,9 +33,9 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "bmesh.h" diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.cc similarity index 93% rename from source/blender/modifiers/intern/MOD_weightvg_util.c rename to source/blender/modifiers/intern/MOD_weightvg_util.cc index e5527b0457d..5dfc38ee095 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.cc @@ -36,9 +36,9 @@ #include "DEG_depsgraph_query.h" #include "MEM_guardedalloc.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" -#include "MOD_weightvg_util.h" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" +#include "MOD_weightvg_util.hh" #include "RE_texture.h" /* Texture masking. */ void weightvg_do_map( @@ -49,7 +49,7 @@ void weightvg_do_map( /* Return immediately, if we have nothing to do! */ /* Also security checks... */ if (!do_invert && - (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL)) || !ELEM(falloff_type, + (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == nullptr)) || !ELEM(falloff_type, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH, @@ -131,7 +131,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, } /* If we want to mask vgroup weights from a texture. */ - if (texture != NULL) { + if (texture != nullptr) { /* The texture coordinates. */ float(*tex_co)[3]; /* See mapping note below... */ @@ -149,8 +149,8 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, BLI_strncpy(t_map.uvlayer_name, tex_uvlayer_name, sizeof(t_map.uvlayer_name)); t_map.texmapping = tex_mapping; - tex_co = MEM_calloc_arrayN(verts_num, sizeof(*tex_co), "WeightVG Modifier, TEX mode, tex_co"); - MOD_get_texture_coords(&t_map, ctx, ob, mesh, NULL, tex_co); + tex_co = static_cast(MEM_calloc_arrayN(verts_num, sizeof(*tex_co), __func__)); + MOD_get_texture_coords(&t_map, ctx, ob, mesh, nullptr, tex_co); MOD_init_texture(&t_map, ctx); @@ -213,9 +213,10 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, /* Proceed only if vgroup is valid, else use constant factor. */ /* Get actual dverts (ie vertex group data). */ - const MDeformVert *dvert = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT); + const MDeformVert *dvert = static_cast( + CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT)); /* Proceed only if vgroup is valid, else assume factor = O. */ - if (dvert == NULL) { + if (dvert == nullptr) { return; } @@ -283,7 +284,7 @@ void weightvg_update_vg(MDeformVert *dvert, float w = weights[i]; MDeformVert *dv = &dvert[indices ? indices[i] : i]; MDeformWeight *dw = dws ? dws[i] : - ((defgrp_idx >= 0) ? BKE_defvert_find_index(dv, defgrp_idx) : NULL); + ((defgrp_idx >= 0) ? BKE_defvert_find_index(dv, defgrp_idx) : nullptr); if (do_normalize) { w = (w - min_w) * norm_fac; @@ -292,7 +293,7 @@ void weightvg_update_vg(MDeformVert *dvert, CLAMP(w, 0.0f, 1.0f); /* If the vertex is in this vgroup, remove it if needed, or just update it. */ - if (dw != NULL) { + if (dw != nullptr) { if (do_rem && w < rem_thresh) { BKE_defvert_remove_group(dv, dw); } @@ -319,7 +320,7 @@ void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiItemR(layout, ptr, "mask_constant", UI_ITEM_R_SLIDER, IFACE_("Global Influence:"), ICON_NONE); if (!has_mask_texture) { - modifier_vgroup_ui(layout, ptr, ob_ptr, "mask_vertex_group", "invert_mask_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, ob_ptr, "mask_vertex_group", "invert_mask_vertex_group", nullptr); } if (!has_mask_vertex_group) { @@ -328,15 +329,15 @@ void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, ptr, "mask_texture", "texture.new", - NULL, - NULL, + nullptr, + nullptr, 0, ICON_NONE, IFACE_("Mask Texture")); if (has_mask_texture) { uiItemR(layout, ptr, "mask_tex_use_channel", 0, IFACE_("Channel"), ICON_NONE); - uiItemR(layout, ptr, "mask_tex_mapping", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "mask_tex_mapping", 0, nullptr, ICON_NONE); if (mask_tex_mapping == MOD_DISP_MAP_OBJECT) { uiItemR(layout, ptr, "mask_tex_map_object", 0, IFACE_("Object"), ICON_NONE); @@ -344,7 +345,7 @@ void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, else if (mask_tex_mapping == MOD_DISP_MAP_UV && RNA_enum_get(ob_ptr, "type") == OB_MESH) { PointerRNA obj_data_ptr = RNA_pointer_get(ob_ptr, "data"); uiItemPointerR( - layout, ptr, "mask_tex_uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); + layout, ptr, "mask_tex_uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE); } } } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.hh similarity index 87% rename from source/blender/modifiers/intern/MOD_weightvg_util.h rename to source/blender/modifiers/intern/MOD_weightvg_util.hh index f6ff03fae18..2d7aea09cb1 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.h +++ b/source/blender/modifiers/intern/MOD_weightvg_util.hh @@ -7,10 +7,6 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - struct CurveMapping; struct MDeformVert; struct MDeformWeight; @@ -49,12 +45,8 @@ struct uiLayout; * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...). * cmap might be NULL, in which case curve mapping mode will return unmodified data. */ -void weightvg_do_map(int num, - float *new_w, - short falloff_type, - bool do_invert, - struct CurveMapping *cmap, - struct RNG *rng); +void weightvg_do_map( + int num, float *new_w, short falloff_type, bool do_invert, CurveMapping *cmap, RNG *rng); /** * Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor. @@ -70,10 +62,10 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, float *org_w, const float *new_w, Object *ob, - struct Mesh *mesh, + Mesh *mesh, float fact, const char defgrp_name[MAX_VGROUP_NAME], - struct Scene *scene, + Scene *scene, Tex *texture, int tex_use_channel, int tex_mapping, @@ -89,9 +81,9 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, * If indices is not NULL, it must be an array of same length as weights, mapping to the real * vertex index (in case the weight array does not cover the whole vertices...). */ -void weightvg_update_vg(struct MDeformVert *dvert, +void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, - struct MDeformWeight **dws, + MDeformWeight **dws, int num, const int *indices, const float *weights, @@ -105,7 +97,3 @@ void weightvg_update_vg(struct MDeformVert *dvert, * Common vertex weight mask interface elements for the modifier panels. */ void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiLayout *layout); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.cc b/source/blender/modifiers/intern/MOD_weightvgedit.cc index e5b0e830fe9..dbd4b66bcf7 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.cc +++ b/source/blender/modifiers/intern/MOD_weightvgedit.cc @@ -45,10 +45,10 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" -#include "MOD_weightvg_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" +#include "MOD_weightvg_util.hh" /************************************** * Modifiers functions. * diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.cc b/source/blender/modifiers/intern/MOD_weightvgmix.cc index 370eff8b8de..82bd0df99f6 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.cc +++ b/source/blender/modifiers/intern/MOD_weightvgmix.cc @@ -39,10 +39,10 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" -#include "MOD_weightvg_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" +#include "MOD_weightvg_util.hh" /** * This mixes the old weight with the new weight factor. diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.cc b/source/blender/modifiers/intern/MOD_weightvgproximity.cc index c1923056efb..9f6e7d7b7aa 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.cc +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.cc @@ -50,10 +50,10 @@ #include "MEM_guardedalloc.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" -#include "MOD_util.h" -#include "MOD_weightvg_util.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" +#include "MOD_util.hh" +#include "MOD_weightvg_util.hh" //#define USE_TIMEIT diff --git a/source/blender/modifiers/intern/MOD_weld.cc b/source/blender/modifiers/intern/MOD_weld.cc index 0d91e0809d2..e64bb55e43f 100644 --- a/source/blender/modifiers/intern/MOD_weld.cc +++ b/source/blender/modifiers/intern/MOD_weld.cc @@ -41,8 +41,8 @@ #include "DEG_depsgraph.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "GEO_mesh_merge_by_distance.hh" diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.cc similarity index 72% rename from source/blender/modifiers/intern/MOD_wireframe.c rename to source/blender/modifiers/intern/MOD_wireframe.cc index 8339e1cea76..1841dcb7065 100644 --- a/source/blender/modifiers/intern/MOD_wireframe.c +++ b/source/blender/modifiers/intern/MOD_wireframe.cc @@ -4,7 +4,7 @@ * \ingroup modifiers */ -#include +#include #include "BLI_utildefines.h" @@ -26,8 +26,8 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_modifiertypes.h" -#include "MOD_ui_common.h" +#include "MOD_modifiertypes.hh" +#include "MOD_ui_common.hh" #include "bmesh.h" #include "tools/bmesh_wireframe.h" @@ -51,7 +51,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma } } -static bool dependsOnNormals(ModifierData *UNUSED(md)) +static bool dependsOnNormals(ModifierData * /*md*/) { return true; } @@ -63,18 +63,18 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh * const int defgrp_index = BKE_id_defgroup_name_index(&mesh->id, wmd->defgrp_name); - bm = BKE_mesh_to_bmesh_ex(mesh, - &(struct BMeshCreateParams){0}, - &(struct BMeshFromMeshParams){ - .calc_face_normal = true, - .calc_vert_normal = true, - .add_key_index = false, - .use_shapekey = false, - .active_shapekey = 0, - .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, - .emask = CD_MASK_ORIGINDEX, - .pmask = CD_MASK_ORIGINDEX}, - }); + BMeshCreateParams create_params{}; + BMeshFromMeshParams convert_params{}; + convert_params.calc_face_normal = true; + convert_params.calc_vert_normal = true; + convert_params.add_key_index = false; + convert_params.use_shapekey = false; + convert_params.active_shapekey = 0; + convert_params.cd_mask_extra.vmask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.emask = CD_MASK_ORIGINDEX; + convert_params.cd_mask_extra.pmask = CD_MASK_ORIGINDEX; + + bm = BKE_mesh_to_bmesh_ex(mesh, &create_params, &convert_params); BM_mesh_wireframe(bm, wmd->offset, @@ -92,18 +92,18 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh * MAX2(ob->totcol - 1, 0), false); - result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); + result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh); BM_mesh_free(bm); return result; } -static Mesh *modifyMesh(ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh) +static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { return WireframeModifier_do((WireframeModifierData *)md, ctx->object, mesh); } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *col, *row, *sub; uiLayout *layout = panel->layout; @@ -114,7 +114,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); uiItemR(layout, ptr, "thickness", 0, IFACE_("Thickness"), ICON_NONE); - uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_boundary", 0, IFACE_("Boundary"), ICON_NONE); @@ -135,7 +135,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) modifier_panel_end(layout, ptr); } -static void vertex_group_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void vertex_group_panel_draw(const bContext * /*C*/, Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; @@ -147,7 +147,7 @@ static void vertex_group_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); row = uiLayoutRow(layout, true); uiLayoutSetActive(row, has_vertex_group); @@ -159,7 +159,7 @@ static void panelRegister(ARegionType *region_type) PanelType *panel_type = modifier_panel_register( region_type, eModifierType_Wireframe, panel_draw); modifier_subpanel_register( - region_type, "vertex_group", "Vertex Group", NULL, vertex_group_panel_draw, panel_type); + region_type, "vertex_group", "Vertex Group", nullptr, vertex_group_panel_draw, panel_type); } ModifierTypeInfo modifierType_Wireframe = { @@ -173,24 +173,24 @@ ModifierTypeInfo modifierType_Wireframe = { /*copyData*/ BKE_modifier_copydata_generic, - /*deformVerts*/ NULL, - /*deformMatrices*/ NULL, - /*deformVertsEM*/ NULL, - /*deformMatricesEM*/ NULL, + /*deformVerts*/ nullptr, + /*deformMatrices*/ nullptr, + /*deformVertsEM*/ nullptr, + /*deformMatricesEM*/ nullptr, /*modifyMesh*/ modifyMesh, - /*modifyGeometrySet*/ NULL, + /*modifyGeometrySet*/ nullptr, /*initData*/ initData, /*requiredDataMask*/ requiredDataMask, - /*freeData*/ NULL, - /*isDisabled*/ NULL, - /*updateDepgraph*/ NULL, - /*dependsOnTime*/ NULL, + /*freeData*/ nullptr, + /*isDisabled*/ nullptr, + /*updateDepgraph*/ nullptr, + /*dependsOnTime*/ nullptr, /*dependsOnNormals*/ dependsOnNormals, - /*foreachIDLink*/ NULL, - /*foreachTexLink*/ NULL, - /*freeRuntimeData*/ NULL, + /*foreachIDLink*/ nullptr, + /*foreachTexLink*/ nullptr, + /*freeRuntimeData*/ nullptr, /*panelRegister*/ panelRegister, - /*blendWrite*/ NULL, - /*blendRead*/ NULL, + /*blendWrite*/ nullptr, + /*blendRead*/ nullptr, };