@@ -215,10 +215,13 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
215215 }
216216 }
217217
218- if ( standard == null || maxElev < standard . MinCantM )
218+ if ( ( standard == null || maxElev < standard . MinCantM ) && ! SectionList . Any ( s => s . NomElevM > 0.0f ) )
219219 {
220220 foreach ( TrVectorSection s in SectionList )
221+ {
221222 s . NomElevM = 0 ; // No superelevation needed, or curve is so short that no meaningful superelevation can be applied
223+ return ;
224+ }
222225 }
223226 else
224227 {
@@ -383,12 +386,17 @@ void MarkSections(Simulator simulator, List<TrVectorSection> SectionList, float
383386
384387 SectionList [ count ] . PhysElevTable = new Interpolator ( positions , elevations ) ;
385388
386- // Visual superelevation is stored in terms of angle in radians rather than meters
387- float [ ] angles = elevations . Select ( e => ( float ) Math . Asin ( e / simulator . SuperElevationGauge ) ) . ToArray ( ) ;
388- SectionList [ count ] . VisElevTable = new Interpolator ( SectionList [ count ] . PhysElevTable . X , angles ) ;
389- // Invert visual elevation values based on curve direction
390- // direction is negated for consistency of direction sense in other places
391- SectionList [ count ] . VisElevTable . ScaleY ( - direction ) ;
389+ // Only generate visual superelevation if option is enabled
390+ if ( simulator . UseSuperElevation )
391+ {
392+ // Visual superelevation is stored in terms of angle in radians rather than meters
393+ float [ ] angles = elevations . Select ( e => ( float ) Math . Asin ( e / simulator . SuperElevationGauge ) ) . ToArray ( ) ;
394+
395+ SectionList [ count ] . VisElevTable = new Interpolator ( SectionList [ count ] . PhysElevTable . X , angles ) ;
396+ // Invert visual elevation values based on curve direction
397+ // direction is negated for consistency of direction sense in other places
398+ SectionList [ count ] . VisElevTable . ScaleY ( - direction ) ;
399+ }
392400
393401 accumulatedLength += lengths [ count ] ;
394402 count ++ ;
0 commit comments