@@ -186,6 +186,8 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH()
186186 public float CarWidthM = 2.5f ;
187187 public float CarLengthM = 40 ; // derived classes must overwrite these defaults
188188 public float CarHeightM = 4 ; // derived classes must overwrite these defaults
189+ public int FrontArticulation = - 1 ; // -1: Determine front articulation automatically, 0: Force no front articulation, 1: Force front articulation
190+ public int RearArticulation = - 1 ; // -1: Determine rear articulation automatically, 0: Force no rear articulation, 1: Force rear articulation
189191 public float MassKG = 10000 ; // Mass in KG at runtime; coincides with InitialMassKG if there is no load and no ORTS freight anim
190192 public float InitialMassKG = 10000 ;
191193 public bool IsDriveable ;
@@ -2908,34 +2910,36 @@ public void SetUpWheels()
29082910 // Decided to control what is sent to SetUpWheelsArticulation()by using
29092911 // WheelAxlesLoaded as a flag. This way, wagons that have to be processed are included
29102912 // and the rest left out.
2911- bool articulatedFront = ! WheelAxles . Any ( a => a . OffsetM . Z < 0 ) ;
2912- bool articulatedRear = ! WheelAxles . Any ( a => a . OffsetM . Z > 0 ) ;
2913- var carIndex = Train . Cars . IndexOf ( this ) ;
2914- //Certain locomotives are testing as articulated wagons for some reason.
2915- if ( WagonType != WagonTypes . Engine )
2916- if ( WheelAxles . Count != 1 && ( articulatedFront || articulatedRear ) )
2917- {
2918- WheelAxlesLoaded = true ;
2919- SetUpWheelsArticulation ( carIndex ) ;
2920- }
2913+
2914+ // Force articulation if stock is configured as such
2915+ // Otherwise, use default behavior which gives articulation if there are no axles forward/reareward on the model,
2916+ // disables articulation on engines, and only allows articulation with 3 or fewer axles, but not 1 axle
2917+ bool articulatedFront = ( FrontArticulation == 1 ||
2918+ ( FrontArticulation == - 1 && ! WheelAxles . Any ( a => a . OffsetM . Z < 0 ) && WagonType != WagonTypes . Engine && WheelAxles . Count != 1 && WheelAxles . Count <= 3 ) ) ;
2919+ bool articulatedRear = ( RearArticulation == 1 ||
2920+ ( RearArticulation == - 1 && ! WheelAxles . Any ( a => a . OffsetM . Z > 0 ) && WagonType != WagonTypes . Engine && WheelAxles . Count != 1 && WheelAxles . Count <= 3 ) ) ;
2921+
2922+ if ( articulatedFront || articulatedRear )
2923+ {
2924+ WheelAxlesLoaded = true ;
2925+ SetUpWheelsArticulation ( articulatedFront , articulatedRear ) ;
2926+ }
29212927 } // end SetUpWheels()
29222928
2923- protected void SetUpWheelsArticulation ( int carIndex )
2929+ protected void SetUpWheelsArticulation ( bool front , bool rear )
29242930 {
29252931 // If there are no forward wheels, this car is articulated (joined
29262932 // to the car in front) at the front. Likewise for the rear.
2927- bool articulatedFront = ! WheelAxles . Any ( a => a . OffsetM . Z < 0 ) ;
2928- bool articulatedRear = ! WheelAxles . Any ( a => a . OffsetM . Z > 0 ) ;
29292933 // Original process originally used caused too many issues.
29302934 // The original process did include the below process of just using WheelAxles.Add
29312935 // if the initial test did not work. Since the below process is working without issues the
29322936 // original process was stripped down to what is below
2933- if ( articulatedFront || articulatedRear )
2937+ if ( front || rear )
29342938 {
2935- if ( articulatedFront && WheelAxles . Count <= 3 )
2939+ if ( front )
29362940 WheelAxles . Add ( new WheelAxle ( new Vector3 ( 0.0f , BogiePivotHeightM , - CarLengthM / 2.0f ) , 0 , 0 ) { Part = Parts [ 0 ] } ) ;
29372941
2938- if ( articulatedRear && WheelAxles . Count <= 3 )
2942+ if ( rear )
29392943 WheelAxles . Add ( new WheelAxle ( new Vector3 ( 0.0f , BogiePivotHeightM , CarLengthM / 2.0f ) , 0 , 0 ) { Part = Parts [ 0 ] } ) ;
29402944
29412945 WheelAxles . Sort ( WheelAxles [ 0 ] ) ;
0 commit comments