Skip to content

Commit e5128e4

Browse files
committed
Bug fix for https://bugs.launchpad.net/or/+bug/1979005 Drive wheels not rotating at correct speed
1 parent ab4f4bd commit e5128e4

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -709,52 +709,32 @@ private void UpdateAnimation(RenderFrame frame, ElapsedTime elapsedTime)
709709

710710
float distanceTravelledM = 0.0f; // Distance travelled by non-driven wheels
711711
float distanceTravelledDrivenM = 0.0f; // Distance travelled by driven wheels
712-
float AnimationWheelRadiusM = 0.0f; // Radius of non driven wheels
713-
float AnimationDriveWheelRadiusM = 0.0f; // Radius of driven wheels
712+
float AnimationWheelRadiusM = MSTSWagon.WheelRadiusM; // Radius of non driven wheels
713+
float AnimationDriveWheelRadiusM = MSTSWagon.DriverWheelRadiusM; // Radius of driven wheels
714714

715715
if (MSTSWagon.IsDriveable && MSTSWagon.Simulator.UseAdvancedAdhesion && !MSTSWagon.Simulator.Settings.SimpleControlPhysics)
716716
{
717717
//TODO: next code line has been modified to flip trainset physics in order to get viewing direction coincident with loco direction when using rear cab.
718718
// To achieve the same result with other means, without flipping trainset physics, the line should be changed as follows:
719719
// distanceTravelledM = MSTSWagon.WheelSpeedMpS * elapsedTime.ClockSeconds;
720720

721-
if (Car.EngineType == Orts.Simulation.RollingStocks.TrainCar.EngineTypes.Steam) // Steam locomotive so set up different speeds for different driver and non-driver wheels
721+
distanceTravelledM = ((MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.WheelSpeedMpS * elapsedTime.ClockSeconds;
722+
if (Car.EngineType == Orts.Simulation.RollingStocks.TrainCar.EngineTypes.Steam)
722723
{
723-
distanceTravelledM = ((MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.WheelSpeedMpS * elapsedTime.ClockSeconds;
724724
distanceTravelledDrivenM = ((MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.WheelSpeedSlipMpS * elapsedTime.ClockSeconds;
725-
// Set values of wheel radius - assume that drive wheel and non driven wheel are different sizes
726-
AnimationWheelRadiusM = MSTSWagon.WheelRadiusM;
727-
AnimationDriveWheelRadiusM = MSTSWagon.DriverWheelRadiusM;
728725
}
729-
else // Other driveable rolling stock - all wheels have same speed.
726+
else // Other driveable rolling stocked.
730727
{
731-
distanceTravelledM = ((MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.WheelSpeedMpS * elapsedTime.ClockSeconds;
732728
distanceTravelledDrivenM = ((MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.WheelSpeedMpS * elapsedTime.ClockSeconds;
733-
// Set values of wheel radius - assume that drive wheel and non driven wheel are same sizes
734-
AnimationWheelRadiusM = MSTSWagon.WheelRadiusM;
735-
AnimationDriveWheelRadiusM = MSTSWagon.WheelRadiusM;
736729
}
737730
}
738731
else // set values for simple adhesion
739732
{
740-
741733
distanceTravelledM = ((MSTSWagon.IsDriveable && MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.SpeedMpS * elapsedTime.ClockSeconds;
742-
distanceTravelledDrivenM = ((MSTSWagon.IsDriveable && MSTSWagon.Train != null && MSTSWagon.Train.IsPlayerDriven && ((MSTSLocomotive)MSTSWagon).UsingRearCab) ? -1 : 1) * MSTSWagon.SpeedMpS * elapsedTime.ClockSeconds;
743-
// Set values of wheel radius - assume that drive wheel and non driven wheel are same sizes
744-
if (Car.EngineType == Orts.Simulation.RollingStocks.TrainCar.EngineTypes.Steam) // set values for steam stock
745-
{
746-
AnimationWheelRadiusM = MSTSWagon.WheelRadiusM;
747-
AnimationDriveWheelRadiusM = MSTSWagon.DriverWheelRadiusM;
748-
}
749-
else // set values for non-driveable stock, eg wagons, and driveable stock such as diesels, electric locomotives
750-
{
751-
AnimationWheelRadiusM = MSTSWagon.WheelRadiusM;
752-
AnimationDriveWheelRadiusM = MSTSWagon.WheelRadiusM;
753-
}
754-
734+
distanceTravelledDrivenM = distanceTravelledM;
755735
}
756736

757-
if (Car.BrakeSkid) // if car wheels are skidding because of brakes lockin wheels up then stop wheels rotating.
737+
if (Car.BrakeSkid) // if car wheels are skidding because of brakes locking wheels up then stop wheels rotating.
758738
{
759739
distanceTravelledM = 0.0f;
760740
distanceTravelledDrivenM = 0.0f;

0 commit comments

Comments
 (0)