Skip to content

Commit fe2433b

Browse files
committed
Forgot check for MSTSFreightAnimEnabled
1 parent 40a9064 commit fe2433b

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Source/Documentation/Manual/features-rollingstock.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ no arguments are specified (ie: ``ORTSAutoSize ()`` was entered in the Wagon sec
439439
offsets are assumed to be 0 meters.
440440

441441
Note that automatic sizing uses the nearest LOD of the main shape file and attached freight animations. LODs for further
442-
distances have no effect on the automatic sizing. :ref:`Shape descriptor overrides <features-shape-manipulation>`
442+
distances have no effect on the automatic sizing. Freight animations using the ``ShapeHierarchy`` feature are also
443+
skipped due to potential unintended behaviors. :ref:`Shape descriptor overrides <features-shape-manipulation>`
443444
are also not considered at this phase, so if any changes are made in the .sd file, this feature may not provide
444445
good results. This method also works best for rolling stock with standard buffers/couplers on each end.
445446
Automatic sizing generally can't produce reasonable results for articulated rolling stock. And should something go

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,21 +460,14 @@ public virtual void LoadFromWagFile(string wagFilePath)
460460

461461
(Vector3 mainMins, Vector3 mainMaxes) = wagShape.GetBoundingLimits();
462462

463-
// Repeat for MSTS freight animation bounds
464-
if (!string.IsNullOrEmpty(FreightShapeFileName))
465-
{
466-
ShapeFile freightShape = new ShapeFile(wagonFolderSlash + FreightShapeFileName, true);
467-
468-
(Vector3 freightMins, Vector3 freightMaxes) = freightShape.GetBoundingLimits();
469-
470-
// MSTS freight animations don't have offsets, so can be simply compared
471-
mainMins = Vector3.Min(mainMins, freightMins);
472-
mainMaxes = Vector3.Max(mainMaxes, freightMaxes);
473-
}
463+
bool mstsFreightAnim = true;
474464

475465
// And also repeat for ORTS freight animations
476466
if (FreightAnimations != null)
477467
{
468+
if (!FreightAnimations.MSTSFreightAnimEnabled)
469+
mstsFreightAnim = false;
470+
478471
foreach (var freightAnim in FreightAnimations.Animations)
479472
{
480473
// We will ignore freight animations not attached to the main shape object for simplicity
@@ -512,6 +505,18 @@ public virtual void LoadFromWagFile(string wagFilePath)
512505
}
513506
}
514507

508+
// And also repeat for MSTS freight animation bounds (if enabled)
509+
if (mstsFreightAnim && !string.IsNullOrEmpty(FreightShapeFileName))
510+
{
511+
ShapeFile freightShape = new ShapeFile(wagonFolderSlash + FreightShapeFileName, true);
512+
513+
(Vector3 freightMins, Vector3 freightMaxes) = freightShape.GetBoundingLimits();
514+
515+
// MSTS freight animations don't have offsets, so can be simply compared
516+
mainMins = Vector3.Min(mainMins, freightMins);
517+
mainMaxes = Vector3.Max(mainMaxes, freightMaxes);
518+
}
519+
515520
// Set dimensions of wagon if configured as such
516521
if (AutoSize)
517522
{

0 commit comments

Comments
 (0)