[Bf-blender-cvs] [cb8614e398d] master: Fix (unreported): Snap to grid not considering Focal Length.

mano-wii noreply at git.blender.org
Tue Feb 26 16:45:13 CET 2019


Commit: cb8614e398d395180a615e7e256a25cfe6f7c9eb
Author: mano-wii
Date:   Tue Feb 26 11:11:04 2019 -0300
Branches: master
https://developer.blender.org/rBcb8614e398d395180a615e7e256a25cfe6f7c9eb

Fix (unreported): Snap to grid not considering Focal Length.

===================================================================

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 bc9b0f107cc..2f9db19747f 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -790,12 +790,11 @@ float ED_view3d_grid_view_scale(
 			/* 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));
+			/* `3.0` was a value obtained by trial and error in order to get
+			 * a nice snap distance.*/
+			float grid_res = 3.0 * (rv3d->dist / v3d->lens);
+			float lvl = (logf(grid_res / grid_scale) / logf(grid_subdiv));
 
-			/* 1.3f is a visually chosen offset for the
-			 * subdivision to match the visible 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