Skip to content

Commit

Permalink
Bug fix for https://bugs.launchpad.net/or/+bug/1810685 Animation of r…
Browse files Browse the repository at this point in the history
…oot matrix does not work.

git-svn-id: http://svn.uktrainsim.com/svn/openrails/trunk@4334 a9f3cfff-6c41-7446-b0ca-052bd761e6eb
  • Loading branch information
carlossantucci committed Jan 8, 2019
1 parent 3baea56 commit b1586ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/RunActivity/Viewer3D/Shapes.cs
Expand Up @@ -1484,6 +1484,13 @@ void LoadContent()
throw new InvalidDataException("Shape file missing lod_control section");
else if (LodControls[0].DistanceLevels.Length > 0 && LodControls[0].DistanceLevels[0].SubObjects.Length > 0)
{
// Zero the position offset of the root matrix for compatibility with MSTS
if (LodControls[0].DistanceLevels[0].SubObjects[0].ShapePrimitives.Length > 0 && LodControls[0].DistanceLevels[0].SubObjects[0].ShapePrimitives[0].Hierarchy[0] == -1)
{
Matrices[0].M41 = 0;
Matrices[0].M42 = 0;
Matrices[0].M43 = 0;
}
// Look for root subobject, it is not necessarily the first (see ProTrain signal)
for (int soIndex = 0; soIndex <= LodControls[0].DistanceLevels[0].SubObjects.Length - 1; soIndex++)
{
Expand Down Expand Up @@ -1974,7 +1981,7 @@ public void PrepareFrame(RenderFrame frame, WorldPosition location, Matrix[] ani
{
var xnaMatrix = Matrix.Identity;
var hi = shapePrimitive.HierarchyIndex;
while (hi >= 0 && hi < shapePrimitive.Hierarchy.Length && shapePrimitive.Hierarchy[hi] != -1)
while (hi >= 0 && hi < shapePrimitive.Hierarchy.Length)
{
Matrix.Multiply(ref xnaMatrix, ref animatedXNAMatrices[hi], out xnaMatrix);
hi = shapePrimitive.Hierarchy[hi];
Expand Down

0 comments on commit b1586ae

Please sign in to comment.