Skip to content

Commit 6bc3aff

Browse files
authored
Merge pull request #413 from peternewell/wheel-rotation
Correct issue with wheels not rotating when simple control/physics is set
2 parents 1c65f5c + e0b3fb7 commit 6bc3aff

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,7 +4468,7 @@ bool FixCouplerForceEquations()
44684468
if (car.CouplerSlackM < 0 || car.CouplerForceB >= 1)
44694469
continue;
44704470

4471-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4471+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
44724472
{
44734473
float MaxZ1TensionM = car.GetMaximumCouplerTensionSlack1M() * AdvancedCouplerDuplicationFactor;
44744474
// If coupler in Zone 1 tension, ie ( -ve CouplerForceU ) then set coupler forces to zero, as coupler faces not touching yet
@@ -4500,7 +4500,7 @@ bool FixCouplerForceEquations()
45004500
if (car.CouplerSlackM > 0 || car.CouplerForceB >= 1)
45014501
continue;
45024502

4503-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4503+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
45044504
{
45054505
float MaxZ1CompressionM = -car.GetMaximumCouplerCompressionSlack1M() * AdvancedCouplerDuplicationFactor;
45064506

@@ -4555,7 +4555,7 @@ bool FixCouplerImpulseForceEquations()
45554555

45564556
if (car.CouplerSlackM < 0 || car.CouplerForceB >= 1) // if coupler in compression on this car, or coupler is not to be solved, then jump to next car and skip processing this one
45574557
continue;
4558-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4558+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
45594559
{
45604560
float MaxZ3TensionM = car.AdvancedCouplerDynamicTensionSlackLimitM;
45614561

@@ -4585,7 +4585,7 @@ bool FixCouplerImpulseForceEquations()
45854585
// Coupler in tension on this car or coupler force is "zero" then jump to next car
45864586
if (car.CouplerSlackM > 0 || car.CouplerForceB >= 1)
45874587
continue;
4588-
if (Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4588+
if (!Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
45894589
{
45904590
float MaxZ3CompressionM = car.AdvancedCouplerDynamicCompressionSlackLimitM;
45914591

@@ -4623,7 +4623,7 @@ public void AddCouplerImpulseForces(float elapsedTime)
46234623
{
46244624
TrainCar car = Cars[i];
46254625

4626-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler"
4626+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler"
46274627
{
46284628
float MaxTensionCouplerLimitM = car.AdvancedCouplerDynamicTensionSlackLimitM;
46294629
float MaxCompressionCouplerLimitM = car.AdvancedCouplerDynamicCompressionSlackLimitM;
@@ -4662,7 +4662,7 @@ public void AddCouplerImpulseForces(float elapsedTime)
46624662
car.ImpulseCouplerForceUN = car.CouplerForceU;
46634663

46644664
// This section seems to be required to get car moving
4665-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler"
4665+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler"
46664666
{
46674667
Cars[i].SpeedMpS += Cars[i].CouplerForceU / Cars[i].MassKG;
46684668
Cars[i + 1].SpeedMpS -= Cars[i].CouplerForceU / Cars[i + 1].MassKG;
@@ -4749,7 +4749,7 @@ public void ComputeCouplerForces(float elapsedTime)
47494749
for (int i = 0; i < Cars.Count - 1; i++)
47504750
{
47514751
TrainCar car = Cars[i];
4752-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4752+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
47534753
{
47544754

47554755
//Force on coupler is set so that no force is applied until coupler faces come into contact with each other
@@ -4824,7 +4824,7 @@ public void ComputeCouplerForces(float elapsedTime)
48244824
// to a "fixed" value until the last car has commenced moving. This is consistent with real life as the coupler would be extended as each car starts moving.
48254825
// A damping factor is also used to reduce any large variations during train start. CouplerForce is also smoothed slightly to also reduce any jerkiness
48264826

4827-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
4827+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
48284828
{
48294829

48304830
// Note different slack lengths can be used depending upon whether the coupler is in tension or compression
@@ -5312,7 +5312,7 @@ public void UpdateCarSpeeds(float elapsedTime)
53125312
// Cycle down the train consist until the first stationary car is found that has its leading couplers starting to pull it. The next car is then started by allowing its speed to increase above 0.
53135313
f += car.TotalForceN - (car.FrictionForceN + car.BrakeForceN + car.CurveForceN + car.WindForceN + car.TunnelForceN);
53145314
m += car.MassKG;
5315-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
5315+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
53165316
{
53175317
if (j == Cars.Count - 1 || car.CouplerSlackM < car.AdvancedCouplerDynamicTensionSlackLimitM)
53185318
break;
@@ -5369,7 +5369,7 @@ public void UpdateCarSpeeds(float elapsedTime)
53695369
// Cycle up the train consist until the first stationary car is found that has its leading couplers starting to pull it. The next car is then started by allowing its speed to increase above 0.
53705370
f += car.TotalForceN + car.FrictionForceN + car.BrakeForceN + car.CurveForceN + car.WindForceN + car.TunnelForceN;
53715371
m += car.MassKG;
5372-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
5372+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
53735373
{
53745374
if (j == 0 || car.CouplerSlackM > car.AdvancedCouplerDynamicCompressionSlackLimitM)
53755375
break;
@@ -5426,7 +5426,7 @@ public void UpdateCouplerSlack(float elapsedTime)
54265426

54275427
// Make sure that coupler slack does not exceed the maximum (dynamic) coupler slack
54285428

5429-
if (car.IsPlayerTrain && Simulator.UseAdvancedAdhesion && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
5429+
if (car.IsPlayerTrain && !Simulator.Settings.SimpleControlPhysics && car.IsAdvancedCoupler) // "Advanced coupler" - operates in three extension zones
54305430
{
54315431
float AdvancedCouplerCompressionLimitM = car.AdvancedCouplerDynamicCompressionSlackLimitM;
54325432
float AdvancedCouplerTensionLimitM = car.AdvancedCouplerDynamicTensionSlackLimitM;

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ public override void Update(float elapsedClockSeconds)
17041704

17051705

17061706

1707-
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
1707+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics) // SimpleControlPhysics will "disable" advanced adhesion if set.
17081708
{
17091709
AdvancedAdhesion(elapsedClockSeconds); // Use advanced adhesion model
17101710
AdvancedAdhesionModel = true; // Set flag to advise advanced adhesion model is in use

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4644,7 +4644,9 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
46444644
// Typically tangential force will be greater at starting then when the locomotive is at speed, as interia and reduce steam pressure will decrease the value.
46454645
// By default this model uses information based upon a "NYC 4-4-2 locomotive", for smaller locomotives this data is changed in the OR initialisation phase.
46464646

4647-
if (Simulator.UseAdvancedAdhesion && this == Simulator.PlayerLocomotive && this.Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING) // only set advanced wheel slip when advanced adhesion and is the player locomotive, AI locomotive will not work to this model. Don't use slip model when train is in auto pilot
4647+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && this == Simulator.PlayerLocomotive && this.Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
4648+
// only set advanced wheel slip when advanced adhesion, and simplecontrols/physics is not set and is the player locomotive, AI locomotive will not work to this model.
4649+
// Don't use slip model when train is in auto pilot
46484650
{
46494651
float SlipCutoffPressureAtmPSI;
46504652
float SlipCylinderReleasePressureAtmPSI;
@@ -6463,7 +6465,8 @@ public override string GetDebugStatus()
64636465
);
64646466
}
64656467

6466-
if (Simulator.UseAdvancedAdhesion && SteamEngineType != SteamEngineTypes.Geared) // Only display slip monitor if advanced adhesion used
6468+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && SteamEngineType != SteamEngineTypes.Geared)
6469+
// Only display slip monitor if advanced adhesion is set and simplecontrols/physics not set
64676470
{
64686471
status.AppendFormat("\n\t\t === {0} === \n", Simulator.Catalog.GetString("Slip Monitor"));
64696472
status.AppendFormat("{0}\t{1}\t{2:N0}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12:N2}\t{13}\t{14}\t{15:N2}\t{16}\t{17}\t{18:N1}\n",

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ public MSTSCoupling Coupler
33863386
}
33873387
public override float GetCouplerZeroLengthM()
33883388
{
3389-
if (IsPlayerTrain && Simulator.UseAdvancedAdhesion && IsAdvancedCoupler)
3389+
if (IsPlayerTrain && Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && IsAdvancedCoupler)
33903390
{
33913391
float zerolength;
33923392
if (Coupler != null)

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public virtual void Update(float elapsedClockSeconds)
782782
{
783783
_AccelerationMpSS = (_SpeedMpS - _PrevSpeedMpS) / elapsedClockSeconds;
784784

785-
if (Simulator.UseAdvancedAdhesion)
785+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
786786
_AccelerationMpSS = AccelerationFilter.Filter(_AccelerationMpSS, elapsedClockSeconds);
787787

788788
_PrevSpeedMpS = _SpeedMpS;
@@ -856,8 +856,8 @@ public void InitializeCarTemperatures()
856856
public virtual void UpdateBrakeSlideCalculation()
857857
{
858858

859-
// Only apply slide, and advanced brake friction, if advanced adhesion is selected, and it is a Player train
860-
if (Simulator.UseAdvancedAdhesion && IsPlayerTrain)
859+
// Only apply slide, and advanced brake friction, if advanced adhesion is selected, simplecontrolphysics is not set, and it is a Player train
860+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && IsPlayerTrain)
861861
{
862862

863863
// Get user defined brake shoe coefficient if defined in WAG file

Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ private void UpdateAnimation(RenderFrame frame, ElapsedTime elapsedTime)
656656
float AnimationWheelRadiusM = 0.0f; // Radius of non driven wheels
657657
float AnimationDriveWheelRadiusM = 0.0f; // Radius of driven wheels
658658

659-
if (MSTSWagon.IsDriveable && MSTSWagon.Simulator.UseAdvancedAdhesion)
659+
if (MSTSWagon.IsDriveable && MSTSWagon.Simulator.UseAdvancedAdhesion && !MSTSWagon.Simulator.Settings.SimpleControlPhysics)
660660
{
661661
//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.
662662
// To achieve the same result with other means, without flipping trainset physics, the line should be changed as follows:

0 commit comments

Comments
 (0)