Skip to content

Commit 8b269d8

Browse files
authored
Merge pull request #533 from cjakeman/fix-for-hidden-shapes
fix for shapes hidden by animations( 0 )
2 parents 7881a1a + ce89a06 commit 8b269d8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
463463
if (Program.Simulator.CarSpawnerLists != null && ((CarSpawnerObj)worldObject).ListName != null)
464464
{
465465
((CarSpawnerObj)worldObject).CarSpawnerListIdx = Program.Simulator.CarSpawnerLists.FindIndex(x => x.ListName == ((CarSpawnerObj)worldObject).ListName);
466-
if (((CarSpawnerObj)worldObject).CarSpawnerListIdx < 0 || ((CarSpawnerObj)worldObject).CarSpawnerListIdx > Program.Simulator.CarSpawnerLists.Count-1)
466+
if (((CarSpawnerObj)worldObject).CarSpawnerListIdx < 0 || ((CarSpawnerObj)worldObject).CarSpawnerListIdx > Program.Simulator.CarSpawnerLists.Count - 1)
467467
((CarSpawnerObj)worldObject).CarSpawnerListIdx = 0;
468468
}
469-
else
469+
else
470470
((CarSpawnerObj)worldObject).CarSpawnerListIdx = 0;
471471
carSpawners.Add(new RoadCarSpawner(viewer, worldMatrix, (CarSpawnerObj)worldObject));
472472
}
@@ -480,9 +480,13 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480480
}
481481
else if (worldObject.GetType() == typeof(StaticObj))
482482
{
483-
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
483+
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
484484
StaticShape preTestShape = (new StaticShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
485-
var animNodes = preTestShape.SharedShape.Animations?[0]?.anim_nodes ?? new List<anim_node>();
485+
486+
// FirstOrDefault() checks for "animations( 0 )" as this is a valid entry in *.s files
487+
// and is included by MSTSexporter for Blender 2.8+ Release V4.0 or older
488+
var animNodes = preTestShape.SharedShape.Animations?.FirstOrDefault()?.anim_nodes ?? new List<anim_node>();
489+
486490
var isAnimatedClock = animNodes.Exists(node => Regex.IsMatch(node.Name, @"^orts_[hmsc]hand_clock", RegexOptions.IgnoreCase));
487491
if (isAnimatedClock)
488492
{

0 commit comments

Comments
 (0)