X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fmain.cxx;h=419614ed303a4fff1afd412bb1d99adbe61cdcf4;hb=a4d27fe7bc81a3c5acca18b76d4f10406b74f8a3;hp=fe21913f8ad133966b943c48deb3b23b2edb93b6;hpb=26dca370280eff3dab0af3cb425dd2c2e94941bd;p=flightgear.git diff --git a/src/Main/main.cxx b/src/Main/main.cxx index fe21913f8..419614ed3 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -81,6 +81,7 @@ #include #include +#include #include #ifdef FG_NETWORK_OLK #include @@ -135,7 +136,7 @@ FGGeneral general; // our initializations out of the glutIdleLoop() so that we can get a // splash screen up and running right away. static int idle_state = 0; -static int global_multi_loop; +static long global_multi_loop; // attempt to avoid a large bounce at startup static bool initial_freeze = true; @@ -377,7 +378,8 @@ void fgRenderFrame( void ) { cur_fdm_state->get_Psi() * RAD_TO_DEG, wup ); sgVec3 npo; // new pilot offset after rotation - sgXformVec3( po, po, pilot_view->get_UP() ); + sgVec3 *pPO = PilotOffsetGet(); + sgXformVec3( po, *pPO, pilot_view->get_UP() ); sgXformVec3( npo, po, CXFM ); chase_view->set_geod_view_pos( cur_fdm_state->get_Longitude(), @@ -480,7 +482,6 @@ void fgRenderFrame( void ) { #endif thesky->modify_vis( cur_fdm_state->get_Altitude() * FEET_TO_METER, - ( global_multi_loop * fgGetInt("/sim/speed-up") ) / (double)fgGetInt("/sim/model-hz") ); @@ -682,8 +683,10 @@ void fgRenderFrame( void ) { // position tile nodes and update range selectors global_tile_mgr.prep_ssg_nodes(); - // draw the sky backdrop - thesky->preDraw(); + if ( fgGetBool("/sim/rendering/skyblend") ) { + // draw the sky backdrop + thesky->preDraw(); + } // draw the ssg scene glEnable( GL_DEPTH_TEST ); @@ -697,8 +700,10 @@ void fgRenderFrame( void ) { ssgCullAndDraw( lighting ); - // draw the sky cloud layers - thesky->postDraw( cur_fdm_state->get_Altitude() * FEET_TO_METER ); + if ( fgGetBool("/sim/rendering/skyblend") ) { + // draw the sky cloud layers + thesky->postDraw( cur_fdm_state->get_Altitude() * FEET_TO_METER ); + } // display HUD && Panel glDisable( GL_FOG ); @@ -731,12 +736,21 @@ void fgRenderFrame( void ) { // Update internal time dependent calculations (i.e. flight model) void fgUpdateTimeDepCalcs() { + static bool inited = false; + fgLIGHT *l = &cur_light_params; int i; - int multi_loop = 1; + long multi_loop = 1; if ( !globals->get_freeze() && !initial_freeze ) { + // conceptually, this could be done for each fdm instance ... + + if ( !inited ) { + cur_fdm_state->stamp(); + inited = true; + } + SGTimeStamp current; current.stamp(); long elapsed = current - cur_fdm_state->get_time_stamp(); @@ -744,20 +758,28 @@ void fgUpdateTimeDepCalcs() { elapsed += cur_fdm_state->get_remainder(); // cout << "elapsed = " << elapsed << endl; // cout << "dt = " << cur_fdm_state->get_delta_t() << endl; - multi_loop = (int)(((double)elapsed * 0.000001) / + multi_loop = (long)(((double)elapsed * 0.000001) / cur_fdm_state->get_delta_t() ); cur_fdm_state->set_multi_loop( multi_loop ); long remainder = elapsed - ( (multi_loop*1000000) * cur_fdm_state->get_delta_t() ); cur_fdm_state->set_remainder( remainder ); + // cout << "remainder = " << remainder << endl; + + // chop max interations to something reasonable if the sim was + // delayed for an excesive amount of time + if ( multi_loop > 2.0 / cur_fdm_state->get_delta_t() ) { + multi_loop = (int)(2.0 / cur_fdm_state->get_delta_t()); + cur_fdm_state->set_remainder( 0 ); + } // cout << "multi_loop = " << multi_loop << endl; - for ( i = 0; i < multi_loop; ++i ) { + for ( i = 0; i < multi_loop * fgGetInt("/sim/speed-up"); ++i ) { // run Autopilot system current_autopilot->run(); - // update autopiot - cur_fdm_state->update( 1 * fgGetInt("/sim/speed-up") ); + // update autopilot + cur_fdm_state->update( 1 ); } FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") ); } else { @@ -978,7 +1000,7 @@ static void fgMainLoop( void ) { // Calculate model iterations needed for next frame elapsed += remainder; - global_multi_loop = (int)(((double)elapsed * 0.000001) * + global_multi_loop = (long)(((double)elapsed * 0.000001) * fgGetInt("/sim/model-hz")); remainder = elapsed - ( (global_multi_loop*1000000) / fgGetInt("/sim/model-hz") ); @@ -986,6 +1008,13 @@ static void fgMainLoop( void ) { "Model iterations needed = " << global_multi_loop << ", new remainder = " << remainder ); + // chop max interations to something reasonable if the sim was + // delayed for an excesive amount of time + if ( global_multi_loop > 2.0 * fgGetInt("/sim/model-hz") ) { + global_multi_loop = (int)(2.0 * fgGetInt("/sim/model-hz") ); + remainder = 0; + } + // flight model if ( global_multi_loop > 0 ) { fgUpdateTimeDepCalcs(); @@ -1034,18 +1063,18 @@ static void fgMainLoop( void ) { double mp_factor; if ( cur_fdm_state->get_engine(0) != NULL ) { mp_factor = - cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 28; + cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 100; } else { - mp_factor = 1.0; + mp_factor = 0.3; } - // cout << "mp = " - // << cur_fdm_state->get_engine(0)->get_Manifold_Pressure() - // << endl; + /* cout << "mp = " + << cur_fdm_state->get_engine(0)->get_Manifold_Pressure() + << endl; */ - double volume = mp_factor; + double volume = 0.3 + mp_factor; if ( volume < 0.3 ) { volume = 0.3; } - if ( volume > 2.0 ) { volume = 2.0; } + if ( volume > 1.0 ) { volume = 1.0; } // cout << "volume = " << volume << endl; pitch_envelope.setStep ( 0, 0.01, pitch ); @@ -1384,6 +1413,9 @@ int main( int argc, char **argv ) { FGViewerLookAt *chase = new FGViewerLookAt; globals->get_viewmgr()->add_view( chase ); + string_list *col = new string_list; + globals->set_channel_options_list( col ); + // set current view to 0 (first) which is our main pilot view globals->set_current_view( globals->get_viewmgr()->get_view( 0 ) );