|
1 | | -// COPYRIGHT 2009 - 2022 by the Open Rails project. |
| 1 | +// COPYRIGHT 2009 - 2022 by the Open Rails project. |
2 | 2 | // |
3 | 3 | // This file is part of Open Rails. |
4 | 4 | // |
@@ -191,6 +191,8 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH() |
191 | 191 | public float AutoWidthOffsetM; |
192 | 192 | public float AutoLengthOffsetM; |
193 | 193 | public float AutoHeightOffsetM; |
| 194 | + public int FrontArticulation = -1; // -1: Determine front articulation automatically, 0: Force no front articulation, 1: Force front articulation |
| 195 | + public int RearArticulation = -1; // -1: Determine rear articulation automatically, 0: Force no rear articulation, 1: Force rear articulation |
194 | 196 | public float MassKG = 10000; // Mass in KG at runtime; coincides with InitialMassKG if there is no load and no ORTS freight anim |
195 | 197 | public float InitialMassKG = 10000; |
196 | 198 | public bool IsDriveable; |
@@ -2715,34 +2717,36 @@ public void SetUpWheels() |
2715 | 2717 | // Decided to control what is sent to SetUpWheelsArticulation()by using |
2716 | 2718 | // WheelAxlesLoaded as a flag. This way, wagons that have to be processed are included |
2717 | 2719 | // and the rest left out. |
2718 | | - bool articulatedFront = !WheelAxles.Any(a => a.OffsetM.Z < 0); |
2719 | | - bool articulatedRear = !WheelAxles.Any(a => a.OffsetM.Z > 0); |
2720 | | - var carIndex = Train.Cars.IndexOf(this); |
2721 | | - //Certain locomotives are testing as articulated wagons for some reason. |
2722 | | - if (WagonType != WagonTypes.Engine) |
2723 | | - if (WheelAxles.Count != 1 && (articulatedFront || articulatedRear)) |
2724 | | - { |
2725 | | - WheelAxlesLoaded = true; |
2726 | | - SetUpWheelsArticulation(carIndex); |
2727 | | - } |
| 2720 | + |
| 2721 | + // Force articulation if stock is configured as such |
| 2722 | + // Otherwise, use default behavior which gives articulation if there are no axles forward/reareward on the mode, |
| 2723 | + // disables articulation on engines, and only allows articulation with 3 or fewer axles, but not 1 axle |
| 2724 | + bool articulatedFront = (FrontArticulation == 1 || |
| 2725 | + (FrontArticulation == -1 && !WheelAxles.Any(a => a.OffsetM.Z < 0) && WagonType != WagonTypes.Engine && WheelAxles.Count != 1 && WheelAxles.Count <= 3)); |
| 2726 | + bool articulatedRear = (RearArticulation == 1 || |
| 2727 | + (RearArticulation == -1 && !WheelAxles.Any(a => a.OffsetM.Z > 0) && WagonType != WagonTypes.Engine && WheelAxles.Count != 1 && WheelAxles.Count <= 3)); |
| 2728 | + |
| 2729 | + if (articulatedFront || articulatedRear) |
| 2730 | + { |
| 2731 | + WheelAxlesLoaded = true; |
| 2732 | + SetUpWheelsArticulation(articulatedFront, articulatedRear); |
| 2733 | + } |
2728 | 2734 | } // end SetUpWheels() |
2729 | 2735 |
|
2730 | | - protected void SetUpWheelsArticulation(int carIndex) |
| 2736 | + protected void SetUpWheelsArticulation(bool front, bool rear) |
2731 | 2737 | { |
2732 | 2738 | // If there are no forward wheels, this car is articulated (joined |
2733 | 2739 | // to the car in front) at the front. Likewise for the rear. |
2734 | | - bool articulatedFront = !WheelAxles.Any(a => a.OffsetM.Z < 0); |
2735 | | - bool articulatedRear = !WheelAxles.Any(a => a.OffsetM.Z > 0); |
2736 | 2740 | // Original process originally used caused too many issues. |
2737 | 2741 | // The original process did include the below process of just using WheelAxles.Add |
2738 | 2742 | // if the initial test did not work. Since the below process is working without issues the |
2739 | 2743 | // original process was stripped down to what is below |
2740 | | - if (articulatedFront || articulatedRear) |
| 2744 | + if (front || rear) |
2741 | 2745 | { |
2742 | | - if (articulatedFront && WheelAxles.Count <= 3) |
| 2746 | + if (front) |
2743 | 2747 | WheelAxles.Add(new WheelAxle(new Vector3(0.0f, BogiePivotHeightM, -CarLengthM / 2.0f), 0, 0) { Part = Parts[0] }); |
2744 | 2748 |
|
2745 | | - if (articulatedRear && WheelAxles.Count <= 3) |
| 2749 | + if (rear) |
2746 | 2750 | WheelAxles.Add(new WheelAxle(new Vector3(0.0f, BogiePivotHeightM, CarLengthM / 2.0f), 0, 0) { Part = Parts[0] }); |
2747 | 2751 |
|
2748 | 2752 | WheelAxles.Sort(WheelAxles[0]); |
|
0 commit comments