Manual merge of soc-2009-kazanbas branch:
[blender.git] / source / blender / editors / mesh / editmesh_mods.c
index 363b6ec..325a1ae 100644 (file)
@@ -39,7 +39,7 @@ editmesh_mods.c, UI level access, no geometry changes
 
 #include "MEM_guardedalloc.h"
 
-#include "MTC_matrixops.h"
+
 
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
@@ -127,7 +127,7 @@ void EM_automerge(int update)
 //             if (len) {
 //                     em->totvert -= len; /* saves doing a countall */
 //                     if (update) {
-//                             DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//                             DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
 //                     }
 //             }
 //     }
@@ -761,7 +761,7 @@ static int similar_face_select__internal(Scene *scene, EditMesh *em, int mode)
                                float angle;
                                for(efa= em->faces.first; efa; efa= efa->next) {
                                        if (!(efa->f & SELECT) && !efa->h) {
-                                               angle= VecAngle2(base_efa->n, efa->n);
+                                               angle= RAD2DEG(VecAngle2(base_efa->n, efa->n));
                                                if (angle/180.0<=thresh) {
                                                        EM_select_face(efa, 1);
                                                        selcount++;
@@ -776,7 +776,7 @@ static int similar_face_select__internal(Scene *scene, EditMesh *em, int mode)
                                base_dot= Inpf(base_efa->cent, base_efa->n);
                                for(efa= em->faces.first; efa; efa= efa->next) {
                                        if (!(efa->f & SELECT) && !efa->h) {
-                                               angle= VecAngle2(base_efa->n, efa->n);
+                                               angle= RAD2DEG(VecAngle2(base_efa->n, efa->n));
                                                if (angle/180.0<=thresh) {
                                                        dot=Inpf(efa->cent, base_efa->n);
                                                        if (fabs(base_dot-dot) <= thresh) {
@@ -807,7 +807,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
        if (selcount) {
                /* here was an edge-mode only select flush case, has to be generalized */
                EM_selectmode_flush(em);
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                BKE_mesh_end_editmesh(me, em);
                return OPERATOR_FINISHED;
        }
@@ -839,7 +839,7 @@ static EnumPropertyItem prop_simedge_types[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode)
+static int similar_edge_select__internal(ToolSettings *ts, EditMesh *em, int mode)
 {
        EditEdge *eed, *base_eed=NULL;
        unsigned int selcount=0; /* count how many new edges we select*/
@@ -849,7 +849,7 @@ static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode)
        unsigned int deselcount=0;
        
        short ok=0;
-       float thresh= scene->toolsettings->select_thresh;
+       float thresh= ts->select_thresh;
        
        for(eed= em->edges.first; eed; eed= eed->next) {
                if (!eed->h) {
@@ -916,7 +916,7 @@ static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode)
                                        else if (eed->f2==0) /* first access, assign the face */
                                                eed->tmp.f= efa;
                                        else if (eed->f2==1) /* second, we assign the angle*/
-                                               eed->tmp.fp= VecAngle2(eed->tmp.f->n, efa->n)/180;
+                                               eed->tmp.fp= RAD2DEG(VecAngle2(eed->tmp.f->n, efa->n))/180;
                                        eed->f2++; /* f2==0 no face assigned. f2==1 one face found. f2==2 angle calculated.*/
                                }
                                j++;
@@ -946,7 +946,7 @@ static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode)
                                for(eed= em->edges.first; eed; eed= eed->next) {
                                        if (!(eed->f & SELECT) && !eed->h) {
                                                VecSubf(dir, eed->v1->co, eed->v2->co);
-                                               angle= VecAngle2(base_dir, dir);
+                                               angle= RAD2DEG(VecAngle2(base_dir, dir));
                                                
                                                if (angle>90) /* use the smallest angle between the edges */
                                                        angle= fabs(angle-180.0f);
@@ -1039,17 +1039,17 @@ static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode)
 /* wrap the above function but do selection flushing edge to face */
 static int similar_edge_select_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
+       ToolSettings *ts= CTX_data_tool_settings(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
        EditMesh *em= BKE_mesh_get_editmesh(me); 
 
-       int selcount = similar_edge_select__internal(scene, em, RNA_int_get(op->ptr, "type"));
+       int selcount = similar_edge_select__internal(ts, em, RNA_int_get(op->ptr, "type"));
        
        if (selcount) {
                /* here was an edge-mode only select flush case, has to be generalized */
                EM_selectmode_flush(em);
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                BKE_mesh_end_editmesh(me, em);
                return OPERATOR_FINISHED;
        }
@@ -1081,7 +1081,7 @@ static EnumPropertyItem prop_simvertex_types[] = {
 
 static int similar_vert_select_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
+       ToolSettings *ts= CTX_data_tool_settings(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
        EditMesh *em= BKE_mesh_get_editmesh(me); 
@@ -1094,7 +1094,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
        int mode= RNA_enum_get(op->ptr, "type");
        
        short ok=0;
-       float thresh= scene->toolsettings->select_thresh;
+       float thresh= ts->select_thresh;
        
        for(eve= em->verts.first; eve; eve= eve->next) {
                if (!eve->h) {
@@ -1137,7 +1137,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                                float angle;
                                for(eve= em->verts.first; eve; eve= eve->next) {
                                        if (!(eve->f & SELECT) && !eve->h) {
-                                               angle= VecAngle2(base_eve->no, eve->no);
+                                               angle= RAD2DEG(VecAngle2(base_eve->no, eve->no));
                                                if (angle/180.0<=thresh) {
                                                        eve->f |= SELECT;
                                                        selcount++;
@@ -1207,7 +1207,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
        } /* end basevert loop */
 
        if(selcount) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                BKE_mesh_end_editmesh(me, em);
                return OPERATOR_FINISHED;
        }
@@ -1413,7 +1413,7 @@ void EM_mesh_copy_edge(EditMesh *em, short type)
        }
        
        if (change) {
-//             DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//             DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
                
        }
 }
@@ -1541,7 +1541,7 @@ void EM_mesh_copy_face(EditMesh *em, wmOperator *op, short type)
        }
        
        if (change) {
-//             DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//             DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
                
        }
 }
@@ -1671,7 +1671,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, wmOperator *op, short type)
        }
 
        if (change) {
-//             DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//             DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
                
        }
 }
@@ -1991,7 +1991,7 @@ static int loop_multiselect(bContext *C, wmOperator *op)
        MEM_freeN(edarray);
 //     if (EM_texFaceCheck())
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -2033,6 +2033,9 @@ static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring
        vc.mval[0]= mval[0];
        vc.mval[1]= mval[1];
        em= vc.em;
+
+       /* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */
+       view3d_validate_backbuf(&vc);
        
        eed= findnearestedge(&vc, &dist);
        if(eed) {
@@ -2060,7 +2063,7 @@ static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring
                EM_selectmode_flush(em);
 //                     if (EM_texFaceCheck())
                
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
        }
 }
 
@@ -2110,6 +2113,9 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2])
        vc.mval[1]= mval[1];
        em= vc.em;
        
+       /* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */
+       view3d_validate_backbuf(&vc);
+       
        eed= findnearestedge(&vc, &dist);
        if(eed) {
                Mesh *me= vc.obedit->data;
@@ -2159,9 +2165,8 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2])
                                break;
                }
                
-               DAG_object_flush_update(vc.scene, vc.obedit, OB_RECALC_DATA);
-       
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
+               DAG_id_flush_update(vc.obedit->data, OB_RECALC_DATA);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
        }
 }
 
@@ -2261,7 +2266,7 @@ void mouse_mesh(bContext *C, short mval[2], short extend)
                }
        }
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
        
 }
 
@@ -2405,12 +2410,12 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
        /* return warning! */
        if(limit) {
                int retval= select_linked_limited_invoke(&vc, 0, sel);
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                return retval;
        }
        
        if( unified_findnearest(&vc, &eve, &eed, &efa)==0 ) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
        
                return OPERATOR_CANCELLED;
        }
@@ -2464,7 +2469,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
        
 //     if (EM_texFaceCheck())
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
        return OPERATOR_FINISHED;       
 }
 
@@ -2545,7 +2550,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
        else
                selectconnected_mesh_all(em);
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -2671,7 +2676,7 @@ void EM_hide_mesh(EditMesh *em, int swap)
        em->totedgesel= em->totfacesel= em->totvertsel= 0;
 //     if(EM_texFaceCheck())
 
-       //      DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
+       //      DAG_id_flush_update(obedit->data, OB_RECALC_DATA);      
 }
 
 static int hide_mesh_exec(bContext *C, wmOperator *op)
@@ -2681,7 +2686,7 @@ static int hide_mesh_exec(bContext *C, wmOperator *op)
        
        EM_hide_mesh(em, RNA_boolean_get(op->ptr, "unselected"));
                
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -2738,7 +2743,7 @@ void EM_reveal_mesh(EditMesh *em)
        EM_selectmode_flush(em);
 
 //     if (EM_texFaceCheck())
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
+//     DAG_id_flush_update(obedit->data, OB_RECALC_DATA);      
 }
 
 static int reveal_mesh_exec(bContext *C, wmOperator *op)
@@ -2748,7 +2753,7 @@ static int reveal_mesh_exec(bContext *C, wmOperator *op)
        
        EM_reveal_mesh(em);
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -2798,7 +2803,7 @@ int select_by_number_vertices_exec(bContext *C, wmOperator *op)
                }
        }
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
        
        return OPERATOR_FINISHED;
 }
@@ -2924,7 +2929,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op)
 
 //     if (EM_texFaceCheck())
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); //TODO is this needed ?
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -3092,7 +3097,7 @@ static int select_linked_flat_faces_exec(bContext *C, wmOperator *op)
        
        select_linked_flat_faces(em, op, RNA_float_get(op->ptr, "sharpness"));
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -3193,7 +3198,7 @@ static int select_non_manifold_exec(bContext *C, wmOperator *op)
        
        select_non_manifold(em, op);
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -3257,7 +3262,7 @@ static int select_inverse_mesh_exec(bContext *C, wmOperator *op)
        
        EM_select_swap(em);
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -3300,7 +3305,7 @@ static int toggle_select_all_exec(bContext *C, wmOperator *op)
        
        EM_toggle_select_all(em);
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);     
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);      
        BKE_mesh_end_editmesh(obedit->data, em);
 
        return OPERATOR_FINISHED;
@@ -3371,7 +3376,7 @@ static int select_more(bContext *C, wmOperator *op)
 
 //     if (EM_texFaceCheck(em))
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -3461,7 +3466,7 @@ static int select_less(bContext *C, wmOperator *op)
        EM_select_less(em);
 
 //     if (EM_texFaceCheck(em))
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -3531,7 +3536,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op)
        
        selectrandom_mesh(em, RNA_float_get(op->ptr,"percent"));
                
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
        
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;       
@@ -3553,7 +3558,7 @@ void MESH_OT_select_random(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of vertices to select randomly.", 0.0001f, 1.0f);
+       RNA_def_float_percentage(ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", "Percentage of vertices to select randomly.", 0.0001f, 1.0f);
 }
 
 void EM_select_by_material(EditMesh *em, int index) 
@@ -3582,7 +3587,7 @@ void EM_deselect_by_material(EditMesh *em, int index)
        EM_selectmode_flush(em);
 }
 
-static void mesh_selection_type(Scene *scene, EditMesh *em, int val)
+static void mesh_selection_type(ToolSettings *ts, EditMesh *em, int val)
 {
        if(val>0) {
                if(val==1) { 
@@ -3603,7 +3608,7 @@ static void mesh_selection_type(Scene *scene, EditMesh *em, int val)
                
                /* note, em stores selectmode to be able to pass it on everywhere without scene,
                   this is only until all select modes and toolsettings are settled more */
-               scene->toolsettings->selectmode= em->selectmode;
+               ts->selectmode= em->selectmode;
 //             if (EM_texFaceCheck())
        }
 }
@@ -3617,13 +3622,13 @@ static EnumPropertyItem prop_mesh_edit_types[] = {
 
 static int mesh_selection_type_exec(bContext *C, wmOperator *op)
 {              
-       
+       ToolSettings *ts= CTX_data_tool_settings(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
 
-       mesh_selection_type(CTX_data_scene(C), em, RNA_enum_get(op->ptr,"type"));
+       mesh_selection_type(ts, em, RNA_enum_get(op->ptr,"type"));
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
        
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -3653,7 +3658,6 @@ void MESH_OT_selection_type(wmOperatorType *ot)
 
 static int editmesh_mark_seam(bContext *C, wmOperator *op)
 {
-       Scene *scene = CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        Mesh *me= ((Mesh *)obedit->data);
@@ -3686,8 +3690,8 @@ static int editmesh_mark_seam(bContext *C, wmOperator *op)
 
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
 }
@@ -3711,7 +3715,6 @@ void MESH_OT_mark_seam(wmOperatorType *ot)
 
 static int editmesh_mark_sharp(bContext *C, wmOperator *op)
 {
-       Scene *scene = CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        Mesh *me= ((Mesh *)obedit->data);
@@ -3739,8 +3742,8 @@ static int editmesh_mark_sharp(bContext *C, wmOperator *op)
 
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
 }
@@ -3970,7 +3973,7 @@ void righthandfaces(EditMesh *em, int select)     /* makes faces righthand turning *
 
        recalc_editnormals(em);
        
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//     DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
 
        waitcursor(0);
 }
@@ -3978,7 +3981,6 @@ void righthandfaces(EditMesh *em, int select)     /* makes faces righthand turning *
 
 static int righthandfaces_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene = CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        
@@ -3989,8 +3991,8 @@ static int righthandfaces_exec(bContext *C, wmOperator *op)
        
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); //TODO is this needed ?
 
        return OPERATOR_FINISHED;       
 }
@@ -4190,7 +4192,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o
 
 static int smooth_vertex(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
+       ToolSettings *ts= CTX_data_tool_settings(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        EditVert *eve, *eve_mir = NULL;
@@ -4278,7 +4280,7 @@ static int smooth_vertex(bContext *C, wmOperator *op)
                if(eve->f & SELECT) {
                        if(eve->f1) {
                                
-                               if (scene->toolsettings->editbutflag & B_MESH_X_MIRROR) {
+                               if (ts->editbutflag & B_MESH_X_MIRROR) {
                                        eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co);
                                }
                                
@@ -4320,8 +4322,8 @@ static int smooth_vertex(bContext *C, wmOperator *op)
 
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
 }
@@ -4354,7 +4356,7 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
-       RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Number of times to smooth the mesh", "", 1, INT_MAX);
+       RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Smooth Iterations", "", 1, INT_MAX);
 }
 
 void vertexnoise(Object *obedit, EditMesh *em)
@@ -4398,7 +4400,7 @@ void vertexnoise(Object *obedit, EditMesh *em)
        }
 
        recalc_editnormals(em);
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//     DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
 
 }
 
@@ -4455,23 +4457,23 @@ static void vertices_to_sphere(Scene *scene, View3D *v3d, Object *obedit, EditMe
        }
        
        recalc_editnormals(em);
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+//     DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
 
 }
 
 static int vertices_to_sphere_exec(bContext *C, wmOperator *op)
 {
+       Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        View3D *v3d = CTX_wm_view3d(C);
-       Scene *scene = CTX_data_scene(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        
        vertices_to_sphere(scene, v3d, obedit, em, RNA_float_get(op->ptr,"percent"));
                
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
        
        return OPERATOR_FINISHED;       
 }
@@ -4480,7 +4482,8 @@ void MESH_OT_vertices_transform_to_sphere(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Vertices to Sphere";
-       ot->description= "Move selected vertices outward in a spherical shape.";
+       //added "around cursor" to differentiate between "TFM_OT_tosphere()"
+       ot->description= "Move selected vertices outward in a spherical shape around cursor.";
        ot->idname= "MESH_OT_vertices_transform_to_sphere";
        
        /* api callbacks */
@@ -4516,7 +4519,6 @@ void flipface(EditMesh *em, EditFace *efa)
 
 static int flip_normals(bContext *C, wmOperator *op)
 {
-       Scene *scene = CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
        EditFace *efa;
@@ -4534,8 +4536,8 @@ static int flip_normals(bContext *C, wmOperator *op)
 
        BKE_mesh_end_editmesh(obedit->data, em);
 
-       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
 
        return OPERATOR_FINISHED;
 }