From 548a2cbe06b23d90b0e09da49fc854178c270b8a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 5 Oct 2022 13:44:02 -0500 Subject: Cleanup: Clang tidy Also remove unnecessary struct keywords in C++ files. --- source/blender/blenkernel/BKE_idprop.hh | 2 +- source/blender/blenkernel/BKE_mball.h | 2 +- .../blender/blenkernel/intern/editmesh_tangent.cc | 20 +-- .../blender/blenkernel/intern/geometry_fields.cc | 11 +- .../blender/blenkernel/intern/mball_tessellate.cc | 60 +++---- source/blender/blenkernel/intern/mesh_mapping.cc | 58 +++---- source/blender/blenkernel/intern/mesh_tangent.cc | 52 +++--- source/blender/blenkernel/intern/modifier.cc | 6 +- source/blender/blenkernel/intern/node.cc | 12 +- .../blender/blenkernel/intern/outliner_treehash.cc | 7 +- source/blender/blenkernel/intern/paint.cc | 41 +++-- source/blender/blenkernel/intern/subdiv_mesh.cc | 8 +- source/blender/blenkernel/intern/viewer_path.cc | 44 ++--- source/blender/blenkernel/intern/workspace.cc | 6 +- source/blender/blenloader/intern/blend_validate.cc | 2 +- source/blender/blenloader/intern/readblenentry.cc | 49 +++--- source/blender/blenloader/intern/readfile.cc | 116 +++++++------ source/blender/blenloader/intern/versioning_300.cc | 17 +- .../blender/blenloader/intern/versioning_common.cc | 4 +- source/blender/blenloader/intern/writefile.cc | 36 ++-- .../draw/engines/eevee_next/eevee_engine.cc | 4 +- .../draw/engines/overlay/overlay_antialiasing.cc | 16 +- .../draw/engines/overlay/overlay_armature.cc | 32 ++-- .../draw/engines/overlay/overlay_edit_uv.cc | 6 +- .../blender/draw/engines/overlay/overlay_engine.cc | 2 +- .../blender/draw/engines/overlay/overlay_extra.cc | 22 +-- .../draw/intern/draw_cache_impl_pointcloud.cc | 2 +- source/blender/draw/intern/draw_manager_data.cc | 43 +++-- source/blender/draw/intern/draw_pbvh.cc | 24 ++- .../editors/gpencil/gpencil_bake_animation.cc | 4 +- source/blender/editors/include/ED_uvedit.h | 6 +- source/blender/editors/interface/interface_ops.cc | 2 +- source/blender/editors/mesh/editmesh_select.cc | 44 ++--- source/blender/editors/mesh/mesh_data.cc | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 16 +- .../editors/sculpt_paint/sculpt_automasking.cc | 2 +- .../editors/sculpt_paint/sculpt_face_set.cc | 20 ++- .../blender/editors/sculpt_paint/sculpt_intern.h | 2 +- source/blender/editors/space_file/filelist.cc | 189 +++++++++++---------- .../blender/editors/space_file/folder_history.cc | 26 +-- source/blender/editors/space_info/info_stats.cc | 2 +- source/blender/editors/space_node/node_add.cc | 2 +- source/blender/editors/space_node/node_group.cc | 2 +- .../editors/space_outliner/outliner_dragdrop.cc | 2 +- .../editors/space_spreadsheet/space_spreadsheet.cc | 14 +- .../blender/editors/space_view3d/space_view3d.cc | 14 +- source/blender/editors/space_view3d/view3d_draw.cc | 2 +- source/blender/editors/uvedit/uvedit_islands.cc | 8 +- source/blender/geometry/GEO_trim_curves.hh | 4 +- source/blender/geometry/intern/trim_curves.cc | 4 +- source/blender/modifiers/intern/MOD_normal_edit.cc | 2 +- source/blender/modifiers/intern/MOD_subsurf.cc | 6 +- source/blender/render/intern/pipeline.cc | 2 +- 53 files changed, 532 insertions(+), 549 deletions(-) diff --git a/source/blender/blenkernel/BKE_idprop.hh b/source/blender/blenkernel/BKE_idprop.hh index e8ac4119970..ce11a56ad5f 100644 --- a/source/blender/blenkernel/BKE_idprop.hh +++ b/source/blender/blenkernel/BKE_idprop.hh @@ -46,7 +46,7 @@ std::unique_ptr create(StringRefNull prop_name, const StringRefNull value); /** \brief Allocate a new IDProperty of type IDP_ID, set its name and value. */ -std::unique_ptr create(StringRefNull prop_name, ID *id); +std::unique_ptr create(StringRefNull prop_name, ID *value); /** * \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_INT. diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 5ffaa13d9d2..beed524df4c 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -68,7 +68,7 @@ struct BoundBox *BKE_mball_boundbox_get(struct Object *ob); * `MBall`, `MBall.001`, `MBall.002`, etc). The most important is to copy properties to the base * meta-ball, because this meta-ball influences polygonization of meta-balls. */ -void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall *active_metaball); +void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall *metaball_src); bool BKE_mball_minmax_ex( const struct MetaBall *mb, float min[3], float max[3], const float obmat[4][4], short flag); diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc index 016cf6acbcc..12799afd2f7 100644 --- a/source/blender/blenkernel/intern/editmesh_tangent.cc +++ b/source/blender/blenkernel/intern/editmesh_tangent.cc @@ -94,12 +94,10 @@ struct SGLSLEditMeshToTangent { const float *uv = (const float *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); return mikk::float3(uv[0], uv[1], 1.0f); } - else { - const float *orco_p = orco[BM_elem_index_get(l->v)]; - float u, v; - map_to_sphere(&u, &v, orco_p[0], orco_p[1], orco_p[2]); - return mikk::float3(u, v, 1.0f); - } + const float *orco_p = orco[BM_elem_index_get(l->v)]; + float u, v; + map_to_sphere(&u, &v, orco_p[0], orco_p[1], orco_p[2]); + return mikk::float3(u, v, 1.0f); } mikk::float3 GetNormal(const uint face_num, const uint vert_index) @@ -108,17 +106,13 @@ struct SGLSLEditMeshToTangent { if (precomputedLoopNormals) { return mikk::float3(precomputedLoopNormals[BM_elem_index_get(l)]); } - else if (BM_elem_flag_test(l->f, BM_ELEM_SMOOTH) == 0) { /* flat */ + if (BM_elem_flag_test(l->f, BM_ELEM_SMOOTH) == 0) { /* flat */ if (precomputedFaceNormals) { return mikk::float3(precomputedFaceNormals[BM_elem_index_get(l->f)]); } - else { - return mikk::float3(l->f->no); - } - } - else { - return mikk::float3(l->v->no); + return mikk::float3(l->f->no); } + return mikk::float3(l->v->no); } void SetTangentSpace(const uint face_num, diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index 00913905c1c..b492af4af77 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -490,12 +490,13 @@ std::optional try_detect_field_domain(const GeometryComponent &comp return std::nullopt; } for (const fn::FieldInput &field_input : field_inputs->deduplicated_nodes) { - if (auto geometry_field_input = dynamic_cast(&field_input)) { + if (const auto *geometry_field_input = dynamic_cast( + &field_input)) { if (!handle_domain(geometry_field_input->preferred_domain(component))) { return std::nullopt; } } - else if (auto mesh_field_input = dynamic_cast(&field_input)) { + else if (const auto *mesh_field_input = dynamic_cast(&field_input)) { if (!handle_domain(mesh_field_input->preferred_domain(*mesh))) { return std::nullopt; } @@ -512,12 +513,14 @@ std::optional try_detect_field_domain(const GeometryComponent &comp return std::nullopt; } for (const fn::FieldInput &field_input : field_inputs->deduplicated_nodes) { - if (auto geometry_field_input = dynamic_cast(&field_input)) { + if (const auto *geometry_field_input = dynamic_cast( + &field_input)) { if (!handle_domain(geometry_field_input->preferred_domain(component))) { return std::nullopt; } } - else if (auto curves_field_input = dynamic_cast(&field_input)) { + else if (const auto *curves_field_input = dynamic_cast( + &field_input)) { if (!handle_domain( curves_field_input->preferred_domain(CurvesGeometry::wrap(curves->geometry)))) { return std::nullopt; diff --git a/source/blender/blenkernel/intern/mball_tessellate.cc b/source/blender/blenkernel/intern/mball_tessellate.cc index 9b32456c6c1..5e8d2bc6d76 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.cc +++ b/source/blender/blenkernel/intern/mball_tessellate.cc @@ -5,12 +5,12 @@ * \ingroup bke */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "MEM_guardedalloc.h" @@ -169,7 +169,7 @@ static uint partition_mainb(MetaElem **mainb, uint start, uint end, uint s, floa uint i = start, j = end - 1; div *= 2.0f; - while (1) { + while (true) { while (i < j && div > (mainb[i]->bb->vec[6][s] + mainb[i]->bb->vec[0][s])) { i++; } @@ -222,7 +222,7 @@ static void build_bvh_spatial( part = partition_mainb(process->mainb, start, end, s, div); make_box_from_metaelem(&node->bb[0], process->mainb[start]); - node->child[0] = NULL; + node->child[0] = nullptr; if (part > start + 1) { for (j = start; j < part; j++) { @@ -234,7 +234,7 @@ static void build_bvh_spatial( build_bvh_spatial(process, node->child[0], start, part, &node->bb[0]); } - node->child[1] = NULL; + node->child[1] = nullptr; if (part < end) { make_box_from_metaelem(&node->bb[1], process->mainb[part]); @@ -461,12 +461,12 @@ static void make_face(PROCESS *process, int i1, int i2, int i3, int i4) accumulate_vertex_normals_v3(process->no[i1], process->no[i2], process->no[i3], - NULL, + nullptr, n, process->co[i1], process->co[i2], process->co[i3], - NULL); + nullptr); } else { normal_quad_v3(n, process->co[i1], process->co[i2], process->co[i3], process->co[i4]); @@ -677,7 +677,7 @@ static CORNER *setcorner(PROCESS *process, int i, int j, int k) index = HASH(i, j, k); c = process->corners[index]; - for (; c != NULL; c = c->next) { + for (; c != nullptr; c = c->next) { if (c->i == i && c->j == j && c->k == k) { return c; } @@ -746,7 +746,7 @@ static int otherface(int edge, int face) /** * create the 256 entry table for cubical polygonization */ -static void makecubetable(void) +static void makecubetable() { static bool is_done = false; int i, e, c, done[12], pos[8]; @@ -765,14 +765,14 @@ static void makecubetable(void) } for (e = 0; e < 12; e++) { if (!done[e] && (pos[corner1[e]] != pos[corner2[e]])) { - INTLIST *ints = NULL; + INTLIST *ints = nullptr; INTLISTS *lists = static_cast(MEM_callocN(sizeof(INTLISTS), "mball_intlist")); int start = e, edge = e; /* get face that is to right of edge from pos to neg corner: */ int face = pos[corner1[e]] ? rightface[e] : leftface[e]; - while (1) { + while (true) { edge = nextcwedge(edge, face); done[edge] = 1; if (pos[corner1[edge]] != pos[corner2[edge]]) { @@ -842,7 +842,7 @@ void BKE_mball_cubeTable_free(void) MEM_freeN(lists); lists = nlists; } - cubetable[i] = NULL; + cubetable[i] = nullptr; } } @@ -859,7 +859,7 @@ static int setcenter(PROCESS *process, CENTERLIST *table[], const int i, const i index = HASH(i, j, k); q = table[index]; - for (l = q; l != NULL; l = l->next) { + for (l = q; l != nullptr; l = l->next) { if (l->i == i && l->j == j && l->k == k) { return 1; } @@ -927,7 +927,7 @@ static int getedge(EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, in k2 = t; } q = table[HASH(i1, j1, k1) + HASH(i2, j2, k2)]; - for (; q != NULL; q = q->next) { + for (; q != nullptr; q = q->next) { if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && q->i2 == i2 && q->j2 == j2 && q->k2 == k2) { return q->vid; } @@ -1160,7 +1160,7 @@ static void polygonize(PROCESS *process) find_first_points(process, i); } - while (process->cubes != NULL) { + while (process->cubes != nullptr) { c = process->cubes->cube; process->cubes = process->cubes->next; @@ -1194,15 +1194,15 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* make main array */ - BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, NULL, NULL); + BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, nullptr, nullptr); while (BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 1, &base, &bob)) { if (bob->type == OB_MBALL) { zero_size = 0; - ml = NULL; + ml = nullptr; /* If this metaball is the original that's used for duplication, only have it visible when * the instancer is visible too. */ - if ((base->flag_legacy & OB_FROMDUPLI) == 0 && ob->parent != NULL && + if ((base->flag_legacy & OB_FROMDUPLI) == 0 && ob->parent != nullptr && (ob->parent->transflag & parenting_dupli_transflag) != 0 && (BKE_object_visibility(ob->parent, deg_eval_mode) & OB_VISIBLE_SELF) == 0) { continue; @@ -1412,10 +1412,10 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) } if (!is_render && (mb->flag == MB_UPDATE_NEVER)) { - return NULL; + return nullptr; } if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) { - return NULL; + return nullptr; } if (is_render) { @@ -1436,7 +1436,7 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) init_meta(depsgraph, &process, scene, ob); if (process.totelem == 0) { freepolygonize(&process); - return NULL; + return nullptr; } build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb); @@ -1448,13 +1448,13 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) ob->scale[1] < 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) || ob->scale[2] < 0.00001f * (process.allbb.max[2] - process.allbb.min[2])) { freepolygonize(&process); - return NULL; + return nullptr; } polygonize(&process); if (process.curindex == 0) { freepolygonize(&process); - return NULL; + return nullptr; } freepolygonize(&process); @@ -1463,7 +1463,7 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) mesh->totvert = int(process.curvertex); MVert *mvert = static_cast( - CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, NULL, mesh->totvert)); + CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, nullptr, mesh->totvert)); for (int i = 0; i < mesh->totvert; i++) { copy_v3_v3(mvert[i].co, process.co[i]); } @@ -1471,9 +1471,9 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) mesh->totpoly = int(process.curindex); MPoly *mpoly = static_cast( - CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, NULL, mesh->totpoly)); + CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, nullptr, mesh->totpoly)); MLoop *mloop = static_cast( - CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, mesh->totpoly * 4)); + CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, nullptr, mesh->totpoly * 4)); int loop_offset = 0; for (int i = 0; i < mesh->totpoly; i++) { diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index 05d1a478c09..bb9f8274b72 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -47,7 +47,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, uint a; int i, totuv, nverts; - bool *winding = NULL; + bool *winding = nullptr; BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, 32); totuv = 0; @@ -61,7 +61,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, } if (totuv == 0) { - return NULL; + return nullptr; } vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); @@ -73,13 +73,13 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, if (!vmap->vert || !vmap->buf) { BKE_mesh_uv_vert_map_free(vmap); - return NULL; + return nullptr; } mp = mpoly; for (a = 0; a < totpoly; a++, mp++) { if (!selected || (!(hide_poly && hide_poly[a]) && (select_poly && select_poly[a]))) { - float(*tf_uv)[2] = NULL; + float(*tf_uv)[2] = nullptr; if (use_winding) { tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, size_t(mp->totloop)); @@ -90,7 +90,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, for (i = 0; i < nverts; i++) { buf->loop_of_poly_index = ushort(i); buf->poly_index = a; - buf->separate = 0; + buf->separate = false; buf->next = vmap->vert[mloop[mp->loopstart + i].v]; vmap->vert[mloop[mp->loopstart + i].v] = buf; @@ -109,7 +109,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, /* sort individual uvs for each vert */ for (a = 0; a < totvert; a++) { - UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; + UvMapVert *newvlist = nullptr, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; const float *uv, *uv2; float uvdiff[2]; @@ -121,7 +121,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, newvlist = v; uv = mloopuv[mpoly[v->poly_index].loopstart + v->loop_of_poly_index].uv; - lastv = NULL; + lastv = nullptr; iterv = vlist; while (iterv) { @@ -148,7 +148,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, iterv = next; } - newvlist->separate = 1; + newvlist->separate = true; } vmap->vert[a] = newvlist; @@ -624,7 +624,7 @@ static void poly_edge_loop_islands_calc(const MEdge *medge, int *poly_groups; int *poly_stack; - BLI_bitmap *edge_borders = NULL; + BLI_bitmap *edge_borders = nullptr; int num_edgeborders = 0; int poly_prev = 0; @@ -637,13 +637,13 @@ static void poly_edge_loop_islands_calc(const MEdge *medge, bool group_id_overflow = false; /* map vars */ - int *edge_poly_mem = NULL; + int *edge_poly_mem = nullptr; if (totpoly == 0) { *r_totgroup = 0; - *r_poly_groups = NULL; + *r_poly_groups = nullptr; if (r_edge_borders) { - *r_edge_borders = NULL; + *r_edge_borders = nullptr; *r_totedgeborder = 0; } return; @@ -830,7 +830,7 @@ int *BKE_mesh_calc_smoothgroups(const MEdge *medge, int *r_totgroup, const bool use_bitflags) { - int *poly_groups = NULL; + int *poly_groups = nullptr; poly_edge_loop_islands_calc(medge, totedge, @@ -838,14 +838,14 @@ int *BKE_mesh_calc_smoothgroups(const MEdge *medge, totpoly, mloop, totloop, - NULL, + nullptr, use_bitflags, poly_is_island_boundary_smooth_cb, - NULL, + nullptr, &poly_groups, r_totgroup, - NULL, - NULL); + nullptr, + nullptr); return poly_groups; } @@ -860,7 +860,7 @@ void BKE_mesh_loop_islands_init(MeshIslandStore *island_store, { MemArena *mem = island_store->mem; - if (mem == NULL) { + if (mem == nullptr) { mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); island_store->mem = mem; } @@ -890,14 +890,14 @@ void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store) { island_store->item_type = MISLAND_TYPE_NONE; island_store->items_to_islands_num = 0; - island_store->items_to_islands = NULL; + island_store->items_to_islands = nullptr; island_store->island_type = MISLAND_TYPE_NONE; island_store->islands_num = 0; - island_store->islands = NULL; + island_store->islands = nullptr; island_store->innercut_type = MISLAND_TYPE_NONE; - island_store->innercuts = NULL; + island_store->innercuts = nullptr; if (island_store->mem) { BLI_memarena_clear(island_store->mem); @@ -910,7 +910,7 @@ void BKE_mesh_loop_islands_free(MeshIslandStore *island_store) { if (island_store->mem) { BLI_memarena_free(island_store->mem); - island_store->mem = NULL; + island_store->mem = nullptr; } } @@ -1032,7 +1032,7 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert * /*verts*/, const MLoopUV *luvs, MeshIslandStore *r_island_store) { - int *poly_groups = NULL; + int *poly_groups = nullptr; int num_poly_groups; /* map vars */ @@ -1051,10 +1051,10 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert * /*verts*/, /* Those are used to detect 'inner cuts', i.e. edges that are borders, * and yet have two or more polys of a same group using them * (typical case: seam used to unwrap properly a cylinder). */ - BLI_bitmap *edge_borders = NULL; + BLI_bitmap *edge_borders = nullptr; int num_edge_borders = 0; - char *edge_border_count = NULL; - int *edge_innercut_indices = NULL; + char *edge_border_count = nullptr; + int *edge_innercut_indices = nullptr; int num_einnercuts = 0; int grp_idx, p_idx, pl_idx, l_idx; @@ -1083,7 +1083,7 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert * /*verts*/, edge_poly_map, false, mesh_check_island_boundary_uv, - luvs ? &edge_boundary_check_data : NULL, + luvs ? &edge_boundary_check_data : nullptr, &poly_groups, &num_poly_groups, &edge_borders, @@ -1182,7 +1182,7 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(const MVert *verts, MeshIslandStore *r_island_store) { return mesh_calc_islands_loop_poly_uv( - verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store); + verts, totvert, edges, totedge, polys, totpoly, loops, totloop, nullptr, r_island_store); } bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts, @@ -1196,7 +1196,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts, const MLoopUV *luvs, MeshIslandStore *r_island_store) { - BLI_assert(luvs != NULL); + BLI_assert(luvs != nullptr); return mesh_calc_islands_loop_poly_uv( verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store); } diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index 07b45cf376d..1162986aaf5 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -7,7 +7,7 @@ * Functions to evaluate mesh tangents. */ -#include +#include #include "MEM_guardedalloc.h" @@ -224,12 +224,10 @@ struct SGLSLMeshToTangent { const float *uv = mloopuv[loop_index].uv; return mikk::float3(uv[0], uv[1], 1.0f); } - else { - const float *l_orco = orco[mloop[loop_index].v]; - float u, v; - map_to_sphere(&u, &v, l_orco[0], l_orco[1], l_orco[2]); - return mikk::float3(u, v, 1.0f); - } + const float *l_orco = orco[mloop[loop_index].v]; + float u, v; + map_to_sphere(&u, &v, l_orco[0], l_orco[1], l_orco[2]); + return mikk::float3(u, v, 1.0f); } mikk::float3 GetNormal(const uint face_num, const uint vert_num) @@ -239,35 +237,31 @@ struct SGLSLMeshToTangent { if (precomputedLoopNormals) { return mikk::float3(precomputedLoopNormals[loop_index]); } - else if ((mpoly[lt->poly].flag & ME_SMOOTH) == 0) { /* flat */ + if ((mpoly[lt->poly].flag & ME_SMOOTH) == 0) { /* flat */ if (precomputedFaceNormals) { return mikk::float3(precomputedFaceNormals[lt->poly]); } - else { #ifdef USE_LOOPTRI_DETECT_QUADS - const MPoly *mp = &mpoly[lt->poly]; - float normal[3]; - if (mp->totloop == 4) { - normal_quad_v3(normal, - mvert[mloop[mp->loopstart + 0].v].co, - mvert[mloop[mp->loopstart + 1].v].co, - mvert[mloop[mp->loopstart + 2].v].co, - mvert[mloop[mp->loopstart + 3].v].co); - } - else + const MPoly *mp = &mpoly[lt->poly]; + float normal[3]; + if (mp->totloop == 4) { + normal_quad_v3(normal, + mvert[mloop[mp->loopstart + 0].v].co, + mvert[mloop[mp->loopstart + 1].v].co, + mvert[mloop[mp->loopstart + 2].v].co, + mvert[mloop[mp->loopstart + 3].v].co); + } + else #endif - { - normal_tri_v3(normal, - mvert[mloop[lt->tri[0]].v].co, - mvert[mloop[lt->tri[1]].v].co, - mvert[mloop[lt->tri[2]].v].co); - } - return mikk::float3(normal); + { + normal_tri_v3(normal, + mvert[mloop[lt->tri[0]].v].co, + mvert[mloop[lt->tri[1]].v].co, + mvert[mloop[lt->tri[2]].v].co); } + return mikk::float3(normal); } - else { - return mikk::float3(vert_normals[mloop[loop_index].v]); - } + return mikk::float3(vert_normals[mloop[loop_index].v]); } void SetTangentSpace(const uint face_num, const uint vert_num, mikk::float3 T, bool orientation) diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index 2f8a02fa516..2eb8ef70a4d 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -406,7 +406,7 @@ bool BKE_modifier_supports_cage(struct Scene *scene, ModifierData *md) { const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); - return ((!mti->isDisabled || !mti->isDisabled(scene, md, 0)) && + return ((!mti->isDisabled || !mti->isDisabled(scene, md, false)) && (mti->flags & eModifierTypeFlag_SupportsEditmode) && BKE_modifier_supports_mapping(md)); } @@ -415,7 +415,7 @@ bool BKE_modifier_couldbe_cage(struct Scene *scene, ModifierData *md) const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); return ((md->mode & eModifierMode_Realtime) && (md->mode & eModifierMode_Editmode) && - (!mti->isDisabled || !mti->isDisabled(scene, md, 0)) && + (!mti->isDisabled || !mti->isDisabled(scene, md, false)) && BKE_modifier_supports_mapping(md)); } @@ -513,7 +513,7 @@ int BKE_modifiers_get_cage_index(const Scene *scene, const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); bool supports_mapping; - if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, false)) { continue; } if (!(mti->flags & eModifierTypeFlag_SupportsEditmode)) { diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 039bb1bf7f3..1d68a2e2b80 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -407,13 +407,13 @@ static void node_foreach_path(ID *id, BPathForeachPathData *bpath_data) static ID **node_owner_pointer_get(ID *id) { if ((id->flag & LIB_EMBEDDED_DATA) == 0) { - return NULL; + return nullptr; } /* TODO: Sort this NO_MAIN or not for embedded node trees. See T86119. */ // BLI_assert((id->tag & LIB_TAG_NO_MAIN) == 0); bNodeTree *ntree = reinterpret_cast(id); - BLI_assert(ntree->owner_id != NULL); + BLI_assert(ntree->owner_id != nullptr); BLI_assert(ntreeFromID(ntree->owner_id) == ntree); return &ntree->owner_id; @@ -662,7 +662,7 @@ void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree) if (BLO_read_fileversion_get(reader) > 300) { BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr); } - BLI_assert(owner_id == NULL || owner_id->lib == ntree->id.lib); + BLI_assert(owner_id == nullptr || owner_id->lib == ntree->id.lib); if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) { /* This is unfortunate, but currently a lot of existing files (including startup ones) have * missing `LIB_EMBEDDED_DATA` flag. @@ -2630,15 +2630,15 @@ static bNodeTree *ntreeAddTree_do( bNodeTree *ntree = (bNodeTree *)BKE_libblock_alloc(bmain, ID_NT, name, flag); BKE_libblock_init_empty(&ntree->id); if (is_embedded) { - BLI_assert(owner_id != NULL); + BLI_assert(owner_id != nullptr); ntree->id.flag |= LIB_EMBEDDED_DATA; ntree->owner_id = owner_id; bNodeTree **ntree_owner_ptr = BKE_ntree_ptr_from_id(owner_id); - BLI_assert(ntree_owner_ptr != NULL); + BLI_assert(ntree_owner_ptr != nullptr); *ntree_owner_ptr = ntree; } else { - BLI_assert(owner_id == NULL); + BLI_assert(owner_id == nullptr); } BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname)); diff --git a/source/blender/blenkernel/intern/outliner_treehash.cc b/source/blender/blenkernel/intern/outliner_treehash.cc index 3f66f6bb745..9cca077509d 100644 --- a/source/blender/blenkernel/intern/outliner_treehash.cc +++ b/source/blender/blenkernel/intern/outliner_treehash.cc @@ -6,8 +6,8 @@ * Tree hash for the outliner space. */ -#include -#include +#include +#include #include "BLI_mempool.h" #include "BLI_utildefines.h" @@ -34,7 +34,6 @@ class TseGroup { * item is exponential and becomes critically slow when there are a lot of items in the group. */ int lastused_reset_count = -1; - public: void add_element(TreeStoreElem &elem); void remove_element(TreeStoreElem &elem); }; @@ -144,7 +143,7 @@ void TreeHash::remove_element(TreeStoreElem &elem) TseGroup *TreeHash::lookup_group(const TreeStoreElemKey &key) const { - auto *group = elem_groups_.lookup_ptr(key); + const auto *group = elem_groups_.lookup_ptr(key); if (group) { return group->get(); } diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 9e3a044ff1c..7b3ad170339 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1559,9 +1559,7 @@ static MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene, /* Multires can't work without displacement layer. */ return nullptr; } - else { - need_mdisps = true; - } + need_mdisps = true; } /* Weight paint operates on original vertices, and needs to treat multires as regular modifier @@ -1794,7 +1792,7 @@ static void sculpt_update_object( BLI_assert(me_eval_deform->totvert == me->totvert); - ss->deform_cos = BKE_mesh_vert_coords_alloc(me_eval, NULL); + ss->deform_cos = BKE_mesh_vert_coords_alloc(me_eval, nullptr); BKE_pbvh_vert_coords_apply(ss->pbvh, ss->deform_cos, me->totvert); used_me_eval = true; @@ -1979,8 +1977,9 @@ int *BKE_sculpt_face_sets_ensure(Mesh *mesh) bool *BKE_sculpt_hide_poly_ensure(Mesh *mesh) { - if (bool *hide_poly = static_cast( - CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly"))) { + bool *hide_poly = static_cast( + CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly")); + if (hide_poly != nullptr) { return hide_poly; } return static_cast(CustomData_add_layer_named( @@ -2368,7 +2367,7 @@ static CustomData *sculpt_get_cdata(Object *ob, eAttrDomain domain) return &ss->bm->pdata; default: BLI_assert_unreachable(); - return NULL; + return nullptr; } } else { @@ -2386,7 +2385,7 @@ static CustomData *sculpt_get_cdata(Object *ob, eAttrDomain domain) return &me->pdata; default: BLI_assert_unreachable(); - return NULL; + return nullptr; } } } @@ -2452,9 +2451,9 @@ static bool sculpt_attribute_create(SculptSession *ss, out->data = MEM_calloc_arrayN(totelem, elemsize, __func__); - out->data_for_bmesh = ss->bm != NULL; + out->data_for_bmesh = ss->bm != nullptr; out->bmesh_cd_offset = -1; - out->layer = NULL; + out->layer = nullptr; out->elem_size = elemsize; out->used = true; out->elem_num = totelem; @@ -2464,7 +2463,7 @@ static bool sculpt_attribute_create(SculptSession *ss, switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_BMESH: { - CustomData *cdata = NULL; + CustomData *cdata = nullptr; out->data_for_bmesh = true; switch (domain) { @@ -2488,14 +2487,14 @@ static bool sculpt_attribute_create(SculptSession *ss, cdata->layers[index].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY; } - out->data = NULL; + out->data = nullptr; out->layer = cdata->layers + index; out->bmesh_cd_offset = out->layer->offset; out->elem_size = CustomData_sizeof(proptype); break; } case PBVH_FACES: { - CustomData *cdata = NULL; + CustomData *cdata = nullptr; out->data_for_bmesh = false; @@ -2513,14 +2512,14 @@ static bool sculpt_attribute_create(SculptSession *ss, BLI_assert(CustomData_get_named_layer_index(cdata, proptype, name) == -1); - CustomData_add_layer_named(cdata, proptype, CD_SET_DEFAULT, NULL, totelem, name); + CustomData_add_layer_named(cdata, proptype, CD_SET_DEFAULT, nullptr, totelem, name); int index = CustomData_get_named_layer_index(cdata, proptype, name); if (!permanent) { cdata->layers[index].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY; } - out->data = NULL; + out->data = nullptr; out->layer = cdata->layers + index; out->bmesh_cd_offset = -1; out->data = out->layer->data; @@ -2601,7 +2600,7 @@ static SculptAttribute *sculpt_get_cached_layer(SculptSession *ss, } } - return NULL; + return nullptr; } bool BKE_sculpt_attribute_exists(Object *ob, @@ -2634,7 +2633,7 @@ static SculptAttribute *sculpt_alloc_attr(SculptSession *ss) } BLI_assert_unreachable(); - return NULL; + return nullptr; } SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob, @@ -2690,7 +2689,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob, } } - return NULL; + return nullptr; } static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob, @@ -2833,7 +2832,7 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr) for (int i = 0; i < ptrs_num; i++) { if (ptrs[i] == attr) { - ptrs[i] = NULL; + ptrs[i] = nullptr; } } @@ -2859,7 +2858,7 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr) BM_data_layer_free_named(ss->bm, cdata, attr->name); } else { - CustomData *cdata = NULL; + CustomData *cdata = nullptr; int totelem = 0; switch (domain) { @@ -2887,7 +2886,7 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr) sculpt_attribute_update_refs(ob); } - attr->data = NULL; + attr->data = nullptr; attr->used = false; return true; diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index de76de9606b..00183ea90c2 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -1110,9 +1110,9 @@ static void subdiv_mesh_vertex_of_loose_edge(const SubdivForeachContext *foreach /* Lazily initialize a vertex to edge map to avoid quadratic runtime when subdividing loose * edges. Do this here to avoid the cost in common cases when there are no loose edges at all. */ - if (ctx->vert_to_edge_map == NULL) { + if (ctx->vert_to_edge_map == nullptr) { std::lock_guard lock{ctx->vert_to_edge_map_mutex}; - if (ctx->vert_to_edge_map == NULL) { + if (ctx->vert_to_edge_map == nullptr) { BKE_mesh_vert_edge_map_create(&ctx->vert_to_edge_map, &ctx->vert_to_edge_buffer, ctx->coarse_edges, @@ -1191,7 +1191,7 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv, } } /* Initialize subdivision mesh creation context. */ - SubdivMeshContext subdiv_context = {0}; + SubdivMeshContext subdiv_context{}; subdiv_context.settings = settings; subdiv_context.coarse_mesh = coarse_mesh; @@ -1206,7 +1206,7 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv, BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH_GEOMETRY); SubdivForeachContext foreach_context; setup_foreach_callbacks(&subdiv_context, &foreach_context); - SubdivMeshTLS tls = {0}; + SubdivMeshTLS tls{}; foreach_context.user_data = &subdiv_context; foreach_context.user_data_tls_size = sizeof(SubdivMeshTLS); foreach_context.user_data_tls = &tls; diff --git a/source/blender/blenkernel/intern/viewer_path.cc b/source/blender/blenkernel/intern/viewer_path.cc index 3074a007af4..edc71787ac5 100644 --- a/source/blender/blenkernel/intern/viewer_path.cc +++ b/source/blender/blenkernel/intern/viewer_path.cc @@ -61,18 +61,18 @@ void BKE_viewer_path_blend_write(struct BlendWriter *writer, const ViewerPath *v LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { switch (ViewerPathElemType(elem->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto typed_elem = reinterpret_cast(elem); + const auto *typed_elem = reinterpret_cast(elem); BLO_write_struct(writer, IDViewerPathElem, typed_elem); break; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: { - auto typed_elem = reinterpret_cast(elem); + const auto *typed_elem = reinterpret_cast(elem); BLO_write_struct(writer, ModifierViewerPathElem, typed_elem); BLO_write_string(writer, typed_elem->modifier_name); break; } case VIEWER_PATH_ELEM_TYPE_NODE: { - auto typed_elem = reinterpret_cast(elem); + const auto *typed_elem = reinterpret_cast(elem); BLO_write_struct(writer, NodeViewerPathElem, typed_elem); BLO_write_string(writer, typed_elem->node_name); break; @@ -90,12 +90,12 @@ void BKE_viewer_path_blend_read_data(struct BlendDataReader *reader, ViewerPath break; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); BLO_read_data_address(reader, &typed_elem->modifier_name); break; } case VIEWER_PATH_ELEM_TYPE_NODE: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); BLO_read_data_address(reader, &typed_elem->node_name); break; } @@ -108,7 +108,7 @@ void BKE_viewer_path_blend_read_lib(BlendLibReader *reader, Library *lib, Viewer LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { switch (ViewerPathElemType(elem->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); BLO_read_id_address(reader, lib, &typed_elem->id); break; } @@ -125,7 +125,7 @@ void BKE_viewer_path_foreach_id(LibraryForeachIDData *data, ViewerPath *viewer_p LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { switch (ViewerPathElemType(elem->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); BKE_LIB_FOREACHID_PROCESS_ID(data, typed_elem->id, IDWALK_CB_NOP); break; } @@ -142,7 +142,7 @@ void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const IDRemapper *mapping LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { switch (ViewerPathElemType(elem->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); BKE_id_remapper_apply(mappings, &typed_elem->id, ID_REMAP_APPLY_DEFAULT); break; } @@ -199,22 +199,22 @@ ViewerPathElem *BKE_viewer_path_elem_copy(const ViewerPathElem *src) ViewerPathElem *dst = BKE_viewer_path_elem_new(ViewerPathElemType(src->type)); switch (ViewerPathElemType(src->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto old_elem = reinterpret_cast(src); - auto new_elem = reinterpret_cast(dst); + const auto *old_elem = reinterpret_cast(src); + auto *new_elem = reinterpret_cast(dst); new_elem->id = old_elem->id; break; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: { - auto old_elem = reinterpret_cast(src); - auto new_elem = reinterpret_cast(dst); + const auto *old_elem = reinterpret_cast(src); + auto *new_elem = reinterpret_cast(dst); if (old_elem->modifier_name != nullptr) { new_elem->modifier_name = BLI_strdup(old_elem->modifier_name); } break; } case VIEWER_PATH_ELEM_TYPE_NODE: { - auto old_elem = reinterpret_cast(src); - auto new_elem = reinterpret_cast(dst); + const auto *old_elem = reinterpret_cast(src); + auto *new_elem = reinterpret_cast(dst); if (old_elem->node_name != nullptr) { new_elem->node_name = BLI_strdup(old_elem->node_name); } @@ -231,18 +231,18 @@ bool BKE_viewer_path_elem_equal(const ViewerPathElem *a, const ViewerPathElem *b } switch (ViewerPathElemType(a->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { - auto a_elem = reinterpret_cast(a); - auto b_elem = reinterpret_cast(b); + const auto *a_elem = reinterpret_cast(a); + const auto *b_elem = reinterpret_cast(b); return a_elem->id == b_elem->id; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: { - auto a_elem = reinterpret_cast(a); - auto b_elem = reinterpret_cast(b); + const auto *a_elem = reinterpret_cast(a); + const auto *b_elem = reinterpret_cast(b); return StringRef(a_elem->modifier_name) == StringRef(b_elem->modifier_name); } case VIEWER_PATH_ELEM_TYPE_NODE: { - auto a_elem = reinterpret_cast(a); - auto b_elem = reinterpret_cast(b); + const auto *a_elem = reinterpret_cast(a); + const auto *b_elem = reinterpret_cast(b); return StringRef(a_elem->node_name) == StringRef(b_elem->node_name); } } @@ -256,12 +256,12 @@ void BKE_viewer_path_elem_free(ViewerPathElem *elem) break; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); MEM_SAFE_FREE(typed_elem->modifier_name); break; } case VIEWER_PATH_ELEM_TYPE_NODE: { - auto typed_elem = reinterpret_cast(elem); + auto *typed_elem = reinterpret_cast(elem); MEM_SAFE_FREE(typed_elem->node_name); break; } diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index a7fd433b42b..6ffef5555fb 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -4,9 +4,9 @@ * \ingroup bke */ -#include -#include -#include +#include +#include +#include #include "BLI_listbase.h" #include "BLI_string.h" diff --git a/source/blender/blenloader/intern/blend_validate.cc b/source/blender/blenloader/intern/blend_validate.cc index 96314ab4324..0f43b20c391 100644 --- a/source/blender/blenloader/intern/blend_validate.cc +++ b/source/blender/blenloader/intern/blend_validate.cc @@ -9,7 +9,7 @@ * \note Does not *fix* anything, only reports found errors. */ -#include /* for #strrchr #strncmp #strstr */ +#include /* for #strrchr #strncmp #strstr */ #include "BLI_utildefines.h" diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc index 55d86371efe..55ac2d31277 100644 --- a/source/blender/blenloader/intern/readblenentry.cc +++ b/source/blender/blenloader/intern/readblenentry.cc @@ -6,12 +6,11 @@ * `.blend` file reading entry point. */ -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "MEM_guardedalloc.h" @@ -106,14 +105,14 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int *r_tot_names) { FileData *fd = (FileData *)bh; - LinkNode *names = NULL; + LinkNode *names = nullptr; BHead *bhead; int tot = 0; for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { if (bhead->code == ofblocktype) { const char *idname = blo_bhead_id_name(fd, bhead); - if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == NULL) { + if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == nullptr) { continue; } @@ -135,7 +134,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, int *r_tot_info_items) { FileData *fd = (FileData *)bh; - LinkNode *infos = NULL; + LinkNode *infos = nullptr; BHead *bhead; int tot = 0; @@ -147,7 +146,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, const char *name = blo_bhead_id_name(fd, bhead) + 2; AssetMetaData *asset_meta_data = blo_bhead_id_asset_data_address(fd, bhead); - const bool is_asset = asset_meta_data != NULL; + const bool is_asset = asset_meta_data != nullptr; const bool skip_datablock = use_assets_only && !is_asset; if (skip_datablock) { continue; @@ -187,7 +186,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, * bhead is consumed. the new bhead is returned by this function. * \param result: the Preview Image where the preview rect will be stored. * \param preview_from_file: The read PreviewImage where the bhead points to. The rects of this - * \return PreviewImage or NULL when no preview Images have been found. Caller owns the returned + * \return PreviewImage or nullptr when no preview Images have been found. Caller owns the returned */ static BHead *blo_blendhandle_read_preview_rects(FileData *fd, BHead *bhead, @@ -206,10 +205,10 @@ static BHead *blo_blendhandle_read_preview_rects(FileData *fd, else { /* This should not be needed, but can happen in 'broken' .blend files, * better handle this gracefully than crashing. */ - BLI_assert(preview_from_file->rect[preview_index] == NULL && + BLI_assert(preview_from_file->rect[preview_index] == nullptr && preview_from_file->w[preview_index] == 0 && preview_from_file->h[preview_index] == 0); - result->rect[preview_index] = NULL; + result->rect[preview_index] = nullptr; result->w[preview_index] = result->h[preview_index] = 0; } BKE_previewimg_finish(result, preview_index); @@ -232,7 +231,7 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh, PreviewImage *preview_from_file = static_cast( BLO_library_read_struct(fd, bhead, "PreviewImage")); - if (preview_from_file == NULL) { + if (preview_from_file == nullptr) { break; } @@ -255,17 +254,17 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh, } } - return NULL; + return nullptr; } LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev) { FileData *fd = (FileData *)bh; - LinkNode *previews = NULL; + LinkNode *previews = nullptr; BHead *bhead; int looking = 0; - PreviewImage *prv = NULL; - PreviewImage *new_prv = NULL; + PreviewImage *prv = nullptr; + PreviewImage *new_prv = nullptr; int tot = 0; for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { @@ -309,8 +308,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_ } else { looking = 0; - new_prv = NULL; - prv = NULL; + new_prv = nullptr; + prv = nullptr; } } @@ -322,7 +321,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) { FileData *fd = (FileData *)bh; GSet *gathered = BLI_gset_ptr_new("linkable_groups gh"); - LinkNode *names = NULL; + LinkNode *names = nullptr; BHead *bhead; for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { @@ -340,7 +339,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) } } - BLI_gset_free(gathered, NULL); + BLI_gset_free(gathered, nullptr); return names; } @@ -358,7 +357,7 @@ BlendFileData *BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, BlendFileReadReport *reports) { - BlendFileData *bfd = NULL; + BlendFileData *bfd = nullptr; FileData *fd; fd = blo_filedata_from_file(filepath, reports); @@ -376,7 +375,7 @@ BlendFileData *BLO_read_from_memory(const void *mem, eBLOReadSkip skip_flags, ReportList *reports) { - BlendFileData *bfd = NULL; + BlendFileData *bfd = nullptr; FileData *fd; BlendFileReadReport bf_reports{}; bf_reports.reports = reports; @@ -397,7 +396,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const struct BlendFileReadParams *params, ReportList *reports) { - BlendFileData *bfd = NULL; + BlendFileData *bfd = nullptr; FileData *fd; ListBase old_mainlist; BlendFileReadReport bf_reports{}; diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index a527c16fa6e..dd954f6e3e9 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -5,13 +5,14 @@ * \ingroup blenloader */ -#include /* for isdigit. */ +#include /* for isdigit. */ +#include +#include +#include /* for va_start/end. */ +#include /* for offsetof. */ +#include /* for atoi. */ +#include /* for gmtime. */ #include /* for open flags (O_BINARY, O_RDONLY). */ -#include -#include /* for va_start/end. */ -#include /* for offsetof. */ -#include /* for atoi. */ -#include /* for gmtime. */ #include "BLI_utildefines.h" #ifndef WIN32 @@ -102,8 +103,6 @@ #include "readfile.h" -#include - /* Make preferences read-only. */ #define U (*((const UserDef *)&U)) @@ -181,7 +180,7 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname); static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name); static BHead *find_bhead_from_idname(FileData *fd, const char *idname); -typedef struct BHeadN { +struct BHeadN { struct BHeadN *next, *prev; #ifdef USE_BHEAD_READ_ON_DEMAND /** Use to read the data from the file directly into memory as needed. */ @@ -191,7 +190,7 @@ typedef struct BHeadN { #endif bool is_memchunk_identical; struct BHead bhead; -} BHeadN; +}; #define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead)))) @@ -230,14 +229,14 @@ static const char *library_parent_filepath(Library *lib) /** \name OldNewMap API * \{ */ -typedef struct OldNew { +struct OldNew { const void *oldp; void *newp; /* `nr` is "user count" for data, and ID code for libdata. */ int nr; -} OldNew; +}; -typedef struct OldNewMap { +struct OldNewMap { /* Array that stores the actual entries. */ OldNew *entries; int nentries; @@ -245,7 +244,7 @@ typedef struct OldNewMap { int32_t *map; int capacity_exp; -} OldNewMap; +}; #define ENTRIES_CAPACITY(onm) (1ll << (onm)->capacity_exp) #define MAP_CAPACITY(onm) (1ll << ((onm)->capacity_exp + 1)) @@ -336,7 +335,7 @@ static void oldnewmap_init_data(OldNewMap *onm, const int capacity_exp) oldnewmap_clear_map(onm); } -static OldNewMap *oldnewmap_new(void) +static OldNewMap *oldnewmap_new() { OldNewMap *onm = static_cast(MEM_mallocN(sizeof(*onm), "OldNewMap")); @@ -677,19 +676,19 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab /** \name File Parsing * \{ */ -typedef struct BlendDataReader { +struct BlendDataReader { FileData *fd; -} BlendDataReader; +}; -typedef struct BlendLibReader { +struct BlendLibReader { FileData *fd; Main *main; -} BlendLibReader; +}; -typedef struct BlendExpander { +struct BlendExpander { FileData *fd; Main *main; -} BlendExpander; +}; static void switch_endian_bh4(BHead4 *bhead) { @@ -1331,7 +1330,7 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, BlendFileReadRe } FileData *blo_filedata_from_memfile(MemFile *memfile, - const struct BlendFileReadParams *params, + const BlendFileReadParams *params, BlendFileReadReport *reports) { if (!memfile) { @@ -1699,15 +1698,15 @@ void blo_make_old_idmap_from_main(FileData *fd, Main *bmain) fd->old_idmap = BKE_main_idmap_create(bmain, false, nullptr, MAIN_IDMAP_TYPE_UUID); } -typedef struct BLOCacheStorage { +struct BLOCacheStorage { GHash *cache_map; MemArena *memarena; -} BLOCacheStorage; +}; -typedef struct BLOCacheStorageValue { +struct BLOCacheStorageValue { void *cache_v; uint new_usage_count; -} BLOCacheStorageValue; +}; /** Register a cache data entry to be preserved when reading some undo memfile. */ static void blo_cache_storage_entry_register( @@ -1857,7 +1856,7 @@ void blo_cache_storage_end(FileData *fd) /** \name DNA Struct Loading * \{ */ -static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead) +static void switch_endian_structs(const SDNA *filesdna, BHead *bhead) { int blocksize, nblocks; char *data; @@ -2318,10 +2317,10 @@ static void lib_link_scenes_check_set(Main *bmain) * \{ */ /* how to handle user count on pointer restore */ -typedef enum ePointerUserMode { +enum ePointerUserMode { USER_IGNORE = 0, /* ignore user count */ USER_REAL = 1, /* ensure at least one real user (fake user ignored) */ -} ePointerUserMode; +}; static void restore_pointer_user(ID *id, ID *newid, ePointerUserMode user) { @@ -2371,7 +2370,7 @@ static void *restore_pointer_by_name_main(Main *mainp, ID *id, ePointerUserMode * this could be made an optional argument (falling back to a full lookup), * however at the moment it's always available. */ -static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user) +static void *restore_pointer_by_name(IDNameLib_Map *id_map, ID *id, ePointerUserMode user) { #ifdef USE_GHASH_RESTORE_POINTER if (id) { @@ -2389,7 +2388,7 @@ static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePoin #endif } -static void lib_link_seq_clipboard_pt_restore(ID *id, struct IDNameLib_Map *id_map) +static void lib_link_seq_clipboard_pt_restore(ID *id, IDNameLib_Map *id_map) { if (id) { /* clipboard must ensure this */ @@ -2399,7 +2398,7 @@ static void lib_link_seq_clipboard_pt_restore(ID *id, struct IDNameLib_Map *id_m } static bool lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt) { - struct IDNameLib_Map *id_map = static_cast(arg_pt); + IDNameLib_Map *id_map = static_cast(arg_pt); lib_link_seq_clipboard_pt_restore((ID *)seq->scene, id_map); lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, id_map); @@ -2409,7 +2408,7 @@ static bool lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt) return true; } -static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map) +static void lib_link_clipboard_restore(IDNameLib_Map *id_map) { /* update IDs stored in sequencer clipboard */ SEQ_for_each_callback(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map); @@ -2436,7 +2435,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data) } } - struct IDNameLib_Map *id_map = static_cast(cb_data->user_data); + IDNameLib_Map *id_map = static_cast(cb_data->user_data); /* NOTE: Handling of user-count here is really bad, defining its own system... * Will have to be refactored at some point, but that is not top priority task for now. @@ -2447,7 +2446,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data) return IDWALK_RET_NOP; } -static void lib_link_main_data_restore(struct IDNameLib_Map *id_map, Main *newmain) +static void lib_link_main_data_restore(IDNameLib_Map *id_map, Main *newmain) { ID *id; FOREACH_MAIN_ID_BEGIN (newmain, id) { @@ -2456,7 +2455,7 @@ static void lib_link_main_data_restore(struct IDNameLib_Map *id_map, Main *newma FOREACH_MAIN_ID_END; } -static void lib_link_wm_xr_data_restore(struct IDNameLib_Map *id_map, wmXrData *xr_data) +static void lib_link_wm_xr_data_restore(IDNameLib_Map *id_map, wmXrData *xr_data) { xr_data->session_settings.base_pose_object = static_cast(restore_pointer_by_name( id_map, (ID *)xr_data->session_settings.base_pose_object, USER_REAL)); @@ -2512,18 +2511,18 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View } } -static void lib_link_restore_viewer_path(struct IDNameLib_Map *id_map, ViewerPath *viewer_path) +static void lib_link_restore_viewer_path(IDNameLib_Map *id_map, ViewerPath *viewer_path) { LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { if (elem->type == VIEWER_PATH_ELEM_TYPE_ID) { - auto typed_elem = reinterpret_cast(elem); + IDViewerPathElem *typed_elem = reinterpret_cast(elem); typed_elem->id = static_cast( restore_pointer_by_name(id_map, (ID *)typed_elem->id, USER_IGNORE)); } } } -static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, +static void lib_link_workspace_layout_restore(IDNameLib_Map *id_map, Main *newmain, WorkSpaceLayout *layout) { @@ -2764,8 +2763,7 @@ void blo_lib_link_restore(Main *oldmain, Scene *curscene, ViewLayer *cur_view_layer) { - struct IDNameLib_Map *id_map = BKE_main_idmap_create( - newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME); + IDNameLib_Map *id_map = BKE_main_idmap_create(newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME); LISTBASE_FOREACH (WorkSpace *, workspace, &newmain->workspaces) { LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { @@ -4069,8 +4067,8 @@ struct BHeadSort { static int verg_bheadsort(const void *v1, const void *v2) { - const struct BHeadSort *x1 = static_cast(v1), - *x2 = static_cast(v2); + const BHeadSort *x1 = static_cast(v1), + *x2 = static_cast(v2); if (x1->old > x2->old) { return 1; @@ -4084,7 +4082,7 @@ static int verg_bheadsort(const void *v1, const void *v2) static void sort_bhead_old_map(FileData *fd) { BHead *bhead; - struct BHeadSort *bhs; + BHeadSort *bhs; int tot = 0; for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { @@ -4097,14 +4095,14 @@ static void sort_bhead_old_map(FileData *fd) } bhs = fd->bheadmap = static_cast( - MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort")); + MEM_malloc_arrayN(tot, sizeof(BHeadSort), "BHeadSort")); for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead), bhs++) { bhs->bhead = bhead; bhs->old = bhead->old; } - qsort(fd->bheadmap, tot, sizeof(struct BHeadSort), verg_bheadsort); + qsort(fd->bheadmap, tot, sizeof(BHeadSort), verg_bheadsort); } static BHead *find_previous_lib(FileData *fd, BHead *bhead) @@ -4128,7 +4126,7 @@ static BHead *find_bhead(FileData *fd, void *old) #if 0 BHead* bhead; #endif - struct BHeadSort *bhs, bhs_s; + BHeadSort *bhs, bhs_s; if (!old) { return nullptr; @@ -4140,7 +4138,7 @@ static BHead *find_bhead(FileData *fd, void *old) bhs_s.old = old; bhs = static_cast( - bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort)); + bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(BHeadSort), verg_bheadsort)); if (bhs) { return bhs->bhead; @@ -4475,7 +4473,7 @@ ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name, - const struct LibraryLink_Params *params) + const LibraryLink_Params *params) { FileData *fd = (FileData *)(*bh); return link_named_part(mainl, fd, idcode, name, params->flag); @@ -4515,8 +4513,8 @@ static Main *library_link_begin(Main *mainvar, return mainl; } -void BLO_library_link_params_init(struct LibraryLink_Params *params, - struct Main *bmain, +void BLO_library_link_params_init(LibraryLink_Params *params, + Main *bmain, const int flag, const int id_tag_extra) { @@ -4526,14 +4524,14 @@ void BLO_library_link_params_init(struct LibraryLink_Params *params, params->id_tag_extra = id_tag_extra; } -void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, - struct Main *bmain, +void BLO_library_link_params_init_with_context(LibraryLink_Params *params, + Main *bmain, const int flag, const int id_tag_extra, /* Context arguments. */ - struct Scene *scene, - struct ViewLayer *view_layer, - const struct View3D *v3d) + Scene *scene, + ViewLayer *view_layer, + const View3D *v3d) { BLO_library_link_params_init(params, bmain, flag, id_tag_extra); if (scene != nullptr) { @@ -4545,7 +4543,7 @@ void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params Main *BLO_library_link_begin(BlendHandle **bh, const char *filepath, - const struct LibraryLink_Params *params) + const LibraryLink_Params *params) { FileData *fd = (FileData *)(*bh); return library_link_begin(params->bmain, &fd, filepath, params->id_tag_extra); @@ -4667,7 +4665,7 @@ static void library_link_end(Main *mainl, FileData **fd, const int flag) } } -void BLO_library_link_end(Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params) +void BLO_library_link_end(Main *mainl, BlendHandle **bh, const LibraryLink_Params *params) { FileData *fd = (FileData *)(*bh); library_link_end(mainl, &fd, params->flag); @@ -5056,7 +5054,7 @@ void BLO_read_list_cb(BlendDataReader *reader, ListBase *list, BlendReadListFn c list->last = prev; } -void BLO_read_list(BlendDataReader *reader, struct ListBase *list) +void BLO_read_list(BlendDataReader *reader, ListBase *list) { BLO_read_list_cb(reader, list, nullptr); } diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 8a6c73a7a5b..0584dd6b059 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -674,7 +674,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt { using namespace blender; /* Otherwise `ntree->typeInfo` is null. */ - ntreeSetTypes(NULL, ntree); + ntreeSetTypes(nullptr, ntree); LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { if (node->type != GEO_NODE_TRANSFER_ATTRIBUTE_DEPRECATED) { continue; @@ -685,7 +685,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt switch (storage->mode) { case GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED: { bNode *sample_nearest_surface = nodeAddStaticNode( - NULL, ntree, GEO_NODE_SAMPLE_NEAREST_SURFACE); + nullptr, ntree, GEO_NODE_SAMPLE_NEAREST_SURFACE); sample_nearest_surface->parent = node->parent; sample_nearest_surface->custom1 = storage->data_type; sample_nearest_surface->locx = node->locx; @@ -711,7 +711,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt eAttrDomain(storage->domain); /* Use a sample index node to retrieve the data with this node's index output. */ - bNode *sample_index = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_INDEX); + bNode *sample_index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_INDEX); NodeGeometrySampleIndex *sample_storage = static_cast( sample_index->storage); sample_storage->data_type = storage->data_type; @@ -727,7 +727,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt nodeFindSocket(sample_index, SOCK_IN, "Geometry")); } - bNode *sample_nearest = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_NEAREST); + bNode *sample_nearest = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_NEAREST); sample_nearest->parent = node->parent; sample_nearest->custom1 = storage->data_type; sample_nearest->custom2 = domain; @@ -767,7 +767,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt break; } case GEO_NODE_ATTRIBUTE_TRANSFER_INDEX: { - bNode *sample_index = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_INDEX); + bNode *sample_index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_INDEX); NodeGeometrySampleIndex *sample_storage = static_cast( sample_index->storage); sample_storage->data_type = storage->data_type; @@ -792,7 +792,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt if (!index_was_linked) { /* Add an index input node, since the new node doesn't use an implicit input. */ - bNode *index = nodeAddStaticNode(NULL, ntree, GEO_NODE_INPUT_INDEX); + bNode *index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_INPUT_INDEX); index->parent = node->parent; index->locx = node->locx - 25.0f; index->locy = node->locy - 25.0f; @@ -807,7 +807,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt } /* The storage must be freed manually because the node type isn't defined anymore. */ MEM_freeN(node->storage); - nodeRemoveNode(NULL, ntree, node, false); + nodeRemoveNode(nullptr, ntree, node, false); } } @@ -2992,7 +2992,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { ToolSettings *tool_settings = scene->toolsettings; - tool_settings->snap_flag_seq = tool_settings->snap_flag & ~(SCE_SNAP | SCE_SNAP_SEQ); + tool_settings->snap_flag_seq = tool_settings->snap_flag & + ~(short(SCE_SNAP) | short(SCE_SNAP_SEQ)); if (tool_settings->snap_flag & SCE_SNAP_SEQ) { tool_settings->snap_flag_seq |= SCE_SNAP; tool_settings->snap_flag &= ~SCE_SNAP_SEQ; diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index c87983f1287..56ada76eae6 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -249,7 +249,7 @@ void node_tree_relink_with_socket_id_map(bNodeTree &ntree, bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_IN, new_identifier->c_str()); link->tonode = &new_node; link->tosock = new_socket; - old_socket->link = NULL; + old_socket->link = nullptr; } } if (link->fromnode == &old_node) { @@ -258,7 +258,7 @@ void node_tree_relink_with_socket_id_map(bNodeTree &ntree, bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_OUT, new_identifier->c_str()); link->fromnode = &new_node; link->fromsock = new_socket; - old_socket->link = NULL; + old_socket->link = nullptr; } } } diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 4625a4471fe..42bc884098e 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -55,12 +55,13 @@ * - write #USER (#UserDef struct) if filename is `~/.config/blender/X.XX/config/startup.blend`. */ +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include #ifdef WIN32 # include "BLI_winstuff.h" @@ -116,8 +117,6 @@ #include "readfile.h" -#include - #include /* Make preferences read-only. */ @@ -143,19 +142,18 @@ static CLG_LogRef LOG = {"blo.writefile"}; /** \name Internal Write Wrapper's (Abstracts Compression) * \{ */ -typedef enum { +enum eWriteWrapType { WW_WRAP_NONE = 1, WW_WRAP_ZSTD, -} eWriteWrapType; +}; -typedef struct ZstdFrame { +struct ZstdFrame { struct ZstdFrame *next, *prev; uint32_t compressed_size; uint32_t uncompressed_size; -} ZstdFrame; +}; -typedef struct WriteWrap WriteWrap; struct WriteWrap { /* callbacks */ bool (*open)(WriteWrap *ww, const char *filepath); @@ -395,8 +393,8 @@ static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww) /** \name Write Data Type & Functions * \{ */ -typedef struct { - const struct SDNA *sdna; +struct WriteData { + const SDNA *sdna; struct { /** Use for file and memory writing (size stored in max_size). */ @@ -429,11 +427,11 @@ typedef struct { * Will be nullptr for UNDO. */ WriteWrap *ww; -} WriteData; +}; -typedef struct BlendWriter { +struct BlendWriter { WriteData *wd; -} BlendWriter; +}; static WriteData *writedata_new(WriteWrap *ww) { @@ -812,11 +810,11 @@ static void current_screen_compat(Main *mainvar, nullptr; } -typedef struct RenderInfo { +struct RenderInfo { int sfra; int efra; char scene_name[MAX_ID_NAME - 2]; -} RenderInfo; +}; /** * This was originally added for the historic render-daemon feature, diff --git a/source/blender/draw/engines/eevee_next/eevee_engine.cc b/source/blender/draw/engines/eevee_next/eevee_engine.cc index 214f6a001f0..3ea6ea475d0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_engine.cc +++ b/source/blender/draw/engines/eevee_next/eevee_engine.cc @@ -165,9 +165,7 @@ static void eevee_render_to_image(void *vedata, instance->render_frame(layer, viewname); EEVEE_Data *ved = static_cast(vedata); - if (ved->instance) { - delete ved->instance; - } + delete ved->instance; ved->instance = instance; } diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.cc b/source/blender/draw/engines/overlay/overlay_antialiasing.cc index 2242ad8b609..2eefdce403c 100644 --- a/source/blender/draw/engines/overlay/overlay_antialiasing.cc +++ b/source/blender/draw/engines/overlay/overlay_antialiasing.cc @@ -53,7 +53,7 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); /* Small texture which will have very small impact on render-time. */ - if (txl->dummy_depth_tx == NULL) { + if (txl->dummy_depth_tx == nullptr) { const float pixel[1] = {1.0f}; txl->dummy_depth_tx = DRW_texture_create_2d( 1, 1, GPU_DEPTH_COMPONENT24, DRWTextureFlag(0), pixel); @@ -68,8 +68,8 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) pd->antialiasing.enabled = need_wire_expansion || ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); - GPUTexture *color_tex = NULL; - GPUTexture *line_tex = NULL; + GPUTexture *color_tex = nullptr; + GPUTexture *line_tex = nullptr; if (pd->antialiasing.enabled) { DRW_texture_ensure_fullscreen_2d(&txl->overlay_color_tx, GPU_SRGB8_A8, DRW_TEX_FILTER); @@ -107,7 +107,7 @@ void OVERLAY_antialiasing_cache_init(OVERLAY_Data *vedata) OVERLAY_PrivateData *pd = vedata->stl->pd; OVERLAY_PassList *psl = vedata->psl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - struct GPUShader *sh; + GPUShader *sh; DRWShadingGroup *grp; if (pd->antialiasing.enabled) { @@ -124,7 +124,7 @@ void OVERLAY_antialiasing_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "depthTex", &dtxl->depth); DRW_shgroup_uniform_texture_ref(grp, "colorTex", &txl->overlay_color_tx); DRW_shgroup_uniform_texture_ref(grp, "lineTex", &txl->overlay_line_tx); - DRW_shgroup_call_procedural_triangles(grp, NULL, 1); + DRW_shgroup_call_procedural_triangles(grp, nullptr, 1); } /* A bit out of place... not related to antialiasing. */ @@ -136,7 +136,7 @@ void OVERLAY_antialiasing_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "depthTex", &dtxl->depth); DRW_shgroup_uniform_texture_ref(grp, "xrayDepthTex", &txl->temp_depth_tx); DRW_shgroup_uniform_float_copy(grp, "opacity", 1.0f - pd->xray_opacity); - DRW_shgroup_call_procedural_triangles(grp, NULL, 1); + DRW_shgroup_call_procedural_triangles(grp, nullptr, 1); } } @@ -169,10 +169,10 @@ void OVERLAY_antialiasing_cache_finish(OVERLAY_Data *vedata) GPU_ATTACHMENT_TEXTURE(txl->overlay_line_tx)}); } - pd->antialiasing.do_depth_copy = !(psl->wireframe_ps == NULL || + pd->antialiasing.do_depth_copy = !(psl->wireframe_ps == nullptr || DRW_pass_is_empty(psl->wireframe_ps)) || (pd->xray_enabled && pd->xray_opacity > 0.0f); - pd->antialiasing.do_depth_infront_copy = !(psl->wireframe_xray_ps == NULL || + pd->antialiasing.do_depth_infront_copy = !(psl->wireframe_xray_ps == nullptr || DRW_pass_is_empty(psl->wireframe_xray_ps)); const bool do_wireframe = pd->antialiasing.do_depth_copy || diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 45bdc9cd123..0cf9d91804a 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -5,9 +5,9 @@ * \ingroup draw_engine */ -#include -#include -#include +#include +#include +#include #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -46,7 +46,7 @@ #define PT_DEFAULT_RAD 0.05f /* radius of the point batch. */ -typedef struct ArmatureDrawContext { +struct ArmatureDrawContext { /* Current armature object */ Object *ob; /* bArmature *arm; */ /* TODO */ @@ -87,7 +87,7 @@ typedef struct ArmatureDrawContext { bool show_relations; const ThemeWireColor *bcolor; /* pchan color */ -} ArmatureDrawContext; +}; bool OVERLAY_armature_is_pose_mode(Object *ob, const DRWContextState *draw_ctx) { @@ -135,7 +135,7 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) DRW_PASS_CREATE(psl->armature_bone_select_ps, state | pd->clipping_state); float alpha = pd->overlay.xray_alpha_bone; - struct GPUShader *sh = OVERLAY_shader_uniform_color(); + GPUShader *sh = OVERLAY_shader_uniform_color(); DRWShadingGroup *grp; pd->armature_bone_select_act_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); @@ -148,8 +148,8 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) } for (int i = 0; i < 2; i++) { - struct GPUShader *sh; - struct GPUVertFormat *format; + GPUShader *sh; + GPUVertFormat *format; DRWShadingGroup *grp = nullptr; OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); @@ -620,7 +620,7 @@ extern "C" void drw_batch_cache_generate_requested_delayed(Object *custom); BLI_INLINE DRWCallBuffer *custom_bone_instance_shgroup(ArmatureDrawContext *ctx, DRWShadingGroup *grp, - struct GPUBatch *custom_geom) + GPUBatch *custom_geom) { DRWCallBuffer *buf = static_cast( BLI_ghash_lookup(ctx->custom_shapes_ghash, custom_geom)); @@ -644,9 +644,9 @@ static void drw_shgroup_bone_custom_solid_mesh(ArmatureDrawContext *ctx, * to assure batch cache is valid. */ DRW_mesh_batch_cache_validate(custom, mesh); - struct GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); - struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, nullptr); - struct GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); + GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); + GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, nullptr); + GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); BoneInstanceData inst_data; DRWCallBuffer *buf; @@ -688,7 +688,7 @@ static void drw_shgroup_bone_custom_mesh_wire(ArmatureDrawContext *ctx, * to assure batch cache is valid. */ DRW_mesh_batch_cache_validate(custom, mesh); - struct GPUBatch *geom = DRW_mesh_batch_cache_get_all_edges(mesh); + GPUBatch *geom = DRW_mesh_batch_cache_get_all_edges(mesh); if (geom) { DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, geom); BoneInstanceData inst_data; @@ -714,7 +714,7 @@ static void drw_shgroup_custom_bone_curve(ArmatureDrawContext *ctx, /* This only handles curves without any surface. The other curve types should have been converted * to meshes and rendered in the mesh drawing function. */ - struct GPUBatch *ledges = nullptr; + GPUBatch *ledges = nullptr; if (custom->type == OB_FONT) { ledges = DRW_cache_text_edge_wire_get(custom); } @@ -2066,7 +2066,7 @@ static void draw_bone_name(ArmatureDrawContext *ctx, bArmature *arm, const int boneflag) { - struct DRWTextStore *dt = DRW_text_cache_ensure(); + DRWTextStore *dt = DRW_text_cache_ensure(); uchar color[4]; float vec[3]; @@ -2579,7 +2579,7 @@ void OVERLAY_pose_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - struct GPUBatch *geom = DRW_cache_object_surface_get(ob); + GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { if (POSE_is_driven_by_active_armature(ob)) { DRW_shgroup_call(pd->armature_bone_select_act_grp, geom, ob); diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 2b1af67175e..0fcbe5ab07d 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -36,11 +36,11 @@ /* Forward declarations. */ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob); -typedef struct OVERLAY_StretchingAreaTotals { +struct OVERLAY_StretchingAreaTotals { void *next, *prev; float *total_area; float *total_area_uv; -} OVERLAY_StretchingAreaTotals; +}; static OVERLAY_UVLineStyle edit_uv_line_style_from_space_image(const SpaceImage *sima) { @@ -328,7 +328,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) } if (pd->edit_uv.do_tiled_image_overlay) { - struct DRWTextStore *dt = DRW_text_cache_ensure(); + DRWTextStore *dt = DRW_text_cache_ensure(); uchar color[4]; /* Color Management: Exception here as texts are drawn in sRGB space directly. */ UI_GetThemeColorShade4ubv(TH_BACK, 60, color); diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc b/source/blender/draw/engines/overlay/overlay_engine.cc index c2c4706138f..f1fdfe98fdc 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -724,7 +724,7 @@ static void OVERLAY_draw_scene(void *vedata) OVERLAY_antialiasing_end(data); } -static void OVERLAY_engine_free(void) +static void OVERLAY_engine_free() { OVERLAY_shader_free(); } diff --git a/source/blender/draw/engines/overlay/overlay_extra.cc b/source/blender/draw/engines/overlay/overlay_extra.cc index f0665f7e90f..724ebd64e16 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.cc +++ b/source/blender/draw/engines/overlay/overlay_extra.cc @@ -60,8 +60,8 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) DRW_PASS_CREATE(psl->extra_grid_ps, state | pd->clipping_state); DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); DRWShadingGroup *grp; - struct GPUShader *sh = OVERLAY_shader_extra_grid(); - struct GPUTexture *tex = DRW_state_is_fbo() ? dtxl->depth : txl->dummy_depth_tx; + GPUShader *sh = OVERLAY_shader_extra_grid(); + GPUTexture *tex = DRW_state_is_fbo() ? dtxl->depth : txl->dummy_depth_tx; pd->extra_grid_grp = grp = DRW_shgroup_create(sh, psl->extra_grid_ps); DRW_shgroup_uniform_texture(grp, "depthBuffer", tex); @@ -71,8 +71,8 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) for (int i = 0; i < 2; i++) { /* Non Meshes Pass (Camera, empties, lights ...) */ - struct GPUShader *sh; - struct GPUVertFormat *format; + GPUShader *sh; + GPUVertFormat *format; DRWShadingGroup *grp, *grp_sub; OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); @@ -248,7 +248,7 @@ OVERLAY_ExtraCallBuffers *OVERLAY_extra_call_buffer_get(OVERLAY_Data *vedata, Ob } void OVERLAY_extra_loose_points(OVERLAY_ExtraCallBuffers *cb, - struct GPUBatch *geom, + GPUBatch *geom, const float mat[4][4], const float color[4]) { @@ -258,7 +258,7 @@ void OVERLAY_extra_loose_points(OVERLAY_ExtraCallBuffers *cb, } void OVERLAY_extra_wire(OVERLAY_ExtraCallBuffers *cb, - struct GPUBatch *geom, + GPUBatch *geom, const float mat[4][4], const float color[4]) { @@ -806,7 +806,7 @@ void OVERLAY_speaker_cache_populate(OVERLAY_Data *vedata, Object *ob) /** \name Camera * \{ */ -typedef union OVERLAY_CameraInstanceData { +union OVERLAY_CameraInstanceData { /* Pack render data into object matrix and object color. */ struct { float color[4]; @@ -842,7 +842,7 @@ typedef union OVERLAY_CameraInstanceData { float mist_end; }; }; -} OVERLAY_CameraInstanceData; +}; static void camera_view3d_reconstruction( OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const float color[4]) @@ -946,7 +946,7 @@ static void camera_view3d_reconstruction( } if ((v3d->flag2 & V3D_SHOW_BUNDLENAME) && !is_select) { - struct DRWTextStore *dt = DRW_text_cache_ensure(); + DRWTextStore *dt = DRW_text_cache_ensure(); DRW_text_cache_add(dt, bundle_mat[3], @@ -1333,7 +1333,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, OVERLAY_extra_line_dashed(cb, ct->matrix[3], ob->obmat[3], constraint_color); } - BKE_constraint_targets_flush(curcon, &targets, 1); + BKE_constraint_targets_flush(curcon, &targets, true); } } } @@ -1507,7 +1507,7 @@ static void OVERLAY_object_center(OVERLAY_ExtraCallBuffers *cb, static void OVERLAY_object_name(Object *ob, int theme_id) { - struct DRWTextStore *dt = DRW_text_cache_ensure(); + DRWTextStore *dt = DRW_text_cache_ensure(); uchar color[4]; /* Color Management: Exception here as texts are drawn in sRGB space directly. */ UI_GetThemeColor4ubv(theme_id, color); diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 9a8f48b33fa..98531637e57 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -7,7 +7,7 @@ * \brief PointCloud API for render engines */ -#include +#include #include "MEM_guardedalloc.h" diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 4ab522952b4..0974f5d14b1 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -1009,7 +1009,7 @@ static void drw_command_set_mutable_state(DRWShadingGroup *shgroup, void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, Object *ob, float (*obmat)[4], - struct GPUBatch *geom, + GPUBatch *geom, bool bypass_culling, void *user_data) { @@ -1036,7 +1036,7 @@ void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, } void DRW_shgroup_call_range( - DRWShadingGroup *shgroup, struct Object *ob, GPUBatch *geom, uint v_sta, uint v_num) + DRWShadingGroup *shgroup, Object *ob, GPUBatch *geom, uint v_sta, uint v_num) { BLI_assert(geom != nullptr); if (G.f & G_FLAG_PICKSEL) { @@ -1047,7 +1047,7 @@ void DRW_shgroup_call_range( } void DRW_shgroup_call_instance_range( - DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_num) + DRWShadingGroup *shgroup, Object *ob, GPUBatch *geom, uint i_sta, uint i_num) { BLI_assert(geom != nullptr); if (G.f & G_FLAG_PICKSEL) { @@ -1105,19 +1105,19 @@ static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup, void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, Object *ob, uint point_count) { - struct GPUBatch *geom = drw_cache_procedural_points_get(); + GPUBatch *geom = drw_cache_procedural_points_get(); drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, point_count); } void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup, Object *ob, uint line_count) { - struct GPUBatch *geom = drw_cache_procedural_lines_get(); + GPUBatch *geom = drw_cache_procedural_lines_get(); drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, line_count * 2); } void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count) { - struct GPUBatch *geom = drw_cache_procedural_triangles_get(); + GPUBatch *geom = drw_cache_procedural_triangles_get(); drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, tri_count * 3); } @@ -1126,7 +1126,7 @@ void DRW_shgroup_call_procedural_indirect(DRWShadingGroup *shgroup, Object *ob, GPUStorageBuf *indirect_buf) { - struct GPUBatch *geom = nullptr; + GPUBatch *geom = nullptr; switch (primitive_type) { case GPU_PRIM_POINTS: geom = drw_cache_procedural_points_get(); @@ -1153,10 +1153,7 @@ void DRW_shgroup_call_procedural_indirect(DRWShadingGroup *shgroup, drw_command_draw_indirect(shgroup, geom, handle, indirect_buf); } -void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, - Object *ob, - struct GPUBatch *geom, - uint count) +void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, Object *ob, GPUBatch *geom, uint count) { BLI_assert(geom != nullptr); if (G.f & G_FLAG_PICKSEL) { @@ -1168,8 +1165,8 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, Object *ob, - struct GPUBatch *geom, - struct GPUBatch *inst_attributes) + GPUBatch *geom, + GPUBatch *inst_attributes) { BLI_assert(geom != nullptr); BLI_assert(inst_attributes != nullptr); @@ -1183,7 +1180,7 @@ void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, } #define SCULPT_DEBUG_BUFFERS (G.debug_value == 889) -typedef struct DRWSculptCallbackData { +struct DRWSculptCallbackData { Object *ob; DRWShadingGroup **shading_groups; int num_shading_groups; @@ -1196,7 +1193,7 @@ typedef struct DRWSculptCallbackData { int debug_node_nr; PBVHAttrReq *attrs; int attrs_num; -} DRWSculptCallbackData; +}; #define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9]) static float sculpt_debug_colors[9][4] = { @@ -1514,7 +1511,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, static GPUVertFormat inst_select_format = {0}; DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, - struct GPUVertFormat *format, + GPUVertFormat *format, GPUPrimType prim_type) { BLI_assert(ELEM(prim_type, GPU_PRIM_POINTS, GPU_PRIM_LINES, GPU_PRIM_TRI_FAN)); @@ -1544,7 +1541,7 @@ DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, } DRWCallBuffer *DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup, - struct GPUVertFormat *format, + GPUVertFormat *format, GPUBatch *geom) { BLI_assert(geom != nullptr); @@ -1740,7 +1737,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP) == -1); } -static DRWShadingGroup *drw_shgroup_create_ex(struct GPUShader *shader, DRWPass *pass) +static DRWShadingGroup *drw_shgroup_create_ex(GPUShader *shader, DRWPass *pass) { DRWShadingGroup *shgroup = static_cast( BLI_memblock_alloc(DST.vmempool->shgroups)); @@ -1785,7 +1782,7 @@ static void drw_shgroup_material_texture(DRWShadingGroup *grp, GPU_texture_ref(gputex); } -void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial *material) +void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *material) { ListBase textures = GPU_material_textures(material); @@ -1849,7 +1846,7 @@ GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat att return format; } -DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass) +DRWShadingGroup *DRW_shgroup_material_create(GPUMaterial *material, DRWPass *pass) { GPUPass *gpupass = GPU_material_get_pass(material); DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass); @@ -1861,14 +1858,14 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa return shgroup; } -DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass) +DRWShadingGroup *DRW_shgroup_create(GPUShader *shader, DRWPass *pass) { DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); drw_shgroup_init(shgroup, shader); return shgroup; } -DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, +DRWShadingGroup *DRW_shgroup_transform_feedback_create(GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target) { @@ -2220,7 +2217,7 @@ DRWView *DRW_view_create(const float viewmat[4][4], if (DST.draw_ctx.evil_C && DST.draw_ctx.region) { int region_origin[2] = {DST.draw_ctx.region->winrct.xmin, DST.draw_ctx.region->winrct.ymin}; - struct wmWindow *win = CTX_wm_window(DST.draw_ctx.evil_C); + wmWindow *win = CTX_wm_window(DST.draw_ctx.evil_C); wm_cursor_position_get(win, &view->storage.mouse_pixel[0], &view->storage.mouse_pixel[1]); sub_v2_v2v2_int(view->storage.mouse_pixel, view->storage.mouse_pixel, region_origin); } diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 287270079e5..4170285e1d9 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -8,17 +8,24 @@ * Embeds GPU meshes inside of PBVH nodes, used by mesh sculpt mode. */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "MEM_guardedalloc.h" #include "BLI_bitmap.h" #include "BLI_ghash.h" +#include "BLI_index_range.hh" +#include "BLI_map.hh" #include "BLI_math_color.h" +#include "BLI_math_vec_types.hh" #include "BLI_utildefines.h" +#include "BLI_vector.hh" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -44,15 +51,6 @@ #define MAX_PBVH_BATCH_KEY 512 #define MAX_PBVH_VBOS 16 -#include "BLI_index_range.hh" -#include "BLI_map.hh" -#include "BLI_math_vec_types.hh" -#include "BLI_vector.hh" -#include - -#include -#include - using blender::char3; using blender::float2; using blender::float3; diff --git a/source/blender/editors/gpencil/gpencil_bake_animation.cc b/source/blender/editors/gpencil/gpencil_bake_animation.cc index a163d95f46b..ad19ac94646 100644 --- a/source/blender/editors/gpencil/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil/gpencil_bake_animation.cc @@ -298,7 +298,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op BLI_addtail(&gpl_dst->frames, gpf_dst); LISTBASE_FOREACH (bGPDstroke *, gps, &gpf_dst->strokes) { - gps->runtime.gps_orig = NULL; + gps->runtime.gps_orig = nullptr; /* Create material of the stroke. */ Material *ma_src = BKE_object_material_get(elem->ob, gps->mat_nr + 1); bool found = false; @@ -322,7 +322,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op for (int j = 0; j < gps->totpoints; j++) { bGPDspoint *pt = &gps->points[j]; pt->runtime.idx_orig = 0; - pt->runtime.pt_orig = NULL; + pt->runtime.pt_orig = nullptr; mul_m4_v3(ob_eval->obmat, &pt->x); mul_m4_v3(invmat, &pt->x); } diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 23cbcabbc0e..b499ae0ce59 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -107,7 +107,7 @@ bool uvedit_uv_select_test(const struct Scene *scene, struct BMLoop *l, int cd_l * Changes selection state of a single UV Face. */ void uvedit_face_select_set(const struct Scene *scene, - struct BMesh *em, + struct BMesh *bm, struct BMFace *efa, bool select, bool do_history, @@ -118,7 +118,7 @@ void uvedit_face_select_set(const struct Scene *scene, * Changes selection state of a single UV Edge. */ void uvedit_edge_select_set(const struct Scene *scene, - struct BMesh *em, + struct BMesh *bm, struct BMLoop *l, bool select, bool do_history, @@ -129,7 +129,7 @@ void uvedit_edge_select_set(const struct Scene *scene, * Changes selection state of a single UV vertex. */ void uvedit_uv_select_set(const struct Scene *scene, - struct BMesh *em, + struct BMesh *bm, struct BMLoop *l, bool select, bool do_history, diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 6815f8689f5..8b29f1075b8 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -1578,7 +1578,7 @@ static bool jump_to_target_button(bContext *C, bool poll) int found = 0; /* Jump to target only works with search properties currently, not search callbacks yet. * See ui_but_add_search. */ - if (coll_search->search_prop != NULL) { + if (coll_search->search_prop != nullptr) { found = RNA_property_collection_lookup_string( &coll_search->search_ptr, coll_search->search_prop, str_ptr, &target_ptr); } diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 86e104359f3..fcd3e579b06 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -546,7 +546,7 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, return nullptr; } - NearestEdgeUserData data = {{0}}; + NearestEdgeUserData data = {{nullptr}}; const NearestEdgeUserData_Hit *hit = nullptr; /* interpolate along the edge before doing a clipping plane test */ const eV3DProjTest clip_flag = V3D_PROJ_TEST_CLIP_DEFAULT & ~V3D_PROJ_TEST_CLIP_BB; @@ -1414,9 +1414,9 @@ void MESH_OT_select_mode(wmOperatorType *ot) PropertyRNA *prop; static const EnumPropertyItem actions_items[] = { - {0, "DISABLE", 0, "Disable", "Disable selected markers"}, - {1, "ENABLE", 0, "Enable", "Enable selected markers"}, - {2, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"}, + {0, "DISABLE", false, "Disable", "Disable selected markers"}, + {1, "ENABLE", false, "Enable", "Enable selected markers"}, + {2, "TOGGLE", false, "Toggle", "Toggle disabled flag for selected markers"}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -1597,7 +1597,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "ring", 0, "Ring", ""); + RNA_def_boolean(ot->srna, "ring", false, "Ring", ""); } /** \} */ @@ -1865,13 +1865,13 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* properties */ PropertyRNA *prop; - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Extend the selection"); + prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", "Extend the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); + prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Select", "Toggle the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", "Select ring"); + prop = RNA_def_boolean(ot->srna, "ring", false, "Select Ring", "Select ring"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -1891,11 +1891,11 @@ void MESH_OT_edgering_select(wmOperatorType *ot) /* Properties. */ PropertyRNA *prop; - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); + prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Select", "Toggle the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -3745,7 +3745,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); + RNA_def_boolean(ot->srna, "deselect", false, "Deselect", ""); prop = RNA_def_enum_flag(ot->srna, "delimit", rna_enum_mesh_delimit_mode_items, @@ -3830,10 +3830,10 @@ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op) void MESH_OT_select_face_by_sides(wmOperatorType *ot) { static const EnumPropertyItem type_items[] = { - {0, "LESS", 0, "Less Than", ""}, - {1, "EQUAL", 0, "Equal To", ""}, - {2, "GREATER", 0, "Greater Than", ""}, - {3, "NOTEQUAL", 0, "Not Equal To", ""}, + {0, "LESS", false, "Less Than", ""}, + {1, "EQUAL", false, "Equal To", ""}, + {2, "GREATER", false, "Greater Than", ""}, + {3, "NOTEQUAL", false, "Not Equal To", ""}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -4023,7 +4023,7 @@ void MESH_OT_select_mirror(wmOperatorType *ot) /* props */ RNA_def_enum_flag(ot->srna, "axis", rna_enum_axis_flag_xyz_items, (1 << 0), "Axis", ""); - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the existing selection"); } /** \} */ @@ -5012,9 +5012,9 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) void MESH_OT_select_axis(wmOperatorType *ot) { static const EnumPropertyItem axis_sign_items[] = { - {SELECT_AXIS_POS, "POS", 0, "Positive Axis", ""}, - {SELECT_AXIS_NEG, "NEG", 0, "Negative Axis", ""}, - {SELECT_AXIS_ALIGN, "ALIGN", 0, "Aligned Axis", ""}, + {SELECT_AXIS_POS, "POS", false, "Positive Axis", ""}, + {SELECT_AXIS_NEG, "NEG", false, "Negative Axis", ""}, + {SELECT_AXIS_ALIGN, "ALIGN", false, "Aligned Axis", ""}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -5345,7 +5345,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot) RNA_def_boolean(ot->srna, "select_bigger", - 0, + false, "Select Bigger", "Select bigger regions instead of smaller ones"); } diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index 9dec3583763..122b8fa7d89 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -639,7 +639,7 @@ static int mesh_customdata_add_exec__internal(bContext *C, char htype, int type) BM_data_layer_add(mesh->edit_mesh->bm, data, type); } else { - CustomData_add_layer(data, type, CD_SET_DEFAULT, NULL, tot); + CustomData_add_layer(data, type, CD_SET_DEFAULT, nullptr, tot); } DEG_id_tag_update(&mesh->id, 0); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 271e94d48d4..a71358f4925 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -6100,23 +6100,23 @@ void SCULPT_fake_neighbors_free(Object *ob) void SCULPT_automasking_node_begin(Object *ob, const SculptSession *UNUSED(ss), AutomaskingCache *automasking, - AutomaskingNodeData *node_data, + AutomaskingNodeData *automask_data, PBVHNode *node) { if (!automasking) { - memset(node_data, 0, sizeof(*node_data)); + memset(automask_data, 0, sizeof(*automask_data)); return; } - node_data->node = node; - node_data->have_orig_data = automasking->settings.flags & - (BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL); + automask_data->node = node; + automask_data->have_orig_data = automasking->settings.flags & + (BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL); - if (node_data->have_orig_data) { - SCULPT_orig_vert_data_init(&node_data->orig_data, ob, node, SCULPT_UNDO_COORDS); + if (automask_data->have_orig_data) { + SCULPT_orig_vert_data_init(&automask_data->orig_data, ob, node, SCULPT_UNDO_COORDS); } else { - memset(&node_data->orig_data, 0, sizeof(node_data->orig_data)); + memset(&automask_data->orig_data, 0, sizeof(automask_data->orig_data)); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index f0ce901e059..ea8cde9312a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -170,7 +170,7 @@ static float sculpt_automasking_normal_calc(SculptSession *ss, return t; } - else if (angle > limit_upper) { + if (angle > limit_upper) { return 0.0f; } diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 8ff84dabbbe..a85aa623519 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -271,12 +271,12 @@ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in /* Face Sets Operators */ -typedef enum eSculptFaceGroupsCreateModes { +enum eSculptFaceGroupsCreateModes { SCULPT_FACE_SET_MASKED = 0, SCULPT_FACE_SET_VISIBLE = 1, SCULPT_FACE_SET_ALL = 2, SCULPT_FACE_SET_SELECTION = 3, -} eSculptFaceGroupsCreateModes; +}; static EnumPropertyItem prop_sculpt_face_set_create_types[] = { { @@ -446,7 +446,7 @@ void SCULPT_OT_face_sets_create(wmOperatorType *ot) ot->srna, "mode", prop_sculpt_face_set_create_types, SCULPT_FACE_SET_MASKED, "Mode", ""); } -typedef enum eSculptFaceSetsInitMode { +enum eSculptFaceSetsInitMode { SCULPT_FACE_SETS_FROM_LOOSE_PARTS = 0, SCULPT_FACE_SETS_FROM_MATERIALS = 1, SCULPT_FACE_SETS_FROM_NORMALS = 2, @@ -456,7 +456,7 @@ typedef enum eSculptFaceSetsInitMode { SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6, SCULPT_FACE_SETS_FROM_FACE_MAPS = 7, SCULPT_FACE_SETS_FROM_FACE_SET_BOUNDARIES = 8, -} eSculptFaceSetsInitMode; +}; static EnumPropertyItem prop_sculpt_face_sets_init_types[] = { { @@ -771,12 +771,12 @@ void SCULPT_OT_face_sets_init(wmOperatorType *ot) 1.0f); } -typedef enum eSculptFaceGroupVisibilityModes { +enum eSculptFaceGroupVisibilityModes { SCULPT_FACE_SET_VISIBILITY_TOGGLE = 0, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE = 1, SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE = 2, SCULPT_FACE_SET_VISIBILITY_INVERT = 3, -} eSculptFaceGroupVisibilityModes; +}; static EnumPropertyItem prop_sculpt_face_sets_change_visibility_types[] = { { @@ -1020,13 +1020,13 @@ void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -typedef enum eSculptFaceSetEditMode { +enum eSculptFaceSetEditMode { SCULPT_FACE_SET_EDIT_GROW = 0, SCULPT_FACE_SET_EDIT_SHRINK = 1, SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY = 2, SCULPT_FACE_SET_EDIT_FAIR_POSITIONS = 3, SCULPT_FACE_SET_EDIT_FAIR_TANGENCY = 4, -} eSculptFaceSetEditMode; +}; static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = { { @@ -1132,7 +1132,9 @@ static void sculpt_face_set_shrink(Object *ob, } } -static bool check_single_face_set(SculptSession *ss, int *face_sets, const bool check_visible_only) +static bool check_single_face_set(SculptSession *ss, + const int *face_sets, + const bool check_visible_only) { if (face_sets == nullptr) { return true; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index d84d7f2f6fb..edb681466b5 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -1353,7 +1353,7 @@ int SCULPT_automasking_settings_hash(Object *ob, AutomaskingCache *automasking); * fallback to euclidean distances to one of the initial vertices in the set. */ float *SCULPT_geodesic_distances_create(struct Object *ob, - struct GSet *initial_vertices, + struct GSet *initial_verts, float limit_radius); float *SCULPT_geodesic_from_vertex_and_symm(struct Sculpt *sd, struct Object *ob, diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index d72d7cb14d0..c2dc8e9196d 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -572,7 +572,7 @@ void filelist_sort(struct FileList *filelist) break; } - FileSortData sort_data{0}; + FileSortData sort_data{}; sort_data.inverted = (filelist->flags & FL_SORT_INVERT) != 0; BLI_listbase_sort_r(&filelist->filelist_intern.entries, sort_cb, &sort_data); @@ -804,7 +804,7 @@ static void prepare_filter_asset_library(const FileList *filelist, FileListFilte static bool asset_tag_matches_filter(const char *filter_search, const AssetMetaData *asset_data) { LISTBASE_FOREACH (const AssetTag *, asset_tag, &asset_data->tags) { - if (BLI_strcasestr(asset_tag->name, filter_search) != NULL) { + if (BLI_strcasestr(asset_tag->name, filter_search) != nullptr) { return true; } } @@ -832,7 +832,7 @@ static bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter) /* When doing a name comparison, get rid of the leading/trailing asterisks. */ filter_search[string_length - 1] = '\0'; - if (BLI_strcasestr(file->name, filter_search + 1) != NULL) { + if (BLI_strcasestr(file->name, filter_search + 1) != nullptr) { return true; } return asset_tag_matches_filter(filter_search + 1, asset_data); @@ -909,7 +909,7 @@ void filelist_filter(FileList *filelist) /* Never show lib ID 'categories' directories when we are in 'flat' mode, unless * root path is a blend file. */ char dir[FILE_MAX_LIBEXTRA]; - if (!filelist_islibrary(filelist, dir, NULL)) { + if (!filelist_islibrary(filelist, dir, nullptr)) { filelist->filter_data.flags |= FLF_HIDE_LIB_DIR; } } @@ -1041,7 +1041,7 @@ static bool filelist_compare_asset_libraries(const AssetLibraryReference *librar /* Don't only check the index, also check that it's valid. */ bUserAssetLibrary *library_ptr_a = BKE_preferences_asset_library_find_from_index( &U, library_a->custom_library_index); - return (library_ptr_a != NULL) && + return (library_ptr_a != nullptr) && (library_a->custom_library_index == library_b->custom_library_index); } @@ -1082,10 +1082,13 @@ void filelist_init_icons(void) BLI_assert(G.background == false); #ifdef WITH_HEADLESS - bbuf = NULL; + bbuf = nullptr; #else - bbuf = IMB_ibImageFromMemory( - (const uchar *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, ""); + bbuf = IMB_ibImageFromMemory((const uchar *)datatoc_prvicons_png, + datatoc_prvicons_png_size, + IB_rect, + nullptr, + ""); #endif if (bbuf) { for (y = 0; y < SPECIAL_IMG_ROWS; y++) { @@ -1113,7 +1116,7 @@ void filelist_free_icons(void) for (int i = 0; i < SPECIAL_IMG_MAX; i++) { IMB_freeImBuf(gSpecialFileImages[i]); - gSpecialFileImages[i] = NULL; + gSpecialFileImages[i] = nullptr; } } @@ -1128,17 +1131,17 @@ ImBuf *filelist_getimage(struct FileList *filelist, const int index) { FileDirEntry *file = filelist_geticon_get_file(filelist, index); - return file->preview_icon_id ? BKE_icon_imbuf_get_buffer(file->preview_icon_id) : NULL; + return file->preview_icon_id ? BKE_icon_imbuf_get_buffer(file->preview_icon_id) : nullptr; } ImBuf *filelist_file_getimage(const FileDirEntry *file) { - return file->preview_icon_id ? BKE_icon_imbuf_get_buffer(file->preview_icon_id) : NULL; + return file->preview_icon_id ? BKE_icon_imbuf_get_buffer(file->preview_icon_id) : nullptr; } ImBuf *filelist_geticon_image_ex(const FileDirEntry *file) { - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; if (file->typeflag & FILE_TYPE_DIR) { if (FILENAME_IS_PARENT(file->relpath)) { @@ -1287,12 +1290,12 @@ int filelist_geticon(struct FileList *filelist, const int index, const bool is_m int ED_file_icon(const FileDirEntry *file) { return file->preview_icon_id ? file->preview_icon_id : - filelist_geticon_ex(file, NULL, false, false); + filelist_geticon_ex(file, nullptr, false, false); } static bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry) { - return intern_entry->local_data.id != NULL; + return intern_entry->local_data.id != nullptr; } /* ********** Main ********** */ @@ -1327,7 +1330,7 @@ static bool filelist_checkdir_lib(struct FileList * /*filelist*/, char *name; const bool is_valid = (BLI_is_dir(r_dir) || - (BLO_library_path_explode(r_dir, tdir, NULL, &name) && + (BLO_library_path_explode(r_dir, tdir, nullptr, &name) && BLI_is_file(tdir) && !name)); if (do_change && !is_valid) { @@ -1484,7 +1487,7 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat } /* Move ownership to the done queue. */ - preview_taskdata->preview = NULL; + preview_taskdata->preview = nullptr; BLI_thread_queue_push(cache->previews_done, preview); @@ -1543,8 +1546,8 @@ static void filelist_cache_previews_free(FileListEntryCache *cache) BLI_thread_queue_free(cache->previews_done); BLI_task_pool_free(cache->previews_pool); - cache->previews_pool = NULL; - cache->previews_done = NULL; + cache->previews_pool = nullptr; + cache->previews_done = nullptr; cache->previews_todo_count = 0; IMB_thumb_locks_release(); @@ -1654,10 +1657,10 @@ static void filelist_cache_free(FileListEntryCache *cache) MEM_freeN(cache->block_entries); - BLI_ghash_free(cache->misc_entries, NULL, NULL); + BLI_ghash_free(cache->misc_entries, nullptr, nullptr); MEM_freeN(cache->misc_entries_indices); - BLI_ghash_free(cache->uids, NULL, NULL); + BLI_ghash_free(cache->uids, nullptr, nullptr); LISTBASE_FOREACH_MUTABLE (FileDirEntry *, entry, &cache->cached_entries) { filelist_entry_free(entry); @@ -1680,14 +1683,14 @@ static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size) MEM_reallocN(cache->block_entries, sizeof(*cache->block_entries) * new_size)); } - BLI_ghash_clear_ex(cache->misc_entries, NULL, NULL, new_size); + BLI_ghash_clear_ex(cache->misc_entries, nullptr, nullptr, new_size); if (new_size != cache->size) { cache->misc_entries_indices = static_cast(MEM_reallocN( cache->misc_entries_indices, sizeof(*cache->misc_entries_indices) * new_size)); } copy_vn_i(cache->misc_entries_indices, new_size, -1); - BLI_ghash_clear_ex(cache->uids, NULL, NULL, new_size * 2); + BLI_ghash_clear_ex(cache->uids, nullptr, nullptr, new_size * 2); cache->size = new_size; @@ -1723,13 +1726,13 @@ void filelist_settype(FileList *filelist, short type) case FILE_MAIN: filelist->check_dir_fn = filelist_checkdir_main; filelist->read_job_fn = filelist_readjob_main; - filelist->prepare_filter_fn = NULL; + filelist->prepare_filter_fn = nullptr; filelist->filter_fn = is_filtered_main; break; case FILE_LOADLIB: filelist->check_dir_fn = filelist_checkdir_lib; filelist->read_job_fn = filelist_readjob_lib; - filelist->prepare_filter_fn = NULL; + filelist->prepare_filter_fn = nullptr; filelist->filter_fn = is_filtered_lib; break; case FILE_ASSET_LIBRARY: @@ -1749,7 +1752,7 @@ void filelist_settype(FileList *filelist, short type) default: filelist->check_dir_fn = filelist_checkdir_dir; filelist->read_job_fn = filelist_readjob_dir; - filelist->prepare_filter_fn = NULL; + filelist->prepare_filter_fn = nullptr; filelist->filter_fn = is_filtered_file; break; } @@ -1760,7 +1763,7 @@ void filelist_settype(FileList *filelist, short type) static void filelist_clear_asset_library(FileList *filelist) { /* The AssetLibraryService owns the AssetLibrary pointer, so no need for us to free it. */ - filelist->asset_library = NULL; + filelist->asset_library = nullptr; file_delete_asset_catalog_filter_settings(&filelist->filter_data.asset_catalog_filter); } @@ -1784,7 +1787,7 @@ void filelist_clear_ex(struct FileList *filelist, filelist_direntryarr_free(&filelist->filelist); if (do_selection && filelist->selection_state) { - BLI_ghash_clear(filelist->selection_state, NULL, NULL); + BLI_ghash_clear(filelist->selection_state, nullptr, nullptr); } if (do_asset_library) { @@ -1814,7 +1817,7 @@ static void filelist_clear_main_files(FileList *filelist, BLI_assert(filelist->filelist.entries_num > FILEDIR_NBR_ENTRIES_UNSET); if (do_selection && filelist->selection_state) { - BLI_ghash_clear(filelist->selection_state, NULL, NULL); + BLI_ghash_clear(filelist->selection_state, nullptr, nullptr); } if (do_asset_library) { @@ -1853,8 +1856,8 @@ void filelist_free(struct FileList *filelist) filelist_cache_free(&filelist->filelist_cache); if (filelist->selection_state) { - BLI_ghash_free(filelist->selection_state, NULL, NULL); - filelist->selection_state = NULL; + BLI_ghash_free(filelist->selection_state, nullptr, nullptr); + filelist->selection_state = nullptr; } MEM_SAFE_FREE(filelist->asset_library_ref); @@ -1874,7 +1877,7 @@ void filelist_freelib(struct FileList *filelist) if (filelist->libfiledata) { BLO_blendhandle_close(filelist->libfiledata); } - filelist->libfiledata = NULL; + filelist->libfiledata = nullptr; } BlendHandle *filelist_lib(struct FileList *filelist) @@ -1887,7 +1890,7 @@ static char *fileentry_uiname(const char *root, const eFileSel_File_Types typeflag, char *buff) { - char *name = NULL; + char *name = nullptr; if (typeflag & FILE_TYPE_FTFONT && !(typeflag & FILE_TYPE_BLENDERLIB)) { char abspath[FILE_MAX_LIBEXTRA]; @@ -1935,7 +1938,7 @@ bool filelist_is_dir(struct FileList *filelist, const char *path) void filelist_setdir(struct FileList *filelist, char *r_dir) { - const bool allow_invalid = filelist->asset_library_ref != NULL; + const bool allow_invalid = filelist->asset_library_ref != nullptr; BLI_assert(strlen(r_dir) < FILE_MAX_LIBEXTRA); BLI_path_normalize_dir(BKE_main_blendfile_path_from_global(), r_dir); @@ -2027,8 +2030,8 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in ret->redirection_path = BLI_strdup(entry->redirection_path); } ret->id = entry->local_data.id; - ret->asset_data = entry->imported_asset_data ? entry->imported_asset_data : NULL; - if (ret->id && (ret->asset_data == NULL)) { + ret->asset_data = entry->imported_asset_data ? entry->imported_asset_data : nullptr; + if (ret->id && (ret->asset_data == nullptr)) { ret->asset_data = ret->id->asset_data; } /* For some file types the preview is already available. */ @@ -2051,7 +2054,7 @@ static void filelist_file_release_entry(FileList *filelist, FileDirEntry *entry) FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index, const bool use_request) { - FileDirEntry *ret = NULL, *old; + FileDirEntry *ret = nullptr, *old; FileListEntryCache *cache = &filelist->filelist_cache; const size_t cache_size = cache->size; int old_index; @@ -2071,7 +2074,7 @@ FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index, const } if (!use_request) { - return NULL; + return nullptr; } // printf("requesting file %d (not yet cached)\n", index); @@ -2080,8 +2083,8 @@ FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index, const ret = filelist_file_create_entry(filelist, index); old_index = cache->misc_entries_indices[cache->misc_cursor]; if ((old = static_cast( - BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), NULL)))) { - BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(old->uid), NULL, NULL); + BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), nullptr)))) { + BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(old->uid), nullptr, nullptr); filelist_file_release_entry(filelist, old); } BLI_ghash_insert(cache->misc_entries, POINTER_FROM_INT(index), ret); @@ -2198,8 +2201,8 @@ static bool filelist_file_cache_block_create(FileList *filelist, FileDirEntry *entry; /* That entry might have already been requested and stored in misc cache... */ - if ((entry = static_cast( - BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(idx), NULL))) == NULL) { + if ((entry = static_cast(BLI_ghash_popkey( + cache->misc_entries, POINTER_FROM_INT(idx), nullptr))) == nullptr) { entry = filelist_file_create_entry(filelist, idx); BLI_ghash_insert(cache->uids, POINTER_FROM_UINT(entry->uid), entry); } @@ -2227,10 +2230,10 @@ static void filelist_file_cache_block_release(struct FileList *filelist, __func__, cursor /*, cache->block_entries[cursor], cache->block_entries[cursor]->relpath*/); #endif - BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(entry->uid), NULL, NULL); + BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(entry->uid), nullptr, nullptr); filelist_file_release_entry(filelist, entry); #ifndef NDEBUG - cache->block_entries[cursor] = NULL; + cache->block_entries[cursor] = nullptr; #endif } } @@ -2461,7 +2464,7 @@ void filelist_cache_previews_set(FileList *filelist, const bool use_previews) if (use_previews && (filelist->flags & FL_IS_READY)) { cache->flags |= FLC_PREVIEWS_ACTIVE; - BLI_assert((cache->previews_pool == NULL) && (cache->previews_done == NULL) && + BLI_assert((cache->previews_pool == nullptr) && (cache->previews_done == nullptr) && (cache->previews_todo_count == 0)); // printf("%s: Init Previews...\n", __func__); @@ -2537,7 +2540,7 @@ bool filelist_cache_previews_running(FileList *filelist) { FileListEntryCache *cache = &filelist->filelist_cache; - return (cache->previews_pool != NULL); + return (cache->previews_pool != nullptr); } bool filelist_cache_previews_done(FileList *filelist) @@ -2548,7 +2551,7 @@ bool filelist_cache_previews_done(FileList *filelist) return false; } - return (cache->previews_pool == NULL) || (cache->previews_done == NULL) || + return (cache->previews_pool == nullptr) || (cache->previews_done == nullptr) || (cache->previews_todo_count == 0); } @@ -2557,7 +2560,7 @@ static bool file_is_blend_backup(const char *str) { const size_t a = strlen(str); size_t b = 7; - bool retval = 0; + bool retval = false; if (a == 0 || b >= a) { /* pass */ @@ -2573,7 +2576,7 @@ static bool file_is_blend_backup(const char *str) loc = BLI_strcasestr(str + a - b, ".blend"); if (loc) { - retval = 1; + retval = true; } } @@ -2594,7 +2597,7 @@ int ED_path_extension_type(const char *path) ".app", /* Safari in-progress/paused download */ ".download", - NULL)) { + nullptr)) { return FILE_TYPE_BUNDLE; } #endif @@ -2611,11 +2614,11 @@ int ED_path_extension_type(const char *path) ".mcr", ".inc", ".fountain", - NULL)) { + nullptr)) { return FILE_TYPE_TEXT; } if (BLI_path_extension_check_n( - path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", NULL)) { + path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", nullptr)) { return FILE_TYPE_FTFONT; } if (BLI_path_extension_check(path, ".btx")) { @@ -2627,7 +2630,7 @@ int ED_path_extension_type(const char *path) if (BLI_path_extension_check(path, ".abc")) { return FILE_TYPE_ALEMBIC; } - if (BLI_path_extension_check_n(path, ".usd", ".usda", ".usdc", NULL)) { + if (BLI_path_extension_check_n(path, ".usd", ".usda", ".usdc", nullptr)) { return FILE_TYPE_USD; } if (BLI_path_extension_check(path, ".vdb")) { @@ -2637,7 +2640,7 @@ int ED_path_extension_type(const char *path) return FILE_TYPE_ARCHIVE; } if (BLI_path_extension_check_n( - path, ".obj", ".mtl", ".3ds", ".fbx", ".glb", ".gltf", ".svg", ".stl", NULL)) { + path, ".obj", ".mtl", ".3ds", ".fbx", ".glb", ".gltf", ".svg", ".stl", nullptr)) { return FILE_TYPE_OBJECT_IO; } if (BLI_path_extension_check_array(path, imb_ext_image)) { @@ -2706,7 +2709,7 @@ uint filelist_entry_select_set(const FileList *filelist, uint flag, FileCheckType check) { - /* Default NULL pointer if not found is fine here! */ + /* Default nullptr pointer if not found is fine here! */ void **es_p = BLI_ghash_lookup_p(filelist->selection_state, POINTER_FROM_UINT(entry->uid)); uint entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0; const uint org_entry_flag = entry_flag; @@ -2735,7 +2738,8 @@ uint filelist_entry_select_set(const FileList *filelist, *es_p = POINTER_FROM_UINT(entry_flag); } else { - BLI_ghash_remove(filelist->selection_state, POINTER_FROM_UINT(entry->uid), NULL, NULL); + BLI_ghash_remove( + filelist->selection_state, POINTER_FROM_UINT(entry->uid), nullptr, nullptr); } } else if (entry_flag) { @@ -2777,7 +2781,7 @@ uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileChec if ((check == CHECK_ALL) || ((check == CHECK_DIRS) && (entry->typeflag & FILE_TYPE_DIR)) || ((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) { - /* Default NULL pointer if not found is fine here! */ + /* Default nullptr pointer if not found is fine here! */ return POINTER_AS_UINT( BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(entry->uid))); } @@ -2801,7 +2805,7 @@ bool filelist_entry_is_selected(FileList *filelist, const int index) BLI_assert(index >= 0 && index < filelist->filelist.entries_filtered_num); FileListInternEntry *intern_entry = filelist->filelist_intern.filtered[index]; - /* BLI_ghash_lookup returns NULL if not found, which gets mapped to 0, which gets mapped to + /* BLI_ghash_lookup returns nullptr if not found, which gets mapped to 0, which gets mapped to * "not selected". */ const uint selection_state = POINTER_AS_UINT( BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(intern_entry->uid))); @@ -2821,7 +2825,7 @@ void filelist_entry_parent_select_set(FileList *filelist, bool filelist_islibrary(struct FileList *filelist, char *dir, char **r_group) { - return BLO_library_path_explode(filelist->filelist.root, dir, r_group, NULL); + return BLO_library_path_explode(filelist->filelist.root, dir, r_group, nullptr); } static int groupname_to_code(const char *group) @@ -2852,10 +2856,10 @@ static uint64_t groupname_to_filter_id(const char *group) * i.e. have to be careful about sharing stuff between background working thread. * and main one (used by UI among other things). */ -typedef struct TodoDir { +struct TodoDir { int level; char *dir; -} TodoDir; +}; static int filelist_readjob_list_dir(const char *root, ListBase *entries, @@ -2915,7 +2919,7 @@ static int filelist_readjob_list_dir(const char *root, } else { MEM_freeN(entry->redirection_path); - entry->redirection_path = NULL; + entry->redirection_path = nullptr; entry->attributes |= FILE_ATTR_HIDDEN; } } @@ -2952,7 +2956,7 @@ static int filelist_readjob_list_dir(const char *root, return entries_num; } -typedef enum ListLibOptions { +enum ListLibOptions { LIST_LIB_OPTION_NONE = 0, /* Will read both the groups + actual ids from the library. Reduces the amount of times that @@ -2964,7 +2968,7 @@ typedef enum ListLibOptions { /* Add given root as result. */ LIST_LIB_ADD_PARENT = (1 << 2), -} ListLibOptions; +}; ENUM_OPERATORS(ListLibOptions, LIST_LIB_ADD_PARENT); static FileListInternEntry *filelist_readjob_list_lib_group_create(const int idcode, @@ -3074,19 +3078,19 @@ static int filelist_readjob_list_lib(const char *root, char dir[FILE_MAX_LIBEXTRA], *group; - struct BlendHandle *libfiledata = NULL; + struct BlendHandle *libfiledata = nullptr; /* Check if the given root is actually a library. All folders are passed to * `filelist_readjob_list_lib` and based on the number of found entries `filelist_readjob_do` * will do a dir listing only when this function does not return any entries. */ /* TODO(jbakker): We should consider introducing its own function to detect if it is a lib and * call it directly from `filelist_readjob_do` to increase readability. */ - const bool is_lib = BLO_library_path_explode(root, dir, &group, NULL); + const bool is_lib = BLO_library_path_explode(root, dir, &group, nullptr); if (!is_lib) { return 0; } - const bool group_came_from_path = group != NULL; + const bool group_came_from_path = group != nullptr; /* Try read from indexer_runtime. */ /* Indexing returns all entries in a blend file. We should ignore the index when listing a group @@ -3097,7 +3101,7 @@ static int filelist_readjob_list_lib(const char *root, * Adding support for partial reading/updating indexes would increase the complexity. */ const bool use_indexer = !group_came_from_path; - FileIndexerEntries indexer_entries = {NULL}; + FileIndexerEntries indexer_entries = {nullptr}; if (use_indexer) { int read_from_index = 0; eFileIndexerResult indexer_result = indexer_runtime->callbacks->read_index( @@ -3113,7 +3117,7 @@ static int filelist_readjob_list_lib(const char *root, /* Open the library file. */ BlendFileReadReport bf_reports{}; libfiledata = BLO_blendhandle_from_file(dir, &bf_reports); - if (libfiledata == NULL) { + if (libfiledata == nullptr) { return 0; } @@ -3186,13 +3190,13 @@ static int filelist_readjob_list_lib(const char *root, static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) { ID *id; - FileDirEntry *files, *firstlib = NULL; + FileDirEntry *files, *firstlib = nullptr; ListBase *lb; int a, fake, idcode, ok, totlib, totbl; // filelist->type = FILE_MAIN; /* XXX TODO: add modes to file-browser */ - BLI_assert(filelist->filelist.entries == NULL); + BLI_assert(filelist->filelist.entries == nullptr); if (filelist->filelist.root[0] == '/') { filelist->filelist.root[0] = '\0'; @@ -3253,7 +3257,7 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) idcode = groupname_to_code(filelist->filelist.root); lb = which_libbase(bmain, idcode); - if (lb == NULL) { + if (lb == nullptr) { return; } @@ -3352,11 +3356,11 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) } #endif -typedef struct FileListReadJob { +struct FileListReadJob { ThreadMutex lock; char main_name[FILE_MAX]; Main *current_main; - struct FileList *filelist; + FileList *filelist; /** Set to request a partial read that only adds files representing #Main data (IDs). Used when * #Main may have received changes of interest (e.g. asset removed or renamed). */ bool only_main_data; @@ -3370,9 +3374,9 @@ typedef struct FileListReadJob { * and moved to #filelist once all categories are loaded. * * NOTE: #tmp_filelist is freed in #filelist_readjob_free, so any copied pointers need to be - * set to NULL to avoid double-freeing them. */ - struct FileList *tmp_filelist; -} FileListReadJob; + * set to nullptr to avoid double-freeing them. */ + FileList *tmp_filelist; +}; static void filelist_readjob_append_entries(FileListReadJob *job_params, ListBase *from_entries, @@ -3437,7 +3441,7 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, float *progress) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ - ListBase entries = {0}; + ListBase entries = {nullptr}; BLI_Stack *todo_dirs; TodoDir *td_dir; char dir[FILE_MAX_LIBEXTRA]; @@ -3553,7 +3557,7 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, } if (indexer_runtime.callbacks->free_user_data && indexer_runtime.user_data) { indexer_runtime.callbacks->free_user_data(indexer_runtime.user_data); - indexer_runtime.user_data = NULL; + indexer_runtime.user_data = nullptr; } /* If we were interrupted by stop, stack may not be empty and we need to free @@ -3574,7 +3578,7 @@ static void filelist_readjob_do(const bool do_lib, { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ - // BLI_assert(filelist->filtered == NULL); + // BLI_assert(filelist->filtered == nullptr); BLI_assert(BLI_listbase_is_empty(&filelist->filelist.entries) && (filelist->filelist.entries_num == FILEDIR_NBR_ENTRIES_UNSET)); @@ -3623,10 +3627,10 @@ static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params *do_update = false; - if (job_params->filelist->asset_library_ref == NULL) { + if (job_params->filelist->asset_library_ref == nullptr) { return; } - if (tmp_filelist->asset_library != NULL) { + if (tmp_filelist->asset_library != nullptr) { /* Asset library already loaded. */ return; } @@ -3774,14 +3778,14 @@ static void filelist_readjob_startjob(void *flrjv, short *stop, short *do_update BLI_mutex_lock(&flrj->lock); - BLI_assert((flrj->tmp_filelist == NULL) && flrj->filelist); + BLI_assert((flrj->tmp_filelist == nullptr) && flrj->filelist); flrj->tmp_filelist = static_cast(MEM_dupallocN(flrj->filelist)); BLI_listbase_clear(&flrj->tmp_filelist->filelist.entries); flrj->tmp_filelist->filelist.entries_num = FILEDIR_NBR_ENTRIES_UNSET; - flrj->tmp_filelist->filelist_intern.filtered = NULL; + flrj->tmp_filelist->filelist_intern.filtered = nullptr; BLI_listbase_clear(&flrj->tmp_filelist->filelist_intern.entries); if (filelist_readjob_is_partial_read(flrj)) { /* Don't unset the current UID on partial read, would give duplicates otherwise. */ @@ -3790,11 +3794,11 @@ static void filelist_readjob_startjob(void *flrjv, short *stop, short *do_update filelist_uid_unset(&flrj->tmp_filelist->filelist_intern.curr_uid); } - flrj->tmp_filelist->libfiledata = NULL; + flrj->tmp_filelist->libfiledata = nullptr; memset(&flrj->tmp_filelist->filelist_cache, 0, sizeof(flrj->tmp_filelist->filelist_cache)); - flrj->tmp_filelist->selection_state = NULL; - flrj->tmp_filelist->asset_library_ref = NULL; - flrj->tmp_filelist->filter_data.asset_catalog_filter = NULL; + flrj->tmp_filelist->selection_state = nullptr; + flrj->tmp_filelist->asset_library_ref = nullptr; + flrj->tmp_filelist->filter_data.asset_catalog_filter = nullptr; BLI_mutex_unlock(&flrj->lock); @@ -3810,7 +3814,7 @@ static void filelist_readjob_update(void *flrjv) { FileListReadJob *flrj = static_cast(flrjv); FileListIntern *fl_intern = &flrj->filelist->filelist_intern; - ListBase new_entries = {NULL}; + ListBase new_entries = {nullptr}; int entries_num, new_entries_num = 0; BLI_movelisttolist(&new_entries, &fl_intern->entries); @@ -3922,7 +3926,7 @@ void filelist_readjob_start(FileList *filelist, const int space_notifier, const filelist_readjob_endjob(flrj); filelist_readjob_free(flrj); - WM_event_add_notifier(C, space_notifier | NA_JOB_FINISHED, NULL); + WM_event_add_notifier(C, space_notifier | NA_JOB_FINISHED, nullptr); return; } @@ -3935,8 +3939,11 @@ void filelist_readjob_start(FileList *filelist, const int space_notifier, const WM_JOB_TYPE_FILESEL_READDIR); WM_jobs_customdata_set(wm_job, flrj, filelist_readjob_free); WM_jobs_timer(wm_job, 0.01, space_notifier, space_notifier | NA_JOB_FINISHED); - WM_jobs_callbacks( - wm_job, filelist_readjob_startjob, NULL, filelist_readjob_update, filelist_readjob_endjob); + WM_jobs_callbacks(wm_job, + filelist_readjob_startjob, + nullptr, + filelist_readjob_update, + filelist_readjob_endjob); /* start the job */ WM_jobs_start(CTX_wm_manager(C), wm_job); diff --git a/source/blender/editors/space_file/folder_history.cc b/source/blender/editors/space_file/folder_history.cc index 1cb8fa279c5..8f44c0aa08a 100644 --- a/source/blender/editors/space_file/folder_history.cc +++ b/source/blender/editors/space_file/folder_history.cc @@ -27,15 +27,15 @@ /** \name FOLDERLIST (previous/next) * \{ */ -typedef struct FolderList { - struct FolderList *next, *prev; +struct FolderList { + FolderList *next, *prev; char *foldername; -} FolderList; +}; void folderlist_popdir(struct ListBase *folderlist, char *dir) { const char *prev_dir; - struct FolderList *folder; + FolderList *folder; folder = static_cast(folderlist->last); if (folder) { @@ -58,7 +58,7 @@ void folderlist_pushdir(ListBase *folderlist, const char *dir) return; } - struct FolderList *folder, *previous_folder; + FolderList *folder, *previous_folder; previous_folder = static_cast(folderlist->last); /* check if already exists */ @@ -78,10 +78,10 @@ void folderlist_pushdir(ListBase *folderlist, const char *dir) const char *folderlist_peeklastdir(ListBase *folderlist) { - struct FolderList *folder; + FolderList *folder; if (!folderlist->last) { - return NULL; + return nullptr; } folder = static_cast(folderlist->last); @@ -91,7 +91,7 @@ const char *folderlist_peeklastdir(ListBase *folderlist) bool folderlist_clear_next(struct SpaceFile *sfile) { const FileSelectParams *params = ED_fileselect_get_active_params(sfile); - struct FolderList *folder; + FolderList *folder; /* if there is no folder_next there is nothing we can clear */ if (BLI_listbase_is_empty(sfile->folders_next)) { @@ -121,7 +121,7 @@ void folderlist_free(ListBase *folderlist) static ListBase folderlist_duplicate(ListBase *folderlist) { - ListBase folderlistn = {NULL}; + ListBase folderlistn = {nullptr}; BLI_duplicatelist(&folderlistn, folderlist); @@ -145,7 +145,7 @@ static FileFolderHistory *folder_history_find(const SpaceFile *sfile, eFileBrows } } - return NULL; + return nullptr; } void folder_history_list_ensure_for_active_browse_mode(SpaceFile *sfile) @@ -165,10 +165,10 @@ void folder_history_list_ensure_for_active_browse_mode(SpaceFile *sfile) static void folder_history_entry_free(SpaceFile *sfile, FileFolderHistory *history) { if (sfile->folders_prev == &history->folders_prev) { - sfile->folders_prev = NULL; + sfile->folders_prev = nullptr; } if (sfile->folders_next == &history->folders_next) { - sfile->folders_next = NULL; + sfile->folders_next = nullptr; } folderlist_free(&history->folders_prev); folderlist_free(&history->folders_next); @@ -184,7 +184,7 @@ void folder_history_list_free(SpaceFile *sfile) ListBase folder_history_list_duplicate(ListBase *listbase) { - ListBase histories = {NULL}; + ListBase histories = {nullptr}; LISTBASE_FOREACH (FileFolderHistory *, history, listbase) { FileFolderHistory *history_new = static_cast(MEM_dupallocN(history)); diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index fb744071a8e..81fa5cc2303 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -410,7 +410,7 @@ static void stats_update(Depsgraph *depsgraph, else { /* Objects. */ GSet *objects_gset = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); - DEGObjectIterSettings deg_iter_settings = {0}; + DEGObjectIterSettings deg_iter_settings{}; deg_iter_settings.depsgraph = depsgraph; deg_iter_settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS; DEG_OBJECT_ITER_BEGIN (°_iter_settings, ob_iter) { diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 984f9647b34..943fc99a7f6 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -777,7 +777,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) ED_node_tree_update(C); } - WM_event_add_notifier(C, NC_NODE | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_NODE | NA_ADDED, nullptr); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 7de02f5d6b8..aedceb1d368 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -1045,7 +1045,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_node_tree_propagate_change(C, bmain, nullptr); - WM_event_add_notifier(C, NC_NODE | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_NODE | NA_ADDED, nullptr); /* We broke relations in node tree, need to rebuild them in the graphs. */ DEG_relations_tag_update(bmain); diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 20e3eb0009d..259d879d76f 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -1571,7 +1571,7 @@ void OUTLINER_OT_item_drag_drop(wmOperatorType *ot) /** \name Drop Boxes * \{ */ -void outliner_dropboxes(void) +void outliner_dropboxes() { ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index b094222b16e..c546a371ef0 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -248,10 +248,8 @@ static void spreadsheet_update_context(const bContext *C) /* The pinned path is still valid, do nothing. */ break; } - else { - /* The pinned path does not exist anymore, clear pinning. */ - sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED; - } + /* The pinned path does not exist anymore, clear pinning. */ + sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED; } else { /* Unknown pinned path, clear pinning. */ @@ -266,11 +264,9 @@ static void spreadsheet_update_context(const bContext *C) /* Nothing changed. */ break; } - else { - /* Update the viewer path from the workspace. */ - BKE_viewer_path_clear(&sspreadsheet->viewer_path); - BKE_viewer_path_copy(&sspreadsheet->viewer_path, &workspace->viewer_path); - } + /* Update the viewer path from the workspace. */ + BKE_viewer_path_clear(&sspreadsheet->viewer_path); + BKE_viewer_path_copy(&sspreadsheet->viewer_path, &workspace->viewer_path); } else { /* No active viewer node, change back to showing evaluated active object. */ diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 672922ac3e5..4ac6f926818 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -8,8 +8,8 @@ /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW -#include -#include +#include +#include #include "DNA_collection_types.h" #include "DNA_defaults.h" @@ -881,7 +881,7 @@ static void view3d_lightcache_update(bContext *C) } /* region dropbox definition */ -static void view3d_dropboxes(void) +static void view3d_dropboxes() { ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); @@ -959,7 +959,7 @@ static void view3d_dropboxes(void) nullptr); } -static void view3d_widgets(void) +static void view3d_widgets() { wmGizmoMapType_Params params{SPACE_VIEW3D, RGN_TYPE_WINDOW}; wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(¶ms); @@ -1367,7 +1367,7 @@ static void view3d_main_region_message_subscribe(const wmRegionMessageSubscribeP * accepting some redundant redraws. * * For other space types we might try avoid this, keep the 3D view as an exceptional case! */ - wmMsgParams_RNA msg_key_params = {{0}}; + wmMsgParams_RNA msg_key_params{}; /* Only subscribe to types. */ StructRNA *type_array[] = { @@ -1563,7 +1563,7 @@ static void view3d_header_region_message_subscribe(const wmRegionMessageSubscrib struct wmMsgBus *mbus = params->message_bus; ARegion *region = params->region; - wmMsgParams_RNA msg_key_params = {{0}}; + wmMsgParams_RNA msg_key_params{}; /* Only subscribe to types. */ StructRNA *type_array[] = { @@ -2048,7 +2048,7 @@ static void view3d_blend_write(BlendWriter *writer, SpaceLink *sl) BKE_viewer_path_blend_write(writer, &v3d->viewer_path); } -void ED_spacetype_view3d(void) +void ED_spacetype_view3d() { SpaceType *st = MEM_cnew("spacetype view3d"); ARegionType *art; diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index ab77cf3407a..33129dfff5d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -5,7 +5,7 @@ * \ingroup spview3d */ -#include +#include #include "BLI_jitter_2d.h" #include "BLI_listbase.h" diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index c226ad4c461..2648ec5e2f6 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -126,7 +126,7 @@ static float (*bm_face_array_calc_unique_uv_coords( BMEdge *e_first = v_pivot->e; const BMEdge *e = e_first; do { - if (e->l != NULL) { + if (e->l != nullptr) { const BMLoop *l_radial = e->l; do { if (l_radial->v == l_iter->v) { @@ -368,7 +368,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene, const int group_len = BM_mesh_calc_face_groups(bm, groups_array, &group_index, - NULL, + nullptr, bm_loop_uv_shared_edge_check, &user_data, hflag_face_test, @@ -435,7 +435,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, } } - ListBase island_list = {NULL}; + ListBase island_list = {nullptr}; bm_mesh_calc_uv_islands(scene, em->bm, &island_list, @@ -536,7 +536,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, float base_offset[2] = {0.0f, 0.0f}; /* CASE: ignore UDIM. */ - if (udim_params == NULL) { + if (udim_params == nullptr) { /* pass */ } /* CASE: Active/specified(smart uv project) UDIM. */ diff --git a/source/blender/geometry/GEO_trim_curves.hh b/source/blender/geometry/GEO_trim_curves.hh index 8275e3cbace..d2ff770f225 100644 --- a/source/blender/geometry/GEO_trim_curves.hh +++ b/source/blender/geometry/GEO_trim_curves.hh @@ -26,11 +26,11 @@ bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, * \param curves: Curve geometry to sample. * \param lengths: Distance along the curve on form [0.0, length] to determine the point for. * \param curve_indices: Curve index to lookup for each 'length', negative index are set to 0. - * \param is_normalized: If true, 'lengths' are normalized to the interval [0.0, 1.0]. + * \param normalized_factors: If true, 'lengths' are normalized to the interval [0.0, 1.0]. */ Array lookup_curve_points(const bke::CurvesGeometry &curves, Span lengths, Span curve_indices, - bool is_normalized); + bool normalized_factors); } // namespace blender::geometry diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 370abe159b4..f2adc3b58d3 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -23,13 +23,13 @@ namespace blender::geometry { #define CURVE_TYPE_AS_MASK(curve_type) ((CurveTypeMask)(1 << int(curve_type))) -typedef enum CurveTypeMask { +enum CurveTypeMask { CURVE_TYPE_MASK_CATMULL_ROM = (1 << 0), CURVE_TYPE_MASK_POLY = (1 << 1), CURVE_TYPE_MASK_BEZIER = (1 << 2), CURVE_TYPE_MASK_NURBS = (1 << 3), CURVE_TYPE_MASK_ALL = (1 << 4) - 1 -} CurveTypeMask; +}; /** \} */ diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index f1d0d8487f7..6f86bf1d8cb 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -4,7 +4,7 @@ * \ingroup modifiers */ -#include +#include #include "MEM_guardedalloc.h" diff --git a/source/blender/modifiers/intern/MOD_subsurf.cc b/source/blender/modifiers/intern/MOD_subsurf.cc index c95368ba442..991bd0d876c 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.cc +++ b/source/blender/modifiers/intern/MOD_subsurf.cc @@ -5,9 +5,9 @@ * \ingroup modifiers */ -#include -#include -#include +#include +#include +#include #include "MEM_guardedalloc.h" diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index baa89d5c845..d2929a7f6ea 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -921,7 +921,7 @@ void *RE_gl_context_get(Render *re) void *RE_gpu_context_get(Render *re) { if (re->gpu_context == nullptr) { - re->gpu_context = GPU_context_create(NULL, re->gl_context); + re->gpu_context = GPU_context_create(nullptr, re->gl_context); } return re->gpu_context; } -- cgit v1.2.3