Skip to content

Commit 53e9cc6

Browse files
committed
Deprecate superelevation minimum length setting, calculate minimum length on the fly, fix static consist superelevation
1 parent 3caecc7 commit 53e9cc6

File tree

6 files changed

+16
-66
lines changed

6 files changed

+16
-66
lines changed

Source/Menu/Options.Designer.cs

Lines changed: 3 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/Options.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ orderby folder.Key
326326

327327
// Experimental tab
328328
numericUseSuperElevation.Value = Settings.UseSuperElevation;
329-
numericSuperElevationMinLen.Value = Settings.SuperElevationMinLen;
330329
numericSuperElevationGauge.Value = Settings.SuperElevationGauge;
331330
trackLODBias.Value = Settings.LODBias;
332331
trackLODBias_ValueChanged(null, null);
@@ -517,7 +516,6 @@ void buttonOK_Click(object sender, EventArgs e)
517516

518517
// Experimental tab
519518
Settings.UseSuperElevation = (int)numericUseSuperElevation.Value;
520-
Settings.SuperElevationMinLen = (int)numericSuperElevationMinLen.Value;
521519
Settings.SuperElevationGauge = (int)numericSuperElevationGauge.Value;
522520
Settings.LODBias = trackLODBias.Value;
523521
Settings.SignalLightGlow = checkSignalLightGlow.Checked;

Source/ORTS.Settings/UserSettings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ public enum DirectXFeature
289289
// Experimental settings:
290290
[Default(0)]
291291
public int UseSuperElevation { get; set; }
292-
[Default(50)]
293-
public int SuperElevationMinLen { get; set; }
294292
[Default(1435)]
295293
public int SuperElevationGauge { get; set; }
296294
[Default(0)]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,7 +4537,7 @@ public void RepositionRearTraveller()
45374537

45384538
// Position car based on MSTS position, and rotate based on superelevation
45394539
car.WorldPosition.XNAMatrix *= Simulator.XNAMatrixFromMSTSCoordinates(traveller.X, traveller.Y, traveller.Z, x, y, z);
4540-
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ(roll) * car.WorldPosition.XNAMatrix;
4540+
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ((car.Flipped ? -1.0f : 1.0f) * roll) * car.WorldPosition.XNAMatrix;
45414541

45424542
// note the railcar sits 0.275meters above the track database path TODO - is this always consistent?
45434543
float railOffset = 0.275f;
@@ -4670,7 +4670,7 @@ public void CalculatePositionOfCars(float elapsedTime, float distance)
46704670

46714671
// Position car based on MSTS position, and rotate based on superelevation
46724672
car.WorldPosition.XNAMatrix *= Simulator.XNAMatrixFromMSTSCoordinates(traveller.X, traveller.Y, traveller.Z, x, y, z);
4673-
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ(roll) * car.WorldPosition.XNAMatrix;
4673+
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ((car.Flipped ? -1.0f : 1.0f) * roll) * car.WorldPosition.XNAMatrix;
46744674

46754675
// note the railcar sits 0.275meters above the track database path TODO - is this always consistent?
46764676
float railOffset = 0.275f;
@@ -4763,7 +4763,7 @@ public void CalculatePositionOfEOT()
47634763

47644764
// Position car based on MSTS position, and rotate based on superelevation
47654765
car.WorldPosition.XNAMatrix *= Simulator.XNAMatrixFromMSTSCoordinates(traveller.X, traveller.Y, traveller.Z, x, y, z);
4766-
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ(roll) * car.WorldPosition.XNAMatrix;
4766+
car.WorldPosition.XNAMatrix = Matrix.CreateRotationZ((car.Flipped ? -1.0f : 1.0f) * roll) * car.WorldPosition.XNAMatrix;
47674767

47684768
// note the railcar sits 0.275meters above the track database path TODO - is this always consistent?
47694769
float railOffset = 0.275f;

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public class Simulator
130130
public int CarVibrating;
131131
public int UseSuperElevation; //amount of superelevation
132132
public SuperElevation SuperElevation;
133-
public int SuperElevationMinLen = 50;
134133
public float SuperElevationGauge = 1.435f;//1.435 guage
135134
public LoadStationsPopulationFile LoadStationsPopulationFile;
136135

@@ -274,7 +273,6 @@ public Simulator(UserSettings settings, string activityPath, bool useOpenRailsDi
274273
BreakCouplers = Settings.BreakCouplers;
275274
CarVibrating = Settings.CarVibratingLevel; //0 no vib, 1-2 mid vib, 3 max vib
276275
UseSuperElevation = Settings.UseSuperElevation;
277-
SuperElevationMinLen = Settings.SuperElevationMinLen;
278276
SuperElevationGauge = (float)Settings.SuperElevationGauge / 1000f;//gauge transfer from mm to m
279277
RoutePath = Path.GetDirectoryName(Path.GetDirectoryName(activityPath));
280278
if (useOpenRailsDirectory) RoutePath = Path.GetDirectoryName(RoutePath); // starting one level deeper!

Source/Orts.Simulation/Simulation/SuperElevation.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
136136
{
137137
if (SectionList.Count <= 0)
138138
return; // Avoid errors with invalid section lists
139-
else if (totLen < simulator.SuperElevationMinLen)
140-
{
141-
// Zero out any curves that are too short
142-
foreach (TrVectorSection s in SectionList)
143-
s.NomElevM = 0;
144-
return;
145-
}
146139

147140
// The superelevation standard we will use. null means no superelevation
148141
SuperElevationStandard standard = null;
@@ -178,7 +171,17 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
178171
}
179172

180173
if (standard == null)
174+
{
175+
foreach (TrVectorSection s in SectionList)
176+
s.NomElevM = 0;
181177
return; // No superelevation needed, stop processing here
178+
}
179+
if ((standard.MinCantM / effectiveRunoffSlope) * 2.0f > totLen * 0.75f)
180+
{
181+
foreach (TrVectorSection s in SectionList)
182+
s.NomElevM = 0;
183+
return; // Curve is so short that no meaningful superelevation can be applied
184+
}
182185

183186
// Determine proper level of superelevation for every section
184187
for (int i = 0; i < SectionList.Count; i++)

0 commit comments

Comments
 (0)