Skip to content

Commit b1586ae

Browse files
author
carlossantucci
committed
Bug fix for https://bugs.launchpad.net/or/+bug/1810685 Animation of root matrix does not work.
git-svn-id: http://svn.uktrainsim.com/svn/openrails/trunk@4334 a9f3cfff-6c41-7446-b0ca-052bd761e6eb
1 parent 3baea56 commit b1586ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Source/RunActivity/Viewer3D/Shapes.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,13 @@ void LoadContent()
14841484
throw new InvalidDataException("Shape file missing lod_control section");
14851485
else if (LodControls[0].DistanceLevels.Length > 0 && LodControls[0].DistanceLevels[0].SubObjects.Length > 0)
14861486
{
1487+
// Zero the position offset of the root matrix for compatibility with MSTS
1488+
if (LodControls[0].DistanceLevels[0].SubObjects[0].ShapePrimitives.Length > 0 && LodControls[0].DistanceLevels[0].SubObjects[0].ShapePrimitives[0].Hierarchy[0] == -1)
1489+
{
1490+
Matrices[0].M41 = 0;
1491+
Matrices[0].M42 = 0;
1492+
Matrices[0].M43 = 0;
1493+
}
14871494
// Look for root subobject, it is not necessarily the first (see ProTrain signal)
14881495
for (int soIndex = 0; soIndex <= LodControls[0].DistanceLevels[0].SubObjects.Length - 1; soIndex++)
14891496
{
@@ -1974,7 +1981,7 @@ public void PrepareFrame(RenderFrame frame, WorldPosition location, Matrix[] ani
19741981
{
19751982
var xnaMatrix = Matrix.Identity;
19761983
var hi = shapePrimitive.HierarchyIndex;
1977-
while (hi >= 0 && hi < shapePrimitive.Hierarchy.Length && shapePrimitive.Hierarchy[hi] != -1)
1984+
while (hi >= 0 && hi < shapePrimitive.Hierarchy.Length)
19781985
{
19791986
Matrix.Multiply(ref xnaMatrix, ref animatedXNAMatrices[hi], out xnaMatrix);
19801987
hi = shapePrimitive.Hierarchy[hi];

0 commit comments

Comments
 (0)