summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-12 16:43:25 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-12 16:43:25 (GMT)
commit06dbad8b4398bb6b8c6c37d6a96ccf47ca9ca867 (patch)
tree58228c13df9bec8757240c8a9962744357169cf6
parent342aa8041cce2e3f5aa38eab00b62934b313b02c (diff)
SphericalProjection::screenCoordinates(): query viewport properties only once
-rw-r--r--src/lib/marble/projections/SphericalProjection.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/marble/projections/SphericalProjection.cpp b/src/lib/marble/projections/SphericalProjection.cpp
index 3b25b98..9531fbc 100644
--- a/src/lib/marble/projections/SphericalProjection.cpp
+++ b/src/lib/marble/projections/SphericalProjection.cpp
@@ -83,14 +83,15 @@ bool SphericalProjection::screenCoordinates( const GeoDataCoordinates &coordinat
const ViewportParams *viewport,
qreal &x, qreal &y, bool &globeHidesPoint ) const
{
- qreal absoluteAltitude = coordinates.altitude() + EARTH_RADIUS;
+ const qreal altitude = coordinates.altitude();
+ const qreal absoluteAltitude = altitude + EARTH_RADIUS;
Quaternion qpos = coordinates.quaternion();
qpos.rotateAroundAxis( viewport->planetAxisMatrix() );
- qreal pixelAltitude = ( ( viewport->radius() )
- / EARTH_RADIUS * absoluteAltitude );
- if ( coordinates.altitude() < 10000 ) {
+ const qreal radius = viewport->radius();
+ const qreal pixelAltitude = (radius / EARTH_RADIUS * absoluteAltitude);
+ if (altitude < 10000) {
// Skip placemarks at the other side of the earth.
if ( qpos.v[Q_Z] < 0 ) {
globeHidesPoint = true;
@@ -100,7 +101,6 @@ bool SphericalProjection::screenCoordinates( const GeoDataCoordinates &coordinat
else {
qreal earthCenteredX = pixelAltitude * qpos.v[Q_X];
qreal earthCenteredY = pixelAltitude * qpos.v[Q_Y];
- qreal radius = viewport->radius();
// Don't draw high placemarks (e.g. satellites) that aren't visible.
if ( qpos.v[Q_Z] < 0
@@ -112,12 +112,15 @@ bool SphericalProjection::screenCoordinates( const GeoDataCoordinates &coordinat
}
}
+ const qreal width = viewport->width();
+ const qreal height = viewport->height();
+
// Let (x, y) be the position on the screen of the placemark..
- x = ((qreal)(viewport->width()) / 2 + pixelAltitude * qpos.v[Q_X]);
- y = ((qreal)(viewport->height()) / 2 - pixelAltitude * qpos.v[Q_Y]);
+ x = (width / 2 + pixelAltitude * qpos.v[Q_X]);
+ y = (height / 2 - pixelAltitude * qpos.v[Q_Y]);
// Skip placemarks that are outside the screen area
- if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) {
+ if (x < 0 || x >= width || y < 0 || y >= height) {
globeHidesPoint = false;
return false;
}