Merge lp:~guillaume-chereau/stellarium/planet-optimization into lp:stellarium

Proposed by Guillaume Chereau
Status: Merged
Merged at revision: 8290
Proposed branch: lp:~guillaume-chereau/stellarium/planet-optimization
Merge into: lp:stellarium
Diff against target: 52 lines (+4/-20)
2 files modified
src/core/modules/Planet.cpp (+3/-19)
src/core/modules/Planet.hpp (+1/-1)
To merge this branch: bzr merge lp:~guillaume-chereau/stellarium/planet-optimization
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
Review via email: mp+291494@code.launchpad.net

Description of the change

Tow small but important optimizations of planet position computation.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Good optimizations, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/modules/Planet.cpp'
2--- src/core/modules/Planet.cpp 2016-04-11 06:54:09 +0000
3+++ src/core/modules/Planet.cpp 2016-04-11 11:28:04 +0000
4@@ -619,9 +619,9 @@
5 {
6 // calculate actual Planet position
7 coordFunc(dateJDE, eclipticPos, userDataPtr);
8- // XXX: do we need to do that even when the orbit is not visible?
9- for( int d=0; d<ORBIT_SEGMENTS; d++ )
10- orbit[d]=getHeliocentricPos(orbitP[d]);
11+ if (orbitFader.getInterstate()>0.000001)
12+ for( int d=0; d<ORBIT_SEGMENTS; d++ )
13+ orbit[d]=getHeliocentricPos(orbitP[d]);
14 lastJDE = dateJDE;
15 }
16
17@@ -781,22 +781,6 @@
18 return eclipticPos;
19 }
20
21-// Return the heliocentric ecliptical position (Vsop87)
22-Vec3d Planet::getHeliocentricEclipticPos() const
23-{
24- Vec3d pos = eclipticPos;
25- PlanetP pp = parent;
26- if (pp)
27- {
28- while (pp->parent)
29- {
30- pos += pp->eclipticPos;
31- pp = pp->parent;
32- }
33- }
34- return pos;
35-}
36-
37 // Return heliocentric coordinate of p
38 Vec3d Planet::getHeliocentricPos(Vec3d p) const
39 {
40
41=== modified file 'src/core/modules/Planet.hpp'
42--- src/core/modules/Planet.hpp 2016-04-06 14:26:12 +0000
43+++ src/core/modules/Planet.hpp 2016-04-11 11:28:04 +0000
44@@ -231,7 +231,7 @@
45 Vec3d getEclipticPos() const;
46
47 // Return the heliocentric ecliptical position
48- Vec3d getHeliocentricEclipticPos() const;
49+ Vec3d getHeliocentricEclipticPos() const {return getHeliocentricPos(eclipticPos);}
50
51 // Return the heliocentric transformation for local coordinate
52 Vec3d getHeliocentricPos(Vec3d) const;