batch remove .'s used with RNA_def_struct_ui_text
[blender.git] / source / blender / editors / space_view3d / view3d_snap.c
index fba8d13c6a5408b0850b896eeec0c69c7e2b3cc5..807e0790e7982bfdbb51d77c130e81a6eeb7dc43 100644 (file)
@@ -48,7 +48,7 @@
 #include "DNA_view3d_types.h"
 
 #include "BLI_blenlib.h"
-#include "BLI_arithb.h"
+#include "BLI_math.h"
 #include "BLI_editVert.h"
 #include "BLI_linklist.h"
 
@@ -106,7 +106,7 @@ static void special_transvert_update(Scene *scene, Object *obedit)
        
        if(obedit) {
                
-               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+               DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
                
                if(obedit->type==OB_MESH) {
                        Mesh *me= obedit->data;
@@ -135,8 +135,8 @@ static void special_transvert_update(Scene *scene, Object *obedit)
                                        if (tv) {
                                                float diffvec[3];
                                                
-                                               VecSubf(diffvec, tv->loc, tv->oldloc);
-                                               VecAddf(ebo->tail, ebo->tail, diffvec);
+                                               sub_v3_v3v3(diffvec, tv->loc, tv->oldloc);
+                                               add_v3_v3v3(ebo->tail, ebo->tail, diffvec);
                                                
                                                a++;
                                                if (a<tottrans) tv++;
@@ -254,7 +254,9 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
        else if (obedit->type==OB_ARMATURE){
                bArmature *arm= obedit->data;
                int totmalloc= BLI_countlist(arm->edbo);
-               
+
+        totmalloc *= 2;  /* probably overkill but bones can have 2 trans verts each */
+
                tv=transvmain= MEM_callocN(totmalloc*sizeof(TransVert), "maketransverts armature");
                
                for (ebo= arm->edbo->first; ebo; ebo=ebo->next){
@@ -302,7 +304,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
                int totmalloc= 0;
                
                for(nu= cu->editnurb->first; nu; nu= nu->next) {
-                       if((nu->type & 7)==CU_BEZIER)
+                       if(nu->type == CU_BEZIER)
                                totmalloc += 3*nu->pntsu;
                        else
                                totmalloc += nu->pntsu*nu->pntsv;
@@ -311,7 +313,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
 
                nu= cu->editnurb->first;
                while(nu) {
-                       if((nu->type & 7)==CU_BEZIER) {
+                       if(nu->type == CU_BEZIER) {
                                a= nu->pntsu;
                                bezt= nu->bezt;
                                while(a--) {
@@ -438,13 +440,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
        extern float originmat[3][3];   /* XXX object.c */
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene= CTX_data_scene(C);
-       View3D *v3d= CTX_wm_view3d(C);
+       RegionView3D *rv3d= CTX_wm_region_data(C);
        TransVert *tv;
-       Object *ob;
        float gridf, imat[3][3], bmat[3][3], vec[3];
        int a;
 
-       gridf= v3d->gridview;
+       gridf= rv3d->gridview;
 
        if(obedit) {
                tottrans= 0;
@@ -453,21 +454,21 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                        make_trans_verts(obedit, bmat[0], bmat[1], 0);
                if(tottrans==0) return OPERATOR_CANCELLED;
                
-               Mat3CpyMat4(bmat, obedit->obmat);
-               Mat3Inv(imat, bmat);
+               copy_m3_m4(bmat, obedit->obmat);
+               invert_m3_m3(imat, bmat);
                
                tv= transvmain;
                for(a=0; a<tottrans; a++, tv++) {
                        
                        VECCOPY(vec, tv->loc);
-                       Mat3MulVecfl(bmat, vec);
-                       VecAddf(vec, vec, obedit->obmat[3]);
-                       vec[0]= v3d->gridview*floor(.5+ vec[0]/gridf);
-                       vec[1]= v3d->gridview*floor(.5+ vec[1]/gridf);
-                       vec[2]= v3d->gridview*floor(.5+ vec[2]/gridf);
-                       VecSubf(vec, vec, obedit->obmat[3]);
+                       mul_m3_v3(bmat, vec);
+                       add_v3_v3v3(vec, vec, obedit->obmat[3]);
+                       vec[0]= gridf*floor(.5+ vec[0]/gridf);
+                       vec[1]= gridf*floor(.5+ vec[1]/gridf);
+                       vec[2]= gridf*floor(.5+ vec[2]/gridf);
+                       sub_v3_v3v3(vec, vec, obedit->obmat[3]);
                        
-                       Mat3MulVecfl(imat, vec);
+                       mul_m3_v3(imat, vec);
                        VECCOPY(tv->loc, vec);
                }
                
@@ -479,10 +480,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
        }
        else {
 
-               CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                       ob= base->object;
-                       
-                       if(ob->flag & OB_POSEMODE) {
+               CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+                       if(ob->mode & OB_MODE_POSE) {
                                bPoseChannel *pchan;
                                bArmature *arm= ob->data;
                                
@@ -514,20 +513,20 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                                
                                /* auto-keyframing */
 // XXX                         autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
-                               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                               DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
                        }
                        else {
                                ob->recalc |= OB_RECALC_OB;
                                
-                               vec[0]= -ob->obmat[3][0]+v3d->gridview*floor(.5+ ob->obmat[3][0]/gridf);
-                               vec[1]= -ob->obmat[3][1]+v3d->gridview*floor(.5+ ob->obmat[3][1]/gridf);
-                               vec[2]= -ob->obmat[3][2]+v3d->gridview*floor(.5+ ob->obmat[3][2]/gridf);
+                               vec[0]= -ob->obmat[3][0]+gridf*floor(.5+ ob->obmat[3][0]/gridf);
+                               vec[1]= -ob->obmat[3][1]+gridf*floor(.5+ ob->obmat[3][1]/gridf);
+                               vec[2]= -ob->obmat[3][2]+gridf*floor(.5+ ob->obmat[3][2]/gridf);
                                
                                if(ob->parent) {
                                        where_is_object(scene, ob);
                                        
-                                       Mat3Inv(imat, originmat);
-                                       Mat3MulVecfl(imat, vec);
+                                       invert_m3_m3(imat, originmat);
+                                       mul_m3_v3(imat, vec);
                                        ob->loc[0]+= vec[0];
                                        ob->loc[1]+= vec[1];
                                        ob->loc[2]+= vec[2];
@@ -544,7 +543,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                }
                CTX_DATA_END;
        }
-       ED_anim_dag_flush_update(C);
+
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -555,6 +555,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Grid";
+       ot->description= "Snap selected item(s) to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_selected_to_grid";
        
        /* api callbacks */
@@ -574,7 +575,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C);
        TransVert *tv;
-       Object *ob;
        float *curs, imat[3][3], bmat[3][3], vec[3];
        int a;
 
@@ -587,8 +587,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                        make_trans_verts(obedit, bmat[0], bmat[1], 0);
                if(tottrans==0) return OPERATOR_CANCELLED;
                
-               Mat3CpyMat4(bmat, obedit->obmat);
-               Mat3Inv(imat, bmat);
+               copy_m3_m4(bmat, obedit->obmat);
+               invert_m3_m3(imat, bmat);
                
                tv= transvmain;
                for(a=0; a<tottrans; a++, tv++) {
@@ -596,7 +596,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                        vec[1]= curs[1]-obedit->obmat[3][1];
                        vec[2]= curs[2]-obedit->obmat[3][2];
                        
-                       Mat3MulVecfl(imat, vec);
+                       mul_m3_v3(imat, vec);
                        VECCOPY(tv->loc, vec);
                }
                
@@ -607,16 +607,15 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                
        }
        else {
-               CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                       ob= base->object;
-                       if(ob->flag & OB_POSEMODE) {
+               CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+                       if(ob->mode & OB_MODE_POSE) {
                                bPoseChannel *pchan;
                                bArmature *arm= ob->data;
                                float cursp[3];
                                
-                               Mat4Invert(ob->imat, ob->obmat);
+                               invert_m4_m4(ob->imat, ob->obmat);
                                VECCOPY(cursp, curs);
-                               Mat4MulVecfl(ob->imat, cursp);
+                               mul_m4_v3(ob->imat, cursp);
                                
                                for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
                                        if(pchan->bone->flag & BONE_SELECTED) {
@@ -640,7 +639,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                                
                                /* auto-keyframing */
 // XXX                         autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
-                               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                               DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
                        }
                        else {
                                ob->recalc |= OB_RECALC_OB;
@@ -652,8 +651,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                                if(ob->parent) {
                                        where_is_object(scene, ob);
                                        
-                                       Mat3Inv(imat, originmat);
-                                       Mat3MulVecfl(imat, vec);
+                                       invert_m3_m3(imat, originmat);
+                                       mul_m3_v3(imat, vec);
                                        ob->loc[0]+= vec[0];
                                        ob->loc[1]+= vec[1];
                                        ob->loc[2]+= vec[2];
@@ -669,7 +668,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                }
                CTX_DATA_END;
        }
-       ED_anim_dag_flush_update(C);
+
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -680,6 +680,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Cursor";
+       ot->description= "Snap selected item(s) to cursor";
        ot->idname= "VIEW3D_OT_snap_selected_to_cursor";
        
        /* api callbacks */
@@ -695,17 +696,18 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
 static int snap_curs_to_grid(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
+       RegionView3D *rv3d= CTX_wm_region_data(C);
        View3D *v3d= CTX_wm_view3d(C);
        float gridf, *curs;
 
-       gridf= v3d->gridview;
+       gridf= rv3d->gridview;
        curs= give_cursor(scene, v3d);
 
-       curs[0]= v3d->gridview*floor(.5+curs[0]/gridf);
-       curs[1]= v3d->gridview*floor(.5+curs[1]/gridf);
-       curs[2]= v3d->gridview*floor(.5+curs[2]/gridf);
+       curs[0]= gridf*floor(.5+curs[0]/gridf);
+       curs[1]= gridf*floor(.5+curs[1]/gridf);
+       curs[2]= gridf*floor(.5+curs[2]/gridf);
        
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);        // hrm
        
        return OPERATOR_FINISHED;
 }
@@ -715,6 +717,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Grid";
+       ot->description= "Snap cursor to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_cursor_to_grid";
        
        /* api callbacks */
@@ -749,19 +752,19 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                        make_trans_verts(obedit, bmat[0], bmat[1], 2);
                if(tottrans==0) return OPERATOR_CANCELLED;
                
-               Mat3CpyMat4(bmat, obedit->obmat);
+               copy_m3_m4(bmat, obedit->obmat);
                
                tv= transvmain;
                for(a=0; a<tottrans; a++, tv++) {
                        VECCOPY(vec, tv->loc);
-                       Mat3MulVecfl(bmat, vec);
-                       VecAddf(vec, vec, obedit->obmat[3]);
-                       VecAddf(centroid, centroid, vec);
+                       mul_m3_v3(bmat, vec);
+                       add_v3_v3v3(vec, vec, obedit->obmat[3]);
+                       add_v3_v3v3(centroid, centroid, vec);
                        DO_MINMAX(vec, min, max);
                }
                
                if(v3d->around==V3D_CENTROID) {
-                       VecMulf(centroid, 1.0/(float)tottrans);
+                       mul_v3_fl(centroid, 1.0/(float)tottrans);
                        VECCOPY(curs, centroid);
                }
                else {
@@ -773,17 +776,17 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                transvmain= NULL;
        }
        else {
-               Object *ob= OBACT;
+               Object *ob= CTX_data_active_object(C);
                
-               if(ob && (ob->flag & OB_POSEMODE)) {
+               if(ob && (ob->mode & OB_MODE_POSE)) {
                        bArmature *arm= ob->data;
                        bPoseChannel *pchan;
                        for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
                                if(arm->layer & pchan->bone->layer) {
                                        if(pchan->bone->flag & BONE_SELECTED) {
                                                VECCOPY(vec, pchan->pose_head);
-                                               Mat4MulVecfl(ob->obmat, vec);
-                                               VecAddf(centroid, centroid, vec);
+                                               mul_m4_v3(ob->obmat, vec);
+                                               add_v3_v3v3(centroid, centroid, vec);
                                                DO_MINMAX(vec, min, max);
                                                count++;
                                        }
@@ -791,9 +794,9 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                        }
                }
                else {
-                       CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                               VECCOPY(vec, base->object->obmat[3]);
-                               VecAddf(centroid, centroid, vec);
+                       CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+                               VECCOPY(vec, ob->obmat[3]);
+                               add_v3_v3v3(centroid, centroid, vec);
                                DO_MINMAX(vec, min, max);
                                count++;
                        }
@@ -801,7 +804,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                }
                if(count) {
                        if(v3d->around==V3D_CENTROID) {
-                               VecMulf(centroid, 1.0/(float)count);
+                               mul_v3_fl(centroid, 1.0/(float)count);
                                VECCOPY(curs, centroid);
                        }
                        else {
@@ -811,7 +814,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                        }
                }
        }
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
        
        return OPERATOR_FINISHED;
 }
@@ -821,6 +824,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Selected";
+       ot->description= "Snap cursor to center of selected item(s)"; 
        ot->idname= "VIEW3D_OT_snap_cursor_to_selected";
        
        /* api callbacks */
@@ -836,6 +840,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
 static int snap_curs_to_active(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
+       Object *obact= CTX_data_active_object(C);
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C);
        float *curs;
@@ -852,16 +857,16 @@ static int snap_curs_to_active(bContext *C, wmOperator *op)
                                EM_editselection_center(curs, &ese);
                        }
                        
-                       Mat4MulVecfl(obedit->obmat, curs);
+                       mul_m4_v3(obedit->obmat, curs);
                }
        }
        else {
-               if (BASACT) {
-                       VECCOPY(curs, BASACT->object->obmat[3]);
+               if (obact) {
+                       VECCOPY(curs, obact->obmat[3]);
                }
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene);
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
        return OPERATOR_FINISHED;
 }
 
@@ -870,6 +875,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Active";
+       ot->description= "Snap cursor to active item";
        ot->idname= "VIEW3D_OT_snap_cursor_to_active";
        
        /* api callbacks */
@@ -889,7 +895,6 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C);
        TransVert *tv;
-       Object *ob;
        float snaploc[3], imat[3][3], bmat[3][3], vec[3], min[3], max[3], centroid[3];
        int count, a;
 
@@ -906,20 +911,20 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                        make_trans_verts(obedit, bmat[0], bmat[1], 0);
                if(tottrans==0) return OPERATOR_CANCELLED;
                
-               Mat3CpyMat4(bmat, obedit->obmat);
-               Mat3Inv(imat, bmat);
+               copy_m3_m4(bmat, obedit->obmat);
+               invert_m3_m3(imat, bmat);
                
                tv= transvmain;
                for(a=0; a<tottrans; a++, tv++) {
                        VECCOPY(vec, tv->loc);
-                       Mat3MulVecfl(bmat, vec);
-                       VecAddf(vec, vec, obedit->obmat[3]);
-                       VecAddf(centroid, centroid, vec);
+                       mul_m3_v3(bmat, vec);
+                       add_v3_v3v3(vec, vec, obedit->obmat[3]);
+                       add_v3_v3v3(centroid, centroid, vec);
                        DO_MINMAX(vec, min, max);
                }
                
                if(v3d->around==V3D_CENTROID) {
-                       VecMulf(centroid, 1.0/(float)tottrans);
+                       mul_v3_fl(centroid, 1.0/(float)tottrans);
                        VECCOPY(snaploc, centroid);
                }
                else {
@@ -933,9 +938,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
        }
        else {
                
-               CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                       ob= base->object;
-                       if(ob->flag & OB_POSEMODE) {
+               CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+                       if(ob->mode & OB_MODE_POSE) {
                                bPoseChannel *pchan;
                                bArmature *arm= ob->data;
                                
@@ -943,7 +947,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                                        if(pchan->bone->flag & BONE_SELECTED) {
                                                if(pchan->bone->layer & arm->layer) {
                                                        VECCOPY(vec, pchan->pose_mat[3]);
-                                                       VecAddf(centroid, centroid, vec);
+                                                       add_v3_v3v3(centroid, centroid, vec);
                                                        DO_MINMAX(vec, min, max);
                                                        count++;
                                                }
@@ -952,8 +956,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                        }
                        else {
                                /* not armature bones (i.e. objects) */
-                               VECCOPY(vec, base->object->obmat[3]);
-                               VecAddf(centroid, centroid, vec);
+                               VECCOPY(vec, ob->obmat[3]);
+                               add_v3_v3v3(centroid, centroid, vec);
                                DO_MINMAX(vec, min, max);
                                count++;
                        }
@@ -962,7 +966,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
 
                if(count) {
                        if(v3d->around==V3D_CENTROID) {
-                               VecMulf(centroid, 1.0/(float)count);
+                               mul_v3_fl(centroid, 1.0/(float)count);
                                VECCOPY(snaploc, centroid);
                        }
                        else {
@@ -981,8 +985,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                        make_trans_verts(obedit, bmat[0], bmat[1], 0);
                if(tottrans==0) return OPERATOR_CANCELLED;
                
-               Mat3CpyMat4(bmat, obedit->obmat);
-               Mat3Inv(imat, bmat);
+               copy_m3_m4(bmat, obedit->obmat);
+               invert_m3_m3(imat, bmat);
                
                tv= transvmain;
                for(a=0; a<tottrans; a++, tv++) {
@@ -990,7 +994,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                        vec[1]= snaploc[1]-obedit->obmat[3][1];
                        vec[2]= snaploc[2]-obedit->obmat[3][2];
                        
-                       Mat3MulVecfl(imat, vec);
+                       mul_m3_v3(imat, vec);
                        VECCOPY(tv->loc, vec);
                }
                
@@ -1002,9 +1006,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
        }
        else {
 
-               CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-                       ob= base->object;
-                       if(ob->flag & OB_POSEMODE) {
+               CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+                       if(ob->mode & OB_MODE_POSE) {
                                bPoseChannel *pchan;
                                bArmature *arm= ob->data;
                                
@@ -1028,7 +1031,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                                /* auto-keyframing */
                                ob->pose->flag |= POSE_DO_UNLOCK;
 // XXX                         autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
-                               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                               DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
                        }
                        else {
                                ob->recalc |= OB_RECALC_OB;
@@ -1040,8 +1043,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                                if(ob->parent) {
                                        where_is_object(scene, ob);
                                        
-                                       Mat3Inv(imat, originmat);
-                                       Mat3MulVecfl(imat, vec);
+                                       invert_m3_m3(imat, originmat);
+                                       mul_m3_v3(imat, vec);
                                        ob->loc[0]+= vec[0];
                                        ob->loc[1]+= vec[1];
                                        ob->loc[2]+= vec[2];
@@ -1058,7 +1061,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                CTX_DATA_END;
        }
        
-       ED_anim_dag_flush_update(C);
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -1069,6 +1072,7 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Center";
+       ot->description= "Snap selected items to selections geometric center";
        ot->idname= "VIEW3D_OT_snap_selected_to_center";
        
        /* api callbacks */
@@ -1080,6 +1084,43 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot)
 }
 
 
+/* **************************************************** */
+/*New Code - Snap Cursor to Center -*/
+static int snap_curs_to_center(bContext *C, wmOperator *op)
+{
+    Scene *scene= CTX_data_scene(C);
+    View3D *v3d= CTX_wm_view3d(C);
+    float *curs;
+    curs= give_cursor(scene, v3d);
+
+    curs[0]= 0.0;
+    curs[1]= 0.0;
+    curs[2]= 0.0;
+       
+    WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
+       
+    return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
+{
+       
+       /* identifiers */
+       ot->name= "Snap Cursor to Center";
+       ot->description= "Snap cursor to the Center";
+       ot->idname= "VIEW3D_OT_snap_cursor_to_center";
+       
+    /* api callbacks */ 
+    ot->exec= snap_curs_to_center;
+       ot->poll= ED_operator_view3d_active;
+       
+    /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* **************************************************** */
+
+
 int minmax_verts(Object *obedit, float *min, float *max)
 {
        TransVert *tv;
@@ -1092,14 +1133,14 @@ int minmax_verts(Object *obedit, float *min, float *max)
        
        if(tottrans==0) return 0;
 
-       Mat3CpyMat4(bmat, obedit->obmat);
+       copy_m3_m4(bmat, obedit->obmat);
        
        tv= transvmain;
        for(a=0; a<tottrans; a++, tv++) {               
                VECCOPY(vec, tv->loc);
-               Mat3MulVecfl(bmat, vec);
-               VecAddf(vec, vec, obedit->obmat[3]);
-               VecAddf(centroid, centroid, vec);
+               mul_m3_v3(bmat, vec);
+               add_v3_v3v3(vec, vec, obedit->obmat[3]);
+               add_v3_v3v3(centroid, centroid, vec);
                DO_MINMAX(vec, min, max);               
        }
        
@@ -1109,41 +1150,3 @@ int minmax_verts(Object *obedit, float *min, float *max)
        return 1;
 }
 
-/* ************************************************* */
-
-static int snap_menu_invoke(bContext *C, wmOperator *unused, wmEvent *event)
-{
-       uiPopupMenu *pup= uiPupMenuBegin(C, "Snap", 0);
-       uiLayout *layout= uiPupMenuLayout(pup);
-       
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_grid");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_cursor");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_center");
-       uiItemS(layout);
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_selected");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_grid");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_active");
-       
-       uiPupMenuEnd(C, pup);
-       
-       /* this operator is only for a menu, not used further */
-       return OPERATOR_CANCELLED;
-}
-
-/* only used as menu */
-void VIEW3D_OT_snap_menu(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name= "Snap Menu";
-       ot->idname= "VIEW3D_OT_snap_menu";
-       
-       /* api callbacks */
-       ot->invoke= snap_menu_invoke;
-       
-       ot->poll= ED_operator_view3d_active;
-       
-       /* flags */
-       ot->flag= 0;
-}
-
-