@@ -61,23 +61,35 @@ public static bool DecomposeStaticSuperElevation(Viewer viewer, TrackObj trackOb
6161
6262 TrackShape shape ;
6363
64+ bool dontRender = false ; // Should this shape be left as a static object?
65+ SectionIdx [ ] SectionIdxs ;
66+
6467 try
6568 {
6669 shape = viewer . Simulator . TSectionDat . TrackShapes . Get ( trackObj . SectionIdx ) ;
6770
68- if ( shape . RoadShape == true )
71+ if ( shape . RoadShape )
6972 return false ; // Roads don't use superelevation, no use in processing them.
73+
74+ // Can't render superelevation on tunnel shapes
75+ dontRender = shape . TunnelShape ;
76+ SectionIdxs = shape . SectionIdxs ;
7077 }
7178 catch ( Exception )
7279 {
73- return false ; // Won't be able to render with superelevation
80+ // Some route-specific shapes (DynaTrax) won't be populated in the TrackShapes list, check the TrackPaths list
81+ if ( viewer . Simulator . TSectionDat . TSectionIdx . TrackPaths . TryGetValue ( trackObj . SectionIdx , out TrackPath path ) )
82+ {
83+ // Translate given data into a SectionIdx object that the rest of the method can interpret
84+ // Assumptions: Each piece of DynaTrax is a single section with origin 0, 0, 0 and 0 angle,
85+ // and the entire section of DynaTrax is defined by the track sections given in the track path
86+ SectionIdxs = new SectionIdx [ 1 ] ;
87+ SectionIdxs [ 0 ] = new SectionIdx ( path ) ;
88+ }
89+ else
90+ return false ; // Not enough info, won't be able to render with superelevation
7491 }
7592
76- SectionIdx [ ] SectionIdxs = shape . SectionIdxs ;
77-
78- // Can't render superelevation on tunnel shapes
79- // NOTE: Even if we don't render superelevation, we still need to run through processing to remove superelevation from track sections
80- bool dontRender = shape . TunnelShape ;
8193 // Sometimes junctions get caught here, physics superelevation should be removed for those as well
8294 bool removePhys = false ;
8395 // 0 = centered, positive = rotation axis moves to inside of curve, negative = moves to outside of curve
0 commit comments