Page MenuHome

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

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



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

rB Blender
D5076 (branched from master)
Build Status
Buildable 4808
Build 4808: 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.