From cb116b42f46fc11c60d1976c190eb1d9570da48a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 11 Dec 2012 14:45:38 +0000 Subject: [PATCH] Bug fix, irc report: When camera is the pivot of 3d window, and you go to camera view, moving out of view with MMB drag causes zooming to stop working. Zooms depend on view3d "dist" value, which then became zero. This fix just makes dist "1.0" then, arbitrary but keeps things at least work. (Tried restoring to previous 'dist', but this fails in cases too) --- source/blender/editors/space_view3d/view3d_edit.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index dc3baf04a74..231a8d3dcf2 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3977,16 +3977,25 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m return (*depth == FLT_MAX) ? 0 : 1; } -float ED_view3d_offset_distance(float mat[4][4], float ofs[3]) { +float ED_view3d_offset_distance(float mat[4][4], float ofs[3]) +{ float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f}; - + float dist; + mul_m4_v4(mat, pos); add_v3_v3(pos, ofs); mul_m4_v4(mat, dir); normalize_v3(dir); - return dot_v3v3(pos, dir); + dist = dot_v3v3(pos, dir); + + /* problem - ofs[3] can be on same location as camera itself. + Blender needs proper dist value for zoom */ + if ( fabs(dist) <= FLT_EPSILON) { + return 1.0f; + } + return dist; } /**