Skip to content

Commit 9e18ed1

Browse files
committed
Animated Clocks recognized by ClockHands without extern Files
1 parent b536b92 commit 9e18ed1

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
327327

328328
var shadowCaster = (worldObject.StaticFlags & (uint)StaticFlag.AnyShadow) != 0 || viewer.Settings.ShadowAllShapes;
329329
var animated = (worldObject.StaticFlags & (uint)StaticFlag.Animate) != 0;
330-
var isAnalogClock = GetClockType(worldObject.FileName) == ClockType.Analog;
330+
var isAnimatedClock = false; //Declare and preset shape is not an animated clock
331331
var global = (worldObject is TrackObj) || (worldObject is HazardObj) || (worldObject.StaticFlags & (uint)StaticFlag.Global) != 0;
332332

333333
// TransferObj have a FileName but it is not a shape, so we need to avoid sanity-checking it as if it was.
@@ -480,7 +480,28 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480480
}
481481
else if (worldObject.GetType() == typeof(StaticObj))
482482
{
483-
if (isAnalogClock)
483+
isAnimatedClock = false; //Preset
484+
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
485+
StaticShape preTestShape = (new StaticShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
486+
if (preTestShape.SharedShape.Animations != null) // shape has an Animation at all
487+
{
488+
if (preTestShape.SharedShape.Animations[0].anim_nodes.Count > 1) // shape has more than 1 anim node
489+
{
490+
//lookup in all anim nodes of the shape for subobjects named as clock hands
491+
foreach (var animNodes in preTestShape.SharedShape.Animations[0].anim_nodes)
492+
{
493+
if (animNodes.Name.ToLowerInvariant().IndexOf("hand_clock") == 6) //Shape anim node name contains "hand_clock"
494+
{
495+
if (animNodes.Name.ToLowerInvariant().IndexOf("orts_") == 0) //Shape anim node name begins with "ORTS_"
496+
{
497+
isAnimatedClock = true; //Shape is animated clock
498+
break; //Exit because of find a clock hand subobject
499+
}
500+
}
501+
}
502+
}
503+
}
504+
if (isAnimatedClock)
484505
{
485506
sceneryObjects.Add(new AnalogClockShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
486507
}

0 commit comments

Comments
 (0)