From 88db722006be777bb787a535282e0f12b0188d2b Mon Sep 17 00:00:00 2001 From: Jonathan Bosson Date: Fri, 10 Mar 2017 16:18:15 -0700 Subject: [PATCH] ugly minHeightFromSurface check on focus node (only earth) --- modules/touch/include/TouchInteraction.h | 2 +- modules/touch/src/TouchInteraction.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/touch/include/TouchInteraction.h b/modules/touch/include/TouchInteraction.h index 80294a17b2..02c2a04c0c 100644 --- a/modules/touch/include/TouchInteraction.h +++ b/modules/touch/include/TouchInteraction.h @@ -100,7 +100,7 @@ class TouchInteraction glm::dvec3 _previousFocusNodePosition; - double _dt; + double _minHeightFromSurface; int _interactionMode; double _sensitivity; double _baseFriction; diff --git a/modules/touch/src/TouchInteraction.cpp b/modules/touch/src/TouchInteraction.cpp index 80e0ea4af2..2fb90a94fc 100644 --- a/modules/touch/src/TouchInteraction.cpp +++ b/modules/touch/src/TouchInteraction.cpp @@ -56,7 +56,7 @@ TouchInteraction::TouchInteraction() _sensitivity{ 0.5 }, _baseFriction{ 0.02 }, _vel{ 0.0, glm::dvec2(0.0), glm::dvec2(0.0), glm::dvec2(0.0), glm::dvec2(0.0) }, _friction{ _baseFriction, _baseFriction/2.0, _baseFriction, _baseFriction, _baseFriction }, - _previousFocusNodePosition{ glm::dvec3(0.0) }, _dt{ 0.0 } + _previousFocusNodePosition{ glm::dvec3(0.0) }, _minHeightFromSurface{ 6.6 * 1000000.0 } {} TouchInteraction::~TouchInteraction() { } @@ -85,7 +85,7 @@ void TouchInteraction::update(const std::vector& list, std::vector

positionVec3(), _camera->focusPositionVec3()); - _vel.zoom += zoomFactor * (_sensitivity*3.0); + _vel.zoom += zoomFactor / _sensitivity; break; } case PAN: { // add local rotation velocity @@ -187,7 +187,11 @@ void TouchInteraction::step(double dt) { globalCamRot = normalize(quat_cast(inverse(lookAtMat))); } { // Zooming - camPos += directionToCenter*_vel.zoom*dt; + dvec3 centerToCamera = camPos - centerPos; + if (length(_vel.zoom*dt) < length(centerToCamera) && length(centerToCamera) > _minHeightFromSurface) // should get boundingsphere from focusnode + camPos += directionToCenter*_vel.zoom*dt; + else + _vel.zoom = 0.0; } decelerate();