diff options
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9fee8f38533..b6ded48d53f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -791,19 +791,18 @@ float ED_view3d_grid_view_scale( /* Decrease the distance between grid snap points depending on zoom. */ float grid_subdiv = v3d->gridsubdiv; if (grid_subdiv > 1) { + /* Allow 3 more subdivisions (see OBJECT_engine_init). */ + grid_scale /= powf(grid_subdiv, 3); + float grid_distance = rv3d->dist; float lvl = (logf(grid_distance / grid_scale) / logf(grid_subdiv)); - if (lvl < 0.0f) { - /* Negative values need an offset for correct casting. - * By convention, the minimum lvl is limited to -2 (see `objec_mode.c`) */ - if (lvl > -2.0f) { - lvl -= 1.0f; - } - else { - lvl = -2.0f; - } - } - grid_scale *= pow(grid_subdiv, (int)lvl - 1); + + /* 1.3f is a visually chosen offset for the + * subdivision to match the displayed grid. */ + lvl -= 1.3f; + CLAMP_MIN(lvl, 0.0f); + + grid_scale *= pow(grid_subdiv, (int)lvl); } } |