Skip to content

Commit 343a09e

Browse files
committed
Automatic merge of T1.5.1-687-gd279e384a and 10 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 67014b7: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #878 at 25f5e06: Implement Polach Adhesion - Pull request #882 at d8a1c4d: Blueprint/train car operations UI window - Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling - Pull request #885 at c81447b: feat: Add notifications to Menu
12 parents dda07f5 + d279e38 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + 25f5e06 + d8a1c4d + edcc2dd + c81447b commit 343a09e

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ public int ActivityDurationS
195195

196196
public bool HasControlCarWithGear = false;
197197

198-
public float ScreenFrameRate;
199-
200198
//To investigate coupler breaks on route
201199
private bool numOfCouplerBreaksNoted = false;
202200
public static int NumOfCouplerBreaks = 0;//Debrief Eval

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,6 @@ public virtual void AdvancedAdhesion(float elapsedClockSeconds)
27672767
axle.CurrentCurveRadiusM = CurrentCurveRadiusM;
27682768
axle.BogieRigidWheelBaseM = RigidWheelBaseM;
27692769
axle.CurtiusKnifflerZeroSpeed = ZeroSpeedAdhesionBase;
2770-
axle.ScreenFrameRate = Train.ScreenFrameRate;
27712770
}
27722771

27732772
LocomotiveAxles.Update(elapsedClockSeconds);

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,6 @@ public float TransmissionEfficiency
519519
/// </summary>
520520
public float CurtiusKnifflerZeroSpeed;
521521

522-
/// <summary>
523-
/// Simulator FPS
524-
/// </summary>
525-
public float ScreenFrameRate;
526-
527522
/// <summary>
528523
/// Wheel adhesion as calculated by Polach
529524
/// </summary>
@@ -863,6 +858,8 @@ void Integrate(float elapsedClockSeconds)
863858
float screenFrameUpperLimit = 60;
864859
float screenFrameLowerLimit = 40;
865860

861+
var ScreenFrameRate = Simulator.SmoothedFrameRate;
862+
866863
// Reduces the number of substeps if screen FPS drops below a nominal rate of 60 fps
867864
if ( (int)ScreenFrameRate >= screenFrameUpperLimit) // Screen FPS > 60, hold substeps @ maximum value
868865
{

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
using ORTS.Common;
3333
using ORTS.Scripting.Api;
3434
using ORTS.Settings;
35+
using SharpDX.MediaFoundation;
3536
using System;
3637
using System.Collections.Generic;
3738
using System.Diagnostics;
3839
using System.IO;
40+
using System.Runtime.Remoting.Messaging;
3941
using Event = Orts.Common.Event;
4042

4143
namespace Orts.Simulation
@@ -58,6 +60,20 @@ namespace Orts.Simulation
5860
/// </summary>
5961
public class Simulator
6062
{
63+
/// <summary>
64+
/// Sets the frame rate object so its value can be read from anywhere in the Simulator and used to tune simulation algorithms.
65+
/// </summary>
66+
/// <param name="frameRate"></param>
67+
public static void SetFrameRate(SmoothedData frameRate)
68+
{
69+
FrameRate = frameRate;
70+
}
71+
public static float SmoothedFrameRate
72+
{
73+
get { return FrameRate.SmoothedValue; }
74+
}
75+
private static SmoothedData FrameRate;
76+
6177
public static GettextResourceManager Catalog { get; private set; }
6278
public static Random Random { get; private set; }
6379
public static double Resolution = 1000000; // resolution for calculation of random value with a pseudo-gaussian distribution
@@ -1355,8 +1371,8 @@ private Train InitializePlayerTrain()
13551371
train.AITrainBrakePercent = 100; //<CSComment> This seems a tricky way for the brake modules to test if it is an AI train or not
13561372
train.EqualReservoirPressurePSIorInHg = prevEQres; // The previous command modifies EQ reservoir pressure, causing issues with EP brake systems, so restore to prev value
13571373

1358-
// if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1359-
// train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1374+
// if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1375+
// train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
13601376

13611377
return (train);
13621378
}
@@ -1432,8 +1448,8 @@ private AITrain InitializeAPPlayerTrain()
14321448

14331449
if (conFileName.Contains("tilted")) train.IsTilting = true;
14341450

1435-
// if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1436-
// train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1451+
// if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1452+
// train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
14371453

14381454
return train;
14391455
}
@@ -1487,7 +1503,7 @@ private void InitializeStaticConsists()
14871503

14881504
if (!File.Exists(wagonFilePath))
14891505
{
1490-
Trace.TraceWarning($"Ignored missing {(wagon.IsEngine? "engine" : "wagon")} {wagonFilePath} in activity definition {activityObject.Train_Config.TrainCfg.Name}");
1506+
Trace.TraceWarning($"Ignored missing {(wagon.IsEngine ? "engine" : "wagon")} {wagonFilePath} in activity definition {activityObject.Train_Config.TrainCfg.Name}");
14911507
continue;
14921508
}
14931509

Source/RunActivity/Viewer3D/Popups/HUDWindow.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,6 @@ void TextPageCommon(TableData table)
474474
TableAddLabelValue(table, Viewer.Catalog.GetString("FPS"), "{0:F0}", Viewer.RenderProcess.FrameRate.SmoothedValue);
475475
TableAddLine(table);
476476

477-
// Used in axle module to adjust substeps for frame rate drops
478-
var mstsLocomotive = Viewer.PlayerLocomotive as MSTSLocomotive;
479-
Viewer.PlayerTrain.ScreenFrameRate = Viewer.RenderProcess.FrameRate.SmoothedValue;
480-
481477
if (Viewer.PlayerLocomotive.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING)
482478
TableAddLine(table, Viewer.Catalog.GetString("Autopilot") + "???");
483479

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ public Viewer(Simulator simulator, Orts.Viewer3D.Processes.Game game)
366366
SpeedpostDatFile = new SpeedpostDatFile(Simulator.RoutePath + @"\speedpost.dat", Simulator.RoutePath + @"\shapes\");
367367
}
368368
}
369+
// So the frame rate can be read from anywhere in the Simulator and used to tune simulation algorithms.
370+
Simulator.SetFrameRate(this.RenderProcess.FrameRate);
369371

370372
Initialize();
371373
}

0 commit comments

Comments
 (0)