- // Calculate frame rate average
-#ifdef FANCY_FRAME_COUNTER
- /* old fps calculation */
- if ( elapsed > 0 ) {
- double tmp;
- accum = 0.0;
- for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) {
- tmp = general.get_frame(i);
- accum += tmp;
- // printf("frame[%d] = %.2f\n", i, g->frames[i]);
- general.set_frame(i+1,tmp);
- }
- tmp = 1000000.0 / (float)elapsed;
- general.set_frame(0,tmp);
- // printf("frame[0] = %.2f\n", general.frames[0]);
- accum += tmp;
- general.set_frame_rate(accum / (float)FG_FRAME_RATE_HISTORY);
- // printf("ave = %.2f\n", general.frame_rate);
- }
-#else
- if ( (t->get_cur_time() != last_time) && (last_time > 0) ) {
- general.set_frame_rate( frames );
- fgSetInt("/sim/frame-rate", frames);
- SG_LOG( SG_ALL, SG_DEBUG,
- "--> Frame rate is = " << general.get_frame_rate() );
- frames = 0;
- }
- last_time = t->get_cur_time();
- ++frames;
-#endif
-
- // Update any multiplayer's network queues, the AIMultiplayer
- // implementation is an AI model and depends on that
- globals->get_multiplayer_mgr()->Update();
-
- // Run ATC subsystem
- if (fgGetBool("/sim/atc/enabled"))
- globals->get_ATC_mgr()->update(delta_time_sec);
-
- // Run the AI subsystem
- // FIXME: run that also if we have multiplaying enabled since the
- // multiplayer information is interpreted by an AI model
- if (fgGetBool("/sim/ai-traffic/enabled"))
- globals->get_AI_mgr()->update(delta_time_sec);
-
- // Run flight model
- if (0 < global_multi_loop) {
- // first run the flight model each frame until it is initialized
- // then continue running each frame only after initial scenery
- // load is complete.
- fgUpdateTimeDepCalcs();
- } else {
- SG_LOG( SG_ALL, SG_DEBUG,
- "Elapsed time is zero ... we're zinging" );
- }
-
- globals->get_subsystem_mgr()->update(delta_time_sec);
-
- //
- // Tile Manager updates - see if we need to load any new scenery tiles.
- // this code ties together the fdm, viewer and scenery classes...
- // we may want to move this to its own class at some point
- //
- double visibility_meters = fgGetDouble("/environment/visibility-m");
- globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
-
- // update tile manager for view...
- SGVec3d viewPos = globals->get_current_view()->get_view_pos();
- SGGeod geodViewPos = SGGeod::fromCart(viewPos);
- globals->get_tile_mgr()->update(geodViewPos, visibility_meters);
-
- // run Nasal's settimer() loops right before the view manager
- globals->get_event_mgr()->update(delta_time_sec);
-
- // pick up model coordidnates that Nasal code may have set relative to the
- // aircraft's
- globals->get_model_mgr()->update(delta_time_sec);
-
- // update the view angle as late as possible, but before sound calculations
- globals->get_viewmgr()->update(real_delta_time_sec);