Skip to content

Commit d16ea96

Browse files
authored
Merge pull request #591 from cjakeman/menu-options02i
02i: Removed menu option ConditionalLoadOfDayOrNightTextures. Now always conditional.
2 parents f5b2085 + c3e0343 commit d16ea96

File tree

9 files changed

+47
-65
lines changed

9 files changed

+47
-65
lines changed
-11 KB
Loading

Source/Documentation/Manual/options.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,6 @@ When this option is selected, when OR is loading the shape (.s) files it
620620
will report errors in syntax and structure (even if these don't cause
621621
runtime errors) in the :ref:`Log file <driving-logfile>` ``OpenRailsLog.txt`` on the desktop.
622622

623-
Load day/night textures only when needed
624-
----------------------------------------
625-
626-
As a default OR loads night textures together with the day textures both at
627-
daytime and nighttime. When this option is selected, to reduce loading time and reduce
628-
memory used, night textures are not loaded in the daytime and are only
629-
loaded at sunset (if the game continues through sunset time); analogously day
630-
textures are not loaded in the nighttime if the related night textures are
631-
available, and are only loaded at sunrise (if the game continues through sunrise
632-
time).
633-
634623
Signal light glow
635624
-----------------
636625

Source/Menu/Options.Designer.cs

Lines changed: 18 additions & 31 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
@@ -316,7 +316,6 @@ orderby folder.Key
316316
numericPerformanceTunerTarget.Value = Settings.PerformanceTunerTarget;
317317
trackLODBias.Value = Settings.LODBias;
318318
trackLODBias_ValueChanged(null, null);
319-
checkConditionalLoadOfNightTextures.Checked = Settings.ConditionalLoadOfDayOrNightTextures;
320319
checkSignalLightGlow.Checked = Settings.SignalLightGlow;
321320
checkPreferDDSTexture.Checked = Settings.PreferDDSTexture;
322321
checkUseLocationPassingPaths.Checked = Settings.UseLocationPassingPaths;
@@ -509,7 +508,6 @@ void buttonOK_Click(object sender, EventArgs e)
509508
Settings.PerformanceTuner = checkPerformanceTuner.Checked;
510509
Settings.PerformanceTunerTarget = (int)numericPerformanceTunerTarget.Value;
511510
Settings.LODBias = trackLODBias.Value;
512-
Settings.ConditionalLoadOfDayOrNightTextures = checkConditionalLoadOfNightTextures.Checked;
513511
Settings.SignalLightGlow = checkSignalLightGlow.Checked;
514512
Settings.PreferDDSTexture = checkPreferDDSTexture.Checked;
515513
Settings.UseLocationPassingPaths = checkUseLocationPassingPaths.Checked;

Source/Menu/Options.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,4 @@
123123
<metadata name="bindingSourceContent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124124
<value>114, 17</value>
125125
</metadata>
126-
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127-
<value>17, 17</value>
128-
</metadata>
129126
</root>

Source/ORTS.Settings/UserSettings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ public enum DirectXFeature
324324
public bool AdhesionProportionalToWeather { get; set; }
325325
[Default(false)]
326326
public bool NoForcedRedAtStationStops { get; set; }
327-
[Default(false)]
328-
public bool ConditionalLoadOfDayOrNightTextures { get; set; }
329327
[Default(100)]
330328
public int PrecipitationBoxHeight { get; set; }
331329
[Default(500)]

Source/RunActivity/Viewer3D/Materials.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,21 +723,21 @@ public SceneryMaterial(Viewer viewer, string texturePath, SceneryMaterialOptions
723723
Texture = SharedMaterialManager.MissingTexture;
724724
NightTexture = SharedMaterialManager.MissingTexture;
725725
// <CSComment> if "trainset" is in the path (true for night textures for 3DCabs) deferred load of night textures is disabled
726-
if (!String.IsNullOrEmpty(texturePath) && (Options & SceneryMaterialOptions.NightTexture) != 0 && ((!viewer.DontLoadNightTextures && !viewer.DontLoadDayTextures)
726+
if (!String.IsNullOrEmpty(texturePath) && (Options & SceneryMaterialOptions.NightTexture) != 0 && ((!viewer.IsDaytime && !viewer.IsNighttime)
727727
|| TexturePath.Contains(@"\trainset\")))
728728
{
729729
var nightTexturePath = Helpers.GetNightTextureFile(Viewer.Simulator, texturePath);
730730
if (!String.IsNullOrEmpty(nightTexturePath))
731731
NightTexture = Viewer.TextureManager.Get(nightTexturePath.ToLower());
732732
Texture = Viewer.TextureManager.Get(texturePath, true);
733733
}
734-
else if ((Options & SceneryMaterialOptions.NightTexture) != 0 && viewer.DontLoadNightTextures)
734+
else if ((Options & SceneryMaterialOptions.NightTexture) != 0 && viewer.IsDaytime)
735735
{
736736
viewer.NightTexturesNotLoaded = true;
737737
Texture = Viewer.TextureManager.Get(texturePath, true);
738738
}
739739

740-
else if ((Options & SceneryMaterialOptions.NightTexture) != 0 && viewer.DontLoadDayTextures)
740+
else if ((Options & SceneryMaterialOptions.NightTexture) != 0 && viewer.IsNighttime)
741741
{
742742
var nightTexturePath = Helpers.GetNightTextureFile(Viewer.Simulator, texturePath);
743743
if (!String.IsNullOrEmpty(nightTexturePath))

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,7 @@ public SceneryDrawer(Viewer viewer)
7777
public void Load()
7878
{
7979
var cancellation = Viewer.LoaderProcess.CancellationToken;
80-
Viewer.DontLoadNightTextures = (Program.Simulator.Settings.ConditionalLoadOfDayOrNightTextures &&
81-
((Viewer.MaterialManager.sunDirection.Y > 0.05f && Program.Simulator.ClockTime % 86400 < 43200) ||
82-
(Viewer.MaterialManager.sunDirection.Y > 0.15f && Program.Simulator.ClockTime % 86400 >= 43200))) ? true : false;
83-
Viewer.DontLoadDayTextures = (Program.Simulator.Settings.ConditionalLoadOfDayOrNightTextures &&
84-
((Viewer.MaterialManager.sunDirection.Y < -0.05f && Program.Simulator.ClockTime % 86400 >= 43200) ||
85-
(Viewer.MaterialManager.sunDirection.Y < -0.15f && Program.Simulator.ClockTime % 86400 < 43200))) ? true : false;
80+
8681
if (TileX != VisibleTileX || TileZ != VisibleTileZ)
8782
{
8883
TileX = VisibleTileX;
@@ -113,7 +108,7 @@ public void Load()
113108
Viewer.tryLoadingNightTextures = true; // when Tiles loaded change you can try
114109
Viewer.tryLoadingDayTextures = true; // when Tiles loaded change you can try
115110
}
116-
else if (Viewer.NightTexturesNotLoaded && Program.Simulator.ClockTime % 86400 >= 43200 && Viewer.tryLoadingNightTextures)
111+
else if (Viewer.NightTexturesNotLoaded && !Viewer.IsBeforeNoon && Viewer.tryLoadingNightTextures)
117112
{
118113
var sunHeight = Viewer.MaterialManager.sunDirection.Y;
119114
if (sunHeight < 0.10f && sunHeight > 0.01)
@@ -133,7 +128,7 @@ public void Load()
133128
else if (sunHeight <= 0.01)
134129
Viewer.NightTexturesNotLoaded = false; // too late to try, we must give up and we don't load the night textures
135130
}
136-
else if (Viewer.DayTexturesNotLoaded && Program.Simulator.ClockTime % 86400 < 43200 && Viewer.tryLoadingDayTextures)
131+
else if (Viewer.DayTexturesNotLoaded && Viewer.IsBeforeNoon && Viewer.tryLoadingDayTextures)
137132
{
138133
var sunHeight = Viewer.MaterialManager.sunDirection.Y;
139134
if (sunHeight > -0.10f && sunHeight < -0.01)

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,30 @@ enum VisibilityState
217217
public float CabTextureInverseRatio = 0.75f; // default of inverse of cab texture ratio
218218

219219
public CommandLog Log { get { return Simulator.Log; } }
220+
public bool IsBeforeNoon
221+
{
222+
get
223+
{
224+
return Program.Simulator.ClockTime % 86400 < 43200;
225+
}
226+
}
220227

221-
public bool DontLoadNightTextures; // Checkbox set and time of day allows not to load textures
222-
public bool DontLoadDayTextures; // Checkbox set and time of day allows not to load textures
228+
public bool IsDaytime // After dawn and before dusk, so definitely daytime
229+
{
230+
get
231+
{
232+
return (MaterialManager.sunDirection.Y > 0.05f && IsBeforeNoon)
233+
|| (MaterialManager.sunDirection.Y > 0.15f && !IsBeforeNoon);
234+
}
235+
}
236+
public bool IsNighttime // Before dawn and after dusk, so definitely nighttime
237+
{
238+
get
239+
{
240+
return (MaterialManager.sunDirection.Y < -0.05f && !IsBeforeNoon)
241+
|| (MaterialManager.sunDirection.Y < -0.15f && IsBeforeNoon);
242+
}
243+
}
223244
public bool NightTexturesNotLoaded; // At least one night texture hasn't been loaded
224245
public bool DayTexturesNotLoaded; // At least one day texture hasn't been loaded
225246
public ulong LoadMemoryThreshold; // Above this threshold loader doesn't bulk load day or night textures
@@ -509,11 +530,8 @@ internal void Initialize()
509530
// This ensures that a) we have all the required objects loaded when the 3D view first appears and b) that
510531
// all loading is performed on a single thread that we can handle in debugging and tracing.
511532
World.LoadPrep();
512-
if (Simulator.Settings.ConditionalLoadOfDayOrNightTextures) // We need to compute sun height only in this case
513-
{
514533
MaterialManager.LoadPrep();
515534
LoadMemoryThreshold = (ulong)HUDWindow.GetVirtualAddressLimit() - 512 * 1024 * 1024;
516-
}
517535
Load();
518536

519537
// MUST be after loading is done! (Or we try and load shapes on the main thread.)

0 commit comments

Comments
 (0)