Fix T59686: snap to adaptive grid occurs with a "delay"
In blender 2.8, when you zoom in, the adaptive subdivisions appear earlier than previous versions. The grid still appears a little before the snap, but since it is very small I see no advantage in snap for this case.
This commit is contained in:
parent
e119868caa
commit
e6e2f65585
Notes:
blender-bot
2023-02-14 05:28:01 +01:00
Referenced by issue #59686, Snap Selection to Grid
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue