From 0aee37599ab31f6aa6393e44803ccdc5377f2f53 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Mon, 30 Nov 2026 11:07:35 +0100 Subject: [PATCH] perf(test): no sounds, smoke, wipers or mirrors in the test mode In the test mode nothing is heard or seen, yet every frame went through the sounds of the scenery and of the vehicles near the camera (basic_region::update_sounds(): the cells' sounds, TTrack:: RenderDynSounds(), TDynamicObject::RenderSounds()), the smoke (particle_manager::update()) and the wipers and the mirrors of every vehicle (updateWipers(), updateMirrors()). They're skipped there now. Checked first that none of them changes what the simulation goes by: - the sounds and the particles draw from the local engine of LocalRandom() only, which the physics, the AI and the events don't use (they draw from Random()'s engines); - RenderSounds() clears the vehicle's sound flags (ClearSoundFlags(), ClearEventFlag(), the brake's GetSoundFlag()), which nothing but the sounds reads; - the wiper positions and timers and the mirror positions are read by the renderers and the cab sounds only. Kept: updateAxleClatter(), whose joint jolts shake the physics (ShakeVertically/Horizontally). Outside the test mode nothing changes. 600 s in --test, seed 12345, one run each, the step before run again in the same session: Tomaszewo sim 129.5 s against 129.9 s, L107 17.9 s against 17.9 s: no gain shows beyond the run-to-run spread (the camera of the test mode, ghostview, has few sounds and smoke sources near it). The physics logs (14 and 9) and the event logs are byte-identical to staging's, unit tests 1207/1207 with exact golden traces. --- application/drivermode.cpp | 9 +++++++-- vehicle/dynamic/update.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/application/drivermode.cpp b/application/drivermode.cpp index 99c3ff31e..79186a4cd 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -487,13 +487,18 @@ bool driver_mode::update() Timer::subsystem.switching.update(); Timer::subsystem.loop_audio.start(); - simulation::Region->update_sounds(); + // the test mode has no sound: the sounds of the scenery and of the vehicles aren't gone through. they draw from the local + // engine of Random() only (LocalRandom()), and clear the sound flags of the vehicles, which nothing else reads + if (false == Global.test.enabled) + simulation::Region->update_sounds(); audio::renderer.update(Global.iPause ? 0.0 : deltarealtime); Timer::subsystem.loop_audio.stop(); // NOTE: particle system runs on simulation time, but needs actual camera position to determine how to update each particle source + // nor smoke in the test mode, which draws nothing: the particles draw from the local engine of Random() only Timer::subsystem.loop_particles.start(); - simulation::Particles.update(); + if (false == Global.test.enabled) + simulation::Particles.update(); Timer::subsystem.loop_particles.stop(); Timer::subsystem.loop_renderer_update.start(); diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 398fe1241..a2328b958 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -159,8 +159,11 @@ bool TDynamicObject::Update(double dt, double dt1) updateWheelAngles( dt1 ); updateCurrentCollectors( dt1 ); - updateWipers( dt1 ); - updateMirrors( dt1 ); + // the wipers and the mirrors only move in the cab and make their sounds: the test mode shows and plays neither + if( false == Global.test.enabled ) { + updateWipers( dt1 ); + updateMirrors( dt1 ); + } // compartment lights // if the vehicle has a controller, we base the light state on state of the controller otherwise we check the vehicle itself