AzimuthalProjection: Avoid duplicated globeHidesPoint calculation in iteration

Summary:
In the first recursive call there is no need to recalculate whether the
currentCoords parameter of AzimuthalProjectionPrivate::findHorizon(...)
is hidden by the globe, because that information is already known on the
previous level.
Splitting the findHorizon() method into a "interface" method and
a "worker" method for the recursion, where the existing information
is passed on, allows to avoid that duplicated calculation.

Reviewers: rahn, #marble

Reviewed By: rahn, #marble

Differential Revision: https://phabricator.kde.org/D2408
parent 2abd0fd1
......@@ -566,11 +566,21 @@ void AzimuthalProjectionPrivate::horizonToPolygon( const ViewportParams *viewpor
GeoDataCoordinates AzimuthalProjectionPrivate::findHorizon( const GeoDataCoordinates & previousCoords,
const GeoDataCoordinates & currentCoords,
const ViewportParams *viewport,
TessellationFlags f,
int recursionCounter ) const
TessellationFlags f) const
{
bool currentHide = globeHidesPoint( currentCoords, viewport ) ;
return doFindHorizon(previousCoords, currentCoords, viewport, f, currentHide, 0);
}
GeoDataCoordinates AzimuthalProjectionPrivate::doFindHorizon( const GeoDataCoordinates & previousCoords,
const GeoDataCoordinates & currentCoords,
const ViewportParams *viewport,
TessellationFlags f,
bool currentHide,
int recursionCounter ) const
{
if ( recursionCounter > 20 ) {
return currentHide ? previousCoords : currentCoords;
}
......@@ -638,10 +648,10 @@ GeoDataCoordinates AzimuthalProjectionPrivate::findHorizon( const GeoDataCoordin
bool horizonHide = globeHidesPoint( horizonCoords, viewport );
if ( horizonHide != currentHide ) {
return findHorizon( horizonCoords, currentCoords, viewport, f, recursionCounter );
return doFindHorizon(horizonCoords, currentCoords, viewport, f, currentHide, recursionCounter);
}
return findHorizon( previousCoords, horizonCoords, viewport, f, recursionCounter );
return doFindHorizon(previousCoords, horizonCoords, viewport, f, horizonHide, recursionCounter);
}
......
......@@ -87,8 +87,14 @@ public:
GeoDataCoordinates findHorizon( const GeoDataCoordinates & previousCoords,
const GeoDataCoordinates & currentCoords,
const ViewportParams *viewport,
TessellationFlags f = 0,
int recursionCounter = 0 ) const;
TessellationFlags f = 0) const;
GeoDataCoordinates doFindHorizon(const GeoDataCoordinates & previousCoords,
const GeoDataCoordinates & currentCoords,
const ViewportParams *viewport,
TessellationFlags f,
bool currentHide,
int recursionCounter) const;
bool globeHidesPoint( const GeoDataCoordinates &coordinates,
const ViewportParams *viewport ) const;
......
Markdown is supported
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