Skip to content

Commit

Permalink
[NF] revert scale (Stellarium#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
silas1037 committed Dec 23, 2020
1 parent b1b44fb commit 0b5a83b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
38 changes: 37 additions & 1 deletion src/core/StelMovementMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>((1.0f-zoomMove.coef)*(1.0f-zoomMove.coef)*(1.0f-zoomMove.coef));
}
else
{
// speed up as we leave zoom target
c = static_cast<double>(zoomMove.coef * zoomMove.coef * zoomMove.coef);
}

double newFov=zoomMove.startFov + (zoomMove.aimFov - zoomMove.startFov) * c;

zoomMove.coef+=zoomMove.speed*static_cast<float>(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.
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion src/core/StelMovementMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0b5a83b

Please sign in to comment.