[Bf-blender-cvs] [e6e2f655857] master: Fix T59686: snap to adaptive grid occurs with a "delay"
mano-wii
noreply at git.blender.org
Fri Dec 21 20:58:17 CET 2018
Commit: e6e2f655857b43326d74577c50755409d7beaf53
Author: mano-wii
Date: Fri Dec 21 16:56:55 2018 -0200
Branches: master
https://developer.blender.org/rBe6e2f655857b43326d74577c50755409d7beaf53
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.
===================================================================
M source/blender/editors/space_view3d/view3d_draw.c
===================================================================
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);
}
}
More information about the Bf-blender-cvs
mailing list