@@ -875,27 +875,29 @@ void Integrate(float elapsedClockSeconds)
875875 if ( elapsedClockSeconds <= 0 ) return ;
876876 double prevSpeedMpS = AxleSpeedMpS ;
877877
878- var upperSubStepStartingLimit = 120 ;
879- var upperSubStepLimit = upperSubStepStartingLimit ;
880- var lowerSubStepLimit = 1 ;
878+ float upperSubStepStartingLimit = 120 ;
879+ float tempupperSubStepLimit = upperSubStepStartingLimit ;
880+ float lowerSubStepLimit = 1 ;
881881
882- var screenFrameUpperLimit = 60 ;
883- var screenFrameLowerLimit = 40 ;
882+ float screenFrameUpperLimit = 60 ;
883+ float screenFrameLowerLimit = 40 ;
884884
885885 // Reduces the number of substeps if screen FPS drops
886- if ( ScreenFrameRate >= screenFrameUpperLimit )
886+ if ( ( int ) ScreenFrameRate >= screenFrameUpperLimit ) // Screen FPS > 60, hold substeps @ maximum value
887887 {
888- upperSubStepLimit = upperSubStepStartingLimit ;
888+ tempupperSubStepLimit = upperSubStepStartingLimit ;
889889 }
890- else if ( ScreenFrameRate < screenFrameLowerLimit )
890+ else if ( ( int ) ScreenFrameRate < screenFrameLowerLimit ) // Screen FPS < 40, hold substeps @ minimum value
891891 {
892- upperSubStepLimit = upperSubStepStartingLimit * ( screenFrameLowerLimit / screenFrameUpperLimit ) ;
892+ tempupperSubStepLimit = upperSubStepStartingLimit * ( screenFrameLowerLimit / screenFrameUpperLimit ) ;
893893 }
894894 else
895895 {
896- upperSubStepLimit = ( int ) ( ( ScreenFrameRate / 60 ) * upperSubStepStartingLimit ) ;
896+ tempupperSubStepLimit = ( int ) ( ( ScreenFrameRate / 60 ) * upperSubStepStartingLimit ) ;
897897 }
898898
899+ var upperSubStepLimit = tempupperSubStepLimit ;
900+
899901 // use straight line graph approximation to increase substeps as slipspeed increases towards the threshold speed point
900902 // Points are 1 = (0, upperLimit) and 2 = (threshold, lowerLimit)
901903 var AdhesGrad = ( ( upperSubStepLimit - lowerSubStepLimit ) / ( WheelSlipThresholdMpS - 0 ) ) ;
@@ -933,10 +935,10 @@ void Integrate(float elapsedClockSeconds)
933935 }
934936
935937 if ( NumOfSubstepsPS < lowerSubStepLimit )
936- NumOfSubstepsPS = lowerSubStepLimit ;
938+ NumOfSubstepsPS = ( int ) lowerSubStepLimit ;
937939
938940 if ( NumOfSubstepsPS > upperSubStepLimit )
939- NumOfSubstepsPS = upperSubStepLimit ;
941+ NumOfSubstepsPS = ( int ) upperSubStepLimit ;
940942
941943 double dt = elapsedClockSeconds / NumOfSubstepsPS ;
942944 double hdt = dt / 2 ;
0 commit comments