From db9f20dc07e044661e0158f7f658de064d393bbe Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Wed, 21 Nov 2018 12:50:14 +0100 Subject: [PATCH] feat(wheelzoom): make it proportionnal to the distance --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b26dbbe..b031964 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -111,9 +111,10 @@ class GLWidget : public QGLWidget{ double wheel_position = event->delta(); if(std::abs(wheel_position) > 700){return;} + double distance_to_zero = sqrt(pow(trans_(0,3),2) + pow(trans_(1,3),2) + pow(trans_(2,3) - 10,2)); trans_tmp_ << 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, wheel_position*0.0008, + 0.0, 0.0, 1.0, wheel_position*0.0003*distance_to_zero, 0.0, 0.0, 0.0, 1.0; trans_ = trans_tmp_ * trans_; }