1
0
Fork 0

Fix a view offset bug in some external views

This commit is contained in:
ehofman 2003-05-18 09:04:14 +00:00
parent ebaa19f1d6
commit 959996f17c

View file

@ -1,5 +1,5 @@
// //
// light.hxx -- lighting routines // light.cxx -- lighting routines
// //
// Written by Curtis Olson, started April 1998. // Written by Curtis Olson, started April 1998.
// //
@ -187,9 +187,11 @@ void fgLIGHT::Update( void ) {
// calculate fog color adjusted for sunrise/sunset effects // calculate fog color adjusted for sunrise/sunset effects
void fgLIGHT::UpdateAdjFog( void ) { void fgLIGHT::UpdateAdjFog( void ) {
FGInterface *f;
f = current_aircraft.fdm_state; double heading = globals->get_current_view()->getHeading_deg()
* SGD_DEGREES_TO_RADIANS;
double heading_offset = globals->get_current_view()->getHeadingOffset_deg()
* SGD_DEGREES_TO_RADIANS;
SG_LOG( SG_EVENT, SG_DEBUG, "Updating adjusted fog parameters." ); SG_LOG( SG_EVENT, SG_DEBUG, "Updating adjusted fog parameters." );
@ -201,14 +203,15 @@ void fgLIGHT::UpdateAdjFog( void ) {
SG_LOG( SG_EVENT, SG_ALERT, "Sun rotation bad = " << sun_rotation ); SG_LOG( SG_EVENT, SG_ALERT, "Sun rotation bad = " << sun_rotation );
exit(-1); exit(-1);
} }
if ( f->get_Psi() < -2.0 * SGD_2PI || f->get_Psi() > 2.0 * SGD_2PI ) {
SG_LOG( SG_EVENT, SG_ALERT, "Psi rotation bad = " << f->get_Psi() ); if ( heading < -2.0 * SGD_2PI || heading > 2.0 * SGD_2PI ) {
SG_LOG( SG_EVENT, SG_ALERT, "Psi rotation bad = " << heading );
exit(-1); exit(-1);
} }
if ( globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS < -2.0 * SGD_2PI ||
globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS > 2.0 * SGD_2PI ) { if ( heading_offset < -2.0 * SGD_2PI || heading_offset > 2.0 * SGD_2PI ) {
SG_LOG( SG_EVENT, SG_ALERT, "current view()->view offset bad = " SG_LOG( SG_EVENT, SG_ALERT, "current view()->view offset bad = "
<< globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS ); << heading_offset );
exit(-1); exit(-1);
} }
@ -216,8 +219,7 @@ void fgLIGHT::UpdateAdjFog( void ) {
// first determine the difference between our view angle and local // first determine the difference between our view angle and local
// direction to the sun // direction to the sun
rotation = -(sun_rotation + SGD_PI) rotation = -(sun_rotation + SGD_PI) - heading - heading_offset;
- (f->get_Psi() - globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS);
while ( rotation < 0 ) { while ( rotation < 0 ) {
rotation += SGD_2PI; rotation += SGD_2PI;
} }