Skip to content

Commit 9fdade0

Browse files
committed
Fix incorrect brake fraction assignment
1 parent ccc5c4d commit 9fdade0

File tree

1 file changed

+17
-2
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions

1 file changed

+17
-2
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ public void Initialize()
354354
else if (axle.DriveType == AxleDriveType.ForceDriven) numForce++;
355355
else if (axle.DriveType == AxleDriveType.MotorDriven) numMotor++;
356356
}
357+
float totalDriveWheelWeightKg = 0;
358+
float totalWheelWeightKg = 0;
357359
foreach (var axle in AxleList)
358360
{
359361
if (numMotor > 0 && axle.DriveType == AxleDriveType.ForceDriven) axle.DriveType = AxleDriveType.NotDriven;
@@ -366,7 +368,6 @@ public void Initialize()
366368
{
367369
if (axle.DriveType != AxleDriveType.NotDriven)
368370
{
369-
axle.BrakeForceFraction = 1.0f / (locomotive.DriveWheelOnlyBrakes ? numDriven : AxleList.Count);
370371
if (axle.WheelWeightKg <= 0) axle.WheelWeightKg = locomotive.DrvWheelWeightKg / numDriven;
371372
if (axle.NumWheelsetAxles <= 0) axle.NumWheelsetAxles = locomotive.LocoNumDrvAxles / numDriven;
372373
if (axle.WheelRadiusM <= 0) axle.WheelRadiusM = locomotive.DriverWheelRadiusM;
@@ -388,7 +389,6 @@ public void Initialize()
388389
if (axle.DriveType == AxleDriveType.NotDriven)
389390
{
390391
var wagon = Car as MSTSWagon;
391-
axle.BrakeForceFraction = locomotive != null && locomotive.DriveWheelOnlyBrakes ? 0 :1.0f / AxleList.Count;
392392
if (axle.WheelWeightKg <= 0)
393393
{
394394
if (locomotive != null) axle.WheelWeightKg = Math.Max((Car.MassKG - locomotive.DrvWheelWeightKg) / numNotDriven, 500);
@@ -402,6 +402,21 @@ public void Initialize()
402402
if (axle.AxleWeightN <= 0) axle.AxleWeightN = 9.81f * axle.WheelWeightKg; //remains fixed for diesel/electric locomotives, but varies for steam locomotives
403403
if (axle.DampingNs <= 0) axle.DampingNs = axle.WheelWeightKg / 1000.0f;
404404
if (axle.FrictionN <= 0) axle.FrictionN = axle.WheelWeightKg / 1000.0f;
405+
406+
if (axle.DriveType != AxleDriveType.NotDriven) totalDriveWheelWeightKg += axle.WheelWeightKg;
407+
totalWheelWeightKg += axle.WheelWeightKg;
408+
}
409+
foreach (var axle in AxleList)
410+
{
411+
var locomotive = Car as MSTSLocomotive;
412+
if (axle.DriveType == AxleDriveType.NotDriven)
413+
{
414+
axle.BrakeForceFraction = locomotive == null || !locomotive.DriveWheelOnlyBrakes ? axle.WheelWeightKg / totalWheelWeightKg : 0;
415+
}
416+
else
417+
{
418+
axle.BrakeForceFraction = axle.WheelWeightKg / (locomotive != null && locomotive.DriveWheelOnlyBrakes ? totalDriveWheelWeightKg : totalWheelWeightKg);
419+
}
405420
axle.Initialize();
406421
}
407422
}

0 commit comments

Comments
 (0)