Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4326a20

Browse files
committed
Correct sound trigger issue
1 parent f59d201 commit 4326a20

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,16 @@ private void UpdateFX(float elapsedClockSeconds)
21712171
SmokeColor.Update(elapsedClockSeconds, MathHelper.Clamp(SmokeColorUnits, 0.25f, 1));
21722172

21732173
// Variable1 is proportional to angular speed, value of 10 means 1 rotation/second.
2174-
var variable1 = Math.Abs(WheelSpeedSlipMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2174+
// If whel is not slipping then use normal wheel speed, this reduces oscillations in variable1 which causes issues with sounds.
2175+
var variable1 = 0.0f;
2176+
if (WheelSlip)
2177+
{
2178+
variable1 = Math.Abs(WheelSpeedSlipMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2179+
}
2180+
else
2181+
{
2182+
variable1 = Math.Abs(WheelSpeedMpS / DriverWheelRadiusM / MathHelper.Pi * 5);
2183+
}
21752184
Variable1 = ThrottlePercent == 0 ? 0 : variable1;
21762185
Variable2 = MathHelper.Clamp((CylinderCocksPressureAtmPSI - OneAtmospherePSI) / BoilerPressurePSI * 100f, 0, 100);
21772186
Variable3 = FuelRateSmoothed * 100;

0 commit comments

Comments
 (0)