@@ -875,27 +875,29 @@ void Integrate(float elapsedClockSeconds)
875
875
if ( elapsedClockSeconds <= 0 ) return ;
876
876
double prevSpeedMpS = AxleSpeedMpS ;
877
877
878
- var upperSubStepStartingLimit = 120 ;
879
- var upperSubStepLimit = upperSubStepStartingLimit ;
880
- var lowerSubStepLimit = 1 ;
878
+ float upperSubStepStartingLimit = 120 ;
879
+ float tempupperSubStepLimit = upperSubStepStartingLimit ;
880
+ float lowerSubStepLimit = 1 ;
881
881
882
- var screenFrameUpperLimit = 60 ;
883
- var screenFrameLowerLimit = 40 ;
882
+ float screenFrameUpperLimit = 60 ;
883
+ float screenFrameLowerLimit = 40 ;
884
884
885
885
// 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
887
887
{
888
- upperSubStepLimit = upperSubStepStartingLimit ;
888
+ tempupperSubStepLimit = upperSubStepStartingLimit ;
889
889
}
890
- else if ( ScreenFrameRate < screenFrameLowerLimit )
890
+ else if ( ( int ) ScreenFrameRate < screenFrameLowerLimit ) // Screen FPS < 40, hold substeps @ minimum value
891
891
{
892
- upperSubStepLimit = upperSubStepStartingLimit * ( screenFrameLowerLimit / screenFrameUpperLimit ) ;
892
+ tempupperSubStepLimit = upperSubStepStartingLimit * ( screenFrameLowerLimit / screenFrameUpperLimit ) ;
893
893
}
894
894
else
895
895
{
896
- upperSubStepLimit = ( int ) ( ( ScreenFrameRate / 60 ) * upperSubStepStartingLimit ) ;
896
+ tempupperSubStepLimit = ( int ) ( ( ScreenFrameRate / 60 ) * upperSubStepStartingLimit ) ;
897
897
}
898
898
899
+ var upperSubStepLimit = tempupperSubStepLimit ;
900
+
899
901
// use straight line graph approximation to increase substeps as slipspeed increases towards the threshold speed point
900
902
// Points are 1 = (0, upperLimit) and 2 = (threshold, lowerLimit)
901
903
var AdhesGrad = ( ( upperSubStepLimit - lowerSubStepLimit ) / ( WheelSlipThresholdMpS - 0 ) ) ;
@@ -933,10 +935,10 @@ void Integrate(float elapsedClockSeconds)
933
935
}
934
936
935
937
if ( NumOfSubstepsPS < lowerSubStepLimit )
936
- NumOfSubstepsPS = lowerSubStepLimit ;
938
+ NumOfSubstepsPS = ( int ) lowerSubStepLimit ;
937
939
938
940
if ( NumOfSubstepsPS > upperSubStepLimit )
939
- NumOfSubstepsPS = upperSubStepLimit ;
941
+ NumOfSubstepsPS = ( int ) upperSubStepLimit ;
940
942
941
943
double dt = elapsedClockSeconds / NumOfSubstepsPS ;
942
944
double hdt = dt / 2 ;
0 commit comments