diff options
author | Campbell Barton <campbell@blender.org> | 2022-10-14 08:32:29 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-10-14 08:32:59 +0300 |
commit | e4e80058c8d8a8c00bcb767b8be3689918c9201f (patch) | |
tree | dc25c24e015760feb00080454b5bdc1fd17833c8 /source/blender/editors/space_image | |
parent | 1fbd300adb9a1b371abe9b5b7f24fa6de1fbe6f4 (diff) |
Cleanup: simplify calculation of NDOF pan/zoom in 2D views
Make the logic for converting NDOF Z-motion to a scale value more
straightforward. Flipping the Z axis was scaling by negative-time,
now the entire pan vector is scaled by time and the zoom value is
calculated as `scale = 1 - (z * time)` instead of `1 + (z * -time)`.
Although they're equivalent, confusion here caused T100953.
Also clamp the scale (while unlikely, negative scale wasn't prevented).
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bb47ad5c6c0..3503c4c8168 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -762,14 +762,14 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmE float pan_vec[3]; const wmNDOFMotionData *ndof = event->customdata; - const float speed = NDOF_PIXELS_PER_SECOND; + const float pan_speed = NDOF_PIXELS_PER_SECOND; WM_event_ndof_pan_get(ndof, pan_vec, true); - mul_v2_fl(pan_vec, (speed * ndof->dt) / sima->zoom); - pan_vec[2] *= -ndof->dt; + mul_v3_fl(pan_vec, ndof->dt); + mul_v2_fl(pan_vec, pan_speed / sima->zoom); - sima_zoom_set_factor(sima, region, 1.0f + pan_vec[2], NULL, false); + sima_zoom_set_factor(sima, region, max_ff(0.0f, 1.0f - pan_vec[2]), NULL, false); sima->xof += pan_vec[0]; sima->yof += pan_vec[1]; |