diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-08-03 18:19:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-08-03 18:19:22 +0300 |
commit | 27aef8b551bd30817bac13cfe77d5a142ac0d037 (patch) | |
tree | 4aca25ed7edf7eafba6fc1ca8fe384e80f56da9f | |
parent | 7f8d620e20c2369838c9bc528fde0b785b345afc (diff) |
3D View: aspect correct trackball rotation
Hard coded aspect was used, doubling horizontal input
however this caused sliding for views which didn't match this aspect.
Calculate the aspect based on the view bounds instead.
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index af862345824..0d0cfce07d7 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -189,10 +189,15 @@ static void calctrackballvec(const rcti *rect, const int event_xy[2], float r_di { const float radius = TRACKBALLSIZE; const float t = radius / (float)M_SQRT2; + const float size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}; + /* Aspect correct so dragging in a non-square view doesn't squash the, + * so diagonal motion rotates diagonally too. */ + const float size_min = min_ff(size[0], size[1]); + const float aspect[2] = {size_min / size[0], size_min / size[1]}; /* Normalize x and y. */ - r_dir[0] = (event_xy[0] - BLI_rcti_cent_x(rect)) / ((float)BLI_rcti_size_x(rect) / 4.0); - r_dir[1] = (event_xy[1] - BLI_rcti_cent_x(rect)) / ((float)BLI_rcti_size_y(rect) / 2.0); + r_dir[0] = (event_xy[0] - BLI_rcti_cent_x(rect)) / ((size[0] * aspect[0]) / 2.0); + r_dir[1] = (event_xy[1] - BLI_rcti_cent_x(rect)) / ((size[1] * aspect[1]) / 2.0); const float d = len_v2(r_dir); if (d < t) { /* Inside sphere. */ |