Merge lp:~wlformyd/stellarium/bug1307444 into lp:stellarium

Proposed by William Formyduval
Status: Merged
Merged at revision: 7138
Proposed branch: lp:~wlformyd/stellarium/bug1307444
Merge into: lp:stellarium
Diff against target: 29 lines (+8/-4)
1 file modified
plugins/CompassMarks/src/CompassMarks.cpp (+8/-4)
To merge this branch: bzr merge lp:~wlformyd/stellarium/bug1307444
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
gzotti Approve
Review via email: mp+241228@code.launchpad.net

Commit message

Reducing the number of compass marks to those on screen to improve performance.

Description of the change

Loop in drawSmallCircleArc is quick at high FOV (5-20 iterations/arc) but becomes larger when FOV is less than 0.5 (1000+ iterations/arc). Proposed solution is to draw only arcs that are visible. This greatly reduces the time spent drawing.

To post a comment you must log in.
Revision history for this message
gzotti (georg-zotti) wrote :

Yes, that's fine, thanks!
You can even remove the texture dis-/enable immediately surrounding it, it's redundant with those outside the loop.

review: Approve
Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve
Revision history for this message
Alexander Wolf (alexwolf) wrote :

It's OK for me, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/CompassMarks/src/CompassMarks.cpp'
2--- plugins/CompassMarks/src/CompassMarks.cpp 2014-11-04 10:59:12 +0000
3+++ plugins/CompassMarks/src/CompassMarks.cpp 2014-11-10 01:50:32 +0000
4@@ -123,7 +123,7 @@
5 {
6 if (markFader.getInterstate() <= 0.0) { return; }
7
8- Vec3d pos;
9+ Vec3d pos, screenPos;
10 StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff);
11 StelPainter painter(prj);
12 painter.setFont(font);
13@@ -155,9 +155,13 @@
14 h = -0.01; // the size of the mark every 5 degrees
15 }
16
17- glDisable(GL_TEXTURE_2D);
18- painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), NULL);
19- glEnable(GL_TEXTURE_2D);
20+ // Limit arcs to those that are visible for improved performance
21+ if (prj->project(pos, screenPos) &&
22+ screenPos[0]>prj->getViewportPosX() && screenPos[0] < prj->getViewportPosX() + prj->getViewportWidth()) {
23+ glDisable(GL_TEXTURE_2D);
24+ painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), NULL);
25+ glEnable(GL_TEXTURE_2D);
26+ }
27 }
28 // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
29 // glDisable(GL_LINE_SMOOTH);