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. --- .../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 +-- 12 files changed, 157 insertions(+), 168 deletions(-) (limited to 'source/blender/blenkernel/intern') 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" -- cgit v1.2.3