diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index 0a20eced..b073e31a 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -869,6 +869,13 @@ void opengl46_renderer::SwapBuffers() count( counts.kind[ kind ] ) + " " + count( counts.standing[ kind ] ) + " " + ms( timers.vehicles_forces_kind[ kind ].average() ) + " " + ms( timers.vehicles_update_kind[ kind ].average() ) ); } + auto const &awake { counts.awake }; + text += timeline( + 3, + std::to_string( awake.vehicles ) + " rail standing with physics on: cab " + std::to_string( awake.cab ) + ", speed " + std::to_string( awake.speed ) + + ", acceleration " + std::to_string( awake.acceleration ) + ", switching " + std::to_string( awake.switching ) + ", ezt/dmu " + + std::to_string( awake.multipleunit ) + ", neighbour " + std::to_string( awake.neighbour ), + "" ); } text += timeline( 2, "secondary steps", ms( timers.sim_secondary.average() ) ); text += timeline( 2, "trains (cabs)", ms( timers.sim_trains.average() ) ); diff --git a/utilities/Timer.h b/utilities/Timer.h index 9714825f..9612d519 100644 --- a/utilities/Timer.h +++ b/utilities/Timer.h @@ -126,6 +126,17 @@ struct subsystem_stopwatches { // enabled vehicles of each kind (see vehicles_forces_kind), and of them the ones standing still std::array kind {}; std::array standing {}; + // rail vehicles standing still (below 0.01 km/h) with the physics on, and what keeps it on by the test of + // TMoverParameters::ComputeTotalForce(); a vehicle can have several of these + struct awake_reasons { + unsigned int vehicles { 0 }; + unsigned int cab { 0 }; // CabActive + unsigned int speed { 0 }; // Vel above 0.0001 km/h + unsigned int acceleration { 0 }; // AccS above 0.0001 m/s2 + unsigned int switching { 0 }; // LastSwitchingTime below 5 s + unsigned int multipleunit { 0 }; // EZT, DMU + unsigned int neighbour { 0 }; // a neighbour moving or accelerating + } awake; }; vehicle_counts vehicles; // of the frame under way vehicle_counts vehicleslast; // of the last frame diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 10eb79dc..d04334d4 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -8614,6 +8614,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { counts.enabled = counts.road = counts.ai = counts.active = 0; counts.kind = {}; counts.standing = {}; + counts.awake = {}; counts.steps += static_cast( std::max( Iterationcount, 1 ) ); // the kind of each vehicle: rail or road, near the camera or farther. the time of each vehicle in the loops below goes to its // kind, measured from the end of the one before it @@ -8627,7 +8628,24 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { kinds[ index ] = static_cast( ( road ? 2 : 0 ) + ( distant ? 1 : 0 ) ); if( false == vehicle->bEnabled ) { continue; } ++counts.kind[ kinds[ index ] ]; - if( vehicle->MoverParameters->Vel < 0.01 ) { ++counts.standing[ kinds[ index ] ]; } + auto const *mover { vehicle->MoverParameters }; + if( mover->Vel < 0.01 ) { + ++counts.standing[ kinds[ index ] ]; + if( ( false == road ) && mover->PhysicActivation ) { + // the test of TMoverParameters::ComputeTotalForce(), part by part + auto const moving = []( neighbour_data const &Neighbour ) { + return ( Neighbour.vehicle != nullptr ) + && ( ( Neighbour.vehicle->MoverParameters->Vel > 0.0001 ) || ( std::abs( Neighbour.vehicle->MoverParameters->AccS ) > 0.0001 ) ); }; + auto &awake { counts.awake }; + ++awake.vehicles; + if( mover->CabActive != 0 ) { ++awake.cab; } + if( mover->Vel > 0.0001 ) { ++awake.speed; } + if( std::abs( mover->AccS ) > 0.0001 ) { ++awake.acceleration; } + if( mover->LastSwitchingTime < 5 ) { ++awake.switching; } + if( ( mover->TrainType == dt_EZT ) || ( mover->TrainType == dt_DMU ) ) { ++awake.multipleunit; } + if( moving( mover->Neighbours[ end::front ] ) || moving( mover->Neighbours[ end::rear ] ) ) { ++awake.neighbour; } + } + } } auto const lap = [ & ]( std::size_t const Index, std::array &Times, std::chrono::steady_clock::time_point &Mark ) { auto const now { std::chrono::steady_clock::now() };