@@ -1265,37 +1265,45 @@ public void Update(float elapsedClockSeconds)
12651265 }
12661266 }
12671267
1268- if ( RealRPM == IdleRPM )
1269- {
1270- ExhaustParticles = InitialExhaust ;
1271- ExhaustMagnitude = InitialMagnitude ;
1272- ExhaustColor = ExhaustSteadyColor ;
1273- }
1268+ ExhaustParticles = InitialExhaust + ( ExhaustRange * ( RealRPM - IdleRPM ) / RPMRange ) ;
1269+ ExhaustMagnitude = InitialMagnitude + ( MagnitudeRange * ( RealRPM - IdleRPM ) / RPMRange ) ;
1270+ ExhaustColor = ExhaustSteadyColor ;
1271+
12741272 if ( RealRPM < DemandedRPM )
12751273 {
1276- dRPM = ( float ) Math . Min ( Math . Sqrt ( 2 * RateOfChangeUpRPMpSS * throttleAcclerationFactor * ( DemandedRPM - RealRPM ) ) , ChangeUpRPMpS ) ;
1274+ // RPM increase exponentially decays, but clamped between 1% and 100% of the linear rate of change
1275+ dRPM = MathHelper . Clamp ( ( float ) Math . Sqrt ( 2 * RateOfChangeUpRPMpSS * throttleAcclerationFactor * ( DemandedRPM - RealRPM ) ) ,
1276+ 0.01f * ChangeUpRPMpS , ChangeUpRPMpS ) ;
12771277
1278- if ( dRPM > 1.0f ) //The forumula above generates a floating point error that we have to compensate for so we can't actually test for zero.
1278+ if ( RealRPM + dRPM * elapsedClockSeconds > DemandedRPM )
12791279 {
1280- ExhaustParticles = ( InitialExhaust + ( ( ExhaustRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ) * ExhaustAccelIncrease ;
1281- ExhaustMagnitude = ( InitialMagnitude + ( ( MagnitudeRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ) * ExhaustAccelIncrease ;
1282- ExhaustColor = ExhaustTransientColor ;
1280+ RealRPM = DemandedRPM ;
1281+ dRPM = 0 ;
12831282 }
1284- else
1283+ else if ( dRPM > 0.25f * ChangeUpRPMpS ) // Only change particle emitter if RPM is still increasing substantially
12851284 {
1286- dRPM = 0 ;
1287- ExhaustParticles = InitialExhaust + ( ( ExhaustRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ;
1288- ExhaustMagnitude = InitialMagnitude + ( ( MagnitudeRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ;
1289- ExhaustColor = ExhaustSteadyColor ;
1285+ ExhaustParticles *= ExhaustAccelIncrease ;
1286+ ExhaustMagnitude *= ExhaustAccelIncrease ;
1287+ ExhaustColor = ExhaustTransientColor ;
12901288 }
12911289 }
12921290 else if ( RealRPM > DemandedRPM )
12931291 {
1294- dRPM = ( float ) Math . Min ( - Math . Sqrt ( 2 * RateOfChangeDownRPMpSS * throttleAcclerationFactor * ( RealRPM - DemandedRPM ) ) , - ChangeDownRPMpS ) ;
1292+ // RPM decrease exponentially decays, but clamped between 1% and 100% of the linear rate of change
1293+ dRPM = - MathHelper . Clamp ( ( float ) Math . Sqrt ( 2 * RateOfChangeDownRPMpSS * throttleAcclerationFactor * ( RealRPM - DemandedRPM ) ) ,
1294+ 0.01f * ChangeDownRPMpS , ChangeDownRPMpS ) ;
12951295
1296- ExhaustParticles = ( InitialExhaust + ( ( ExhaustRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ) * ExhaustDecelReduction ;
1297- ExhaustMagnitude = ( InitialMagnitude + ( ( MagnitudeRange * ( RealRPM - IdleRPM ) / RPMRange ) ) ) * ExhaustDecelReduction ;
1298- ExhaustColor = ExhaustDecelColor ;
1296+ if ( RealRPM + dRPM * elapsedClockSeconds < DemandedRPM )
1297+ {
1298+ RealRPM = DemandedRPM ;
1299+ dRPM = 0 ;
1300+ }
1301+ else if ( dRPM < - 0.25f * ChangeDownRPMpS ) // Only change particle emitter if RPM is still decreasing substantially
1302+ {
1303+ ExhaustParticles *= ExhaustDecelReduction ;
1304+ ExhaustMagnitude *= ExhaustDecelReduction ;
1305+ ExhaustColor = ExhaustDecelColor ;
1306+ }
12991307 }
13001308
13011309 RealRPM = Math . Max ( RealRPM + dRPM * elapsedClockSeconds , 0 ) ;
0 commit comments