Commit: 1c1dc5f8440d918aca480904c53e31a528aef42f Author: Hans Goudey Date: Thu Sep 29 18:32:44 2022 -0500 Branches: master https://developer.blender.org/rB1c1dc5f8440d918aca480904c53e31a528aef42f
Cleanup: Move files that use mesh runtime data to C++ In preparation for moving the mesh runtime struct out of DNA. =================================================================== M source/blender/blenkernel/BKE_editmesh.h M source/blender/blenkernel/CMakeLists.txt R067 source/blender/blenkernel/intern/editmesh.c source/blender/blenkernel/intern/editmesh.cc R083 source/blender/blenkernel/intern/mesh_iterators.c source/blender/blenkernel/intern/mesh_iterators.cc M source/blender/draw/CMakeLists.txt R094 source/blender/draw/intern/draw_manager_text.c source/blender/draw/intern/draw_manager_text.cc M source/blender/editors/include/ED_view3d.h M source/blender/editors/space_view3d/CMakeLists.txt R091 source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc M source/blender/modifiers/CMakeLists.txt R084 source/blender/modifiers/intern/MOD_wave.c source/blender/modifiers/intern/MOD_wave.cc =================================================================== 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 similarity index 67% rename from source/blender/blenkernel/intern/editmesh.c rename to 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] = nul @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs