diff options
author | Ton Roosendaal <ton@blender.org> | 2012-12-11 18:45:38 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2012-12-11 18:45:38 +0400 |
commit | cb116b42f46fc11c60d1976c190eb1d9570da48a (patch) | |
tree | d15ada86984d7ea4125e751ea9ace638c3e17247 | |
parent | 8d4bd2cf3b08456dfdec39b9c88f744ce8f12c72 (diff) |
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)
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 15 |
1 files 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; } /** |