diff options
author | Hans Goudey <h.goudey@me.com> | 2022-10-02 19:16:14 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-10-02 19:17:40 +0300 |
commit | 15e6673ccdc39a20e3b2821dbe0cb0ade61bc4e5 (patch) | |
tree | 3403890bc9ca3eb15d757f7961bbe290f81dfe2b /source | |
parent | ed6764dedeeada8d705594e962e2e7e254bb5c4a (diff) |
Cleanup: Move three modifier files to C++
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.h | 8 | ||||
-rw-r--r-- | source/blender/modifiers/CMakeLists.txt | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_datatransfer.cc (renamed from source/blender/modifiers/intern/MOD_datatransfer.c) | 100 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_normal_edit.cc (renamed from source/blender/modifiers/intern/MOD_normal_edit.c) | 96 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_subsurf.cc (renamed from source/blender/modifiers/intern/MOD_subsurf.c) | 80 |
5 files changed, 155 insertions, 135 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index 863a0a2eb91..218f2c58470 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -6,6 +6,10 @@ * \ingroup bke */ +#ifdef __cplusplus +extern "C" { +#endif + typedef void *CCGMeshHDL; typedef void *CCGVertHDL; typedef void *CCGEdgeHDL; @@ -215,3 +219,7 @@ void ccgEdgeIterator_next(CCGEdgeIterator *ei); CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *fi); int ccgFaceIterator_isStopped(CCGFaceIterator *fi); void ccgFaceIterator_next(CCGFaceIterator *fi); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index a982a181ed7..90ae3c8093c 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -43,7 +43,7 @@ set(SRC intern/MOD_collision.c intern/MOD_correctivesmooth.c intern/MOD_curve.c - intern/MOD_datatransfer.c + intern/MOD_datatransfer.cc intern/MOD_decimate.c intern/MOD_displace.c intern/MOD_dynamicpaint.c @@ -66,7 +66,7 @@ set(SRC intern/MOD_multires.c intern/MOD_nodes.cc intern/MOD_none.c - intern/MOD_normal_edit.c + intern/MOD_normal_edit.cc intern/MOD_ocean.c intern/MOD_particleinstance.c intern/MOD_particlesystem.cc @@ -81,7 +81,7 @@ set(SRC intern/MOD_solidify.c intern/MOD_solidify_extrude.c intern/MOD_solidify_nonmanifold.c - intern/MOD_subsurf.c + intern/MOD_subsurf.cc intern/MOD_surface.c intern/MOD_surfacedeform.c intern/MOD_triangulate.c diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.cc index 613d3d5196f..2a686c772ea 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.cc @@ -50,7 +50,7 @@ static void initData(ModifierData *md) DataTransferModifierData *dtmd = (DataTransferModifierData *)md; int i; - dtmd->ob_source = NULL; + dtmd->ob_source = nullptr; dtmd->data_types = 0; dtmd->vmap_mode = MREMAP_MODE_VERT_NEAREST; @@ -115,7 +115,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { DataTransferModifierData *dtmd = (DataTransferModifierData *)md; - if (dtmd->ob_source != NULL) { + if (dtmd->ob_source != nullptr) { CustomData_MeshMasks cddata_masks = {0}; BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, &cddata_masks); BKE_mesh_remap_calc_source_cddata_masks_from_map_modes( @@ -159,7 +159,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * ReportList reports; /* Only used to check whether we are operating on org data or not... */ - Mesh *me = ctx->object->data; + const Mesh *me = static_cast<const Mesh *>(ctx->object->data); Object *ob_source = dtmd->ob_source; @@ -171,7 +171,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * SpaceTransform space_transform_data; SpaceTransform *space_transform = (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) ? &space_transform_data : - NULL; + nullptr; if (space_transform) { BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, ob_source); @@ -186,7 +186,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * (dtmd->data_types & DT_TYPES_AFFECT_MESH)) { /* We need to duplicate data here, otherwise setting custom normals, edges' sharpness, etc., * could modify org mesh, see T43671. */ - result = (Mesh *)BKE_id_copy_ex(NULL, &me_mod->id, NULL, LIB_ID_COPY_LOCALIZE); + result = (Mesh *)BKE_id_copy_ex(nullptr, &me_mod->id, nullptr, LIB_ID_COPY_LOCALIZE); } BKE_reports_init(&reports, RPT_STORE); @@ -247,7 +247,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropDecorate(sub, false); uiItemR(sub, ptr, "use_object_transform", 0, "", ICON_ORIENTATION_GLOBAL); - uiItemR(layout, ptr, "mix_mode", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "mix_mode", 0, nullptr, ICON_NONE); row = uiLayoutRow(layout, false); uiLayoutSetActive(row, @@ -255,9 +255,9 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) CDT_MIX_NOMIX, CDT_MIX_REPLACE_ABOVE_THRESHOLD, CDT_MIX_REPLACE_BELOW_THRESHOLD)); - uiItemR(row, ptr, "mix_factor", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "mix_factor", 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); uiItemO(layout, IFACE_("Generate Data Layers"), ICON_NONE, "OBJECT_OT_datalayout_transfer"); @@ -266,22 +266,22 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) static void vertex_panel_draw_header(const bContext *UNUSED(C), Panel *panel) { - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiLayout *layout = panel->layout; - uiItemR(layout, ptr, "use_vert_data", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_vert_data", 0, nullptr, ICON_NONE); } static void vertex_panel_draw(const bContext *UNUSED(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_vert_data = RNA_boolean_get(ptr, "use_vert_data"); uiLayoutSetActive(layout, use_vert_data); - uiItemR(layout, ptr, "data_types_verts", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "data_types_verts", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -292,7 +292,7 @@ static void vertex_vgroup_panel_draw(const bContext *UNUSED(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); uiLayoutSetActive(layout, RNA_enum_get(ptr, "data_types_verts") & DT_TYPE_MDEFORMVERT); @@ -306,20 +306,20 @@ static void edge_panel_draw_header(const bContext *UNUSED(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, "use_edge_data", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_edge_data", 0, nullptr, ICON_NONE); } static void edge_panel_draw(const bContext *UNUSED(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); uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_edge_data")); - uiItemR(layout, ptr, "data_types_edges", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "data_types_edges", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -330,20 +330,20 @@ static void face_corner_panel_draw_header(const bContext *UNUSED(C), Panel *pane { 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, "use_loop_data", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_loop_data", 0, nullptr, ICON_NONE); } static void face_corner_panel_draw(const bContext *UNUSED(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); uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_loop_data")); - uiItemR(layout, ptr, "data_types_loops", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "data_types_loops", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -354,7 +354,7 @@ static void vert_vcol_panel_draw(const bContext *UNUSED(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); uiLayoutSetPropSep(layout, true); @@ -370,7 +370,7 @@ static void face_corner_vcol_panel_draw(const bContext *UNUSED(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); uiLayoutSetPropSep(layout, true); @@ -386,7 +386,7 @@ static void face_corner_uv_panel_draw(const bContext *UNUSED(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); uiLayoutSetPropSep(layout, true); @@ -394,27 +394,27 @@ static void face_corner_uv_panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(layout, ptr, "layers_uv_select_src", 0, IFACE_("Layer Selection"), ICON_NONE); uiItemR(layout, ptr, "layers_uv_select_dst", 0, IFACE_("Layer Mapping"), ICON_NONE); - uiItemR(layout, ptr, "islands_precision", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "islands_precision", 0, nullptr, ICON_NONE); } static void face_panel_draw_header(const bContext *UNUSED(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, "use_poly_data", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_poly_data", 0, nullptr, ICON_NONE); } static void face_panel_draw(const bContext *UNUSED(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); uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_poly_data")); - uiItemR(layout, ptr, "data_types_polys", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "data_types_polys", 0, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -426,7 +426,7 @@ static void advanced_panel_draw(const bContext *UNUSED(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); @@ -436,7 +436,7 @@ static void advanced_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max_distance")); uiItemR(sub, ptr, "max_distance", 0, "", ICON_NONE); - uiItemR(layout, ptr, "ray_radius", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "ray_radius", 0, nullptr, ICON_NONE); } static void panelRegister(ARegionType *region_type) @@ -445,11 +445,15 @@ static void panelRegister(ARegionType *region_type) region_type, eModifierType_DataTransfer, panel_draw); PanelType *vertex_panel = modifier_subpanel_register( region_type, "vertex", "", vertex_panel_draw_header, vertex_panel_draw, panel_type); - modifier_subpanel_register( - region_type, "vertex_vgroup", "Vertex Groups", NULL, vertex_vgroup_panel_draw, vertex_panel); + modifier_subpanel_register(region_type, + "vertex_vgroup", + "Vertex Groups", + nullptr, + vertex_vgroup_panel_draw, + vertex_panel); modifier_subpanel_register( - region_type, "vert_vcol", "Colors", NULL, vert_vcol_panel_draw, vertex_panel); + region_type, "vert_vcol", "Colors", nullptr, vert_vcol_panel_draw, vertex_panel); modifier_subpanel_register( region_type, "edge", "", edge_panel_draw_header, edge_panel_draw, panel_type); @@ -463,16 +467,16 @@ static void panelRegister(ARegionType *region_type) modifier_subpanel_register(region_type, "face_corner_vcol", "Colors", - NULL, + nullptr, face_corner_vcol_panel_draw, face_corner_panel); modifier_subpanel_register( - region_type, "face_corner_uv", "UVs", NULL, face_corner_uv_panel_draw, face_corner_panel); + region_type, "face_corner_uv", "UVs", nullptr, face_corner_uv_panel_draw, face_corner_panel); modifier_subpanel_register( region_type, "face", "", face_panel_draw_header, face_panel_draw, panel_type); modifier_subpanel_register( - region_type, "advanced", "Topology Mapping", NULL, advanced_panel_draw, panel_type); + region_type, "advanced", "Topology Mapping", nullptr, advanced_panel_draw, panel_type); } #undef DT_TYPES_AFFECT_MESH @@ -489,24 +493,24 @@ ModifierTypeInfo modifierType_DataTransfer = { /* 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, + /* 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_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.cc index 24a1e743ee7..91d8688ce2d 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -56,15 +56,15 @@ static void generate_vert_coordinates(Mesh *mesh, const MVert *mv = BKE_mesh_verts(mesh); for (int i = 0; i < mesh->totvert; i++, mv++) { copy_v3_v3(r_cos[i], mv->co); - if (r_size != NULL && ob_center == NULL) { + if (r_size != nullptr && ob_center == nullptr) { minmax_v3v3_v3(min_co, max_co, r_cos[i]); } } /* Get size (i.e. deformation of the spheroid generating normals), * either from target object, or own geometry. */ - if (r_size != NULL) { - if (ob_center != NULL) { + if (r_size != nullptr) { + if (ob_center != nullptr) { /* Using 'scale' as 'size' here. The input object is typically an empty * who's scale is used to define an ellipsoid instead of a simple sphere. */ @@ -88,7 +88,7 @@ static void generate_vert_coordinates(Mesh *mesh, } } - if (ob_center != NULL) { + if (ob_center != nullptr) { float inv_obmat[4][4]; /* Translate our coordinates so that center of ob_center is at (0, 0, 0). */ @@ -100,7 +100,7 @@ static void generate_vert_coordinates(Mesh *mesh, do_diff = true; } - else if (offset != NULL && !is_zero_v3(offset)) { + else if (offset != nullptr && !is_zero_v3(offset)) { negate_v3_v3(diff, offset); do_diff = true; @@ -129,12 +129,12 @@ static void mix_normals(const float mix_factor, const int loops_num) { /* Mix with org normals... */ - float *facs = NULL, *wfac; + float *facs = nullptr, *wfac; float(*no_new)[3], (*no_old)[3]; int i; if (dvert) { - facs = MEM_malloc_arrayN((size_t)loops_num, sizeof(*facs), __func__); + facs = static_cast<float *>(MEM_malloc_arrayN((size_t)loops_num, sizeof(*facs), __func__)); BKE_defvert_extract_vgroup_to_loopweights( dvert, defgrp_index, verts_num, mloop, loops_num, use_invert_vgroup, facs); } @@ -180,7 +180,7 @@ static bool polygons_check_flip(MLoop *mloop, const int polys_num) { const MPoly *mp; - MDisps *mdisp = CustomData_get_layer(ldata, CD_MDISPS); + MDisps *mdisp = static_cast<MDisps *>(CustomData_get_layer(ldata, CD_MDISPS)); int i; bool flipped = false; @@ -235,8 +235,10 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; int i; - float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); - float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); + float(*cos)[3] = static_cast<float(*)[3]>( + MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__)); + float(*nos)[3] = static_cast<float(*)[3]>( + MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__)); float size[3]; BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); @@ -372,7 +374,8 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; - float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); + float(*nos)[3] = static_cast<float(*)[3]>( + MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__)); float target_co[3]; int i; @@ -395,8 +398,9 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, } } else { - float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); - generate_vert_coordinates(mesh, ob, ob_target, NULL, verts_num, cos, NULL); + float(*cos)[3] = static_cast<float(*)[3]>( + MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__)); + generate_vert_coordinates(mesh, ob, ob_target, nullptr, verts_num, cos, nullptr); BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); const MLoop *ml; @@ -513,7 +517,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, /* We need to duplicate data here, otherwise setting custom normals * (which may also affect sharp edges) could * modify original mesh, see T43671. */ - result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE); + result = (Mesh *)BKE_id_copy_ex(nullptr, &mesh->id, nullptr, LIB_ID_COPY_LOCALIZE); } else { result = mesh; @@ -531,17 +535,19 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, int defgrp_index; const MDeformVert *dvert; - float(*loopnors)[3] = NULL; + float(*loopnors)[3] = nullptr; CustomData *ldata = &result->ldata; const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(result); const float(*poly_normals)[3] = BKE_mesh_poly_normals_ensure(result); - short(*clnors)[2] = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); + short(*clnors)[2] = static_cast<short(*)[2]>(CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL)); if (use_current_clnors) { - clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, loops_num); - loopnors = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loopnors), __func__); + clnors = static_cast<short(*)[2]>( + CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, loops_num)); + loopnors = static_cast<float(*)[3]>( + MEM_malloc_arrayN((size_t)loops_num, sizeof(*loopnors), __func__)); BKE_mesh_normals_loop_split(verts, vert_normals, @@ -556,13 +562,14 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, polys_num, true, result->smoothresh, - NULL, + nullptr, clnors, - NULL); + nullptr); } - if (clnors == NULL) { - clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num); + if (clnors == nullptr) { + clnors = static_cast<short(*)[2]>( + CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, loops_num)); } MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index); @@ -687,15 +694,15 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) int mode = RNA_enum_get(ptr, "mode"); - uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "target", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, mode == MOD_NORMALEDIT_MODE_DIRECTIONAL); - uiItemR(col, ptr, "use_direction_parallel", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_direction_parallel", 0, nullptr, ICON_NONE); modifier_panel_end(layout, ptr); } @@ -711,13 +718,13 @@ static void mix_mode_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "mix_mode", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "mix_factor", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "mix_mode", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "mix_factor", 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); row = uiLayoutRow(layout, true); - uiItemR(row, ptr, "mix_limit", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "mix_limit", 0, nullptr, ICON_NONE); uiItemR(row, ptr, "no_polynors_fix", @@ -730,7 +737,7 @@ static void offset_panel_draw(const bContext *UNUSED(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); int mode = RNA_enum_get(ptr, "mode"); PointerRNA target_ptr = RNA_pointer_get(ptr, "target"); @@ -742,15 +749,16 @@ static void offset_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); uiLayoutSetActive(layout, needs_object_offset); - uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE); } static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register( region_type, eModifierType_NormalEdit, panel_draw); - modifier_subpanel_register(region_type, "mix", "Mix", NULL, mix_mode_panel_draw, panel_type); - modifier_subpanel_register(region_type, "offset", "Offset", NULL, offset_panel_draw, panel_type); + modifier_subpanel_register(region_type, "mix", "Mix", nullptr, mix_mode_panel_draw, panel_type); + modifier_subpanel_register( + region_type, "offset", "Offset", nullptr, offset_panel_draw, panel_type); } ModifierTypeInfo modifierType_NormalEdit = { @@ -765,24 +773,24 @@ ModifierTypeInfo modifierType_NormalEdit = { /* 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, + /* 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_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.cc index 95bbc5ea8cc..ab2f07513d2 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.cc @@ -91,16 +91,16 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla BKE_modifier_copydata_generic(md, target, flag); - tsmd->emCache = tsmd->mCache = NULL; + tsmd->emCache = tsmd->mCache = nullptr; } static void freeRuntimeData(void *runtime_data_v) { - if (runtime_data_v == NULL) { + if (runtime_data_v == nullptr) { return; } SubsurfRuntimeData *runtime_data = (SubsurfRuntimeData *)runtime_data_v; - if (runtime_data->subdiv != NULL) { + if (runtime_data->subdiv != nullptr) { BKE_subdiv_free(runtime_data->subdiv); } MEM_freeN(runtime_data); @@ -111,12 +111,12 @@ static void freeData(ModifierData *md) SubsurfModifierData *smd = (SubsurfModifierData *)md; if (smd->mCache) { - ccgSubSurf_free(smd->mCache); - smd->mCache = NULL; + ccgSubSurf_free(static_cast<CCGSubSurf *>(smd->mCache)); + smd->mCache = nullptr; } if (smd->emCache) { - ccgSubSurf_free(smd->emCache); - smd->emCache = NULL; + ccgSubSurf_free(static_cast<CCGSubSurf *>(smd->emCache)); + smd->emCache = nullptr; } freeRuntimeData(smd->modifier.runtime); } @@ -235,7 +235,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Same check as in `DRW_mesh_batch_cache_create_requested` to keep both code coherent. The * difference is that here we do not check for the final edit mesh pointer as it is not yet * assigned at this stage of modifier stack evaluation. */ - const bool is_editmode = (mesh->edit_mesh != NULL); + const bool is_editmode = (mesh->edit_mesh != nullptr); const int required_mode = BKE_subsurf_modifier_eval_required_mode(is_render_mode, is_editmode); if (BKE_subsurf_modifier_can_do_gpu_subdiv(scene, ctx->object, mesh, smd, required_mode)) { subdiv_cache_mesh_wrapper_settings(ctx, mesh, smd, runtime_data); @@ -244,7 +244,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(runtime_data, mesh, false); - if (subdiv == NULL) { + if (subdiv == nullptr) { /* Happens on bad topology, but also on empty input mesh. */ return result; } @@ -265,8 +265,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } if (use_clnors) { - float(*lnors)[3] = CustomData_get_layer(&result->ldata, CD_NORMAL); - BLI_assert(lnors != NULL); + float(*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&result->ldata, CD_NORMAL)); + BLI_assert(lnors != nullptr); BKE_mesh_set_custom_normals(result, lnors); CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); @@ -299,7 +299,7 @@ static void deformMatrices(ModifierData *md, } SubsurfRuntimeData *runtime_data = (SubsurfRuntimeData *)smd->modifier.runtime; Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(runtime_data, mesh, false); - if (subdiv == NULL) { + if (subdiv == nullptr) { /* Happens on bad topology, but also on empty input mesh. */ return; } @@ -319,9 +319,9 @@ static bool get_show_adaptive_options(const bContext *C, Panel *panel) } /* Only show adaptive options if this is the last modifier. */ - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); - ModifierData *md = ptr->data; - if (md->next != NULL) { + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); + ModifierData *md = static_cast<ModifierData *>(ptr->data); + if (md->next != nullptr) { return false; } @@ -350,8 +350,8 @@ static void panel_draw(const bContext *C, Panel *panel) /* Only test for adaptive subdivision if built with cycles. */ bool show_adaptive_options = false; bool ob_use_adaptive_subdivision = false; - PointerRNA cycles_ptr = {NULL}; - PointerRNA ob_cycles_ptr = {NULL}; + PointerRNA cycles_ptr = {nullptr}; + PointerRNA ob_cycles_ptr = {nullptr}; #ifdef WITH_CYCLES PointerRNA scene_ptr; Scene *scene = CTX_data_scene(C); @@ -368,7 +368,7 @@ static void panel_draw(const bContext *C, Panel *panel) UNUSED_VARS(C); #endif - uiItemR(layout, ptr, "subdivision_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "subdivision_type", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -381,7 +381,7 @@ static void panel_draw(const bContext *C, Panel *panel) ICON_NONE); } if (ob_use_adaptive_subdivision && show_adaptive_options) { - uiItemR(layout, &ob_cycles_ptr, "dicing_rate", 0, NULL, ICON_NONE); + uiItemR(layout, &ob_cycles_ptr, "dicing_rate", 0, nullptr, ICON_NONE); float render = MAX2(RNA_float_get(&cycles_ptr, "dicing_rate") * RNA_float_get(&ob_cycles_ptr, "dicing_rate"), 0.1f); @@ -406,11 +406,11 @@ static void panel_draw(const bContext *C, Panel *panel) uiItemR(col, ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); } - uiItemR(layout, ptr, "show_only_control_edges", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "show_only_control_edges", 0, nullptr, ICON_NONE); - SubsurfModifierData *smd = ptr->data; - Object *ob = ob_ptr.data; - Mesh *mesh = ob->data; + SubsurfModifierData *smd = static_cast<SubsurfModifierData *>(ptr->data); + const Object *ob = static_cast<const Object *>(ob_ptr.data); + const Mesh *mesh = static_cast<const Mesh *>(ob->data); if (BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(smd, mesh)) { uiItemL(layout, "Autosmooth or custom normals detected, disabling GPU subdivision", ICON_INFO); } @@ -443,30 +443,30 @@ static void advanced_panel_draw(const bContext *C, Panel *panel) uiLayoutSetPropSep(layout, true); uiLayoutSetActive(layout, !(show_adaptive_options && ob_use_adaptive_subdivision)); - uiItemR(layout, ptr, "use_limit_surface", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_limit_surface", 0, nullptr, ICON_NONE); uiLayout *col = uiLayoutColumn(layout, true); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_limit_surface")); - uiItemR(col, ptr, "quality", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "quality", 0, nullptr, ICON_NONE); - uiItemR(layout, ptr, "uv_smooth", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "boundary_smooth", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_creases", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_custom_normals", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "uv_smooth", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "boundary_smooth", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "use_creases", 0, nullptr, ICON_NONE); + uiItemR(layout, ptr, "use_custom_normals", 0, nullptr, ICON_NONE); } static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Subsurf, panel_draw); modifier_subpanel_register( - region_type, "advanced", "Advanced", NULL, advanced_panel_draw, panel_type); + region_type, "advanced", "Advanced", nullptr, advanced_panel_draw, panel_type); } static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) { SubsurfModifierData *smd = (SubsurfModifierData *)md; - smd->emCache = smd->mCache = NULL; + smd->emCache = smd->mCache = nullptr; } ModifierTypeInfo modifierType_Subsurf = { @@ -482,24 +482,24 @@ ModifierTypeInfo modifierType_Subsurf = { /* copyData */ copyData, - /* deformVerts */ NULL, + /* deformVerts */ nullptr, /* deformMatrices */ deformMatrices, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, + /* 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, + /* foreachIDLink */ nullptr, + /* foreachTexLink */ nullptr, /* freeRuntimeData */ freeRuntimeData, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, + /* blendWrite */ nullptr, /* blendRead */ blendRead, }; |