Skip to content

Commit 1b0a451

Browse files
committed
Automatic merge of T1.5.1-1090-g9915d87ce6 and 21 pull requests
- Pull request #891 at 9a1d6b2: Auto save - Pull request #903 at 4a4b032: Downloading route content (Github, zip) - Pull request #959 at 2452cb0: Fix TrackViewer crash on big zoom value - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #976 at 877cc94: Increased center of gravity range - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #882 at 8f695a4: Blueprint/train car operations UI window - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #922 at a3bc9e7: Autopilot for timetable mode - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 8b2d4ca: Multiple Track Profiles & Superelevation Improvements - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #970 at 6fa5eed: feat: Remove unnecessary Windows.Forms usage - Pull request #973 at c35be87: fix: Using singular target framework to allow for different platforms across different projects - Pull request #974 at 5faea6f: Bug fix for https://bugs.launchpad.net/or/+bug/2076034 Doors remain open in AI trains - Pull request #977 at a30c659: adds cache for SD files - Pull request #978 at 91f3ee8: fix: adds MilepostUnitsMiles to Manual - Pull request #900 at c27f32d: DMI updates - Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #952 at 8347095: Investigation - Pulsing graphics
23 parents aa75d5d + 9915d87 + 9a1d6b2 + 4a4b032 + 2452cb0 + e90a2aa + 877cc94 + d00beb9 + 8f695a4 + 1f5ba4c + a3bc9e7 + a519452 + 8b2d4ca + 46d0472 + 6fa5eed + c35be87 + 5faea6f + a30c659 + 91f3ee8 + c27f32d + dfc715e + f92de76 + 8347095 commit 1b0a451

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

Source/Orts.Formats.Msts/TrackDatabaseFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,11 @@ public class TrVectorSection
788788

789789
/// <summary>Interpolator storing the amount of physics superelevation in meters vs distance along
790790
/// the track section normalized from 0 to 1.</summary>
791-
public Interpolator PhysElevTable;
791+
public Interpolator PhysElevTable = new Interpolator(new float[] { 0, 1 }, new float[] { 0, 0 });
792792

793793
/// <summary>Interpolator storing the angle of visual superelevation in radians vs distance along
794794
/// the track section normalized from 0 to 1.</summary>
795-
public Interpolator VisElevTable;
795+
public Interpolator VisElevTable = new Interpolator(new float[] { 0, 1 }, new float[] { 0, 0 });
796796
/// <summary>Nominal amount of superelevation based on speed and radius.
797797
/// Actual superelevation used will depend on adjacent curves and superelevation settings.</summary>
798798
public float NomElevM { get; set; } = -1.0f;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ public void ComputePosition(Traveller traveler, bool backToFront, float elapsedT
28302830
if (-.2 < d && d < .2)
28312831
continue;
28322832
// Add a fake "wheel" to serve as a pivot point
2833-
p.AddWheelSetLocation(1, p.OffsetM, p0.Pos[0] + p.OffsetM * p0.Dir[0], p0.Pos[1] + p.OffsetM * p0.Dir[1], p0.Pos[2] + p.OffsetM * p0.Dir[2], 0);
2833+
p.AddWheelSetLocation(1, p.OffsetM, p0.Pos[0] + p.OffsetM * p0.Dir[0], p0.Pos[1] + p.OffsetM * p0.Dir[1], p0.Pos[2] + p.OffsetM * p0.Dir[2], p.Roll);
28342834
p.FindCenterLine();
28352835
}
28362836
}

Source/Orts.Simulation/Simulation/SuperElevation.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public SuperElevation(Simulator simulator)
9090
}
9191
else if (curveDir != Math.Sign(sec.SectionCurve.Angle)) // we are in curve, but bending different dir
9292
{
93-
MarkSections(simulator, sectionList, curveLen, sectionLengths); // treat the sections encountered so far, then restart with other dir
93+
MarkSections(simulator, sectionList, curveLen, sectionLengths, curveDir); // treat the sections encountered so far, then restart with other dir
9494
curveDir = Math.Sign(sec.SectionCurve.Angle);
9595
sectionList.Clear();
9696
sectionLengths.Clear();
@@ -104,7 +104,7 @@ public SuperElevation(Simulator simulator)
104104
{
105105
if (startCurve == true) // we are in a curve, need to finish
106106
{
107-
MarkSections(simulator, sectionList, curveLen, sectionLengths);
107+
MarkSections(simulator, sectionList, curveLen, sectionLengths, curveDir);
108108
curveLen = 0f;
109109
sectionList.Clear();
110110
sectionLengths.Clear();
@@ -126,16 +126,23 @@ public SuperElevation(Simulator simulator)
126126
}
127127
if (startCurve == true) // we are in a curve after looking at every section
128128
{
129-
MarkSections(simulator, sectionList, curveLen, sectionLengths);
129+
MarkSections(simulator, sectionList, curveLen, sectionLengths, curveDir);
130130
}
131131
sectionList.Clear();
132132
}
133133
}
134134

135-
void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float totLen, List<float> lengths)
135+
void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float totLen, List<float> lengths, int direction)
136136
{
137-
if (totLen < simulator.SuperElevationMinLen || SectionList.Count == 0)
138-
return; // Ignore curves too short or invalid data
137+
if (SectionList.Count <= 0)
138+
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+
}
139146

140147
// The superelevation standard we will use. null means no superelevation
141148
SuperElevationStandard standard = null;
@@ -218,9 +225,8 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
218225
}
219226
else // No superelevation needed (shouldn't reach this point, this is a failsafe)
220227
superElevation = 0.0f;
221-
222-
SectionList[i].NomElevM = superElevation;
223228
}
229+
SectionList[i].NomElevM = superElevation;
224230
}
225231
}
226232
}
@@ -325,6 +331,9 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
325331
// Visual superelevation is stored in terms of angle in radians rather than meters
326332
float[] angles = elevations.Select(e => (float)Math.Asin(e / simulator.SuperElevationGauge)).ToArray();
327333
SectionList[count].VisElevTable = new Interpolator(SectionList[count].PhysElevTable.X, angles);
334+
// Invert visual elevation values based on curve direction
335+
// direction is negated for consistency of direction sense in other places
336+
SectionList[count].VisElevTable.ScaleY(-direction);
328337

329338
accumulatedLength += lengths[count];
330339
count++;

Source/Orts.Simulation/Simulation/Traveller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ public float GetVisualElevation(bool useVisualElev = true)
10411041
{
10421042
visualElev = trackVectorSection.VisElevTable[to];
10431043
// Correct the direction of tilt for the direction of travel
1044-
visualElev *= Math.Sign(trackSection.SectionCurve.Angle) > 0 ^ direction == TravellerDirection.Backward ? -1 : 1;
1044+
visualElev *= direction == TravellerDirection.Backward ? -1 : 1;
10451045
}
10461046
else
10471047
visualElev = 0;

Source/RunActivity/Viewer3D/SuperElevation.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,9 @@ public SuperElevationPrimitive(Viewer viewer, WorldPosition worldPosition,
646646

647647
Matrix PreRotation = Matrix.Identity;
648648
Elevated = ElevAngles[0];
649-
if (Elevated > 0.0f) // Section starts in a curve; first cross section needs to be rotated
649+
if (Math.Abs(Elevated) > 0.0f) // Section starts in a curve; first cross section needs to be rotated
650650
{
651-
PreRotation = Matrix.CreateRotationZ(-Elevated * Math.Sign(DTrackData.param1));
651+
PreRotation = Matrix.CreateRotationZ(Elevated);
652652
PrevRotation = Elevated;
653653
}
654654

@@ -660,7 +660,7 @@ public SuperElevationPrimitive(Viewer viewer, WorldPosition worldPosition,
660660
{
661661
tmp = new Vector3(v.Position.X, v.Position.Y, v.Position.Z);
662662

663-
if (Elevated > 0.0f)
663+
if (Math.Abs(Elevated) > 0.0f)
664664
{
665665
tmp -= RollOffset;
666666
tmp = Vector3.Transform(tmp, PreRotation);
@@ -684,8 +684,6 @@ public SuperElevationPrimitive(Viewer viewer, WorldPosition worldPosition,
684684
CurrentRotation = DetermineRotation();
685685
Elevated = CurrentRotation - PrevRotation;
686686
PrevRotation = CurrentRotation;
687-
if (DTrackData.param1 > 0)
688-
Elevated *= -1;
689687

690688
foreach (Polyline pl in lodItem.Polylines)
691689
{
@@ -837,7 +835,7 @@ void CircArcGen()
837835
public float DetermineRotation()
838836
{
839837
float to = (Offset + 1f) / NumSections;
840-
838+
841839
return ElevAngles[to];
842840
}
843841
}

0 commit comments

Comments
 (0)