summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-11 13:44:35 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-23 17:52:00 (GMT)
commit64efed1e3ba2c645e3d322ff846901019e0b0f20 (patch)
tree42474ec8e3aa6b8b1a30299d81d035f657276636
parent2abd0fd1f0df4295304f8da2accd78397e6dc4cf (diff)
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
-rw-r--r--src/lib/marble/projections/AzimuthalProjection.cpp18
-rw-r--r--src/lib/marble/projections/AzimuthalProjection_p.h10
2 files changed, 22 insertions, 6 deletions
diff --git a/src/lib/marble/projections/AzimuthalProjection.cpp b/src/lib/marble/projections/AzimuthalProjection.cpp
index 6fc6023..b75f53c 100644
--- a/src/lib/marble/projections/AzimuthalProjection.cpp
+++ b/src/lib/marble/projections/AzimuthalProjection.cpp
@@ -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);
}
diff --git a/src/lib/marble/projections/AzimuthalProjection_p.h b/src/lib/marble/projections/AzimuthalProjection_p.h
index 6f1e975..41d2783 100644
--- a/src/lib/marble/projections/AzimuthalProjection_p.h
+++ b/src/lib/marble/projections/AzimuthalProjection_p.h
@@ -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;