diff --git a/src/core/StelMovementMgr.cpp b/src/core/StelMovementMgr.cpp index 4acc4467503b5..be2d96b8f0f38 100644 --- a/src/core/StelMovementMgr.cpp +++ b/src/core/StelMovementMgr.cpp @@ -1541,10 +1541,35 @@ void StelMovementMgr::updateAutoZoom(double deltaTime) { if (flagAutoZoom) { +#ifdef Q_OS_ANDROID + // Use a smooth function + double c; + + if( zoomMove.startFov > zoomMove.aimFov ) + { + // slow down as we approach final view + c = 1.0 - static_cast((1.0f-zoomMove.coef)*(1.0f-zoomMove.coef)*(1.0f-zoomMove.coef)); + } + else + { + // speed up as we leave zoom target + c = static_cast(zoomMove.coef * zoomMove.coef * zoomMove.coef); + } + + double newFov=zoomMove.startFov + (zoomMove.aimFov - zoomMove.startFov) * c; + + zoomMove.coef+=zoomMove.speed*static_cast(deltaTime)*1000; + if (zoomMove.coef>=1.f) + { + flagAutoZoom = 0; + newFov=zoomMove.aimFov; + } +#else zoomMove.update(deltaTime); double newFov = zoomMove.getValue(); if (zoomMove.finished()) flagAutoZoom = 0; +#endif setFov(newFov); // updates currentFov->don't use newFov later! // In case we have offset center, we want object still visible in center. @@ -1605,8 +1630,15 @@ void StelMovementMgr::updateAutoZoom(double deltaTime) void StelMovementMgr::zoomTo(double aim_fov, float zoomDuration) { zoomDuration /= movementsSpeedFactor; +#ifdef Q_OS_ANDROID + zoomMove.aimFov=aim_fov; + zoomMove.startFov=currentFov; + zoomMove.speed=1.f/(zoomDuration*1000); + zoomMove.coef=0.; +#else zoomMove.setTarget(currentFov, aim_fov, zoomDuration); - flagAutoZoom = true; +#endif + flagAutoZoom = true; } void StelMovementMgr::changeFov(double deltaFov) @@ -1618,7 +1650,11 @@ void StelMovementMgr::changeFov(double deltaFov) double StelMovementMgr::getAimFov(void) const { +#ifdef Q_OS_ANDROID + return (flagAutoZoom ? zoomMove.aimFov : currentFov); +#else return (flagAutoZoom ? zoomMove.getAim() : currentFov); +#endif } void StelMovementMgr::setMaxFov(double max) diff --git a/src/core/StelMovementMgr.hpp b/src/core/StelMovementMgr.hpp index c1d862d4a7b45..619de48db690a 100644 --- a/src/core/StelMovementMgr.hpp +++ b/src/core/StelMovementMgr.hpp @@ -536,9 +536,27 @@ private slots: // Time mouse control bool dragTimeMode; // Internal flag, true during mouse time motion. This is set true when mouse is moving with ctrl pressed. Set false when releasing ctrl. +#ifdef Q_OS_ANDROID + //! @internal + //! Store data for auto-zoom. + // Components: + // startFov: field of view at start + // aimFov: intended field of view at end of zoom move + // speed: rate of change. UNITS? + // coef: set to 0 at begin of zoom, will increase to 1 during autozoom motion. + struct AutoZoom + { + double startFov; + double aimFov; + float speed; + float coef; + }; + // Automove + AutoZoom zoomMove; // Current auto movement +#else // Internal state for smooth zoom animation. Smoother zoomMove; - +#endif bool flagAutoZoom; // Define if autozoom is on or off bool flagAutoZoomOutResetsDirection;