diff options
author | Hans Goudey <h.goudey@me.com> | 2022-05-15 22:02:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-05-15 22:02:15 +0300 |
commit | c5bee564eeeaecab37ba4add9026f2e68a7f0632 (patch) | |
tree | 99183a143efa1f2504234ce1d573a1a0e0340ac9 /source/blender/editors/mesh | |
parent | a6b37d8c88f916b59a4196ac634b33285834fba0 (diff) | |
parent | 84a764156340f3fff65cb76d3bd96f06807dc8c3 (diff) |
Merge branch 'master' into refactor-mesh-hide-generic
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/CMakeLists.txt | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/editface.cc (renamed from source/blender/editors/mesh/editface.c) | 48 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.cc (renamed from source/blender/editors/mesh/mesh_data.c) | 114 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.cc (renamed from source/blender/editors/mesh/meshtools.c) | 225 |
6 files changed, 205 insertions, 200 deletions
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index ed09e5a6334..28ac913a3e3 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -24,7 +24,7 @@ set(INC ) set(SRC - editface.c + editface.cc editmesh_add.c editmesh_add_gizmo.c editmesh_automerge.c @@ -51,10 +51,10 @@ set(SRC editmesh_tools.c editmesh_undo.c editmesh_utils.c - mesh_data.c + mesh_data.cc mesh_mirror.c mesh_ops.c - meshtools.c + meshtools.cc mesh_intern.h ) diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.cc index d7a7e80aa6e..36086148bb4 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.cc @@ -36,16 +36,16 @@ /* own include */ -void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const bool flush_hidden) +void paintface_flush_flags(bContext *C, Object *ob, short flag, const bool flush_hidden) { Mesh *me = BKE_mesh_from_object(ob); MPoly *polys, *mp_orig; - const int *index_array = NULL; + const int *index_array = nullptr; int totpoly; BLI_assert((flag & SELECT) || flush_hidden); - if (me == NULL) { + if (me == nullptr) { return; } @@ -60,7 +60,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const boo Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - if (ob_eval == NULL) { + if (ob_eval == nullptr) { return; } @@ -68,7 +68,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const boo Mesh *me_eval = (Mesh *)ob_eval->runtime.data_eval; bool updated = false; - if (me_orig != NULL && me_eval != NULL && me_orig->totpoly == me->totpoly) { + if (me_orig != nullptr && me_eval != nullptr && me_orig->totpoly == me->totpoly) { /* Update the COW copy of the mesh. */ for (int i = 0; i < me->totpoly; i++) { me_orig->mpoly[i].flag = me->mpoly[i].flag; @@ -79,7 +79,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const boo updated = true; } /* Mesh polys => Final derived polys */ - else if ((index_array = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX))) { + else if ((index_array = (const int *)CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX))) { polys = me_eval->mpoly; totpoly = me_eval->totpoly; @@ -104,10 +104,10 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const boo BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT_PAINT); } - DEG_id_tag_update(ob->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast<ID *>(ob->data), ID_RECALC_SELECT); } else { - DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT); + DEG_id_tag_update(static_cast<ID *>(ob->data), ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT); } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); @@ -116,7 +116,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag, const boo void paintface_hide(bContext *C, Object *ob, const bool unselected) { Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) { + if (me == nullptr || me->totpoly == 0) { return; } @@ -143,7 +143,7 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected) void paintface_reveal(bContext *C, Object *ob, const bool select) { Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) { + if (me == nullptr || me->totpoly == 0) { return; } @@ -244,7 +244,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b uint index = (uint)-1; Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) { + if (me == nullptr || me->totpoly == 0) { return; } @@ -262,7 +262,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags) { Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL) { + if (me == nullptr) { return false; } @@ -350,12 +350,12 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) return ok; } -bool paintface_mouse_select(struct bContext *C, +bool paintface_mouse_select(bContext *C, const int mval[2], - const struct SelectPick_Params *params, + const SelectPick_Params *params, Object *ob) { - MPoly *mpoly_sel = NULL; + MPoly *mpoly_sel = nullptr; uint index; bool changed = false; bool found = false; @@ -430,11 +430,11 @@ void paintvert_flush_flags(Object *ob) Mesh *me = BKE_mesh_from_object(ob); Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); MVert *mvert_eval, *mv; - const int *index_array = NULL; + const int *index_array = nullptr; int totvert; int i; - if (me == NULL) { + if (me == nullptr) { return; } @@ -442,11 +442,11 @@ void paintvert_flush_flags(Object *ob) * since this could become slow for realtime updates (circle-select for eg) */ BKE_mesh_flush_select_from_verts(me); - if (me_eval == NULL) { + if (me_eval == nullptr) { return; } - index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); + index_array = (const int *)CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); mvert_eval = me_eval->mvert; totvert = me_eval->totvert; @@ -471,16 +471,16 @@ void paintvert_flush_flags(Object *ob) BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL); } -void paintvert_tag_select_update(struct bContext *C, struct Object *ob) +void paintvert_tag_select_update(bContext *C, Object *ob) { - DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT); + DEG_id_tag_update(static_cast<ID *>(ob->data), ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); } bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags) { Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL) { + if (me == nullptr) { return false; } @@ -547,7 +547,7 @@ void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags) { Mesh *me = BKE_mesh_from_object(ob); - if (me == NULL || me->dvert == NULL) { + if (me == nullptr || me->dvert == nullptr) { return; } @@ -562,7 +562,7 @@ void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags) MVert *mv = &me->mvert[i]; MDeformVert *dv = &me->dvert[i]; if (!(vert_hide && vert_hide[i])) { - if (dv->dw == NULL) { + if (dv->dw == nullptr) { /* if null weight then not grouped */ mv->flag |= SELECT; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index c3d5f33705c..c7c7e5cf2f8 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -9,6 +9,7 @@ #include "DNA_key_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "BLI_alloca.h" @@ -19,6 +20,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_context.h" +#include "BKE_customdata.h" #include "BKE_editmesh.h" #include "BKE_editmesh_bvh.h" #include "BKE_global.h" diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.cc index 6b857fccec7..48d118c96ec 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.cc @@ -46,7 +46,7 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot) { CustomData *data; - BMesh *bm = (me->edit_mesh) ? me->edit_mesh->bm : NULL; + BMesh *bm = (me->edit_mesh) ? me->edit_mesh->bm : nullptr; int tot; switch (htype) { @@ -93,7 +93,7 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t default: BLI_assert(0); tot = 0; - data = NULL; + data = nullptr; break; } @@ -195,7 +195,7 @@ static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv) mesh_uv_reset_array(fuv, mp->totloop); } -void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) +void ED_mesh_uv_loop_reset_ex(Mesh *me, const int layernum) { BMEditMesh *em = me->edit_mesh; @@ -219,7 +219,7 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) else { /* Collect Mesh UVs */ BLI_assert(CustomData_has_layer(&me->ldata, CD_MLOOPUV)); - MLoopUV *mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); + MLoopUV *mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); for (int i = 0; i < me->totpoly; i++) { mesh_uv_reset_mface(&me->mpoly[i], mloopuv); @@ -229,7 +229,7 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) DEG_id_tag_update(&me->id, 0); } -void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) +void ED_mesh_uv_loop_reset(bContext *C, Mesh *me) { /* could be ldata or pdata */ CustomData *ldata = GET_CD_DATA(me, ldata); @@ -284,7 +284,7 @@ int ED_mesh_uv_texture_add( is_init = true; } else { - CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name); + CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, name); } if (active_set || layernum_dst == 0) { @@ -305,7 +305,7 @@ int ED_mesh_uv_texture_add( return layernum_dst; } -void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name) +void ED_mesh_uv_texture_ensure(Mesh *me, const char *name) { BMEditMesh *em; int layernum_dst; @@ -315,13 +315,13 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name) layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV); if (layernum_dst == 0) { - ED_mesh_uv_texture_add(me, name, true, true, NULL); + ED_mesh_uv_texture_add(me, name, true, true, nullptr); } } else { layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); if (layernum_dst == 0) { - ED_mesh_uv_texture_add(me, name, true, true, NULL); + ED_mesh_uv_texture_add(me, name, true, true, nullptr); } } } @@ -333,7 +333,7 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n) int index; index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n); - cdlu = (index == -1) ? NULL : &ldata->layers[index]; + cdlu = (index == -1) ? nullptr : &ldata->layers[index]; if (!cdlu) { return false; @@ -409,7 +409,7 @@ int ED_mesh_color_add( } else { CustomData_add_layer_named( - &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, NULL, me->totloop, name); + &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name); } if (active_set || layernum == 0) { @@ -425,14 +425,14 @@ int ED_mesh_color_add( return layernum; } -bool ED_mesh_color_ensure(struct Mesh *me, const char *name) +bool ED_mesh_color_ensure(Mesh *me, const char *name) { - BLI_assert(me->edit_mesh == NULL); + BLI_assert(me->edit_mesh == nullptr); CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me->id); if (!layer) { CustomData_add_layer_named( - &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, NULL, me->totloop, name); + &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name); layer = me->ldata.layers + CustomData_get_layer_index(&me->ldata, CD_PROP_BYTE_COLOR); BKE_id_attributes_active_color_set(&me->id, layer); @@ -441,7 +441,7 @@ bool ED_mesh_color_ensure(struct Mesh *me, const char *name) DEG_id_tag_update(&me->id, 0); - return (layer != NULL); + return (layer != nullptr); } bool ED_mesh_color_remove_index(Mesh *me, const int n) @@ -451,7 +451,7 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n) int index; index = CustomData_get_layer_index_n(ldata, CD_PROP_BYTE_COLOR, n); - cdl = (index == -1) ? NULL : &ldata->layers[index]; + cdl = (index == -1) ? nullptr : &ldata->layers[index]; if (!cdl) { return false; @@ -487,7 +487,7 @@ bool ED_mesh_color_remove_named(Mesh *me, const char *name) static bool layers_poll(bContext *C) { Object *ob = ED_object_context(C); - ID *data = (ob) ? ob->data : NULL; + ID *data = (ob) ? static_cast<ID *>(ob->data) : nullptr; return (ob && !ID_IS_LINKED(ob) && !ID_IS_OVERRIDE_LIBRARY(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data)); } @@ -501,7 +501,7 @@ static bool sculpt_vertex_color_remove_poll(bContext *C) } Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); CustomData *vdata = GET_CD_DATA(me, vdata); const int active = CustomData_get_active_layer(vdata, CD_PROP_COLOR); if (active != -1) { @@ -549,12 +549,14 @@ int ED_mesh_sculpt_color_add( } if (CustomData_has_layer(&me->vdata, CD_PROP_COLOR) && do_init) { - const MPropCol *color_data = CustomData_get_layer(&me->vdata, CD_PROP_COLOR); + const MPropCol *color_data = (const MPropCol *)CustomData_get_layer(&me->vdata, + CD_PROP_COLOR); CustomData_add_layer_named( &me->vdata, CD_PROP_COLOR, CD_DUPLICATE, (MPropCol *)color_data, me->totvert, name); } else { - CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, me->totvert, name); + CustomData_add_layer_named( + &me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name); } if (active_set || layernum == 0) { @@ -570,18 +572,18 @@ int ED_mesh_sculpt_color_add( return layernum; } -bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name) +bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name) { - BLI_assert(me->edit_mesh == NULL); + BLI_assert(me->edit_mesh == nullptr); if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) { - CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, me->totvert, name); + CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name); BKE_mesh_update_customdata_pointers(me, true); } DEG_id_tag_update(&me->id, 0); - return (me->mloopcol != NULL); + return (me->mloopcol != nullptr); } bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n) @@ -591,7 +593,7 @@ bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n) int index; index = CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, n); - cdl = (index == -1) ? NULL : &vdata->layers[index]; + cdl = (index == -1) ? nullptr : &vdata->layers[index]; if (!cdl) { return false; @@ -631,7 +633,7 @@ static bool uv_texture_remove_poll(bContext *C) } Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); CustomData *ldata = GET_CD_DATA(me, ldata); const int active = CustomData_get_active_layer(ldata, CD_MLOOPUV); if (active != -1) { @@ -644,16 +646,16 @@ static bool uv_texture_remove_poll(bContext *C) static int mesh_uv_texture_add_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); - if (ED_mesh_uv_texture_add(me, NULL, true, true, op->reports) == -1) { + if (ED_mesh_uv_texture_add(me, nullptr, true, true, op->reports) == -1) { return OPERATOR_CANCELLED; } if (ob->mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); - ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr); + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, nullptr); } return OPERATOR_FINISHED; @@ -677,7 +679,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); if (!ED_mesh_uv_texture_remove_active(me)) { return OPERATOR_CANCELLED; @@ -685,8 +687,8 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); - ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr); + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, nullptr); } return OPERATOR_FINISHED; @@ -716,7 +718,7 @@ static bool vertex_color_remove_poll(bContext *C) } Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); CustomData *ldata = GET_CD_DATA(me, ldata); const int active = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR); if (active != -1) { @@ -729,9 +731,9 @@ static bool vertex_color_remove_poll(bContext *C) static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); - if (ED_mesh_color_add(me, NULL, true, true, op->reports) == -1) { + if (ED_mesh_color_add(me, nullptr, true, true, op->reports) == -1) { return OPERATOR_CANCELLED; } @@ -756,7 +758,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); if (!ED_mesh_color_remove_active(me)) { return OPERATOR_CANCELLED; @@ -785,9 +787,9 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); - if (ED_mesh_sculpt_color_add(me, NULL, true, true, op->reports) == -1) { + if (ED_mesh_sculpt_color_add(me, nullptr, true, true, op->reports) == -1) { return OPERATOR_CANCELLED; } @@ -812,7 +814,7 @@ void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot) static int mesh_sculpt_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); if (!ED_mesh_sculpt_color_remove_active(me)) { return OPERATOR_CANCELLED; @@ -868,7 +870,7 @@ static bool mesh_customdata_mask_clear_poll(bContext *C) { Object *ob = ED_object_context(C); if (ob && ob->type == OB_MESH) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); /* special case - can't run this if we're in sculpt mode */ if (ob->mode & OB_MODE_SCULPT) { @@ -925,7 +927,7 @@ static int mesh_customdata_skin_state(bContext *C) Object *ob = ED_object_context(C); if (ob && ob->type == OB_MESH) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); if (!ID_IS_LINKED(me) && !ID_IS_OVERRIDE_LIBRARY(me)) { CustomData *data = GET_CD_DATA(me, vdata); return CustomData_has_layer(data, CD_MVERT_SKIN); @@ -942,7 +944,7 @@ static bool mesh_customdata_skin_add_poll(bContext *C) static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BKE_mesh_ensure_skin_customdata(me); @@ -1025,7 +1027,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator me->smoothresh); } - CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, NULL, me->totloop); + CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, nullptr, me->totloop); } DEG_id_tag_update(&me->id, 0); @@ -1057,7 +1059,7 @@ static int mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperato if (BKE_mesh_has_custom_loop_normals(me)) { BMEditMesh *em = me->edit_mesh; - if (em != NULL && em->bm->lnor_spacearr != NULL) { + if (em != nullptr && em->bm->lnor_spacearr != nullptr) { BKE_lnor_spacearr_clear(em->bm->lnor_spacearr); } return mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_CUSTOMLOOPNORMAL); @@ -1114,7 +1116,7 @@ static void mesh_add_verts(Mesh *mesh, int len) CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert); if (!CustomData_has_layer(&vdata, CD_MVERT)) { - CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert); + CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, nullptr, totvert); } CustomData_free(&mesh->vdata, mesh->totvert); @@ -1152,7 +1154,7 @@ static void mesh_add_edges(Mesh *mesh, int len) CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge); if (!CustomData_has_layer(&edata, CD_MEDGE)) { - CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge); } CustomData_free(&mesh->edata, mesh->totedge); @@ -1186,7 +1188,7 @@ static void mesh_add_loops(Mesh *mesh, int len) CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop); if (!CustomData_has_layer(&ldata, CD_MLOOP)) { - CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop); + CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop); } BKE_mesh_runtime_clear_cache(mesh); @@ -1215,7 +1217,7 @@ static void mesh_add_polys(Mesh *mesh, int len) CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly); if (!CustomData_has_layer(&pdata, CD_MPOLY)) { - CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly); + CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly); } CustomData_free(&mesh->pdata, mesh->totpoly); @@ -1413,21 +1415,21 @@ void ED_mesh_report_mirror(wmOperator *op, int totmirr, int totfail) ED_mesh_report_mirror_ex(op, totmirr, totfail, SCE_SELECT_VERTEX); } -Mesh *ED_mesh_context(struct bContext *C) +Mesh *ED_mesh_context(bContext *C) { - Mesh *mesh = CTX_data_pointer_get_type(C, "mesh", &RNA_Mesh).data; - if (mesh != NULL) { + Mesh *mesh = static_cast<Mesh *>(CTX_data_pointer_get_type(C, "mesh", &RNA_Mesh).data); + if (mesh != nullptr) { return mesh; } Object *ob = ED_object_active_context(C); - if (ob == NULL) { - return NULL; + if (ob == nullptr) { + return nullptr; } ID *data = (ID *)ob->data; - if (data == NULL || GS(data->name) != ID_ME) { - return NULL; + if (data == nullptr || GS(data->name) != ID_ME) { + return nullptr; } return (Mesh *)data; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index b39a0b90f6d..196c4957d84 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -9,6 +9,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + struct BMEditMesh; struct BMElem; struct BMOperator; @@ -301,7 +305,7 @@ void MESH_OT_mark_freestyle_edge(struct wmOperatorType *ot); void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot); #endif -/* *** mesh_data.c *** */ +/* *** mesh_data.cc *** */ void MESH_OT_uv_texture_add(struct wmOperatorType *ot); void MESH_OT_uv_texture_remove(struct wmOperatorType *ot); @@ -314,3 +318,7 @@ void MESH_OT_customdata_skin_add(struct wmOperatorType *ot); void MESH_OT_customdata_skin_clear(struct wmOperatorType *ot); void MESH_OT_customdata_custom_splitnormals_add(struct wmOperatorType *ot); void MESH_OT_customdata_custom_splitnormals_clear(struct wmOperatorType *ot); + +#ifdef __cplusplus +} +#endif
\ No newline at end of file diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.cc index e27c3b56a47..524f3dfb053 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.cc @@ -21,10 +21,8 @@ #include "DNA_view3d_types.h" #include "DNA_workspace_types.h" -#include "BLI_blenlib.h" -#include "BLI_math.h" - #include "BKE_context.h" +#include "BKE_customdata.h" #include "BKE_deform.h" #include "BKE_editmesh.h" #include "BKE_key.h" @@ -91,7 +89,7 @@ static void join_mesh_single(Depsgraph *depsgraph, { int a, b; - Mesh *me = ob_src->data; + Mesh *me = static_cast<Mesh *>(ob_src->data); MVert *mvert = *mvert_pp; MEdge *medge = *medge_pp; MLoop *mloop = *mloop_pp; @@ -106,12 +104,13 @@ static void join_mesh_single(Depsgraph *depsgraph, CustomData_copy_data_named(&me->vdata, vdata, 0, *vertofs, me->totvert); /* vertex groups */ - MDeformVert *dvert = CustomData_get(vdata, *vertofs, CD_MDEFORMVERT); - const MDeformVert *dvert_src = CustomData_get(&me->vdata, 0, CD_MDEFORMVERT); + MDeformVert *dvert = (MDeformVert *)CustomData_get(vdata, *vertofs, CD_MDEFORMVERT); + const MDeformVert *dvert_src = (const MDeformVert *)CustomData_get( + &me->vdata, 0, CD_MDEFORMVERT); /* Remap to correct new vgroup indices, if needed. */ if (dvert_src) { - BLI_assert(dvert != NULL); + BLI_assert(dvert != nullptr); /* Build src to merged mapping of vgroup indices. */ int *vgroup_index_map; @@ -120,7 +119,7 @@ static void join_mesh_single(Depsgraph *depsgraph, ob_src, ob_dst, &vgroup_index_map_len); BKE_object_defgroup_index_map_apply( dvert, me->totvert, vgroup_index_map, vgroup_index_map_len); - if (vgroup_index_map != NULL) { + if (vgroup_index_map != nullptr) { MEM_freeN(vgroup_index_map); } } @@ -150,11 +149,11 @@ static void join_mesh_single(Depsgraph *depsgraph, float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; /* Check if this mesh has such a shape-key. */ - KeyBlock *okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL; + KeyBlock *okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : nullptr; if (okb) { /* copy this mesh's shape-key to the destination shape-key * (need to transform first) */ - float(*ocos)[3] = okb->data; + float(*ocos)[3] = static_cast<float(*)[3]>(okb->data); for (a = 0; a < me->totvert; a++, cos++, ocos++) { copy_v3_v3(*cos, *ocos); mul_m4_v3(cmat, *cos); @@ -180,10 +179,10 @@ static void join_mesh_single(Depsgraph *depsgraph, float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; /* Check if this was one of the original shape-keys. */ - KeyBlock *okb = nkey ? BKE_keyblock_find_name(nkey, kb->name) : NULL; + KeyBlock *okb = nkey ? BKE_keyblock_find_name(nkey, kb->name) : nullptr; if (okb) { /* copy this mesh's shape-key to the destination shape-key */ - float(*ocos)[3] = okb->data; + float(*ocos)[3] = static_cast<float(*)[3]>(okb->data); for (a = 0; a < me->totvert; a++, cos++, ocos++) { copy_v3_v3(*cos, *ocos); } @@ -254,17 +253,17 @@ static void join_mesh_single(Depsgraph *depsgraph, } /* Face maps. */ - int *fmap = CustomData_get(pdata, *polyofs, CD_FACEMAP); - const int *fmap_src = CustomData_get(&me->pdata, 0, CD_FACEMAP); + int *fmap = (int *)CustomData_get(pdata, *polyofs, CD_FACEMAP); + const int *fmap_src = (const int *)CustomData_get(&me->pdata, 0, CD_FACEMAP); /* Remap to correct new face-map indices, if needed. */ if (fmap_src) { - BLI_assert(fmap != NULL); + BLI_assert(fmap != nullptr); int *fmap_index_map; int fmap_index_map_len; fmap_index_map = BKE_object_facemap_index_map_create(ob_src, ob_dst, &fmap_index_map_len); BKE_object_facemap_index_map_apply(fmap, me->totpoly, fmap_index_map, fmap_index_map_len); - if (fmap_index_map != NULL) { + if (fmap_index_map != nullptr) { MEM_freeN(fmap_index_map); } } @@ -290,7 +289,7 @@ static void mesh_join_offset_face_sets_ID(const Mesh *mesh, int *face_set_offset return; } - int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); + int *face_sets = (int *)CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); if (!face_sets) { return; } @@ -317,20 +316,18 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - Material **matar = NULL, *ma; + Material **matar = nullptr, *ma; Mesh *me; - MVert *mvert = NULL; - MEdge *medge = NULL; - MPoly *mpoly = NULL; - MLoop *mloop = NULL; - Key *key, *nkey = NULL; - KeyBlock *kb, *kbn; + MVert *mvert = nullptr; + MEdge *medge = nullptr; + MPoly *mpoly = nullptr; + MLoop *mloop = nullptr; + Key *key, *nkey = nullptr; float imat[4][4]; int a, b, totcol, totmat = 0, totedge = 0, totvert = 0; - int totloop = 0, totpoly = 0, vertofs, *matmap = NULL; + int totloop = 0, totpoly = 0, vertofs, *matmap = nullptr; int i, haskey = 0, edgeofs, loopofs, polyofs; bool ok = false, join_parent = false; - bDeformGroup *dg, *odg; CustomData vdata, edata, fdata, ldata, pdata; if (ob->mode & OB_MODE_EDIT) { @@ -349,7 +346,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* count & check */ CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob_iter->type == OB_MESH) { - me = ob_iter->data; + me = static_cast<Mesh *>(ob_iter->data); totvert += me->totvert; totedge += me->totedge; @@ -361,7 +358,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) ok = true; } - if ((ob->parent != NULL) && (ob_iter == ob->parent)) { + if ((ob->parent != nullptr) && (ob_iter == ob->parent)) { join_parent = true; } @@ -376,7 +373,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* Apply parent transform if the active object's parent was joined to it. * NOTE: This doesn't apply recursive parenting. */ if (join_parent) { - ob->parent = NULL; + ob->parent = nullptr; BKE_object_apply_mat4_ex(ob, ob->obmat, ob->parent, ob->parentinv, false); } @@ -416,8 +413,8 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* new material indices and material array */ if (totmat) { - matar = MEM_callocN(sizeof(*matar) * totmat, "join_mesh matar"); - matmap = MEM_callocN(sizeof(*matmap) * totmat, "join_mesh matmap"); + matar = static_cast<Material **>(MEM_callocN(sizeof(*matar) * totmat, __func__)); + matmap = static_cast<int *>(MEM_callocN(sizeof(*matmap) * totmat, __func__)); } totcol = ob->totcol; @@ -438,7 +435,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) nkey = (Key *)BKE_id_copy(bmain, &key->id); /* for all keys in old block, clear data-arrays */ - for (kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { if (kb->data) { MEM_freeN(kb->data); } @@ -462,13 +459,14 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { /* only act if a mesh, and not the one we're joining to */ if ((ob != ob_iter) && (ob_iter->type == OB_MESH)) { - me = ob_iter->data; + me = static_cast<Mesh *>(ob_iter->data); /* Join this object's vertex groups to the base one's */ - for (dg = me->vertex_group_names.first; dg; dg = dg->next) { + LISTBASE_FOREACH (bDeformGroup *, dg, &me->vertex_group_names) { /* See if this group exists in the object (if it doesn't, add it to the end) */ if (!BKE_object_defgroup_find_name(ob, dg->name)) { - odg = MEM_mallocN(sizeof(bDeformGroup), "join deformGroup"); + bDeformGroup *odg = static_cast<bDeformGroup *>( + MEM_mallocN(sizeof(bDeformGroup), __func__)); memcpy(odg, dg, sizeof(bDeformGroup)); BLI_addtail(&mesh_active->vertex_group_names, odg); } @@ -481,8 +479,8 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* Join this object's face maps to the base one's. */ LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) { /* See if this group exists in the object (if it doesn't, add it to the end) */ - if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) { - bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap"); + if (BKE_object_facemap_find_name(ob, fmap->name) == nullptr) { + bFaceMap *fmap_new = static_cast<bFaceMap *>(MEM_mallocN(sizeof(bFaceMap), __func__)); memcpy(fmap_new, fmap, sizeof(bFaceMap)); BLI_addtail(&ob->fmaps, fmap_new); } @@ -522,13 +520,15 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) * check if destination mesh already has matching entries too. */ if (me->key && key) { /* for remapping KeyBlock.relative */ - int *index_map = MEM_mallocN(sizeof(int) * me->key->totkey, __func__); - KeyBlock **kb_map = MEM_mallocN(sizeof(KeyBlock *) * me->key->totkey, __func__); + int *index_map = static_cast<int *>( + MEM_mallocN(sizeof(int) * me->key->totkey, __func__)); + KeyBlock **kb_map = static_cast<KeyBlock **>( + MEM_mallocN(sizeof(KeyBlock *) * me->key->totkey, __func__)); - for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) { + LISTBASE_FOREACH_INDEX (KeyBlock *, kb, &me->key->block, i) { BLI_assert(i < me->key->totkey); - kbn = BKE_keyblock_find_name(key, kb->name); + KeyBlock *kbn = BKE_keyblock_find_name(key, kb->name); /* if key doesn't exist in destination mesh, add it */ if (kbn) { index_map[i] = BLI_findindex(&key->block, kbn); @@ -549,7 +549,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) } /* remap relative index values */ - for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) { + LISTBASE_FOREACH_INDEX (KeyBlock *, kb, &me->key->block, i) { /* sanity check, should always be true */ if (LIKELY(kb->relative < me->key->totkey)) { kb_map[i]->relative = index_map[kb->relative]; @@ -571,10 +571,10 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) CustomData_reset(&ldata); CustomData_reset(&pdata); - mvert = CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert); - medge = CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); - mloop = CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop); - mpoly = CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly); + mvert = (MVert *)CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, nullptr, totvert); + medge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge); + mloop = (MLoop *)CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop); + mpoly = (MPoly *)CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly); vertofs = 0; edgeofs = 0; @@ -661,7 +661,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* return to mesh we're merging to */ - me = ob->data; + me = static_cast<Mesh *>(ob->data); CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); @@ -703,8 +703,8 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) if (totcol) { me->mat = matar; - ob->mat = MEM_callocN(sizeof(*ob->mat) * totcol, "join obmatar"); - ob->matbits = MEM_callocN(sizeof(*ob->matbits) * totcol, "join obmatbits"); + ob->mat = static_cast<Material **>(MEM_callocN(sizeof(*ob->mat) * totcol, __func__)); + ob->matbits = static_cast<char *>(MEM_callocN(sizeof(*ob->matbits) * totcol, __func__)); MEM_freeN(matmap); } @@ -751,8 +751,8 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op) Object *ob_active = CTX_data_active_object(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = (Mesh *)ob_active->data; - Mesh *selme = NULL; - Mesh *me_deformed = NULL; + Mesh *selme = nullptr; + Mesh *me_deformed = nullptr; Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; @@ -769,7 +769,7 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op) ok = true; } else { - nonequal_verts = 1; + nonequal_verts = true; } } } @@ -787,12 +787,12 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (key == NULL) { + if (key == nullptr) { key = me->key = BKE_key_add(bmain, (ID *)me); key->type = KEY_RELATIVE; /* first key added, so it was the basis. initialize it with the existing mesh */ - kb = BKE_keyblock_add(key, NULL); + kb = BKE_keyblock_add(key, nullptr); BKE_keyblock_convert_from_mesh(me, key, kb); } @@ -835,21 +835,21 @@ int ED_mesh_shapes_join_objects_exec(bContext *C, wmOperator *op) /** \name Mesh Topology Mirror API * \{ */ -static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1}; +static MirrTopoStore_t mesh_topo_store = {nullptr, -1, -1, false}; BLI_INLINE void mesh_mirror_topo_table_get_meshes(Object *ob, Mesh *me_eval, Mesh **r_me_mirror, BMEditMesh **r_em_mirror) { - Mesh *me_mirror = NULL; - BMEditMesh *em_mirror = NULL; + Mesh *me_mirror = nullptr; + BMEditMesh *em_mirror = nullptr; - Mesh *me = ob->data; - if (me_eval != NULL) { + Mesh *me = static_cast<Mesh *>(ob->data); + if (me_eval != nullptr) { me_mirror = me_eval; } - else if (me->edit_mesh != NULL) { + else if (me->edit_mesh != nullptr) { em_mirror = me->edit_mesh; } else { @@ -892,7 +892,7 @@ static bool ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *me_eval, int index) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); MVert *mvert = me_eval ? me_eval->mvert : me->mvert; float vec[3]; @@ -901,7 +901,7 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *me_eval, int index) vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - return ED_mesh_mirror_spatial_table_lookup(ob, NULL, me_eval, vec); + return ED_mesh_mirror_spatial_table_lookup(ob, nullptr, me_eval, vec); } static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) @@ -928,28 +928,25 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c /* ignore nan verts */ if ((isfinite(co[0]) == false) || (isfinite(co[1]) == false) || (isfinite(co[2]) == false)) { - return NULL; + return nullptr; } vec[0] = -co[0]; vec[1] = co[1]; vec[2] = co[2]; - i = ED_mesh_mirror_spatial_table_lookup(ob, em, NULL, vec); + i = ED_mesh_mirror_spatial_table_lookup(ob, em, nullptr, vec); if (i != -1) { return BM_vert_at_index(em->bm, i); } - return NULL; + return nullptr; } -static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, - struct BMEditMesh *em, - BMVert *eve, - int index) +static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, BMEditMesh *em, BMVert *eve, int index) { intptr_t poinval; - if (!ed_mesh_mirror_topo_table_update(ob, NULL)) { - return NULL; + if (!ed_mesh_mirror_topo_table_update(ob, nullptr)) { + return nullptr; } if (index == -1) { @@ -965,7 +962,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, } if (index == em->bm->totvert) { - return NULL; + return nullptr; } } @@ -974,15 +971,11 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, if (poinval != -1) { return (BMVert *)(poinval); } - return NULL; + return nullptr; } -BMVert *editbmesh_get_x_mirror_vert(Object *ob, - struct BMEditMesh *em, - BMVert *eve, - const float co[3], - int index, - const bool use_topology) +BMVert *editbmesh_get_x_mirror_vert( + Object *ob, BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology) { if (use_topology) { return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); @@ -992,7 +985,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, int ED_mesh_mirror_get_vert(Object *ob, int index) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BMEditMesh *em = me->edit_mesh; bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; int index_mirr; @@ -1004,7 +997,7 @@ int ED_mesh_mirror_get_vert(Object *ob, int index) index_mirr = eve_mirr ? BM_elem_index_get(eve_mirr) : -1; } else { - index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, use_topology); + index_mirr = mesh_get_x_mirror_vert(ob, nullptr, index, use_topology); } return index_mirr; @@ -1021,7 +1014,7 @@ static float *editmesh_get_mirror_uv( /* ignore nan verts */ if (isnan(uv[0]) || !isfinite(uv[0]) || isnan(uv[1]) || !isfinite(uv[1])) { - return NULL; + return nullptr; } if (axis) { @@ -1061,14 +1054,14 @@ static float *editmesh_get_mirror_uv( } } - return NULL; + return nullptr; } #endif static uint mirror_facehash(const void *ptr) { - const MFace *mf = ptr; + const MFace *mf = static_cast<const MFace *>(ptr); uint v0, v1; if (mf->v4) { @@ -1121,21 +1114,21 @@ static bool mirror_facecmp(const void *a, const void *b) int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); MVert *mv, *mvert; MFace mirrormf, *mf, *hashmf, *mface; GHash *fhash; int *mirrorverts, *mirrorfaces; - BLI_assert(em == NULL); /* Does not work otherwise, currently... */ + BLI_assert(em == nullptr); /* Does not work otherwise, currently... */ const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; const int totvert = me_eval ? me_eval->totvert : me->totvert; const int totface = me_eval ? me_eval->totface : me->totface; int a; - mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); - mirrorfaces = MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces"); + mirrorverts = static_cast<int *>(MEM_callocN(sizeof(int) * totvert, "MirrorVerts")); + mirrorfaces = static_cast<int *>(MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces")); mvert = me_eval ? me_eval->mvert : me->mvert; mface = me_eval ? me_eval->mface : me->mface; @@ -1165,7 +1158,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) SWAP(uint, mirrormf.v2, mirrormf.v4); } - hashmf = BLI_ghash_lookup(fhash, &mirrormf); + hashmf = static_cast<MFace *>(BLI_ghash_lookup(fhash, &mirrormf)); if (hashmf) { mirrorfaces[a * 2] = hashmf - mface; mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf); @@ -1175,7 +1168,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) } } - BLI_ghash_free(fhash, NULL, NULL); + BLI_ghash_free(fhash, nullptr, nullptr); MEM_freeN(mirrorverts); return mirrorfaces; @@ -1186,7 +1179,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) { ViewContext vc; - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BLI_assert(me && GS(me->id.name) == ID_ME); @@ -1220,7 +1213,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, static void ed_mesh_pick_face_vert__mpoly_find( /* context */ - struct ARegion *region, + ARegion *region, const float mval[2], /* mesh data (evaluated) */ const MPoly *mp, @@ -1250,14 +1243,14 @@ bool ED_mesh_pick_face_vert( { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); uint poly_index; - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BLI_assert(me && GS(me->id.name) == ID_ME); if (ED_mesh_pick_face(C, ob, mval, dist_px, &poly_index)) { Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - struct ARegion *region = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); /* derived mesh to find deformed locations */ Mesh *me_eval = mesh_get_eval_final( @@ -1266,7 +1259,7 @@ bool ED_mesh_pick_face_vert( int v_idx_best = ORIGINDEX_NONE; /* find the vert closest to 'mval' */ - const float mval_f[2] = {UNPACK2(mval)}; + const float mval_f[2] = {(float)mval[0], (float)mval[1]}; float len_best = FLT_MAX; MPoly *me_eval_mpoly; @@ -1280,7 +1273,7 @@ bool ED_mesh_pick_face_vert( me_eval_mpoly_len = me_eval->totpoly; - const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); + const int *index_mp_to_orig = (const int *)CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); /* tag all verts using this face */ if (index_mp_to_orig) { @@ -1312,7 +1305,8 @@ bool ED_mesh_pick_face_vert( /* map 'dm -> me' r_index if possible */ if (v_idx_best != ORIGINDEX_NONE) { - const int *index_mv_to_orig = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); + const int *index_mv_to_orig = (const int *)CustomData_get_layer(&me_eval->vdata, + CD_ORIGINDEX); if (index_mv_to_orig) { v_idx_best = index_mv_to_orig[v_idx_best]; } @@ -1333,7 +1327,7 @@ bool ED_mesh_pick_face_vert( * * \return boolean true == Found */ -typedef struct VertPickData { +struct VertPickData { const MVert *mvert; const bool *vert_hide; const float *mval_f; /* [2] */ @@ -1342,19 +1336,18 @@ typedef struct VertPickData { /* runtime */ float len_best; int v_idx_best; -} VertPickData; +}; static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no[3])) { - VertPickData *data = userData; + VertPickData *data = static_cast<VertPickData *>(userData); if (data->vert_hide && data->vert_hide[index]) { return; } float sco[2]; - if (ED_view3d_project_float_object(data->region, co, sco, V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) { const float len = len_manhattan_v2v2(data->mval_f, sco); @@ -1368,7 +1361,7 @@ bool ED_mesh_pick_vert( bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf, uint *r_index) { ViewContext vc; - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); BLI_assert(me && GS(me->id.name) == ID_ME); @@ -1405,16 +1398,16 @@ bool ED_mesh_pick_vert( /* derived mesh to find deformed locations */ Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH); ARegion *region = vc.region; - RegionView3D *rv3d = region->regiondata; + RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata); /* find the vert closest to 'mval' */ const float mval_f[2] = {(float)mval[0], (float)mval[1]}; - VertPickData data = {NULL}; + VertPickData data = {nullptr}; ED_view3d_init_mats_rv3d(ob, rv3d); - if (me_eval == NULL) { + if (me_eval == nullptr) { return false; } @@ -1442,7 +1435,7 @@ bool ED_mesh_pick_vert( MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve) { if (ob->mode & OB_MODE_EDIT && ob->type == OB_MESH) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); if (!BLI_listbase_is_empty(&me->vertex_group_names)) { BMesh *bm = me->edit_mesh->bm; const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT); @@ -1454,27 +1447,27 @@ MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve) if (r_eve) { *r_eve = eve; } - return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); + return static_cast<MDeformVert *>(BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset)); } } } } if (r_eve) { - *r_eve = NULL; + *r_eve = nullptr; } - return NULL; + return nullptr; } MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index) { - Mesh *me = ob->data; + Mesh *me = static_cast<Mesh *>(ob->data); int index = BKE_mesh_mselect_active_get(me, ME_VSEL); if (r_index) { *r_index = index; } - if (index == -1 || me->dvert == NULL) { - return NULL; + if (index == -1 || me->dvert == nullptr) { + return nullptr; } return me->dvert + index; } @@ -1483,14 +1476,14 @@ MDeformVert *ED_mesh_active_dvert_get_only(Object *ob) { if (ob->type == OB_MESH) { if (ob->mode & OB_MODE_EDIT) { - return ED_mesh_active_dvert_get_em(ob, NULL); + return ED_mesh_active_dvert_get_em(ob, nullptr); } - return ED_mesh_active_dvert_get_ob(ob, NULL); + return ED_mesh_active_dvert_get_ob(ob, nullptr); } - return NULL; + return nullptr; } -void EDBM_mesh_stats_multi(struct Object **objects, +void EDBM_mesh_stats_multi(Object **objects, const uint objects_len, int totelem[3], int totelem_sel[3]) |