diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-30 02:32:44 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-30 02:32:44 +0300 |
commit | 1c1dc5f8440d918aca480904c53e31a528aef42f (patch) | |
tree | 86e44149f759960a2ccf118463b12a1aae00cce4 /source | |
parent | 7db79feecd657039f3e97e2ef6445400070ab42f (diff) |
Cleanup: Move files that use mesh runtime data to C++
In preparation for moving the mesh runtime struct out of DNA.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_editmesh.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editmesh.cc (renamed from source/blender/blenkernel/intern/editmesh.c) | 106 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_iterators.cc (renamed from source/blender/blenkernel/intern/mesh_iterators.c) | 77 | ||||
-rw-r--r-- | source/blender/draw/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_text.cc (renamed from source/blender/draw/intern/draw_manager_text.c) | 40 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc (renamed from source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c) | 78 | ||||
-rw-r--r-- | source/blender/modifiers/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_wave.cc (renamed from source/blender/modifiers/intern/MOD_wave.c) | 98 |
11 files changed, 208 insertions, 205 deletions
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h index 5916e7e83fb..dbfc9fd0799 100644 --- a/source/blender/blenkernel/BKE_editmesh.h +++ b/source/blender/blenkernel/BKE_editmesh.h @@ -69,7 +69,7 @@ typedef struct BMEditMesh { } BMEditMesh; -/* editmesh.c */ +/* editmesh.cc */ void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, const struct BMeshCalcTessellation_Params *params); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 4c5deead9d4..627e34be424 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -125,7 +125,7 @@ set(SRC intern/displist.cc intern/dynamicpaint.c intern/editlattice.c - intern/editmesh.c + intern/editmesh.cc intern/editmesh_bvh.c intern/editmesh_cache.cc intern/editmesh_tangent.cc @@ -199,7 +199,7 @@ set(SRC intern/mesh_debug.cc intern/mesh_evaluate.cc intern/mesh_fair.cc - intern/mesh_iterators.c + intern/mesh_iterators.cc intern/mesh_legacy_convert.cc intern/mesh_mapping.cc intern/mesh_merge.c diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.cc index a952da6fa52..deca24afc0f 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.cc @@ -28,14 +28,14 @@ BMEditMesh *BKE_editmesh_create(BMesh *bm) { - BMEditMesh *em = MEM_callocN(sizeof(BMEditMesh), __func__); + BMEditMesh *em = MEM_cnew<BMEditMesh>(__func__); em->bm = bm; return em; } BMEditMesh *BKE_editmesh_copy(BMEditMesh *em) { - BMEditMesh *em_copy = MEM_callocN(sizeof(BMEditMesh), __func__); + BMEditMesh *em_copy = MEM_cnew<BMEditMesh>(__func__); *em_copy = *em; em_copy->bm = BM_mesh_copy(em->bm); @@ -46,7 +46,7 @@ BMEditMesh *BKE_editmesh_copy(BMEditMesh *em) * it in the case of errors in an operation. For performance reasons, * in that case it makes more sense to do the * tessellation only when/if that copy ends up getting used. */ - em_copy->looptris = NULL; + em_copy->looptris = nullptr; /* Copy various settings. */ em_copy->selectmode = em->selectmode; @@ -70,7 +70,7 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob) } static void editmesh_tessface_calc_intern(BMEditMesh *em, - const struct BMeshCalcTessellation_Params *params) + const BMeshCalcTessellation_Params *params) { /* allocating space before calculating the tessellation */ @@ -86,7 +86,7 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em, BMLoop *(*looptris)[3]; /* this means no reallocs for quad dominant models, for */ - if ((em->looptris != NULL) && + if ((em->looptris != nullptr) && /* (*em->tottri >= looptris_tot)) */ /* Check against allocated size in case we over allocated a little. */ ((looptris_tot_prev_alloc >= looptris_tot) && @@ -97,7 +97,8 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em, if (em->looptris) { MEM_freeN(em->looptris); } - looptris = MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__); + looptris = static_cast<BMLoop *(*)[3]>( + MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__)); } em->looptris = looptris; @@ -107,8 +108,7 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em, BM_mesh_calc_tessellation_ex(em->bm, em->looptris, params); } -void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, - const struct BMeshCalcTessellation_Params *params) +void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, const BMeshCalcTessellation_Params *params) { editmesh_tessface_calc_intern(em, params); @@ -126,56 +126,46 @@ void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, void BKE_editmesh_looptri_calc(BMEditMesh *em) { - BKE_editmesh_looptri_calc_ex(em, - &(const struct BMeshCalcTessellation_Params){ - .face_normals = false, - }); + BMeshCalcTessellation_Params params{}; + params.face_normals = false; + BKE_editmesh_looptri_calc_ex(em, ¶ms); } void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em) { - BKE_editmesh_looptri_calc_ex(em, - &(const struct BMeshCalcTessellation_Params){ - .face_normals = true, - }); - BM_mesh_normals_update_ex(em->bm, - &(const struct BMeshNormalsUpdate_Params){ - .face_normals = false, - }); + BMeshCalcTessellation_Params looptri_params{}; + looptri_params.face_normals = true; + BKE_editmesh_looptri_calc_ex(em, &looptri_params); + BMeshNormalsUpdate_Params normals_params{}; + normals_params.face_normals = false; + BM_mesh_normals_update_ex(em->bm, &normals_params); } void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em, - struct BMPartialUpdate *bmpinfo, - const struct BMeshCalcTessellation_Params *params) + BMPartialUpdate *bmpinfo, + const BMeshCalcTessellation_Params *params) { BLI_assert(em->tottri == poly_to_tri_count(em->bm->totface, em->bm->totloop)); - BLI_assert(em->looptris != NULL); + BLI_assert(em->looptris != nullptr); BM_mesh_calc_tessellation_with_partial_ex(em->bm, em->looptris, bmpinfo, params); } -void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMPartialUpdate *bmpinfo) +void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo) { - BKE_editmesh_looptri_calc_with_partial_ex(em, - bmpinfo, - &(const struct BMeshCalcTessellation_Params){ - .face_normals = false, - }); + BMeshCalcTessellation_Params looptri_params{}; + looptri_params.face_normals = false; + BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, &looptri_params); } -void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em, - struct BMPartialUpdate *bmpinfo) +void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo) { - BKE_editmesh_looptri_calc_with_partial_ex(em, - bmpinfo, - &(const struct BMeshCalcTessellation_Params){ - .face_normals = true, - }); - BM_mesh_normals_update_with_partial_ex(em->bm, - bmpinfo, - &(const struct BMeshNormalsUpdate_Params){ - .face_normals = false, - }); + BMeshCalcTessellation_Params looptri_params{}; + looptri_params.face_normals = true; + BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, &looptri_params); + BMeshNormalsUpdate_Params normals_params{}; + normals_params.face_normals = false; + BM_mesh_normals_update_with_partial_ex(em->bm, bmpinfo, &normals_params); } void BKE_editmesh_free_data(BMEditMesh *em) @@ -201,7 +191,7 @@ static void cage_mapped_verts_callback(void *userData, const float co[3], const float UNUSED(no[3])) { - struct CageUserData *data = userData; + CageUserData *data = static_cast<CageUserData *>(userData); if ((index >= 0 && index < data->totvert) && (!BLI_BITMAP_TEST(data->visit_bitmap, index))) { BLI_BITMAP_ENABLE(data->visit_bitmap, index); @@ -209,20 +199,18 @@ static void cage_mapped_verts_callback(void *userData, } } -float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph, - BMEditMesh *em, - struct Scene *scene, - Object *ob, - int *r_vert_len))[3] +float (*BKE_editmesh_vert_coords_alloc( + Depsgraph *depsgraph, BMEditMesh *em, Scene *scene, Object *ob, int *r_vert_len))[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"); + float(*cos_cage)[3] = static_cast<float(*)[3]>( + MEM_callocN(sizeof(*cos_cage) * 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; + CageUserData data; data.totvert = em->bm->totvert; data.cos_cage = cos_cage; data.visit_bitmap = visit_bitmap; @@ -238,27 +226,27 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph, return cos_cage; } -const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph *depsgraph, +const float (*BKE_editmesh_vert_coords_when_deformed(Depsgraph *depsgraph, BMEditMesh *em, - struct Scene *scene, + Scene *scene, Object *ob, int *r_vert_len, bool *r_is_alloc))[3] { - const float(*coords)[3] = NULL; + const float(*coords)[3] = nullptr; *r_is_alloc = false; - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object_eval); - if ((me->runtime.edit_data != NULL) && (me->runtime.edit_data->vertexCos != NULL)) { + if ((me->runtime.edit_data != nullptr) && (me->runtime.edit_data->vertexCos != nullptr)) { /* Deformed, and we have deformed coords already. */ coords = me->runtime.edit_data->vertexCos; } - else if ((editmesh_eval_final != NULL) && + else if ((editmesh_eval_final != nullptr) && (editmesh_eval_final->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH)) { - /* If this is an edit-mesh type, leave NULL as we can use the vertex coords. */ + /* If this is an edit-mesh type, leave nullptr as we can use the vertex coords. */ } else { /* Constructive modifiers have been used, we need to allocate coordinates. */ @@ -302,16 +290,16 @@ void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, Mesh *me) } } -BoundBox *BKE_editmesh_cage_boundbox_get(struct Object *object, BMEditMesh *UNUSED(em)) +BoundBox *BKE_editmesh_cage_boundbox_get(Object *object, BMEditMesh *UNUSED(em)) { - if (object->runtime.editmesh_bb_cage == NULL) { + if (object->runtime.editmesh_bb_cage == nullptr) { float min[3], max[3]; INIT_MINMAX(min, max); if (object->runtime.editmesh_eval_cage) { BKE_mesh_wrapper_minmax(object->runtime.editmesh_eval_cage, min, max); } - object->runtime.editmesh_bb_cage = MEM_callocN(sizeof(BoundBox), "BMEditMesh.bb_cage"); + object->runtime.editmesh_bb_cage = MEM_cnew<BoundBox>("BMEditMesh.bb_cage"); BKE_boundbox_init_from_minmax(object->runtime.editmesh_bb_cage, min, max); } diff --git a/source/blender/blenkernel/intern/mesh_iterators.c b/source/blender/blenkernel/intern/mesh_iterators.cc index d3a7f6cc72f..281c84a3df5 100644 --- a/source/blender/blenkernel/intern/mesh_iterators.c +++ b/source/blender/blenkernel/intern/mesh_iterators.cc @@ -36,13 +36,13 @@ void BKE_mesh_foreach_mapped_vert( void *userData, MeshForeachFlag flag) { - if (mesh->edit_mesh != NULL && mesh->runtime.edit_data != NULL) { + if (mesh->edit_mesh != nullptr && mesh->runtime.edit_data != nullptr) { BMEditMesh *em = mesh->edit_mesh; BMesh *bm = em->bm; BMIter iter; BMVert *eve; int i; - if (mesh->runtime.edit_data->vertexCos != NULL) { + if (mesh->runtime.edit_data->vertexCos != nullptr) { const float(*vertexCos)[3] = mesh->runtime.edit_data->vertexCos; const float(*vertexNos)[3]; if (flag & MESH_FOREACH_USE_NORMAL) { @@ -50,30 +50,30 @@ void BKE_mesh_foreach_mapped_vert( vertexNos = mesh->runtime.edit_data->vertexNos; } else { - vertexNos = NULL; + vertexNos = nullptr; } BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { - const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vertexNos[i] : NULL; + const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vertexNos[i] : nullptr; func(userData, i, vertexCos[i], no); } } else { BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { - const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? eve->no : NULL; + const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? eve->no : nullptr; func(userData, i, eve->co, no); } } } else { const MVert *mv = BKE_mesh_verts(mesh); - const int *index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX); + const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)); const float(*vert_normals)[3] = (flag & MESH_FOREACH_USE_NORMAL) ? BKE_mesh_vertex_normals_ensure(mesh) : - NULL; + nullptr; if (index) { for (int i = 0; i < mesh->totvert; i++, mv++) { - const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : NULL; + const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : nullptr; const int orig = *index++; if (orig == ORIGINDEX_NONE) { continue; @@ -83,7 +83,7 @@ void BKE_mesh_foreach_mapped_vert( } else { for (int i = 0; i < mesh->totvert; i++, mv++) { - const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : NULL; + const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : nullptr; func(userData, i, mv->co, no); } } @@ -96,13 +96,13 @@ void BKE_mesh_foreach_mapped_edge( void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData) { - if (mesh->edit_mesh != NULL && mesh->runtime.edit_data) { + if (mesh->edit_mesh != nullptr && mesh->runtime.edit_data) { BMEditMesh *em = mesh->edit_mesh; BMesh *bm = em->bm; BMIter iter; BMEdge *eed; int i; - if (mesh->runtime.edit_data->vertexCos != NULL) { + if (mesh->runtime.edit_data->vertexCos != nullptr) { const float(*vertexCos)[3] = mesh->runtime.edit_data->vertexCos; BM_mesh_elem_index_ensure(bm, BM_VERT); @@ -122,7 +122,7 @@ void BKE_mesh_foreach_mapped_edge( else { const MVert *mv = BKE_mesh_verts(mesh); const MEdge *med = BKE_mesh_edges(mesh); - const int *index = CustomData_get_layer(&mesh->edata, CD_ORIGINDEX); + const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->edata, CD_ORIGINDEX)); if (index) { for (int i = 0; i < mesh->totedge; i++, med++) { @@ -154,7 +154,7 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh, /* We can't use dm->getLoopDataLayout(dm) here, * we want to always access dm->loopData, EditDerivedBMesh would * return loop data from bmesh itself. */ - if (mesh->edit_mesh != NULL && mesh->runtime.edit_data) { + if (mesh->edit_mesh != nullptr && mesh->runtime.edit_data) { BMEditMesh *em = mesh->edit_mesh; BMesh *bm = em->bm; BMIter iter; @@ -164,8 +164,9 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh, /* XXX: investigate using EditMesh data. */ const float(*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ? - CustomData_get_layer(&mesh->ldata, CD_NORMAL) : - NULL; + static_cast<const float(*)[3]>( + CustomData_get_layer(&mesh->ldata, CD_NORMAL)) : + nullptr; int f_idx; @@ -178,21 +179,24 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh, do { const BMVert *eve = l_iter->v; const int v_idx = BM_elem_index_get(eve); - const float *no = lnors ? *lnors++ : NULL; + const float *no = lnors ? *lnors++ : nullptr; func(userData, v_idx, f_idx, vertexCos ? vertexCos[v_idx] : eve->co, no); } while ((l_iter = l_iter->next) != l_first); } } else { const float(*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ? - CustomData_get_layer(&mesh->ldata, CD_NORMAL) : - NULL; + static_cast<const float(*)[3]>( + CustomData_get_layer(&mesh->ldata, CD_NORMAL)) : + nullptr; const MVert *mv = BKE_mesh_verts(mesh); const MLoop *ml = BKE_mesh_loops(mesh); const MPoly *mp = BKE_mesh_polys(mesh); - const int *v_index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX); - const int *f_index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX); + const int *v_index = static_cast<const int *>( + CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)); + const int *f_index = static_cast<const int *>( + CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX)); int p_idx, i; if (v_index || f_index) { @@ -200,7 +204,7 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh, for (i = 0; i < mp->totloop; i++, ml++) { const int v_idx = v_index ? v_index[ml->v] : ml->v; const int f_idx = f_index ? f_index[p_idx] : p_idx; - const float *no = lnors ? *lnors++ : NULL; + const float *no = lnors ? *lnors++ : nullptr; if (ELEM(ORIGINDEX_NONE, v_idx, f_idx)) { continue; } @@ -213,7 +217,7 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh, for (i = 0; i < mp->totloop; i++, ml++) { const int v_idx = ml->v; const int f_idx = p_idx; - const float *no = lnors ? *lnors++ : NULL; + const float *no = lnors ? *lnors++ : nullptr; func(userData, v_idx, f_idx, mv[ml->v].co, no); } } @@ -227,7 +231,7 @@ void BKE_mesh_foreach_mapped_face_center( void *userData, MeshForeachFlag flag) { - if (mesh->edit_mesh != NULL && mesh->runtime.edit_data != NULL) { + if (mesh->edit_mesh != nullptr && mesh->runtime.edit_data != nullptr) { BMEditMesh *em = mesh->edit_mesh; BMesh *bm = em->bm; const float(*polyCos)[3]; @@ -241,10 +245,10 @@ void BKE_mesh_foreach_mapped_face_center( if (flag & MESH_FOREACH_USE_NORMAL) { BKE_editmesh_cache_ensure_poly_normals(em, mesh->runtime.edit_data); - polyNos = mesh->runtime.edit_data->polyNos; /* maybe NULL */ + polyNos = mesh->runtime.edit_data->polyNos; /* maybe nullptr */ } else { - polyNos = NULL; + polyNos = nullptr; } if (polyNos) { @@ -255,7 +259,7 @@ void BKE_mesh_foreach_mapped_face_center( } else { BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) { - const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? efa->no : NULL; + const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? efa->no : nullptr; func(userData, i, polyCos[i], no); } } @@ -266,8 +270,8 @@ void BKE_mesh_foreach_mapped_face_center( const MLoop *loops = BKE_mesh_loops(mesh); const MLoop *ml; float _no_buf[3]; - float *no = (flag & MESH_FOREACH_USE_NORMAL) ? _no_buf : NULL; - const int *index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX); + float *no = (flag & MESH_FOREACH_USE_NORMAL) ? _no_buf : nullptr; + const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX)); if (index) { for (int i = 0; i < mesh->totpoly; i++, mp++) { @@ -311,10 +315,10 @@ void BKE_mesh_foreach_mapped_subdiv_face_center( const MVert *mv; const float(*vert_normals)[3] = (flag & MESH_FOREACH_USE_NORMAL) ? BKE_mesh_vertex_normals_ensure(mesh) : - NULL; - const int *index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX); + nullptr; + const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX)); const BLI_bitmap *facedot_tags = mesh->runtime.subsurf_face_dot_tags; - BLI_assert(facedot_tags != NULL); + BLI_assert(facedot_tags != nullptr); if (index) { for (int i = 0; i < mesh->totpoly; i++, mp++) { @@ -329,7 +333,7 @@ void BKE_mesh_foreach_mapped_subdiv_face_center( func(userData, orig, mv->co, - (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : NULL); + (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : nullptr); } } } @@ -340,7 +344,10 @@ void BKE_mesh_foreach_mapped_subdiv_face_center( for (int j = 0; j < mp->totloop; j++, ml++) { mv = &verts[ml->v]; if (BLI_BITMAP_TEST(facedot_tags, ml->v)) { - func(userData, i, mv->co, (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : NULL); + func(userData, + i, + mv->co, + (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : nullptr); } } } @@ -349,10 +356,10 @@ void BKE_mesh_foreach_mapped_subdiv_face_center( /* Helpers based on above foreach loopers> */ -typedef struct MappedVCosData { +struct MappedVCosData { float (*vertexcos)[3]; BLI_bitmap *vertex_visit; -} MappedVCosData; +}; static void get_vertexcos__mapFunc(void *user_data, int index, diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 2acff89ce7e..1f47496ae82 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -92,7 +92,7 @@ set(SRC intern/draw_manager_exec.c intern/draw_manager_profiling.c intern/draw_manager_shader.c - intern/draw_manager_text.c + intern/draw_manager_text.cc intern/draw_manager_texture.c intern/draw_pbvh.cc intern/draw_select_buffer.c diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.cc index 8987a6e2b20..e09050877c9 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -38,7 +38,7 @@ #include "draw_manager_text.h" #include "intern/bmesh_polygon.h" -typedef struct ViewCachedString { +struct ViewCachedString { float vec[3]; union { uchar ub[4]; @@ -51,20 +51,20 @@ typedef struct ViewCachedString { /* str is allocated past the end */ char str[0]; -} ViewCachedString; +}; -typedef struct DRWTextStore { +struct DRWTextStore { BLI_memiter *cache_strings; -} DRWTextStore; +}; DRWTextStore *DRW_text_cache_create(void) { - DRWTextStore *dt = MEM_callocN(sizeof(*dt), __func__); + DRWTextStore *dt = MEM_cnew<DRWTextStore>(__func__); dt->cache_strings = BLI_memiter_create(1 << 14); /* 16kb */ return dt; } -void DRW_text_cache_destroy(struct DRWTextStore *dt) +void DRW_text_cache_destroy(DRWTextStore *dt) { BLI_memiter_destroy(dt->cache_strings); MEM_freeN(dt); @@ -90,7 +90,8 @@ void DRW_text_cache_add(DRWTextStore *dt, alloc_len = str_len + 1; } - vos = BLI_memiter_alloc(dt->cache_strings, sizeof(ViewCachedString) + alloc_len); + vos = static_cast<ViewCachedString *>( + BLI_memiter_alloc(dt->cache_strings, sizeof(ViewCachedString) + alloc_len)); copy_v3_v3(vos->vec, co); copy_v4_v4_uchar(vos->col.ub, col); @@ -128,7 +129,7 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region) BLF_size(font_id, style->widget.points * U.dpi_fac); BLI_memiter_iter_init(dt->cache_strings, &it); - while ((vos = BLI_memiter_iter_step(&it))) { + while ((vos = static_cast<ViewCachedString *>(BLI_memiter_iter_step(&it)))) { if (vos->sco[0] != IS_CLIPPED) { if (col_pack_prev != vos->col.pack) { BLF_color4ubv(font_id, vos->col.ub); @@ -147,16 +148,16 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region) GPU_matrix_projection_set(original_proj); } -void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, struct View3D *v3d) +void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, View3D *v3d) { ViewCachedString *vos; if (v3d) { - RegionView3D *rv3d = region->regiondata; + RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata); int tot = 0; /* project first and test */ BLI_memiter_handle it; BLI_memiter_iter_init(dt->cache_strings, &it); - while ((vos = BLI_memiter_iter_step(&it))) { + while ((vos = static_cast<ViewCachedString *>(BLI_memiter_iter_step(&it)))) { if (ED_view3d_project_short_ex( region, (vos->flag & DRW_TEXT_CACHE_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob, @@ -192,10 +193,10 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, struct View3D *v3d) BLI_memiter_iter_init(dt->cache_strings, &it); View2D *v2d = ®ion->v2d; float viewmat[4][4]; - rctf region_space = {0.0f, region->winx, 0.0f, region->winy}; + rctf region_space = {0.0f, float(region->winx), 0.0f, float(region->winy)}; BLI_rctf_transform_calc_m4_pivot_min(&v2d->cur, ®ion_space, viewmat); - while ((vos = BLI_memiter_iter_step(&it))) { + while ((vos = static_cast<ViewCachedString *>(BLI_memiter_iter_step(&it)))) { float p[3]; copy_v3_v3(p, vos->vec); mul_m4_v3(viewmat, p); @@ -216,9 +217,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, * etc.). See bug T36090. */ - struct DRWTextStore *dt = DRW_text_cache_ensure(); + DRWTextStore *dt = DRW_text_cache_ensure(); const short txt_flag = DRW_TEXT_CACHE_GLOBALSPACE; - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BMEditMesh *em = me->edit_mesh; float v1[3], v2[3], v3[3], vmid[3], fvec[3]; char numstr[32]; /* Stores the measurement display text here */ @@ -232,8 +233,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, float clip_planes[4][4]; /* allow for displaying shape keys and deform mods */ BMIter iter; - const float(*vert_coords)[3] = (me->runtime.edit_data ? me->runtime.edit_data->vertexCos : NULL); - const bool use_coords = (vert_coords != NULL); + const float(*vert_coords)[3] = (me->runtime.edit_data ? me->runtime.edit_data->vertexCos : + nullptr); + const bool use_coords = (vert_coords != nullptr); /* when 2 or more edge-info options are enabled, space apart */ short edge_tex_count = 0; @@ -334,7 +336,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col); - const float(*poly_normals)[3] = NULL; + const float(*poly_normals)[3] = nullptr; if (use_coords) { BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); BKE_editmesh_cache_ensure_poly_normals(em, me->runtime.edit_data); @@ -410,7 +412,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); int i, n; - BMFace *f = NULL; + BMFace *f = nullptr; /* Alternative to using `poly_to_tri_count(i, BM_elem_index_get(f->l_first))` * without having to add an extra loop. */ int looptri_index = 0; diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index a4857c2b92f..7c7b5771a04 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -1311,7 +1311,7 @@ void ED_view3d_draw_bgpic_test(const struct Scene *scene, bool do_foreground, bool do_camera_frame); -/* view3d_gizmo_preselect_type.c */ +/* view3d_gizmo_preselect_type.cc */ void ED_view3d_gizmo_mesh_preselect_get_active(struct bContext *C, struct wmGizmo *gz, diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index eaac33fda26..97e39c00c48 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -42,7 +42,7 @@ set(SRC view3d_gizmo_navigate.c view3d_gizmo_navigate_type.c view3d_gizmo_preselect.c - view3d_gizmo_preselect_type.c + view3d_gizmo_preselect_type.cc view3d_gizmo_ruler.c view3d_gizmo_tool_generic.c view3d_header.c diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc index 73617c0670f..fefc5d6fa93 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc @@ -75,7 +75,7 @@ static bool gizmo_preselect_poll_for_draw(const bContext *C, wmGizmo *gz) /** \name Mesh Element (Vert/Edge/Face) Pre-Select Gizmo API * \{ */ -typedef struct MeshElemGizmo3D { +struct MeshElemGizmo3D { wmGizmo gizmo; Base **bases; uint bases_len; @@ -83,8 +83,8 @@ typedef struct MeshElemGizmo3D { int vert_index; int edge_index; int face_index; - struct EditMesh_PreSelElem *psel; -} MeshElemGizmo3D; + EditMesh_PreSelElem *psel; +}; static void gizmo_preselect_elem_draw(const bContext *C, wmGizmo *gz) { @@ -115,21 +115,20 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int EDBM_preselect_action_set(gz_ele->psel, PRESELECT_ACTION_DELETE); } - struct { + struct Best { Object *ob; BMElem *ele; float dist; int base_index; - } best = { - .dist = ED_view3d_select_dist_px(), - }; + } best{}; + best.dist = ED_view3d_select_dist_px(); { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); BKE_view_layer_synced_ensure(scene, view_layer); - if ((gz_ele->bases) == NULL || + if ((gz_ele->bases) == nullptr || (gz_ele->bases[0] != BKE_view_layer_active_base_get(view_layer))) { MEM_SAFE_FREE(gz_ele->bases); gz_ele->bases = BKE_view_layer_array_from_bases_in_edit_mode( @@ -183,7 +182,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int if (eve_test) { BMVert *vert = (BMVert *)eve_test; float vert_p_co[2], vert_co[3]; - const float mval_f[2] = {UNPACK2(vc.mval)}; + const float mval_f[2] = {float(vc.mval[0]), float(vc.mval[1])}; mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->obmat, vert->co); ED_view3d_project_v2(vc.region, vert_co, vert_p_co); float len = len_v2v2(vert_p_co, mval_f); @@ -206,7 +205,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int } } - BMesh *bm = NULL; + BMesh *bm = nullptr; gz_ele->base_index = -1; gz_ele->vert_index = -1; @@ -230,11 +229,11 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int } if (best.ele) { - const float(*coords)[3] = NULL; + const float(*coords)[3] = nullptr; { Object *ob = gz_ele->bases[gz_ele->base_index]->object; Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data); + Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, static_cast<ID *>(ob->data)); if (me_eval->runtime.edit_data) { coords = me_eval->runtime.edit_data->vertexCos; } @@ -264,7 +263,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int static void gizmo_preselect_elem_setup(wmGizmo *gz) { MeshElemGizmo3D *gz_ele = (MeshElemGizmo3D *)gz; - if (gz_ele->psel == NULL) { + if (gz_ele->psel == nullptr) { gz_ele->psel = EDBM_preselect_elem_create(); } gz_ele->base_index = -1; @@ -274,7 +273,7 @@ static void gizmo_preselect_elem_free(wmGizmo *gz) { MeshElemGizmo3D *gz_ele = (MeshElemGizmo3D *)gz; EDBM_preselect_elem_destroy(gz_ele->psel); - gz_ele->psel = NULL; + gz_ele->psel = nullptr; MEM_SAFE_FREE(gz_ele->bases); } @@ -311,14 +310,14 @@ static void GIZMO_GT_mesh_preselect_elem_3d(wmGizmoType *gzt) /** \name Mesh Edge-Ring Pre-Select Gizmo API * \{ */ -typedef struct MeshEdgeRingGizmo3D { +struct MeshEdgeRingGizmo3D { wmGizmo gizmo; Base **bases; uint bases_len; int base_index; int edge_index; - struct EditMesh_PreSelEdgeRing *psel; -} MeshEdgeRingGizmo3D; + EditMesh_PreSelEdgeRing *psel; +}; static void gizmo_preselect_edgering_draw(const bContext *C, wmGizmo *gz) { @@ -336,29 +335,27 @@ static void gizmo_preselect_edgering_draw(const bContext *C, wmGizmo *gz) static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const int mval[2]) { MeshEdgeRingGizmo3D *gz_ring = (MeshEdgeRingGizmo3D *)gz; - struct { + struct Best { Object *ob; BMEdge *eed; float dist; int base_index; - } best = { - .dist = ED_view3d_select_dist_px(), - }; + } best{}; + best.dist = ED_view3d_select_dist_px(); - struct { + struct Prev { int base_index; int edge_index; - } prev = { - .base_index = gz_ring->base_index, - .edge_index = gz_ring->edge_index, - }; + } prev{}; + prev.base_index = gz_ring->base_index; + prev.edge_index = gz_ring->edge_index; { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); BKE_view_layer_synced_ensure(scene, view_layer); - if ((gz_ring->bases) == NULL || + if ((gz_ring->bases) == nullptr || (gz_ring->bases[0] != BKE_view_layer_active_base_get(view_layer))) { MEM_SAFE_FREE(gz_ring->bases); gz_ring->bases = BKE_view_layer_array_from_bases_in_edit_mode( @@ -371,8 +368,15 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const copy_v2_v2_int(vc.mval, mval); uint base_index; - BMEdge *eed_test = EDBM_edge_find_nearest_ex( - &vc, &best.dist, NULL, false, false, NULL, gz_ring->bases, gz_ring->bases_len, &base_index); + BMEdge *eed_test = EDBM_edge_find_nearest_ex(&vc, + &best.dist, + nullptr, + false, + false, + nullptr, + gz_ring->bases, + gz_ring->bases_len, + &base_index); if (eed_test) { best.ob = gz_ring->bases[base_index]->object; @@ -380,7 +384,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const best.base_index = base_index; } - BMesh *bm = NULL; + BMesh *bm = nullptr; if (best.eed) { gz_ring->base_index = best.base_index; bm = BKE_editmesh_from_object(gz_ring->bases[gz_ring->base_index]->object)->bm; @@ -405,7 +409,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const * the mesh hasn't been edited since last update. */ bool is_alloc = false; const float(*coords)[3] = BKE_editmesh_vert_coords_when_deformed( - vc.depsgraph, em_eval, scene_eval, ob_eval, NULL, &is_alloc); + vc.depsgraph, em_eval, scene_eval, ob_eval, nullptr, &is_alloc); EDBM_preselect_edgering_update_from_edge(gz_ring->psel, bm, best.eed, 1, coords); if (is_alloc) { MEM_freeN((void *)coords); @@ -429,7 +433,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const static void gizmo_preselect_edgering_setup(wmGizmo *gz) { MeshEdgeRingGizmo3D *gz_ring = (MeshEdgeRingGizmo3D *)gz; - if (gz_ring->psel == NULL) { + if (gz_ring->psel == nullptr) { gz_ring->psel = EDBM_preselect_edgering_create(); } gz_ring->base_index = -1; @@ -439,7 +443,7 @@ static void gizmo_preselect_edgering_free(wmGizmo *gz) { MeshEdgeRingGizmo3D *gz_ring = (MeshEdgeRingGizmo3D *)gz; EDBM_preselect_edgering_destroy(gz_ring->psel); - gz_ring->psel = NULL; + gz_ring->psel = nullptr; MEM_SAFE_FREE(gz_ring->bases); } @@ -500,8 +504,8 @@ void ED_view3d_gizmo_mesh_preselect_get_active(bContext *C, const int object_index = RNA_int_get(gz->ptr, "object_index"); /* weak, allocate an array just to access the index. */ - Base *base = NULL; - Object *obedit = NULL; + Base *base = nullptr; + Object *obedit = nullptr; { uint bases_len; Base **bases = BKE_view_layer_array_from_bases_in_edit_mode( @@ -514,7 +518,7 @@ void ED_view3d_gizmo_mesh_preselect_get_active(bContext *C, } *r_base = base; - *r_ele = NULL; + *r_ele = nullptr; if (obedit) { BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -562,7 +566,7 @@ void ED_view3d_gizmo_mesh_preselect_clear(wmGizmo *gz) const char *prop_ids[] = {"object_index", "vert_index", "edge_index", "face_index"}; for (int i = 0; i < ARRAY_SIZE(prop_ids); i++) { PropertyRNA *prop = RNA_struct_find_property(gz->ptr, prop_ids[i]); - if (prop == NULL) { + if (prop == nullptr) { continue; } RNA_property_int_set(gz->ptr, prop, -1); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 8bace2e048c..a982a181ed7 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -92,7 +92,7 @@ set(SRC intern/MOD_volume_displace.cc intern/MOD_volume_to_mesh.cc intern/MOD_warp.c - intern/MOD_wave.c + intern/MOD_wave.cc intern/MOD_weighted_normal.c intern/MOD_weightvg_util.c intern/MOD_weightvgedit.c diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.cc index b49a47b0fb4..44002b2d719 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.cc @@ -55,7 +55,7 @@ static void initData(ModifierData *md) MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WaveModifierData), modifier); } -static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) +static bool dependsOnTime(Scene *UNUSED(scene), ModifierData *UNUSED(md)) { return true; } @@ -79,15 +79,15 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte WaveModifierData *wmd = (WaveModifierData *)md; bool need_transform_relation = false; - if (wmd->objectcenter != NULL) { + if (wmd->objectcenter != nullptr) { DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier"); need_transform_relation = true; } - if (wmd->texture != NULL) { + if (wmd->texture != nullptr) { DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier"); - if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) { + if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != nullptr) { MOD_depsgraph_update_object_bone_relation( ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier"); need_transform_relation = true; @@ -137,18 +137,18 @@ static void waveModifier_do(WaveModifierData *md, float ctime = DEG_get_ctime(ctx->depsgraph); float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); float lifefac = wmd->height; - float(*tex_co)[3] = NULL; + float(*tex_co)[3] = nullptr; const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y); const float falloff = wmd->falloff; float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */ const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0; - const float(*vert_normals)[3] = NULL; - if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) { + const float(*vert_normals)[3] = nullptr; + if ((wmd->flag & MOD_WAVE_NORM) && (mesh != nullptr)) { vert_normals = BKE_mesh_vertex_normals_ensure(mesh); } - if (wmd->objectcenter != NULL) { + if (wmd->objectcenter != nullptr) { float mat[4][4]; /* get the control object's location in local coordinates */ invert_m4_m4(ob->imat, ob->obmat); @@ -181,8 +181,8 @@ static void waveModifier_do(WaveModifierData *md, } Tex *tex_target = wmd->texture; - if (mesh != NULL && tex_target != NULL) { - tex_co = MEM_malloc_arrayN(verts_num, sizeof(*tex_co), "waveModifier_do tex_co"); + if (mesh != nullptr && tex_target != nullptr) { + tex_co = static_cast<float(*)[3]>(MEM_malloc_arrayN(verts_num, sizeof(*tex_co), __func__)); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); MOD_init_texture((MappingInfoModifierData *)wmd, ctx); @@ -295,54 +295,54 @@ static void deformVerts(ModifierData *md, int verts_num) { WaveModifierData *wmd = (WaveModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (wmd->flag & MOD_WAVE_NORM) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, verts_num, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, vertexCos, verts_num, false); } - else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); + else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') { + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); } waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { - BKE_id_free(NULL, mesh_src); + if (!ELEM(mesh_src, nullptr, mesh)) { + BKE_id_free(nullptr, mesh_src); } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, + BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int verts_num) { WaveModifierData *wmd = (WaveModifierData *)md; - Mesh *mesh_src = NULL; + Mesh *mesh_src = nullptr; if (wmd->flag & MOD_WAVE_NORM) { mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, verts_num, false); } - else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); + else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') { + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); } /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ - if (mesh_src != NULL) { + if (mesh_src != nullptr) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); - if (!ELEM(mesh_src, NULL, mesh)) { + if (!ELEM(mesh_src, nullptr, mesh)) { /* Important not to free `vertexCos` owned by the caller. */ EditMeshData *edit_data = mesh_src->runtime.edit_data; if (edit_data->vertexCos == vertexCos) { - edit_data->vertexCos = NULL; + edit_data->vertexCos = nullptr; } - BKE_id_free(NULL, mesh_src); + BKE_id_free(nullptr, mesh_src); } } @@ -357,10 +357,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetPropSep(layout, true); row = uiLayoutRowWithHeading(layout, true, IFACE_("Motion")); - uiItemR(row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); - uiItemR(row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); + uiItemR( + row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE); + uiItemR( + row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_cyclic", 0, nullptr, ICON_NONE); row = uiLayoutRowWithHeading(layout, true, IFACE_("Along Normals")); uiItemR(row, ptr, "use_normal", 0, "", ICON_NONE); @@ -372,11 +374,11 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "falloff_radius", 0, IFACE_("Falloff"), ICON_NONE); - uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); + uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); + uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); - modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); modifier_panel_end(layout, ptr); } @@ -386,7 +388,7 @@ static void position_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiLayoutSetPropSep(layout, true); @@ -402,7 +404,7 @@ static void time_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); uiLayoutSetPropSep(layout, true); @@ -410,7 +412,7 @@ static void time_panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(col, ptr, "time_offset", 0, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "lifetime", 0, IFACE_("Life"), ICON_NONE); uiItemR(col, ptr, "damping_time", 0, IFACE_("Damping"), ICON_NONE); - uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); } static void texture_panel_draw(const bContext *C, Panel *panel) @@ -423,7 +425,7 @@ static void texture_panel_draw(const bContext *C, Panel *panel) int texture_coords = RNA_enum_get(ptr, "texture_coords"); - uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); + uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr); uiLayoutSetPropSep(layout, true); @@ -446,7 +448,7 @@ static void texture_panel_draw(const bContext *C, Panel *panel) } else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); - uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); + uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE); } } @@ -454,10 +456,10 @@ static void panelRegister(ARegionType *region_type) { PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Wave, panel_draw); modifier_subpanel_register( - region_type, "position", "Start Position", NULL, position_panel_draw, panel_type); - modifier_subpanel_register(region_type, "time", "Time", NULL, time_panel_draw, panel_type); + region_type, "position", "Start Position", nullptr, position_panel_draw, panel_type); + modifier_subpanel_register(region_type, "time", "Time", nullptr, time_panel_draw, panel_type); modifier_subpanel_register( - region_type, "texture", "Texture", NULL, texture_panel_draw, panel_type); + region_type, "texture", "Texture", nullptr, texture_panel_draw, panel_type); } ModifierTypeInfo modifierType_Wave = { @@ -473,23 +475,23 @@ ModifierTypeInfo modifierType_Wave = { /* copyData */ BKE_modifier_copydata_generic, /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, + /* deformMatrices */ nullptr, /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* modifyMesh */ NULL, - /* modifyGeometrySet */ NULL, + /* deformMatricesEM */ nullptr, + /* modifyMesh */ nullptr, + /* modifyGeometrySet */ nullptr, /* initData */ initData, /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ NULL, + /* freeData */ nullptr, + /* isDisabled */ nullptr, /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ dependsOnNormals, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, - /* freeRuntimeData */ NULL, + /* freeRuntimeData */ nullptr, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, - /* blendRead */ NULL, + /* blendWrite */ nullptr, + /* blendRead */ nullptr, }; |