@@ -2827,6 +2827,7 @@ public void SimpleAdhesion()
2827
2827
2828
2828
float max0 = DrvWheelWeightKg * 9.81f * uMax ; //Ahesion limit in [N]
2829
2829
float max1 ;
2830
+ float SandingFrictionFactor = 1 ;
2830
2831
2831
2832
if ( Simulator . WeatherType == WeatherType . Rain || Simulator . WeatherType == WeatherType . Snow )
2832
2833
{
@@ -2845,30 +2846,19 @@ public void SimpleAdhesion()
2845
2846
//float max1 = (Sander ? .95f : Adhesion2) * max0; //Not used this way
2846
2847
max1 = MaxForceN ;
2847
2848
//add sander
2848
- if ( AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
2849
+ if ( Sander && AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
2849
2850
{
2850
- if ( SanderSpeedEffectUpToMpS > 0.0f )
2851
+ switch ( Simulator . WeatherType )
2851
2852
{
2852
- if ( ( Sander ) & & ( AbsSpeedMpS < SanderSpeedEffectUpToMpS ) )
2853
- {
2854
- switch ( Simulator . WeatherType )
2855
- {
2856
- case WeatherType . Clear : max0 *= ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 1.2f ; break ;
2857
- case WeatherType . Rain : max0 *= ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 1.8f ; break ;
2858
- case WeatherType . Snow : max0 *= ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 2.5f ; break ;
2859
- }
2860
- }
2853
+ case WeatherType . Clear : SandingFrictionFactor = 1.2f ; break ;
2854
+ case WeatherType . Rain : SandingFrictionFactor = 1.8f ; break ;
2855
+ case WeatherType . Snow : SandingFrictionFactor = 2.5f ; break ;
2861
2856
}
2862
- else
2863
- if ( Sander )
2857
+ if ( SanderSpeedEffectUpToMpS > 0.0f ) // Reduce sander effectiveness if max effective speed is defined
2864
2858
{
2865
- switch ( Simulator . WeatherType )
2866
- {
2867
- case WeatherType . Clear : max0 *= 1.2f ; break ;
2868
- case WeatherType . Rain : max0 *= 1.8f ; break ;
2869
- case WeatherType . Snow : max0 *= 2.5f ; break ;
2870
- }
2859
+ SandingFrictionFactor *= ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) ;
2871
2860
}
2861
+ max0 *= Math . Max ( SandingFrictionFactor , 1.0f ) ; // Prevent sand from harming adhesion above max effective speed
2872
2862
}
2873
2863
2874
2864
max1 = max0 ;
@@ -3142,92 +3132,22 @@ public virtual void UpdateFrictionCoefficient(float elapsedClockSeconds)
3142
3132
}
3143
3133
}
3144
3134
3145
- BaseFrictionCoefficientFactor = MathHelper . Clamp ( BaseFrictionCoefficientFactor , 0.5f , 1.0f ) ;
3135
+ BaseFrictionCoefficientFactor = MathHelper . Clamp ( BaseFrictionCoefficientFactor , 0.5f , 1.0f ) ;
3146
3136
3147
- // Snow covered track
3148
- if ( Simulator . WeatherType == WeatherType . Snow )
3137
+ // Increase friction coefficient when sanding
3138
+ if ( Sander && AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
3149
3139
{
3150
- if ( AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && ( AbsSpeedMpS > 0 ) )
3140
+ switch ( Simulator . WeatherType )
3151
3141
{
3152
- if ( SanderSpeedEffectUpToMpS > 0.0f )
3153
- {
3154
- if ( ( Sander ) & & ( AbsSpeedMpS < SanderSpeedEffectUpToMpS ) )
3155
- {
3156
- SandingFrictionCoefficientFactor = ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 1.50f ;
3157
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ;
3158
-
3159
- }
3160
- }
3161
- else
3162
- {
3163
- if ( Sander ) // If sander is on, and train speed is greater then zero, then put sand on the track
3164
- {
3165
- SandingFrictionCoefficientFactor = 1.50f ;
3166
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 150% adhesion (best case)
3167
- }
3168
- }
3142
+ case WeatherType . Clear : SandingFrictionCoefficientFactor = 1.40f ; break ;
3143
+ case WeatherType . Rain : SandingFrictionCoefficientFactor = 1.25f ; break ;
3144
+ case WeatherType . Snow : SandingFrictionCoefficientFactor = 1.50f ; break ;
3169
3145
}
3170
- else if ( Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
3146
+ if ( SanderSpeedEffectUpToMpS > 0.0f ) // Reduce sander effectiveness if max effective speed is defined
3171
3147
{
3172
- SandingFrictionCoefficientFactor = 1.50f ;
3173
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 150% adhesion (best case)
3148
+ SandingFrictionCoefficientFactor *= ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) ;
3174
3149
}
3175
- }
3176
- else if ( Simulator . WeatherType == WeatherType . Rain )
3177
- {
3178
- if ( AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && ( AbsSpeedMpS > 0 ) )
3179
- {
3180
- if ( SanderSpeedEffectUpToMpS > 0.0f )
3181
- {
3182
- if ( ( Sander ) & & ( AbsSpeedMpS < SanderSpeedEffectUpToMpS ) )
3183
- {
3184
- SandingFrictionCoefficientFactor = ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 1.25f ;
3185
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ;
3186
-
3187
- }
3188
- }
3189
- else
3190
- {
3191
- if ( Sander ) // If sander is on, and train speed is greater then zero, then put sand on the track
3192
- {
3193
- SandingFrictionCoefficientFactor = 1.25f ;
3194
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 125% adhesion (best case)
3195
- }
3196
- }
3197
- }
3198
- else if ( Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
3199
- {
3200
- SandingFrictionCoefficientFactor = 1.25f ;
3201
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 125% adhesion (best case)
3202
- }
3203
- }
3204
- else // dry weather
3205
- {
3206
- if ( AbsSpeedMpS < SanderSpeedOfMpS && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 && ( AbsSpeedMpS > 0 ) )
3207
- {
3208
- if ( SanderSpeedEffectUpToMpS > 0.0f )
3209
- {
3210
- if ( ( Sander ) & & ( AbsSpeedMpS < SanderSpeedEffectUpToMpS ) )
3211
- {
3212
- SandingFrictionCoefficientFactor = ( 1.0f - 0.5f / SanderSpeedEffectUpToMpS * AbsSpeedMpS ) * 1.40f ;
3213
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ;
3214
- }
3215
- }
3216
- else
3217
- {
3218
- if ( Sander ) // If sander is on, and train speed is greater then zero, then put sand on the track
3219
- {
3220
- SandingFrictionCoefficientFactor = 1.40f ;
3221
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 140% adhesion (best case)
3222
- }
3223
- }
3224
- }
3225
- else if ( Sander && CurrentTrackSandBoxCapacityM3 > 0.0 && MainResPressurePSI > 80.0 )
3226
- {
3227
- SandingFrictionCoefficientFactor = 1.40f ;
3228
- BaseFrictionCoefficientFactor *= SandingFrictionCoefficientFactor ; // Sanding track adds approx 140% adhesion (best case)
3229
- }
3230
-
3150
+ BaseFrictionCoefficientFactor *= Math . Max ( SandingFrictionCoefficientFactor , 1.0f ) ; // Prevent sand from harming adhesion above max effective speed
3231
3151
}
3232
3152
3233
3153
// For wagons use base Curtius-Kniffler adhesion factor - u = 0.33
@@ -3282,7 +3202,7 @@ public void UpdateTrackSander(float elapsedClockSeconds)
3282
3202
// The following assumptions have been made:
3283
3203
//
3284
3204
3285
- if ( Sander ) // If sander is on adjust parameters
3205
+ if ( Sander && AbsSpeedMpS < SanderSpeedOfMpS ) // If sander switch is on, and not blocked by speed, adjust parameters
3286
3206
{
3287
3207
if ( CurrentTrackSandBoxCapacityM3 > 0.0 ) // if sand still in sandbox then sanding is available
3288
3208
{
0 commit comments