Fix T60015: snap to grid - snaps only to largest increment
[blender.git] / source / blender / editors / space_view3d / view3d_snap.c
index dbf2271e114d11dfe56fe711ad00b7f143a65eee..9729598b0226d4417c7f74add3893539d193d0b4 100644 (file)
@@ -79,13 +79,14 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
        ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
        Object *obedit = CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
+       RegionView3D *rv3d = CTX_wm_region_data(C);
        View3D *v3d = CTX_wm_view3d(C);
        TransVertStore tvs = {NULL};
        TransVert *tv;
        float gridf, imat[3][3], bmat[3][3], vec[3];
        int a;
 
-       gridf = ED_view3d_grid_scale(scene, v3d, NULL);
+       gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
 
        if (obedit) {
                ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -516,10 +517,11 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot)
 static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
+       RegionView3D *rv3d = CTX_wm_region_data(C);
        View3D *v3d = CTX_wm_view3d(C);
        float gridf, *curs;
 
-       gridf = ED_view3d_grid_scale(scene, v3d, NULL);
+       gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
        curs = scene->cursor.location;
 
        curs[0] = gridf * floorf(0.5f + curs[0] / gridf);