@@ -753,7 +753,7 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
753
753
car . SoundHeardInternallyCorrection [ MSTSWagon . LeftWindowFrontIndex ] = LeftWindowFront . AnimationKeyFraction ( ) ;
754
754
if ( RightWindowFront . FrameCount > 0 )
755
755
car . SoundHeardInternallyCorrection [ MSTSWagon . RightWindowFrontIndex ] = RightWindowFront . AnimationKeyFraction ( ) ;
756
- }
756
+ }
757
757
}
758
758
759
759
@@ -774,18 +774,18 @@ private void UpdateAnimation(RenderFrame frame, ElapsedTime elapsedTime)
774
774
foreach ( var kvp in RunningGears )
775
775
{
776
776
if ( ! kvp . Value . Empty ( ) )
777
- {
777
+ {
778
778
var axle = kvp . Key >= 0 && kvp . Key < loco . LocomotiveAxles . Count ? loco . LocomotiveAxles [ kvp . Key ] : null ;
779
779
if ( axle != null )
780
780
//TODO: next code line has been modified to flip trainset physics in order to get viewing direction coincident with loco direction when using rear cab.
781
781
kvp . Value . UpdateLoop ( ( ( MSTSWagon . Train != null && MSTSWagon . Train . IsPlayerDriven && loco . UsingRearCab ) ? - 1 : 1 ) * ( float ) axle . AxleSpeedMpS * elapsedTime . ClockSeconds / MathHelper . TwoPi / axle . WheelRadiusM ) ;
782
782
else if ( AnimationDriveWheelRadiusM > 0.001 )
783
783
kvp . Value . UpdateLoop ( distanceTravelledM / MathHelper . TwoPi / AnimationDriveWheelRadiusM ) ;
784
- }
785
-
786
784
}
785
+
786
+ }
787
787
foreach ( var kvp in WheelPartIndexes )
788
- {
788
+ {
789
789
var axle = kvp . Key < loco . LocomotiveAxles . Count && kvp . Key >= 0 ? loco . LocomotiveAxles [ kvp . Key ] : ( Car . EngineType == TrainCar . EngineTypes . Steam ? null : loco . LocomotiveAxles [ 0 ] ) ;
790
790
Matrix wheelRotationMatrix ;
791
791
if ( axle != null )
@@ -800,33 +800,33 @@ private void UpdateAnimation(RenderFrame frame, ElapsedTime elapsedTime)
800
800
wheelRotationMatrix = Matrix . CreateRotationX ( WheelRotationR ) ;
801
801
}
802
802
foreach ( var iMatrix in kvp . Value )
803
- {
803
+ {
804
804
TrainCarShape . XNAMatrices [ iMatrix ] = wheelRotationMatrix * TrainCarShape . SharedShape . Matrices [ iMatrix ] ;
805
- }
805
+ }
806
806
}
807
807
}
808
808
else // set values for simple adhesion
809
- {
809
+ {
810
810
distanceTravelledM = ( ( MSTSWagon . IsDriveable && MSTSWagon . Train != null && MSTSWagon . Train . IsPlayerDriven && ( ( MSTSLocomotive ) MSTSWagon ) . UsingRearCab ) ? - 1 : 1 ) * MSTSWagon . SpeedMpS * elapsedTime . ClockSeconds ;
811
811
if ( Car . BrakeSkid ) distanceTravelledM = 0 ;
812
812
foreach ( var kvp in RunningGears )
813
813
{
814
814
if ( ! kvp . Value . Empty ( ) && AnimationDriveWheelRadiusM > 0.001 )
815
815
kvp . Value . UpdateLoop ( distanceTravelledM / MathHelper . TwoPi / AnimationDriveWheelRadiusM ) ;
816
816
}
817
- // Wheel rotation (animation) - for non-drive wheels in steam locomotives and all wheels in other stock
818
- if ( WheelPartIndexes . Count > 0 )
819
- {
817
+ // Wheel rotation (animation) - for non-drive wheels in steam locomotives and all wheels in other stock
818
+ if ( WheelPartIndexes . Count > 0 )
819
+ {
820
820
var rotationalDistanceR = distanceTravelledM / AnimationWheelRadiusM ; // in radians
821
- WheelRotationR = MathHelper . WrapAngle ( WheelRotationR - rotationalDistanceR ) ;
822
- var wheelRotationMatrix = Matrix . CreateRotationX ( WheelRotationR ) ;
821
+ WheelRotationR = MathHelper . WrapAngle ( WheelRotationR - rotationalDistanceR ) ;
822
+ var wheelRotationMatrix = Matrix . CreateRotationX ( WheelRotationR ) ;
823
823
foreach ( var kvp in WheelPartIndexes )
824
- {
824
+ {
825
825
foreach ( var iMatrix in kvp . Value )
826
826
{
827
- TrainCarShape . XNAMatrices [ iMatrix ] = wheelRotationMatrix * TrainCarShape . SharedShape . Matrices [ iMatrix ] ;
828
- }
829
- }
827
+ TrainCarShape . XNAMatrices [ iMatrix ] = wheelRotationMatrix * TrainCarShape . SharedShape . Matrices [ iMatrix ] ;
828
+ }
829
+ }
830
830
}
831
831
}
832
832
0 commit comments