diff options
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 6 |
3 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 7df626ad801..a6ebc81c178 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2124,11 +2124,12 @@ static bool gp_snap_poll(bContext *C) static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); + RegionView3D *rv3d = CTX_wm_region_data(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *obact = CTX_data_active_object(C); - const float gridf = ED_view3d_grid_scale(scene, v3d, NULL); + const float gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL); for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b6ded48d53f..a64ba5b2197 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -780,9 +780,9 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) return v3d->grid * ED_scene_grid_scale(scene, grid_unit); } -/* Simulates the grid scale that is visualized by the shaders drawing functions. - * The actual code is seen in `object_grid_frag.glsl` when you get the `grid_res` value. - * Currently the simulation is done only when RV3D_VIEW_IS_AXIS. */ +/* Simulates the grid scale that is actually viewed. + * The actual code is seen in `object_grid_frag.glsl` (see `grid_res`). + * Currently the simulation is only done when RV3D_VIEW_IS_AXIS. */ float ED_view3d_grid_view_scale( Scene *scene, View3D *v3d, RegionView3D *rv3d, const char **grid_unit) { @@ -798,7 +798,7 @@ float ED_view3d_grid_view_scale( float lvl = (logf(grid_distance / grid_scale) / logf(grid_subdiv)); /* 1.3f is a visually chosen offset for the - * subdivision to match the displayed grid. */ + * subdivision to match the visible grid. */ lvl -= 1.3f; CLAMP_MIN(lvl, 0.0f); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index dbf2271e114..9729598b022 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -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); |