Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scroll-to-zoom a lot more responsive in 3D views #4668

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

emilk
Copy link
Member

@emilk emilk commented Jan 4, 2024

What

Switch from linear interpolation to exponential.

Now 90% of the scroll delta is applied within 0.1 seconds. This is long enough to feel smooth, but short enough to feel responsive.

This feels great on my Mac

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

self.unprocessed_scroll_delta += raw_scroll_delta;

let dt = response.ctx.input(|i| i.stable_dt).at_most(0.1);
let t = egui::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds
Copy link
Member Author

@emilk emilk Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really happy with the exponential_smooth_factor function ❤️

https://docs.rs/emath/latest/emath/fn.exponential_smooth_factor.html

@Wumpf Wumpf self-requested a review January 4, 2024 10:08
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried on Mac @ web with touchpad, mouse wheel stepped, mouse wheel smooth (logitech stuff) and all modes feel great with this fix! <3

@Wumpf Wumpf merged commit 634c31a into main Jan 4, 2024
43 of 44 checks passed
@Wumpf Wumpf deleted the emilk/responsive-mouse-scroll-in-3d branch January 4, 2024 10:14
@Wumpf
Copy link
Member

Wumpf commented Jan 4, 2024

@AnkeAnke gave it a spin (pun intended) on Linux @ Firefox and confirmed it behaving nicely

@jleibs
Copy link
Member

jleibs commented Jan 4, 2024

I still find the size of a scroll step to be unreasonably large on linux

This is one wheel click forward/backward:

2024-01-04.18-34-47.mp4

@Wumpf
Copy link
Member

Wumpf commented Jan 4, 2024

size of scroll step hasn't changed in this PR. I suppose we need to do something more clever scene dependent and maybe clamp large scroll steps on some mouse wheels? The annoying thing is that what we get from a mouse wheel is "number of text lines to scroll up or down"

@jleibs
Copy link
Member

jleibs commented Jan 4, 2024

size of scroll step hasn't changed in this PR

Yeah -- it hasn't gotten worse. I'm just saying any improvements from this PR are dwarfed by the fact that it's always been terrible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working include in changelog 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scroll wheel zoom has extreme overshoot (on macOS)
3 participants