]> git.mxchange.org Git - flightgear.git/blobdiff - src/Time/tmp.cxx
Clean up scenery center handling. It is set now less often.
[flightgear.git] / src / Time / tmp.cxx
index f734cbd290b5b9737218423e69fd5563db5a0866..1803964846717155fa9c969f996a0b5b44c25b73 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -69,7 +69,6 @@ void fgUpdateLocalTime() {
 // update the cur_time_params structure with the current sun position
 void fgUpdateSunPos( void ) {
     sgVec3 nup, nsun;
-    Point3D rel_sunpos;
     double dot, east_dot;
     double sun_gd_lat, sl_radius;
 
@@ -94,8 +93,9 @@ void fgUpdateSunPos( void ) {
     sgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &sun_l);
     l->set_sun_gc_lat(sun_l);
 
-    Point3D p = Point3D( l->get_sun_lon(), l->get_sun_gc_lat(), sl_radius );
-    l->set_sunpos( sgPolarToCart3d(p) );
+    SGGeoc geocSun = SGGeoc::fromRadM( l->get_sun_lon(), l->get_sun_gc_lat(),
+                                       sl_radius );
+    l->set_sunpos( SGVec3d::fromGeoc(geocSun) );
 
     SG_LOG( SG_EVENT, SG_DEBUG, "    t->cur_time = " << t->get_cur_time() );
     SG_LOG( SG_EVENT, SG_DEBUG,
@@ -130,10 +130,9 @@ void fgUpdateSunPos( void ) {
            << l->get_sun_angle() );
     
     // calculate vector to sun's position on the earth's surface
-    Point3D vp( v->get_view_pos()[0],
-               v->get_view_pos()[1],
-               v->get_view_pos()[2] );
-    rel_sunpos = l->get_sunpos() - (vp + globals->get_scenery()->get_center());
+    SGVec3d rel_sunpos = globals->get_scenery()->get_center();
+    SGVec3f vp( v->get_view_pos() );
+    rel_sunpos += l->get_sunpos() - toVec3d(vp);
     sgSetVec3( to_sun, rel_sunpos.x(), rel_sunpos.y(), rel_sunpos.z() );
     // printf( "Vector to sun = %.2f %.2f %.2f\n",
     //         v->to_sun[0], v->to_sun[1], v->to_sun[2]);