Skip to content

Commit 6fe110b

Browse files
committed
Automatic merge of T1.5.1-1088-g264349b1ce and 21 pull requests
- Pull request #891 at 9a1d6b2: Auto save - 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 #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 #975 at b2dd5c0: Bug fix for https://bugs.launchpad.net/or/+bug/2076133 Crash when AI train dissolves near camera - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 9dabe97: Downloading route content (Github, zip) - 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 #946 at 91a03af: Advanced track sounds - Pull request #952 at 8347095: Investigation - Pulsing graphics - Pull request #968 at a88cb26: Initial build of adding track section identifier for rack railway
23 parents 51aadb2 + 264349b + 9a1d6b2 + 2452cb0 + e90a2aa + 877cc94 + d00beb9 + 8f695a4 + 1f5ba4c + a3bc9e7 + a519452 + 46d0472 + 6fa5eed + c35be87 + 5faea6f + b2dd5c0 + c27f32d + 9dabe97 + dfc715e + f92de76 + 91a03af + 8347095 + a88cb26 commit 6fe110b

File tree

8 files changed

+57
-363
lines changed

8 files changed

+57
-363
lines changed
Binary file not shown.

Source/Orts.Formats.Msts/TrackDatabaseFile.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,6 @@ public class TrVectorSection
794794

795795
/// <summary>??? (needed for ActivityEditor, but not used here, so why is it defined here?)</summary>
796796
public bool Reduced { get; set; }
797-
/// <summary>The index of the track profile suitable for this section</summary>
798-
public int TRPIndex { get; set; } = -1;
799797

800798
/// <summary>
801799
/// Default constructor used during file parsing.

Source/RunActivity/Viewer3D/DynamicTrack.cs

Lines changed: 36 additions & 316 deletions
Large diffs are not rendered by default.

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,6 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
300300
}
301301
}
302302

303-
// Generate track profiles if none have been set up yet
304-
if (viewer.TRPs == null)
305-
{
306-
Trace.Write(" TRP");
307-
// Creates profile and loads materials into SceneryMaterials
308-
TRPFile.CreateTrackProfile(viewer, viewer.Simulator.RoutePath, out viewer.TRPs);
309-
}
310-
311303
// create all the individual scenery objects specified in the WFile
312304
foreach (var worldObject in WFile.Tr_Worldfile)
313305
{
@@ -375,8 +367,7 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
375367
// We might not have found the junction node; if so, fall back to the static track shape.
376368
if (trJunctionNode != null)
377369
{
378-
if (viewer.Simulator.UseSuperElevation > 0)
379-
SuperElevationManager.DecomposeStaticSuperElevation(viewer, dTrackList, trackObj, worldMatrix, TileX, TileZ, shapeFilePath);
370+
if (viewer.Simulator.UseSuperElevation > 0) SuperElevationManager.DecomposeStaticSuperElevation(viewer, dTrackList, trackObj, worldMatrix, TileX, TileZ, shapeFilePath);
380371
sceneryObjects.Add(new SwitchTrackShape(viewer, shapeFilePath, worldMatrix, trJunctionNode));
381372
}
382373
else
@@ -385,14 +376,15 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
385376
if (viewer.Simulator.UseSuperElevation > 0
386377
&& SuperElevationManager.DecomposeStaticSuperElevation(viewer, dTrackList, trackObj, worldMatrix, TileX, TileZ, shapeFilePath))
387378
{
388-
// No need to add shapes for this segment of track
379+
//var success = SuperElevation.DecomposeStaticSuperElevation(viewer, dTrackList, trackObj, worldMatrix, TileX, TileZ, shapeFilePath);
380+
//if (success == 0) sceneryObjects.Add(new StaticTrackShape(viewer, shapeFilePath, worldMatrix));
389381
}
390382
//otherwise, use shapes
391383
else if (!containsMovingTable) sceneryObjects.Add(new StaticTrackShape(viewer, shapeFilePath, worldMatrix));
392384
else
393385
{
394386
var found = false;
395-
foreach (var movingTable in Program.Simulator.MovingTables)
387+
foreach (var movingTable in Program.Simulator. MovingTables)
396388
{
397389
if (worldObject.UID == movingTable.UID && WFileName == movingTable.WFile)
398390
{
@@ -428,14 +420,6 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
428420
}
429421
else if (worldObject.GetType() == typeof(DyntrackObj))
430422
{
431-
if (viewer.TRPs == null)
432-
{
433-
// First to need a track profile creates it
434-
Trace.Write(" TRP");
435-
// Creates profile and loads materials into SceneryMaterials
436-
TRPFile.CreateTrackProfile(viewer, viewer.Simulator.RoutePath, out viewer.TRPs);
437-
}
438-
439423
if (viewer.Simulator.Settings.Wire == true && viewer.Simulator.TRK.Tr_RouteFile.Electrified == true)
440424
Wire.DecomposeDynamicWire(viewer, dTrackList, (DyntrackObj)worldObject, worldMatrix);
441425
// Add DyntrackDrawers for individual subsections

Source/RunActivity/Viewer3D/Shapes.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,6 @@ public class SharedShape : IDisposable
19661966

19671967
// This data is common to all instances of the shape
19681968
public List<string> MatrixNames = new List<string>();
1969-
public List<string> ImageNames; // Names of textures without paths or file extensions
19701969
public Matrix[] Matrices = new Matrix[0]; // the original natural pose for this shape - shared by all instances
19711970
public animations Animations;
19721971
public LodControl[] LodControls;
@@ -2051,8 +2050,6 @@ void LoadContent()
20512050
}
20522051
Animations = sFile.shape.animations;
20532052

2054-
ImageNames = new List<string>(sFile.shape.images.ConvertAll(img => Path.GetFileNameWithoutExtension(img)));
2055-
20562053
#if DEBUG_SHAPE_HIERARCHY
20572054
var debugShapeHierarchy = new StringBuilder();
20582055
debugShapeHierarchy.AppendFormat("Shape {0}:\n", Path.GetFileNameWithoutExtension(FilePath).ToUpper());

Source/RunActivity/Viewer3D/SuperElevation.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
using ORTS.Common;
2525
using System;
2626
using System.Collections.Generic;
27-
using System.IO;
27+
using System.Diagnostics;
2828

2929
namespace Orts.Viewer3D
3030
{
@@ -85,11 +85,6 @@ public static bool DecomposeStaticSuperElevation(Viewer viewer, List<DynamicTrac
8585
}
8686
sectionsinShape.Add(tmp);
8787

88-
// Determine the track profile to use for this section
89-
// It's possible that the tsection ID used by the track section points to the wrong shape
90-
// Instead, send the shape file path to ensure the correct shape is used in calculations
91-
DynamicTrackViewer.GetBestTrackProfile(viewer, tmp, shapeFilePath);
92-
9388
drawn++;
9489
}
9590
}
@@ -160,13 +155,12 @@ public static int DecomposeStaticSuperElevationOneSection(Viewer viewer, List<Dy
160155
sv = ev = mv = 0f; dir = 1f;
161156
sv = ts.StartElev; ev = ts.EndElev; mv = ts.MaxElev;
162157

163-
int trpIndex = ts.TRPIndex < 0 ? DynamicTrackViewer.GetBestTrackProfile(viewer, ts) : ts.TRPIndex;
164-
165158
//nextRoot.XNAMatrix.Translation += Vector3.Transform(trackLoc, worldMatrix.XNAMatrix);
166-
dTrackList.Add(new SuperElevationViewer(viewer, root, nextRoot, tss.SectionCurve.Radius, tss.SectionCurve.Angle * 3.14f / 180, sv, ev, mv, dir, trpIndex));
159+
dTrackList.Add(new SuperElevationViewer(viewer, root, nextRoot, tss.SectionCurve.Radius, tss.SectionCurve.Angle * 3.14f / 180, sv, ev, mv, dir));
167160
return 1;
168161
}
169162

163+
//no use anymore
170164
public static int DecomposeStaticSuperElevation(Viewer viewer, List<DynamicTrackViewer> dTrackList, int TileX, int TileZ)
171165
{
172166
var key = (int)(Math.Abs(TileX) + Math.Abs(TileZ));
@@ -209,10 +203,8 @@ public static int DecomposeStaticSuperElevation(Viewer viewer, List<DynamicTrack
209203
dir = 1f;
210204
sv = ts.StartElev; ev = ts.EndElev; mv = ts.MaxElev;
211205

212-
int trpIndex = ts.TRPIndex < 0 ? DynamicTrackViewer.GetBestTrackProfile(viewer, ts) : ts.TRPIndex;
213-
214206
//nextRoot.XNAMatrix.Translation += Vector3.Transform(trackLoc, worldMatrix.XNAMatrix);
215-
dTrackList.Add(new SuperElevationViewer(viewer, root, nextRoot, tss.SectionCurve.Radius, tss.SectionCurve.Angle * 3.14f / 180, sv, ev, mv, dir, trpIndex));
207+
dTrackList.Add(new SuperElevationViewer(viewer, root, nextRoot, tss.SectionCurve.Radius, tss.SectionCurve.Angle * 3.14f / 180, sv, ev, mv, dir));
216208
}
217209
return 1;
218210
}
@@ -493,19 +485,19 @@ public static bool UseSuperElevationDyn(Viewer viewer, List<DynamicTrackViewer>
493485
public class SuperElevationViewer : DynamicTrackViewer
494486
{
495487
public SuperElevationViewer(Viewer viewer, WorldPosition position, WorldPosition endPosition, float radius, float angle,
496-
float s, float e, float m, float dir, int trpIndex = 0)//values for start, end and max elevation
488+
float s, float e, float m, float dir)//values for start, end and max elevation
497489
: base(viewer, position, endPosition)
498490
{
499491
// Instantiate classes
500-
Primitive = new SuperElevationPrimitive(viewer, position, endPosition, radius, angle, s, e, m, dir, trpIndex);
492+
Primitive = new SuperElevationPrimitive(viewer, position, endPosition, radius, angle, s, e, m, dir);
501493
}
502494
}
503495

504496
public class SuperElevationPrimitive : DynamicTrackPrimitive
505497
{
506498
float StartElev, MaxElev, EndElv;
507499
public SuperElevationPrimitive(Viewer viewer, WorldPosition worldPosition,
508-
WorldPosition endPosition, float radius, float angle, float s, float e, float m, float dir, int trpIndex = 0)
500+
WorldPosition endPosition, float radius, float angle, float s, float e, float m, float dir)
509501
: base()
510502
{
511503
StartElev = s; EndElv = e; MaxElev = m;
@@ -535,7 +527,14 @@ public SuperElevationPrimitive(Viewer viewer, WorldPosition worldPosition,
535527
}
536528
DTrackData.deltaY = 0;
537529

538-
TrProfile = viewer.TRPs[trpIndex].TrackProfile;
530+
if (viewer.TRP == null)
531+
{
532+
// First to need a track profile creates it
533+
Trace.Write(" TRP");
534+
// Creates profile and loads materials into SceneryMaterials
535+
TRPFile.CreateTrackProfile(viewer, viewer.Simulator.RoutePath, out viewer.TRP);
536+
}
537+
TrProfile = viewer.TRP.TrackProfile;
539538

540539
XNAEnd = endPosition.XNAMatrix.Translation;
541540

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ void CameraActivate()
203203

204204
public bool SoundDebugFormEnabled { get; set; }
205205

206-
public List<TRPFile> TRPs; // Track profile file(s)
207-
// Dictionary associating a specific shape file name (string) with the track profile index to be used for that shape
208-
// Shape file names are to be matched ignoring case for simplicity
209-
public Dictionary<string, int> TrackProfileIndicies = new Dictionary<string, int>(StringComparer.InvariantCultureIgnoreCase);
206+
public TRPFile TRP; // Track profile file
210207

211208
enum VisibilityState
212209
{

Source/RunActivity/Viewer3D/World.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public void Load()
116116
Precipitation.Mark();
117117
Terrain.Mark();
118118
Scenery.Mark();
119-
foreach (TRPFile trp in Viewer.TRPs)
120-
trp.TrackProfile?.Mark();
119+
Viewer.TRP?.TrackProfile?.Mark();
121120
Trains.Mark();
122121
RoadCars.Mark();
123122
Containers.Mark();

0 commit comments

Comments
 (0)