Skip to content

Commit 34d0991

Browse files
committed
Correct issue for coupler disappearing when car crosses a tile boundary
1 parent 9f0c709 commit 34d0991

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ public float ConvectionFactor
322322
public TrainCar CarAhead;
323323
public TrainCar CarBehind;
324324
public Vector3 RearCouplerLocation;
325+
public int RearCouplerLocationTileX;
326+
public int RearCouplerLocationTileZ;
325327
public float AdvancedCouplerDynamicTensionSlackLimitM; // Varies as coupler moves
326328
public float AdvancedCouplerDynamicCompressionSlackLimitM; // Varies as coupler moves
327329

Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,6 @@ private void UpdateCouplers(RenderFrame frame, ElapsedTime elapsedTime)
926926
Z = (Car.FrontCouplerAnimLengthM + (Car.CarLengthM / 2.0f) + Car.FrontCouplerSlackM - Car.WagonFrontCouplerCurveExtM)
927927
};
928928

929-
var tempZ = (Car.FrontCouplerAnimLengthM + (Car.CarLengthM / 2.0f) + Car.FrontCouplerSlackM - Car.WagonFrontCouplerCurveExtM);
930-
931929
if (Car.CarAhead != null) // Display animated coupler if there is a car infront of this car
932930
{
933931
var quaternion = PositionCoupler(Car, FrontCouplerShape, displacement);
@@ -949,6 +947,8 @@ private void UpdateCouplers(RenderFrame frame, ElapsedTime elapsedTime)
949947
if ((absXc > 0.005 || absYc > 0.005 || absZc > 0.005))
950948
{
951949
FrontCouplerShape.Location.Location = Car.CarAhead.RearCouplerLocation; // Set coupler to same location as previous car coupler
950+
FrontCouplerShape.Location.TileX = Car.CarAhead.RearCouplerLocationTileX;
951+
FrontCouplerShape.Location.TileZ = Car.CarAhead.RearCouplerLocationTileZ;
952952
}
953953

954954
// Display Animation Shape
@@ -1001,7 +1001,11 @@ private void UpdateCouplers(RenderFrame frame, ElapsedTime elapsedTime)
10011001
// Display Animation Shape
10021002
RearCouplerShape.PrepareFrame(frame, elapsedTime);
10031003

1004+
// Save coupler location for use on following car front coupler
10041005
Car.RearCouplerLocation = RearCouplerShape.Location.Location;
1006+
Car.RearCouplerLocationTileX = RearCouplerShape.Location.TileX;
1007+
Car.RearCouplerLocationTileZ = RearCouplerShape.Location.TileZ;
1008+
10051009
}
10061010
else if (RearCouplerOpenShape != null && Car.RearCouplerOpenFitted && Car.RearCouplerOpen) // Display open coupler if no car is behind car, and an open coupler shape is present
10071011
{

0 commit comments

Comments
 (0)