diff options
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 126 |
1 files changed, 30 insertions, 96 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 959cbd21b87..0ae3076170c 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -38,6 +38,11 @@ #include "DNA_scene_types.h" #include "DNA_view3d_types.h" +#include "BLI_math.h" +#include "BLI_editVert.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" @@ -48,10 +53,6 @@ #include "BKE_report.h" #include "BKE_tessmesh.h" -#include "BLI_math.h" -#include "BLI_editVert.h" -#include "BLI_edgehash.h" - #include "RNA_access.h" #include "RNA_define.h" @@ -170,7 +171,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la } } -int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set) +int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set) { BMEditMesh *em; int layernum; @@ -191,7 +192,6 @@ int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, cons CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum); if(active_set || layernum==0) CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum); - } else { layernum= CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); @@ -214,7 +214,7 @@ int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, cons mesh_update_customdata_pointers(me); } - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -238,7 +238,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) delete_customdata_layer(C, ob, cdlp); delete_customdata_layer(C, ob, cdlu); - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -287,7 +287,7 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha */ } - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -305,7 +305,7 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me) return 0; delete_customdata_layer(C, ob, cdl); - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -320,13 +320,12 @@ static int layers_poll(bContext *C) return (ob && !ob->id.lib && ob->type==OB_MESH && data && !data->lib); } -static int uv_texture_add_exec(bContext *C, wmOperator *op) +static int uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; - if(!ED_mesh_uv_texture_add(C, scene, ob, me, NULL, TRUE)) + if(!ED_mesh_uv_texture_add(C, me, NULL, TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -350,6 +349,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) { Scene *scene= CTX_data_scene(C); + View3D *v3d= CTX_wm_view3d(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); Image *ima= NULL; Mesh *me; @@ -368,8 +368,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima= BKE_add_image_file(path, - scene ? scene->r.cfra : 1); + ima= BKE_add_image_file(path); } else { RNA_string_get(op->ptr, "name", name); @@ -402,6 +401,10 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) me->edit_btmesh= NULL; } + /* dummie drop support; ensure view shows a result :) */ + if(v3d) + v3d->flag2 |= V3D_SOLID_TEX; + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -426,7 +429,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } -static int uv_texture_remove_exec(bContext *C, wmOperator *op) +static int uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; @@ -454,7 +457,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) /*********************** vertex color operators ************************/ -static int vertex_color_add_exec(bContext *C, wmOperator *op) +static int vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -481,7 +484,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int vertex_color_remove_exec(bContext *C, wmOperator *op) +static int vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; @@ -509,7 +512,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) /*********************** sticky operators ************************/ -static int sticky_add_exec(bContext *C, wmOperator *op) +static int sticky_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); @@ -521,7 +524,7 @@ static int sticky_add_exec(bContext *C, wmOperator *op) RE_make_sticky(scene, v3d); - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -542,7 +545,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int sticky_remove_exec(bContext *C, wmOperator *op) +static int sticky_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; @@ -553,7 +556,7 @@ static int sticky_remove_exec(bContext *C, wmOperator *op) CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); me->msticky= NULL; - DAG_id_flush_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -576,83 +579,14 @@ void MESH_OT_sticky_remove(wmOperatorType *ot) /************************** Add Geometry Layers *************************/ -static void mesh_calc_edges(Mesh *mesh, int update) -{ -#if 0 - CustomData edata; - EdgeHashIterator *ehi; - MFace *mf = mesh->mface; - MEdge *med, *med_orig; - EdgeHash *eh = BLI_edgehash_new(); - int i, *index, totedge, totface = mesh->totface; - - if(mesh->totedge==0) - update= 0; - - if(update) { - /* assume existing edges are valid - * useful when adding more faces and generating edges from them */ - med= mesh->medge; - for(i= 0; i<mesh->totedge; i++, med++) - BLI_edgehash_insert(eh, med->v1, med->v2, med); - } - - for (i = 0; i < totface; i++, mf++) { - if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) - BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL); - if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3)) - BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL); - - if (mf->v4) { - if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4)) - BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL); - if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1)) - BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL); - } else { - if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1)) - BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL); - } - } - - totedge = BLI_edgehash_size(eh); - - /* write new edges into a temporary CustomData */ - memset(&edata, 0, sizeof(edata)); - CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); - - ehi = BLI_edgehashIterator_new(eh); - med = CustomData_get_layer(&edata, CD_MEDGE); - for(i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { - - if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) { - *med= *med_orig; /* copy from the original */ - } else { - BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2); - med->flag = ME_EDGEDRAW|ME_EDGERENDER; - } - } - BLI_edgehashIterator_free(ehi); - - /* free old CustomData and assign new one */ - CustomData_free(&mesh->edata, mesh->totedge); - mesh->edata = edata; - mesh->totedge = totedge; - - mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE); - - BLI_edgehash_free(eh, NULL); -#endif -} - void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges) { if(calc_edges || (mesh->totface && mesh->totedge == 0)) - mesh_calc_edges(mesh, calc_edges); + BKE_mesh_calc_edges(mesh, calc_edges); mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL); - DAG_id_flush_update(&mesh->id, OB_RECALC_DATA); + DAG_id_tag_update(&mesh->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh); } @@ -779,8 +713,7 @@ void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count) if(mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode."); return; -} - + } mesh_add_faces(mesh, count); } @@ -808,3 +741,4 @@ void ED_mesh_calc_normals(Mesh *me) { mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } + |