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_clip/clip_ops.c | |
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_clip/clip_ops.c')
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 2b107b423e5..a625c124dd3 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1641,14 +1641,14 @@ static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv 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) / sc->zoom); - pan_vec[2] *= -ndof->dt; + mul_v3_fl(pan_vec, ndof->dt); + mul_v2_fl(pan_vec, pan_speed / sc->zoom); - sclip_zoom_set_factor(C, 1.0f + pan_vec[2], NULL, false); + sclip_zoom_set_factor(C, max_ff(0.0f, 1.0f - pan_vec[2]), NULL, false); sc->xof += pan_vec[0]; sc->yof += pan_vec[1]; |