]> git.mxchange.org Git - flightgear.git/blobdiff - src/Time/tmp.cxx
Modified Files:
[flightgear.git] / src / Time / tmp.cxx
index 1658924476765ea1e04dadfb763868c95af51ead..1533d1eb1f3413beee08778098d86a99503cdd71 100644 (file)
@@ -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,
@@ -103,11 +103,11 @@ void fgUpdateSunPos( void ) {
            << " Geocentric lat = " << l->get_sun_gc_lat() );
 
     // update the sun light vector
-    sgSetVec4( l->sun_vec(), l->get_sunpos().x(),
+    sgSetVec4( l->sun_vec().data(), l->get_sunpos().x(),
               l->get_sunpos().y(), l->get_sunpos().z(), 0.0 );
-    sgNormalizeVec4( l->sun_vec() );
-    sgCopyVec4( l->sun_vec_inv(), l->sun_vec() );
-    sgNegateVec4( l->sun_vec_inv() );
+    sgNormalizeVec4( l->sun_vec().data() );
+    sgCopyVec4( l->sun_vec_inv().data(), l->sun_vec().data() );
+    sgNegateVec4( l->sun_vec_inv().data() );
 
     // make sure these are directional light sources only
     l->sun_vec()[3] = l->sun_vec_inv()[3] = 0.0;
@@ -115,7 +115,7 @@ void fgUpdateSunPos( void ) {
     //      << ","<< l->sun_vec[2] << endl;
 
     // calculate the sun's relative angle to local up
-    sgCopyVec3( nup, v->get_world_up() );
+    sgCopyVec3( nup, v->get_world_up().data() );
     sgSetVec3( nsun, l->get_sunpos().x(),
                l->get_sunpos().y(), l->get_sunpos().z() );
     sgNormalizeVec3(nup);
@@ -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]);
@@ -142,7 +141,9 @@ void fgUpdateSunPos( void ) {
     // earth's surface the sun is directly over, map into onto the
     // local plane representing "horizontal".
 
-    sgmap_vec_onto_cur_surface_plane( v->get_world_up(), v->get_view_pos(),
+    SGVec3f world_up = v->get_world_up();
+    SGVec3f view_pos = v->get_view_pos();
+    sgmap_vec_onto_cur_surface_plane( world_up.data(), view_pos.data(),
                                      to_sun, surface_to_sun );
     sgNormalizeVec3(surface_to_sun);
     // cout << "(sg) Surface direction to sun is "
@@ -156,13 +157,13 @@ void fgUpdateSunPos( void ) {
     // v->get_surface_east().  We do this so we can sort out the
     // acos() ambiguity.  I wish I could think of a more efficient
     // way. :-(
-    east_dot = sgScalarProductVec3( surface_to_sun, v->get_surface_east() );
+    east_dot = sgScalarProductVec3( surface_to_sun, v->get_surface_east().data() );
     // cout << "  East dot product = " << east_dot << endl;
 
     // calculate the angle between v->surface_to_sun and
     // v->surface_south.  this is how much we have to rotate the sky
     // for it to align with the sun
-    dot = sgScalarProductVec3( surface_to_sun, v->get_surface_south() );
+    dot = sgScalarProductVec3( surface_to_sun, v->get_surface_south().data() );
     // cout << "  Dot product = " << dot << endl;
 
     if (dot > 1.0) {