diff options
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 77 |
1 files changed, 26 insertions, 51 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 772bb1bd308..49755c75480 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -42,7 +42,6 @@ #include "BLI_math.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_mesh.h" @@ -50,6 +49,8 @@ #include "BKE_report.h" #include "BKE_editmesh.h" +#include "DEG_depsgraph.h" + #include "RNA_define.h" #include "WM_api.h" @@ -245,14 +246,14 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) } } - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); } void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) { /* could be ldata or pdata */ - CustomData *pdata = GET_CD_DATA(me, pdata); - const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY); + CustomData *ldata = GET_CD_DATA(me, ldata); + const int layernum = CustomData_get_active_layer_index(ldata, CD_MLOOPUV); ED_mesh_uv_loop_reset_ex(me, layernum); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -269,21 +270,10 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) if (me->edit_btmesh) { em = me->edit_btmesh; - layernum_dst = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY); + layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) return -1; - /* CD_MTEXPOLY */ - BM_data_layer_add_named(em->bm, &em->bm->pdata, CD_MTEXPOLY, name); - /* copy data from active UV */ - if (layernum_dst) { - const int layernum_src = CustomData_get_active_layer(&em->bm->pdata, CD_MTEXPOLY); - BM_data_layer_copy(em->bm, &em->bm->pdata, CD_MTEXPOLY, layernum_src, layernum_dst); - } - if (active_set || layernum_dst == 0) { - CustomData_set_layer_active(&em->bm->pdata, CD_MTEXPOLY, layernum_dst); - } - /* CD_MLOOPUV */ BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name); /* copy data from active UV */ @@ -298,26 +288,22 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) } } else { - layernum_dst = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); + layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) return -1; - if (me->mtpoly) { - CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name); + if (me->mloopuv) { CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name); is_init = true; } else { - CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name); CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name); } if (active_set || layernum_dst == 0) { - CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum_dst); CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst); - CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum_dst); } @@ -329,7 +315,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) ED_mesh_uv_loop_reset_ex(me, layernum_dst); } - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, me); return layernum_dst; @@ -343,12 +329,12 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name) if (me->edit_btmesh) { em = me->edit_btmesh; - layernum_dst = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY); + layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV); if (layernum_dst == 0) ED_mesh_uv_texture_add(me, name, true); } else { - layernum_dst = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); + layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); if (layernum_dst == 0) ED_mesh_uv_texture_add(me, name, true); } @@ -357,23 +343,19 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name) bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n) { - CustomData *pdata = GET_CD_DATA(me, pdata), *ldata = GET_CD_DATA(me, ldata); - CustomDataLayer *cdlp, *cdlu; + CustomData *ldata = GET_CD_DATA(me, ldata); + CustomDataLayer *cdlu; int index; - index = CustomData_get_layer_index_n(pdata, CD_MTEXPOLY, n); - cdlp = (index == -1) ? NULL : &pdata->layers[index]; - index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n); cdlu = (index == -1) ? NULL : &ldata->layers[index]; - if (!cdlp || !cdlu) + if (!cdlu) return false; - delete_customdata_layer(me, cdlp); delete_customdata_layer(me, cdlu); - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, me); return true; @@ -381,14 +363,8 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n) bool ED_mesh_uv_texture_remove_active(Mesh *me) { /* texpoly/uv are assumed to be in sync */ - CustomData *pdata = GET_CD_DATA(me, pdata); - const int n = CustomData_get_active_layer(pdata, CD_MTEXPOLY); - - /* double check active layers align! */ -#ifdef DEBUG CustomData *ldata = GET_CD_DATA(me, ldata); - BLI_assert(CustomData_get_active_layer(ldata, CD_MLOOPUV) == n); -#endif + const int n = CustomData_get_active_layer(ldata, CD_MLOOPUV); if (n != -1) { return ED_mesh_uv_texture_remove_index(me, n); @@ -400,8 +376,8 @@ bool ED_mesh_uv_texture_remove_active(Mesh *me) bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name) { /* texpoly/uv are assumed to be in sync */ - CustomData *pdata = GET_CD_DATA(me, pdata); - const int n = CustomData_get_named_layer(pdata, CD_MTEXPOLY, name); + CustomData *ldata = GET_CD_DATA(me, ldata); + const int n = CustomData_get_named_layer(ldata, CD_MLOOPUV, name); if (n != -1) { return ED_mesh_uv_texture_remove_index(me, n); } @@ -458,7 +434,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set) BKE_mesh_update_customdata_pointers(me, true); } - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, me); return layernum; @@ -477,7 +453,7 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n) return false; delete_customdata_layer(me, cdl); - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, me); return true; @@ -551,7 +527,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Base *base; + BaseLegacy *base; Image *ima = NULL; Mesh *me; Object *obedit; @@ -598,7 +574,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e /* load_editMesh free's pointers used by CustomData layers which might be used by DerivedMesh too, * so signal to re-create DerivedMesh here (sergey) */ - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); } /* dummie drop support; ensure view shows a result :) */ @@ -737,7 +713,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, CustomData_free_layers(data, type, tot); } - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); return OPERATOR_FINISHED; @@ -833,7 +809,7 @@ static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_ensure_skin_customdata(me); - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); return OPERATOR_FINISHED; @@ -895,7 +871,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, NULL, me->totloop); } - DAG_id_tag_update(&me->id, 0); + DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); return OPERATOR_FINISHED; @@ -972,7 +948,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) BKE_mesh_calc_normals(mesh); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh); } @@ -1292,7 +1268,6 @@ void ED_mesh_calc_tessface(Mesh *mesh, bool free_mpoly) mesh->mloopcol = NULL; mesh->mloopuv = NULL; mesh->mpoly = NULL; - mesh->mtpoly = NULL; } } |