Distance Measurement

Discussion in 'TSW General Discussion' started by montes_1234, Dec 4, 2020.

  1. montes_1234

    montes_1234 Well-Known Member

    Joined:
    May 5, 2020
    Messages:
    382
    Likes Received:
    379
    Why TSW measures distance like straight line to objective not like real distance which would be measured by rail miles/km? And are there plans to change that?
     
    • Like Like x 6
  2. Cyklisten

    Cyklisten Well-Known Member

    Joined:
    Sep 29, 2019
    Messages:
    322
    Likes Received:
    461
    I was really confused while driving RSN for the first time and the distance to Hagen began to raise ;)
     
  3. Clumsy Pacer

    Clumsy Pacer Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    2,956
    Likes Received:
    3,934
    Apparently it's to do with performance or efficency or something. It could, thus, be perhaps something to do with how routes are actually built, or perhaps could be to do with the fact you can get up and walk around (distances would have to be measured in a straight line there because the game can't dictate a specific path you'll take).
     
    • Like Like x 2
  4. JGRudnick

    JGRudnick Well-Known Member

    Joined:
    Jul 2, 2019
    Messages:
    1,744
    Likes Received:
    3,129
    Iirc, the same tool is used to measure distance while walking and running a train.
     
    • Like Like x 2
  5. wxtr7

    wxtr7 Well-Known Member

    Joined:
    Jun 1, 2019
    Messages:
    210
    Likes Received:
    751
    It's a performance decision. The game does a distance calculation between player location and marker most likely either every time movement is made or in rendering each frame (not sure how they actually do it). Assume its the latter...
    Straight-line distance is just the distance formula which is super quick to calculate. Calculating track distance requires the game to create a path accounting for curves, switches, etc... along the track between player and marker and is more intensive.

    For simplicity, let's assume the track in the game is laid in segments, of which we know the length. Since the dispatcher knows the path the train is going to take (since DTG have a more scripted/preset dispatcher), the path is technically already there. One way in a very simplistic approach would just be to loop over each track segment of which a distance is known and sum it up between point A and B. Problems also arise when curves, switches, etc. come into play, as its very difficult to calculate a distance along a curved line. Typically, the curve is "flattened" into very small straight line segments to estimate the distance. But all this would have to be done each time the distance is updated, and if that's changing every time the scene is rendered (and you're at 60FPS), that's A LOT to calculate that takes time away from other more important game functions (physics engine, rendering, etc.), especially if you're doing something like an ICE run where the two points are on the opposite side of the map. Of course this is a simplistic example, and there are more optimized ways of doing things, but that takes dev time away from more pressing issues.
     
    • Helpful Helpful x 1
  6. montes_1234

    montes_1234 Well-Known Member

    Joined:
    May 5, 2020
    Messages:
    382
    Likes Received:
    379
    When measuring distance to objective it is like straight line. But when driving train and measuring distance to the next speed limit and next signal TSW measures it like rail miles/km. So it seems that there are two measuring systems in place.
     
    • Like Like x 2
  7. stujoy

    stujoy Well-Known Member

    Joined:
    Aug 29, 2019
    Messages:
    6,477
    Likes Received:
    17,340
    I noticed that too. You can have the objective and a signal at the same point and the distance to each shows as being different when quite far from it on a bendy track. I suppose it’s because signals and speed limits etc are only active when driving the train but the objectives can be uncoupling tasks, switches to change, places to walk to etc which are also active when you are on foot.
     
    • Like Like x 1
  8. montes_1234

    montes_1234 Well-Known Member

    Joined:
    May 5, 2020
    Messages:
    382
    Likes Received:
    379
    That is why Train Sim World can't have estimated time of arrival either. I wonder if there is improper distance measurement while driving the train because it will affect system performance?
     
    • Like Like x 1
  9. Crosstie

    Crosstie Well-Known Member

    Joined:
    Dec 8, 2016
    Messages:
    4,530
    Likes Received:
    10,149
    Yes it can be confusing. On relatively straight routes like HMA it doesn't matter much but on SPG you don't know where you are sometimes. Imagine your car GPS doing the same thing. Gives new meaning to "Daddy, are we there yet?". :love:
     
    • Like Like x 1
  10. Quentin

    Quentin Well-Known Member

    Joined:
    Dec 8, 2016
    Messages:
    438
    Likes Received:
    426
    wxtr7 makes a good point, but I think there are ways round that issue. The game 'knows' where you're starting and all your way points, which are generally linear, so you only need to hold a small table of the fixed, known distances along the line and then to keep track of how far the loco has travelled (a continuous calculation of speed x time ought to be near enough). There might be some minor issues with different routings, but that can be handled by reverting to 'straight line' distance calculation once you're within (say) 1 mile or 1 km.
     
    • Like Like x 1

Share This Page