Page MenuHome

fix T65714: scale the dx and dy values for the continuous zoom modus
AbandonedPublic

Authored by Jean First (robbott) on Jun 14 2019, 9:05 PM.

Details

Summary

the dx and dy values for the continuous zoom modus are way to high for an apple trackpad.
After scaling them down the v2d->cur.xmin and v2d->cur.xmax values in UI_view2d_multi_grid_draw
are in a normal range and the zooming in the shader view works as expected.

Not sure what the implication for users with other input devices is.

Diff Detail

Repository
rB Blender
Branch
T65714 (branched from master)
Build Status
Buildable 3872
Build 3872: arc lint + arc unit

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Aug 14 2019, 12:22 PM

I think the issue is that vzd->timer_lastdraw is being used without it being initialized yet. If that's zero then you will get a very large time step.

I think this should just move vzd->timer_lastdraw = PIL_check_seconds_timer(); earlier in the invoke function, before apply is called.

This revision now requires changes to proceed.Aug 14 2019, 12:22 PM

using a mouse and "continuous zoom modus" enabled, the vzd->timer_lastdraw gets updated until the modal exits but with a trackpad it never enters the modal state and vzd->timer_lastdraw is not not set.

Moving vzd->timer_lastdraw = PIL_check_seconds_timer(); earier in the invoke or adding a timer does not help because for each movement on the trackpad the function gets immediately applied (view_zoomdrag_invoke -> view_zoomdrag_init -> view_zoomdrag_apply).

I thought of A) adding a fake vzd->timer_lastdraw = PIL_check_seconds_timer() - 10; to the corresponding if branch in view_zoomdrag_invoke to satisfy view_zoomdrag_apply or B) add a time_step = MIN2(time_step, 10); to the to this hunk in view_zoomdrag_apply.

/* continuous zoom shouldn't move that fast... */
 if (U.viewzoom == USER_ZOOM_CONT) {  // XXX store this setting as RNA prop?
   double time = PIL_check_seconds_timer();
   float time_step = (float)(time - vzd->timer_lastdraw);

   time_step = MIN2(time_step, 10);

   dx *= time_step * 0.5f;
   dy *= time_step * 0.5f;

   vzd->timer_lastdraw = time;
 }

Both feel hackish, maybe someone has a better idea.

view3d_edit.c, image_ops.c and clip_ops.c all have code for continuous zoom as well. If they don't suffer from the same issue, then you could copy the logic from those?

calculate the redraw in view_zoomdrag_invoke and at the same time allow the "zoom to mouse". This patch can be tested in the "shader editor" with the navigation zoom method set to "continuos zoom" (in the preferences) on a computer with a trackpad.

I applied the patch against current blender-v2.82-release, and pinch zooming with Continue zoom + Zoom to Mouse no longer crashes in i.e. node editor.

I am under the impression that this code can be deduplicated.
Part of the logic is seen in view_zoomdrag_apply

Brecht Van Lommel (brecht) requested changes to this revision.Feb 10 2020, 9:01 AM

Yes, this should not just copy code from view_zoomdrag_apply but probably modify it.

It's not clear why this extra logic would only be needed in view_zoomdrag_invoke and not view_zoomdrag_exec and view_zoomdrag_modal.

This revision now requires changes to proceed.Feb 10 2020, 9:01 AM

This patch breaks zooming in other editors such as Graph Editors,
which have the ability to independently scale by x/y.

For trackpad Dolly zoom should be used, as in all other editors. Fixed in D8520.