Commit 06dbad8b authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

SphericalProjection::screenCoordinates(): query viewport properties only once

parent 342aa804
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment