Skip to content

Commit 56bb992

Browse files
committed
Correct water gauge level representation
1 parent 625c917 commit 56bb992

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7177,22 +7177,16 @@ private void UpdateWaterGauge()
71777177
// water variation is calculated as the opposite side of a triangle with half the boiler length as the reference length (Adjacent side)
71787178
var waterVariationLevelM = (float)Math.Tan(boilerangleRad) * (BoilerLengthM / 2.0f);
71797179

7180-
float glassLevelGradientM = 0;
7181-
71827180
// Downslope - CurrentElevationPercent = +ve, level variation will be -ve
71837181
// Uphill - CurrentElevationPercent = -ve, level variation will be +ve
71847182
// So, for example, if the loco is on a 1 in 100 down slope, the water level at the front of the boiler will be lower than at the
71857183
// back by 0.5% of the boiler length
71867184

71877185
// gradient variation due to slope needs to be reversed
7188-
glassLevelGradientM = waterVariationLevelM * -1.0f;
7189-
7190-
// Assume that reference glass height is 50% of glass
7191-
var maxWaterVariationIN = Me.ToIn(WaterGlassLengthM) / 2.0f;
7186+
waterVariationLevelM *= -1.0f;
71927187

71937188
float currentglasslevelfraction = 0;
7194-
float glasslevelM = 0;
7195-
7189+
71967190
// Convert reference point to a reading on glass
71977191
if (BoilerWaterFractionAbs > referenceBoilerLevelFraction)
71987192
{
@@ -7204,9 +7198,9 @@ private void UpdateWaterGauge()
72047198
currentglasslevelfraction = -1.0f * waterGlassFractionLevel;
72057199
}
72067200

7207-
glasslevelM = currentglasslevelfraction * BoilerDiameterM;
7201+
GradientBoilerLevelFraction = ((BoilerWaterFractionAbs + waterVariationLevelM / BoilerDiameterM) - WaterGlassMinLevel) / (WaterGlassMaxLevel - WaterGlassMinLevel); // Calculate water glass grade fraction
72087202

7209-
GradientBoilerLevelFraction = currentglasslevelfraction + (glassLevelGradientM / BoilerDiameterM);
7203+
GradientBoilerLevelFraction = MathHelper.Clamp(GradientBoilerLevelFraction, 0.0f, 1.0f);
72107204

72117205
if (BoilerWaterFractionAbs < WaterMinLevel) // Blow fusible plugs if absolute boiler water drops below minimum level
72127206
{

0 commit comments

Comments
 (0)