diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 100 |
1 files changed, 69 insertions, 31 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index abd42f60e23..89e7fcbc775 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -487,7 +487,7 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data)); char msg[100]; int cnt = removedoublesflag(em,1,0,scene->toolsettings->doublimit); @@ -500,6 +500,7 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -700,7 +701,7 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op) static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); extrude_mesh(obedit,em, op); @@ -709,6 +710,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -716,12 +718,13 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) static int mesh_extrude_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh(obedit->data); extrude_mesh(obedit,em, op); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -747,7 +750,7 @@ void MESH_OT_extrude(wmOperatorType *ot) static int split_mesh(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); WM_cursor_wait(1); @@ -762,6 +765,7 @@ static int split_mesh(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -783,8 +787,8 @@ void MESH_OT_split(wmOperatorType *ot) static int extrude_repeat_mesh(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; - + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); + RegionView3D *rv3d = CTX_wm_region_view3d(C); int steps = RNA_int_get(op->ptr,"steps"); @@ -820,6 +824,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -848,7 +853,7 @@ static int spin_mesh(bContext *C, float *dvec, int steps, float degr, int dupli Object *obedit= CTX_data_edit_object(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); RegionView3D *rv3d= CTX_wm_region_view3d(C); EditVert *eve,*nextve; float nor[3]= {0.0f, 0.0f, 0.0f}; @@ -931,6 +936,7 @@ static int spin_mesh(bContext *C, float *dvec, int steps, float degr, int dupli DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); } + EM_EndEditMesh(obedit->data, em); return ok; } @@ -971,7 +977,7 @@ void MESH_OT_spin(wmOperatorType *ot) static int screw_mesh_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditVert *eve,*v1=0,*v2=0; EditEdge *eed; float dvec[3], nor[3]; @@ -1007,6 +1013,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) } if(v1==NULL || v2==NULL) { BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -1025,13 +1032,16 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) if(spin_mesh(C, dvec, turns*steps, 360.0f*turns, 0)) { WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } else { BKE_report(op->reports, RPT_ERROR, "No valid vertices are selected"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } + + EM_EndEditMesh(obedit->data, em); } void MESH_OT_screw(wmOperatorType *ot) @@ -1252,12 +1262,13 @@ static EnumPropertyItem prop_mesh_delete_types[] = { static int delete_mesh_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); delete_mesh(obedit,em, op,RNA_enum_get(op->ptr, "type")); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -3626,7 +3637,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed,int dir) static int edge_rotate_selected(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); int dir = RNA_int_get(op->ptr,"dir"); // dir == 2 when clockwise and ==1 for counter CW. EditEdge *eed; @@ -3665,6 +3676,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) else { BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } } @@ -3680,6 +3692,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) else { BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -3691,7 +3704,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -4746,7 +4759,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= ar->regiondata; Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditVert *eve, *nextve; EditEdge *eed, *seed= NULL; EditFace *efa, *sefa= NULL; @@ -4790,10 +4803,12 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) if(efa) { BKE_report(op->reports, RPT_ERROR, "Can't perform ripping with faces selected this way"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } if(sefa==NULL) { BKE_report(op->reports, RPT_ERROR, "No proper selection or faces included"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -4858,6 +4873,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) if(seed==NULL) { // never happens? BKE_report(op->reports, RPT_ERROR, "No proper edge found to start"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -4947,6 +4963,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) // scene->prop_mode = propmode; // XXX scene->proportional = prop; + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -5885,7 +5902,7 @@ void pathselect(EditMesh *em, wmOperator *op) static int region_to_loop(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditEdge *eed; EditFace *efa; @@ -5918,6 +5935,7 @@ static int region_to_loop(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6062,7 +6080,7 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){ static int loop_to_region(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditFace *efa; @@ -6094,7 +6112,7 @@ static int loop_to_region(bContext *C, wmOperator *op) // if (EM_texFaceCheck()) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6119,7 +6137,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot) static int mesh_rotate_uvs(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditFace *efa; short change = 0, ccw; @@ -6129,6 +6147,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op) if (!EM_texFaceCheck(em)) { BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -6185,13 +6204,14 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); } + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } static int mesh_mirror_uvs(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditFace *efa; short change = 0, altaxis; @@ -6201,6 +6221,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op) if (!EM_texFaceCheck(em)) { BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -6271,13 +6292,15 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op) // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); } + + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } static int mesh_rotate_colors(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditFace *efa; short change = 0, ccw; @@ -6286,6 +6309,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op) if (!EM_vertColorCheck(em)) { BKE_report(op->reports, RPT_ERROR, "mesh has no color layers"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -6325,6 +6349,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); } + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6332,7 +6357,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op) static int mesh_mirror_colors(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); EditFace *efa; short change = 0, altaxis; @@ -6341,6 +6366,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op) if (!EM_vertColorCheck(em)) { BKE_report(op->reports, RPT_ERROR, "Mesh has no color layers"); + EM_EndEditMesh(obedit->data, em); return OPERATOR_CANCELLED; } @@ -6379,6 +6405,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); } + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6442,12 +6469,13 @@ static int subdivide_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, 1, 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6469,12 +6497,13 @@ static int subdivide_multi_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, RNA_int_get(op->ptr,"number_cuts"), 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6499,12 +6528,13 @@ static int subdivide_multi_fractal_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); esubdivideflag(obedit, em, 1, -(RNA_float_get(op->ptr, "random_factor")/100), scene->toolsettings->editbutflag, RNA_int_get(op->ptr, "number_cuts"), 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6530,12 +6560,13 @@ static int subdivide_smooth_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); esubdivideflag(obedit, em, 1, 0.292f*RNA_float_get(op->ptr, "smoothness"), scene->toolsettings->editbutflag | B_SMOOTH, 1, 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6870,13 +6901,14 @@ static void fill_mesh(EditMesh *em) static int fill_mesh_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); fill_mesh(em); DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6898,12 +6930,13 @@ void MESH_OT_fill(wmOperatorType *ot) static int beauty_fill_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); beauty_fill(em); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6924,12 +6957,13 @@ void MESH_OT_beauty_fill(wmOperatorType *ot) static int convert_quads_to_tris_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); convert_to_triface(em,0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6950,12 +6984,13 @@ void MESH_OT_convert_quads_to_tris(wmOperatorType *ot) static int convert_tris_to_quads_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); join_triangles(em); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -6976,12 +7011,13 @@ void MESH_OT_convert_tris_to_quads(wmOperatorType *ot) static int edge_flip_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); edge_flip(em); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -7002,12 +7038,13 @@ void MESH_OT_edge_flip(wmOperatorType *ot) static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); mesh_set_smooth_faces(em,1); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } @@ -7028,12 +7065,13 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot) static int mesh_faces_shade_solid_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data); mesh_set_smooth_faces(em,0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + EM_EndEditMesh(obedit->data, em); return OPERATOR_FINISHED; } |