mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 00:22:42 +01:00
d40bcd6c85
With physics.sleepheld a vehicle standing still and held by its brakes lets its physics sleep. ComputeTotalForce() then returns before FStand and Fb are computed, so they keep the values of the step it fell asleep in. Two cases kept them wrong: - the brakes changed while it slept. The brake system steps on while asleep in the vehicle the user is in (MechInside) and in the unit test vehicles, and the hand and local brake settings change by hand or by a command on any vehicle. A released vehicle kept its braking force: it stayed held on a gradient and Fb stayed at the braked value. - rerail() (repair_damage(), resetconsist, SetDamage) cleared the derailment of a stopped, sleeping vehicle, which kept the friction of the derailment in FStand and could not be moved. switch_physics(false) now remembers the brake cylinder pressure, the spring brake cylinder pressure, the hand brake notch and the local brake setting. ComputeTotalForce() wakes a sleeping vehicle (wake_cause::other) when either pressure moved by more than 0.05 bar, the hand brake by a notch or the local brake by 1 percent. 0.05 bar is less than a distributor moves the cylinder in a second when it applies or releases, and well below the pressure the cylinder's return spring takes, so a release ends asleep with no force left. A cylinder holding its pressure leaves the vehicle asleep: a braked wagon on a gradient sleeps through 120 s without a single wake (new test). rerail() wakes the vehicle with wake_cause::command, as it comes from a command. No new wake cause: the debug panel lists the existing ones. Fixes the 4 staging unit tests that failed after the merge (pullee x3, derailment: a repaired vehicle is back on the rails).