diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-14 02:02:21 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-14 02:02:21 +0300 |
commit | 232b388455a53fdd2c6028be99a094ed796b4d18 (patch) | |
tree | 76b5cfd30d23e95baea91a241169a776a9aa9861 /source/blender/blenkernel/intern | |
parent | ad3378215c0465898fde26270985ab2487d9b3ca (diff) |
Cleanup: Declare variables where initialized
Also adjust comment formatting and use nullptr
where the previous commit missed.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/editmesh.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editmesh_cache.cc | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_wrapper.cc | 20 |
3 files changed, 25 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 114d33b1a3d..d176bf41254 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -214,18 +214,14 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph, Object *ob, int *r_vert_len))[3] { - Mesh *cage; - BLI_bitmap *visit_bitmap; - struct CageUserData data; - float(*cos_cage)[3]; + Mesh *cage = editbmesh_get_eval_cage(depsgraph, scene, ob, em, &CD_MASK_BAREMESH); + float(*cos_cage)[3] = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage"); - cage = editbmesh_get_eval_cage(depsgraph, scene, ob, em, &CD_MASK_BAREMESH); - cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage"); - - /* when initializing cage verts, we only want the first cage coordinate for each vertex, - * so that e.g. mirror or array use original vertex coordinates and not mirrored or duplicate */ - visit_bitmap = BLI_BITMAP_NEW(em->bm->totvert, __func__); + /* When initializing cage verts, we only want the first cage coordinate for each vertex, + * so that e.g. mirror or array use original vertex coordinates and not mirrored or duplicate. */ + BLI_bitmap *visit_bitmap = BLI_BITMAP_NEW(em->bm->totvert, __func__); + struct CageUserData data; data.totvert = em->bm->totvert; data.cos_cage = cos_cage; data.visit_bitmap = visit_bitmap; diff --git a/source/blender/blenkernel/intern/editmesh_cache.cc b/source/blender/blenkernel/intern/editmesh_cache.cc index 1ea2f38ce27..c2ce1405111 100644 --- a/source/blender/blenkernel/intern/editmesh_cache.cc +++ b/source/blender/blenkernel/intern/editmesh_cache.cc @@ -21,23 +21,21 @@ void BKE_editmesh_cache_ensure_poly_normals(BMEditMesh *em, EditMeshData *emd) { - if (!(emd->vertexCos && (emd->polyNos == NULL))) { + if (!(emd->vertexCos && (emd->polyNos == nullptr))) { return; } BMesh *bm = em->bm; - const float(*vertexCos)[3]; - float(*polyNos)[3]; - BMFace *efa; BMIter fiter; int i; BM_mesh_elem_index_ensure(bm, BM_VERT); - polyNos = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*polyNos) * bm->totface, __func__)); + float(*polyNos)[3] = static_cast<float(*)[3]>( + MEM_mallocN(sizeof(*polyNos) * bm->totface, __func__)); - vertexCos = emd->vertexCos; + const float(*vertexCos)[3] = emd->vertexCos; BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) { BM_elem_index_set(efa, i); /* set_inline */ @@ -50,7 +48,7 @@ void BKE_editmesh_cache_ensure_poly_normals(BMEditMesh *em, EditMeshData *emd) void BKE_editmesh_cache_ensure_vert_normals(BMEditMesh *em, EditMeshData *emd) { - if (!(emd->vertexCos && (emd->vertexNos == NULL))) { + if (!(emd->vertexCos && (emd->vertexNos == nullptr))) { return; } @@ -58,7 +56,7 @@ void BKE_editmesh_cache_ensure_vert_normals(BMEditMesh *em, EditMeshData *emd) const float(*vertexCos)[3], (*polyNos)[3]; float(*vertexNos)[3]; - /* calculate vertex normals from poly normals */ + /* Calculate vertex normals from poly normals. */ BKE_editmesh_cache_ensure_poly_normals(em, emd); BM_mesh_elem_index_ensure(bm, BM_FACE); @@ -74,17 +72,17 @@ void BKE_editmesh_cache_ensure_vert_normals(BMEditMesh *em, EditMeshData *emd) void BKE_editmesh_cache_ensure_poly_centers(BMEditMesh *em, EditMeshData *emd) { - if (emd->polyCos != NULL) { + if (emd->polyCos != nullptr) { return; } BMesh *bm = em->bm; - float(*polyCos)[3]; BMFace *efa; BMIter fiter; int i; - polyCos = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*polyCos) * bm->totface, __func__)); + float(*polyCos)[3] = static_cast<float(*)[3]>( + MEM_mallocN(sizeof(*polyCos) * bm->totface, __func__)); if (emd->vertexCos) { const float(*vertexCos)[3]; diff --git a/source/blender/blenkernel/intern/mesh_wrapper.cc b/source/blender/blenkernel/intern/mesh_wrapper.cc index 189a94809cb..8291765c2ef 100644 --- a/source/blender/blenkernel/intern/mesh_wrapper.cc +++ b/source/blender/blenkernel/intern/mesh_wrapper.cc @@ -51,7 +51,7 @@ Mesh *BKE_mesh_wrapper_from_editmesh_with_coords(BMEditMesh *em, const float (*vert_coords)[3], const Mesh *me_settings) { - Mesh *me = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, NULL)); + Mesh *me = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, nullptr)); BKE_mesh_copy_parameters_for_eval(me, me_settings); BKE_mesh_runtime_ensure_edit_data(me); @@ -66,7 +66,7 @@ Mesh *BKE_mesh_wrapper_from_editmesh_with_coords(BMEditMesh *em, me->edit_mesh = static_cast<BMEditMesh *>(MEM_dupallocN(em)); me->edit_mesh->is_shallow_copy = true; -/* Make sure, we crash if these are ever used. */ + /* Make sure we crash if these are ever used. */ #ifdef DEBUG me->totvert = INT_MAX; me->totedge = INT_MAX; @@ -88,7 +88,7 @@ Mesh *BKE_mesh_wrapper_from_editmesh(BMEditMesh *em, const CustomData_MeshMasks *cd_mask_extra, const Mesh *me_settings) { - return BKE_mesh_wrapper_from_editmesh_with_coords(em, cd_mask_extra, NULL, me_settings); + return BKE_mesh_wrapper_from_editmesh_with_coords(em, cd_mask_extra, nullptr, me_settings); } void BKE_mesh_wrapper_ensure_mdata(Mesh *me) @@ -118,8 +118,8 @@ void BKE_mesh_wrapper_ensure_mdata(Mesh *me) me->totpoly = 0; me->totloop = 0; - BLI_assert(me->edit_mesh != NULL); - BLI_assert(me->runtime.edit_data != NULL); + BLI_assert(me->edit_mesh != nullptr); + BLI_assert(me->runtime.edit_data != nullptr); BMEditMesh *em = me->edit_mesh; BM_mesh_bm_to_me_for_eval(em->bm, me, &me->runtime.cd_mask_extra); @@ -177,7 +177,7 @@ void BKE_mesh_wrapper_vert_coords_copy(const Mesh *me, BMesh *bm = me->edit_mesh->bm; BLI_assert(vert_coords_len <= bm->totvert); EditMeshData *edit_data = me->runtime.edit_data; - if (edit_data->vertexCos != NULL) { + if (edit_data->vertexCos != nullptr) { for (int i = 0; i < vert_coords_len; i++) { copy_v3_v3(vert_coords[i], edit_data->vertexCos[i]); } @@ -215,7 +215,7 @@ void BKE_mesh_wrapper_vert_coords_copy_with_mat4(const Mesh *me, BMesh *bm = me->edit_mesh->bm; BLI_assert(vert_coords_len == bm->totvert); EditMeshData *edit_data = me->runtime.edit_data; - if (edit_data->vertexCos != NULL) { + if (edit_data->vertexCos != nullptr) { for (int i = 0; i < vert_coords_len; i++) { mul_v3_m4v3(vert_coords[i], mat, edit_data->vertexCos[i]); } @@ -336,7 +336,7 @@ static Mesh *mesh_wrapper_ensure_subdivision(const Object *ob, Mesh *me) SubsurfRuntimeData *runtime_data = BKE_subsurf_modifier_ensure_runtime(smd); Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(smd, &subdiv_settings, me, false); - if (subdiv == NULL) { + if (subdiv == nullptr) { /* Happens on bad topology, but also on empty input mesh. */ return me; } @@ -348,8 +348,8 @@ static Mesh *mesh_wrapper_ensure_subdivision(const Object *ob, Mesh *me) } if (subdiv_mesh != me) { - if (me->runtime.mesh_eval != NULL) { - BKE_id_free(NULL, me->runtime.mesh_eval); + if (me->runtime.mesh_eval != nullptr) { + BKE_id_free(nullptr, me->runtime.mesh_eval); } me->runtime.mesh_eval = subdiv_mesh; me->runtime.wrapper_type = ME_WRAPPER_TYPE_SUBD; |