Skip to content

Commit

Permalink
Automatic merge of T1.5.1-413-g1daa6a7c6 and 21 pull requests
Browse files Browse the repository at this point in the history
- Pull request #570 at 7269d24: Experimental glTF 2.0 support with PBR lighting
- Pull request #757 at d9d75f4: Unify RailDriver code implementations
- Pull request #799 at dc03850: Consolidated wind simulation
- Pull request #802 at 4d198e4: Added support for activity location events to the TrackViewer
- Pull request #803 at 7157e08: Various adjustments to steam adhesion
- Pull request #813 at 7fdad38: Refactored garbage generators
- Pull request #815 at a5cc165: chore: Add GitHub automatic release notes configuration
- Pull request #818 at 23f3488: Allow independent drive axles for locomotives
- Pull request #821 at e0fa5a8: Adds suppression of safety valves
- Pull request #823 at 5e1c03b: Select track sound volume percent retained in .eng and .wag files
- Pull request #824 at f16ebed: Update Readme.md
- Pull request #825 at 29ed427: 2D Cabview controls for side viewpoints https://blueprints.launchpad.net/or/+spec/2dcabview-controls-for-side-views
- Pull request #829 at 434af02: Improvements for air brakes #3 - Emergency valves
- Pull request #830 at ceeaba7: Electric locomotive hot start
- Pull request #831 at c8927a4: preliminary version switchpanel on tablet
- Pull request #834 at 7a98eca: Replaces email service with FormSpark
- Pull request #835 at c3d05c4: Correct Brake Shoe Force Calculation
- Pull request #836 at 62e6d02: Adds policy on crashes and derailments
- Pull request #837 at 0497316: copies website policies to repo
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #840 at daca020: Bug fix for sanding max speed not working
  • Loading branch information
Showing 1 changed file with 18 additions and 98 deletions.
116 changes: 18 additions & 98 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs
Expand Up @@ -2827,6 +2827,7 @@ public void SimpleAdhesion()

float max0 = DrvWheelWeightKg * 9.81f * uMax; //Ahesion limit in [N]
float max1;
float SandingFrictionFactor = 1;

if (Simulator.WeatherType == WeatherType.Rain || Simulator.WeatherType == WeatherType.Snow)
{
Expand All @@ -2845,30 +2846,19 @@ public void SimpleAdhesion()
//float max1 = (Sander ? .95f : Adhesion2) * max0; //Not used this way
max1 = MaxForceN;
//add sander
if (AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
if (SanderSpeedEffectUpToMpS > 0.0f)
{
if ((Sander) && (AbsSpeedMpS < SanderSpeedEffectUpToMpS))
if (Sander && AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
switch (Simulator.WeatherType)
{
case WeatherType.Clear: max0 *= (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 1.2f; break;
case WeatherType.Rain: max0 *= (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 1.8f; break;
case WeatherType.Snow: max0 *= (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 2.5f; break;
case WeatherType.Clear: SandingFrictionFactor = 1.2f; break;
case WeatherType.Rain: SandingFrictionFactor = 1.8f; break;
case WeatherType.Snow: SandingFrictionFactor = 2.5f; break;
}
}
}
else
if (Sander)
if (SanderSpeedEffectUpToMpS > 0.0f) // Reduce sander effectiveness if max effective speed is defined
{
switch (Simulator.WeatherType)
{
case WeatherType.Clear: max0 *= 1.2f; break;
case WeatherType.Rain: max0 *= 1.8f; break;
case WeatherType.Snow: max0 *= 2.5f; break;
}
SandingFrictionFactor *= (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS);
}
max0 *= Math.Max(SandingFrictionFactor, 1.0f); // Prevent sand from harming adhesion above max effective speed
}

max1 = max0;
Expand Down Expand Up @@ -3144,90 +3134,20 @@ public virtual void UpdateFrictionCoefficient(float elapsedClockSeconds)

BaseFrictionCoefficientFactor = MathHelper.Clamp(BaseFrictionCoefficientFactor, 0.5f, 1.0f);

// Snow covered track
if (Simulator.WeatherType == WeatherType.Snow)
// Increase friction coefficient when sanding
if (Sander && AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
if (AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && (AbsSpeedMpS > 0))
switch (Simulator.WeatherType)
{
if (SanderSpeedEffectUpToMpS > 0.0f)
{
if ((Sander) && (AbsSpeedMpS < SanderSpeedEffectUpToMpS))
{
SandingFrictionCoefficientFactor = (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 1.50f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor;

case WeatherType.Clear: SandingFrictionCoefficientFactor = 1.40f; break;
case WeatherType.Rain: SandingFrictionCoefficientFactor = 1.25f; break;
case WeatherType.Snow: SandingFrictionCoefficientFactor = 1.50f; break;
}
}
else
if (SanderSpeedEffectUpToMpS > 0.0f) // Reduce sander effectiveness if max effective speed is defined
{
if (Sander) // If sander is on, and train speed is greater then zero, then put sand on the track
{
SandingFrictionCoefficientFactor = 1.50f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 150% adhesion (best case)
SandingFrictionCoefficientFactor *= (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS);
}
}
}
else if (Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
SandingFrictionCoefficientFactor = 1.50f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 150% adhesion (best case)
}
}
else if (Simulator.WeatherType == WeatherType.Rain)
{
if (AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && (AbsSpeedMpS > 0))
{
if (SanderSpeedEffectUpToMpS > 0.0f)
{
if ((Sander) && (AbsSpeedMpS < SanderSpeedEffectUpToMpS))
{
SandingFrictionCoefficientFactor = (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 1.25f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor;

}
}
else
{
if (Sander) // If sander is on, and train speed is greater then zero, then put sand on the track
{
SandingFrictionCoefficientFactor = 1.25f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 125% adhesion (best case)
}
}
}
else if (Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
SandingFrictionCoefficientFactor = 1.25f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 125% adhesion (best case)
}
}
else // dry weather
{
if (AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && (AbsSpeedMpS > 0))
{
if (SanderSpeedEffectUpToMpS > 0.0f)
{
if ((Sander) && (AbsSpeedMpS < SanderSpeedEffectUpToMpS))
{
SandingFrictionCoefficientFactor = (1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS) * 1.40f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor;
}
}
else
{
if (Sander) // If sander is on, and train speed is greater then zero, then put sand on the track
{
SandingFrictionCoefficientFactor = 1.40f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 140% adhesion (best case)
}
}
}
else if (Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0)
{
SandingFrictionCoefficientFactor = 1.40f;
BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor; // Sanding track adds approx 140% adhesion (best case)
}

BaseFrictionCoefficientFactor *= Math.Max(SandingFrictionCoefficientFactor, 1.0f); // Prevent sand from harming adhesion above max effective speed
}

// For wagons use base Curtius-Kniffler adhesion factor - u = 0.33
Expand Down Expand Up @@ -3282,7 +3202,7 @@ public void UpdateTrackSander(float elapsedClockSeconds)
// The following assumptions have been made:
//

if (Sander) // If sander is on adjust parameters
if (Sander && AbsSpeedMpS < SanderSpeedOfMpS) // If sander switch is on, and not blocked by speed, adjust parameters
{
if (CurrentTrackSandBoxCapacityM3 > 0.0) // if sand still in sandbox then sanding is available
{
Expand Down

0 comments on commit 9ec450a

Please sign in to comment.