shift-middledrag (camera distance modification) should be expomential #282

chrysn opened this Issue Feb 20, 2013 · 3 comments


None yet

2 participants


when moving the camera to or away from the screen center, the absolute camera movement is linear to the mouse distance. this is

  • counter-intuitive, as the perceived mouse-to-world-coordinate ratio is changing during the operation
  • imprecise when viewing objects from very close
  • impractical with large objects (try with distances > 6000)

on my screen, dragging from top to bottom moves the camera by 450 world units; i'd prefer it to roughly double with one screen drag independently of the distance.

(this might or might not be an issue with mouse wheel zooming too -- for lack of one, i can't try.)

observed on openscad 2013.01.


the issue can be solved as easily as applying this:

diff --git a/src/ b/src/
index b23ba8e..1e5628f 100644
--- a/src/
+++ b/src/
@@ -221,7 +221,7 @@ void QGLView::mouseMoveEvent(QMouseEvent *event)
       // Middle button pans in the xy plane
       // Shift-right and Shift-middle zooms
       if ((QApplication::keyboardModifiers() & Qt::ShiftModifier) != 0) {
-        cam.viewer_distance += (GLdouble)dy;
+        cam.viewer_distance *= (GLdouble)(1.0 + (double)dy / ((QApplication::keyboardModifiers() & Qt::AltModifier) ? 2000.0 : 100.0));
       } else {

       double mx = +(dx) * cam.viewer_distance/1000;

please apply as you consider it suitable; the choice of 2000.0 for coarse motion and 100.0 for fine motion works well on my system, and even if it's not a perfect fit for every resolution, it's much better than the old behavior. the "press alt for slower motion" was just a spontaenous idea; if you don't see a need for it or it doesn't fit in the user interface paradigm, replace the conditional expression with 2000.0

openscad member

The "real" solution is to not use our own navigation code but rely on a library, but this looks like a decent enough hack - I'll look at it :)

openscad member

This was improved recently

@kintel kintel closed this Jan 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment