Skip to content

Commit cfa5bca

Browse files
committed
Automatic merge of T1.6-rc6-37-g6dd094783 and 12 pull requests
- Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1104 at 86d38a2: Handle simple adhesion within the axle module - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1120 at ba3c47f: Automatically Calculate Friction Values if Missing - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1130 at 8ae6bb7: Fix F9 points to an incorrect car ID. - Pull request #1139 at b47224d: Fix for bug https://bugs.launchpad.net/or/+bug/2117357. - Pull request #1142 at a24747c: Fix light position calculation for deeper hierarchy levels - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification - Pull request #1124 at fab5457: Built-in PBL2 brake controller - Pull request #1128 at 58de4c3: Particle Emitter Overhaul
14 parents 9feee6e + 6dd0947 + e10390b + 86d38a2 + 270f22f + ba3c47f + 91d2d26 + 8ae6bb7 + b47224d + a24747c + 5845a1a + 689494b + fab5457 + 58de4c3 commit cfa5bca

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Source/RunActivity/Viewer3D/Lights.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,29 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
226226

227227
// Calculate XNA matrix for shape file objects by offsetting from car's location
228228
// The new List<int> is intentional, this allows the dictionary to be changed while iterating
229+
int maxDepth = trainCarShape.Hierarchy.Max();
229230
foreach (int index in new List<int>(ShapeXNATranslations.Keys))
230-
ShapeXNATranslations[index] = trainCarShape.XNAMatrices[index] * xnaDTileTranslation;
231+
{
232+
Matrix res = trainCarShape.XNAMatrices[index];
233+
int hIndex = trainCarShape.Hierarchy[index];
234+
235+
int i = 0;
236+
237+
// Transform the matrix repeatedly for all of its parents
238+
while (hIndex > -1 && hIndex < trainCarShape.Hierarchy.Length && i < maxDepth)
239+
{
240+
res = res * trainCarShape.XNAMatrices[hIndex];
241+
// Prevent potential infinite loop due to faulty hierarchy definition
242+
if (hIndex != trainCarShape.Hierarchy[hIndex])
243+
hIndex = trainCarShape.Hierarchy[hIndex];
244+
else
245+
break;
246+
247+
i++;
248+
}
249+
250+
ShapeXNATranslations[index] = res * xnaDTileTranslation;
251+
}
231252

232253
float objectRadius = 20; // Even more arbitrary.
233254
float objectViewingDistance = Viewer.Settings.ViewingDistance; // Arbitrary.

0 commit comments

Comments
 (0)