batch remove .'s used with RNA_def_struct_ui_text
[blender.git] / source / blender / editors / space_view3d / view3d_snap.c
index 3147abd499b7328bec256f54ec6ef54beb6271f8..807e0790e7982bfdbb51d77c130e81a6eeb7dc43 100644 (file)
@@ -440,12 +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;
        float gridf, imat[3][3], bmat[3][3], vec[3];
        int a;
 
-       gridf= v3d->gridview;
+       gridf= rv3d->gridview;
 
        if(obedit) {
                tottrans= 0;
@@ -463,9 +463,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                        VECCOPY(vec, tv->loc);
                        mul_m3_v3(bmat, vec);
                        add_v3_v3v3(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);
+                       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]);
                        
                        mul_m3_v3(imat, vec);
@@ -518,9 +518,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                        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);
@@ -555,7 +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->description= "Snap selected item(s) to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_selected_to_grid";
        
        /* api callbacks */
@@ -680,7 +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->description= "Snap selected item(s) to cursor";
        ot->idname= "VIEW3D_OT_snap_selected_to_cursor";
        
        /* api callbacks */
@@ -696,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;
 }
@@ -716,7 +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->description= "Snap cursor to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_cursor_to_grid";
        
        /* api callbacks */
@@ -813,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;
 }
@@ -823,7 +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->description= "Snap cursor to center of selected item(s)"; 
        ot->idname= "VIEW3D_OT_snap_cursor_to_selected";
        
        /* api callbacks */
@@ -865,7 +866,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *op)
                }
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene);
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
        return OPERATOR_FINISHED;
 }
 
@@ -874,7 +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->description= "Snap cursor to active item";
        ot->idname= "VIEW3D_OT_snap_cursor_to_active";
        
        /* api callbacks */
@@ -1071,7 +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->description= "Snap selected items to selections geometric center";
        ot->idname= "VIEW3D_OT_snap_selected_to_center";
        
        /* api callbacks */
@@ -1083,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;