Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2018-12-21 21:56:55 +0300
committermano-wii <germano.costa@ig.com.br>2018-12-21 21:56:55 +0300
commite6e2f655857b43326d74577c50755409d7beaf53 (patch)
tree846d7bffcb302bb086a6f32a4c3f06bd91e3952d /source/blender/editors/space_view3d/view3d_draw.c
parente119868caaed07314df3a1372fbeec975e73c8b3 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c21
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);
}
}