These two blueprints both fit six cars, but the preview when hovering the station or signal only shows 5 (even when the option is set higher than 5, that's just a coincidence, the bug also appears with other lengths)
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Fri Sep 18, 2020 10:07 pm
by Rseding91
Looking at it my guess is: the position rendering and the actual train positions are 2 different pieces of code and so the preview isn't representative of what actually happens when you put a train on it.
I don't know if one of the other developers wants to go tinker with it more or call it 'good enough' so i'll leave this for them.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Thu Oct 01, 2020 10:07 am
by boskid
Not a bug.
You can place 6 rolling stocks and the 6th one does not register as being inside of the adjacent rail segment because of the rail joint placement (they are not at the absolute ends of rolling stock but are 1 unit inside) however the rail segment has length of 41.84 meaning that part of the rolling stock collision box would be outside of that rail segment. Moving last rail joint back by 1 unit leads to different rail block so the 6th spot is not rendered.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Thu Oct 01, 2020 6:31 pm
by sparr
I'm not sure why you think this is not a bug. Everything you described about the internal mechanisms doesn't seem to be actually important from a player point of view. Six cars can stop in that block without causing the previous block to turn signals red, and that's what matters to me as someone laying out my rail network. When would these other things matter?
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Thu Oct 01, 2020 6:38 pm
by boskid
Without this check something like this could happen:
89185-no-check.png (147.28 KiB) Viewed 4240 times
I do not want this to happen so the joint is moved 1 unit more to check if the rolling stock will be entirely inside of a single rail block.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Fri Oct 02, 2020 6:22 pm
by sparr
The point of this bug report is that the check is faulty. The current implementation of the check reports that a rolling stock will not be entirely inside a rail block when it actually will be. I definitely don't have enough insight into the game code to understand why it's wrong, I can just see in the game that it is wrong.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Fri Oct 02, 2020 9:06 pm
by boskid
No. It is 0.16 of distance outside of current block. End of the rolling stock is at the point A while the block ends at the point B.
89185-detailed.png (196.21 KiB) Viewed 4171 times
If you want to measure the length of the segment yourself, use this command by pointing onto a rail between a train stop and a signal (no junctions or other signals in between as they will split rail segment into multiple smaller ones)
If it shows you less than 42, train visualisation will not show 6 boxes. On the first blueprint it shows 41.84208 so there will be at most 5 boxes from train visualisation. Second blueprint after adding missing diagonal rail shows 42.6705 so there are 6 boxes from train visualisation.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sat Oct 03, 2020 6:20 am
by sparr
Thank you for helping explain how the current calculation works.
That does not change the fact that the current calculation does not match the relevant game mechanics.
Screenshot-2020-10-02-231810.png (511.03 KiB) Viewed 4130 times
Notice the green signal. When the train stops in the given position, the block behind it is not occupied according to the signal and routing algorithms, and another train will be able to enter that block. If it's following the stopped train, it will move right up against it, nose to tail. If there's an intersection crossing the cyan segment then trains will drive through it. As far as I can tell, that's the only thing that really matters. I can't find any practical game effect of the calculation you're describing.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sat Oct 03, 2020 7:40 am
by boskid
sparr wrote: ↑Sat Oct 03, 2020 6:20 am
That does not change the fact that the current calculation does not match the relevant game mechanics.
I know, and it is intended to not follow them. You are right that the block behind is not occupied by that train since the last rail joint is within block ahead with a 0.842 of distance to spare. However the last rolling stock box is not rendered because the rolling stock box itself would be outside of the current block.
89185-box-outside-of-block.png (147.53 KiB) Viewed 4116 times
In this case train is also able to have all its joints within a single block so following your logic the box should be rendered. However the box itself is clearly outside of current block and is misleading and is not always guaranteed the train will leave the block behind because the rail joint is exactly at the transition so it may not transition to the next rail block yet.
If you want to squeeze every possible bit of rail distance accepting some trains artifacts, you may use the get_rail_segment_length() ruler and if it shows more than 41 (but not 41 exactly), the train should fit entirely inside of that rail segment and release the block behind, however the 6th box will not be rendered until the get_rail_segment_length() gets up to 42.
89185-box-within-block-but-gfx-not.png (381.71 KiB) Viewed 4116 times
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sat Oct 03, 2020 6:29 pm
by sparr
Why doesn't the internal code use >41 instead of >=42? That's what I still don't understand. What would break or be inaccurate if we did that?
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sat Oct 03, 2020 6:43 pm
by boskid
sparr wrote: ↑Sat Oct 03, 2020 6:29 pm
Why doesn't the internal code use >41 instead of >=42? That's what I still don't understand. What would break or be inaccurate if we did that?
Because it would look bad when box would stick out of the block.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Tue Oct 06, 2020 3:44 pm
by Therax
I'm with sparr here. Functionality trumps appearance. If 6 wagons fit in the block without spilling into the next block, there should be 6 frames shown, even if they visually spill past the train signal.
If it's desired that the frames don't spill past the signal for cosmetic reasons, then the logic for occupied blocks should be adjusted to account for the physical wagon size (collision box) rather than using only train joint locations.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Wed Nov 01, 2023 2:53 pm
by sparr
With 2.0 introducing new rail functionality, a lot of us intense rail optimizers are going to be taking a fresh crack at a whole new assortment of layouts. Having to manually check whether trains fit in blocks (instead of relying on the visualization) is going to jump back to the top of my tediousness list.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sun Nov 26, 2023 8:10 pm
by boskid
Gergely wrote: ↑Sun Nov 26, 2023 8:04 pm
What about this case?
I am not seeing anything interesting with this case. Diagonal straight rail has front and back signal positions overlapping and so the signal binding logic is implemented to choose if a signal is binding to the front or to the back. If one of those is not possible (because there is also curved rail nearby forcing a merge of diagonal straight rail and next diagonal straight rail) then it will choose the other position but if both are possible the the signal is binding to the back of diagonal straight rail. When there are 5 spots rendered it is simply signal binding to the back of the diagonal rail causing the rail segment with a train inside to be longer by 1.41 and so there is enough distance to fit 5 spots with the required margin.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Gergely wrote: ↑Sun Nov 26, 2023 8:04 pm
What about this case?
Diagonal straight rail has front and back signal positions overlapping and so the signal binding logic is implemented to choose if a signal is binding to the front or to the back. If one of those is not possible (because there is also curved rail nearby forcing a merge of diagonal straight rail and next diagonal straight rail) then it will choose the other position but if both are possible the the signal is binding to the back of diagonal straight rail. When there are 5 spots rendered it is simply signal binding to the back of the diagonal rail causing the rail segment with a train inside to be longer by 1.41 and so there is enough distance to fit 5 spots with the required margin.
I was about to post a similar problem of there being an inconsistency when I mirror a track.
What3.png (422.08 KiB) Viewed 1652 times
What4.png (340.83 KiB) Viewed 1652 times
But yeah, after reading your explanation I came to understand this has to do with the logic having to choose between either end of the diagonal track.
Yeah5.png (1.09 MiB) Viewed 1652 times
Therefore the blocks are split at different heights.
Yeah6.png (1.08 MiB) Viewed 1652 times
Actually both stations appear to fit a 5-length train while leaving the neutral block intact. How do I compute the required rail segment length for any train?
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sun Nov 26, 2023 8:42 pm
by boskid
You can check available length by measuring rail segment length (assuming there are no merges or splits in the middle) using the command mentioned above:
As for the length a train needs to fit entirely inside of such segment: Lets introduce arriveDistance = 2 (distance between position where train stop binds and front joint of a train), jointDistance = 4 (distance between joints of same rolling stock) and connectionDistance = 3 (distance between 2 rolling stocks that have a connection). After arrival the train will need `arriveDistance + N*jointDistance + (N-1)*connectionDistance` to fit. For example a train with 3 rolling stocks will need a rail segment of at least 20. It is not guaranteed last rail joint will pass the transition if the segment has length of exactly 20 so usually it must be slightly more. Visualisation takes a margin of 1 for this so if a segment has length of 21, there will be 3 boxes rendered. If the segment length is between 20 and 21 the train may fit but the visualisation will no longer draw 3rd spot.
Re: [1.0.0] more trains fit between signals than the preview shows on c
Posted: Sun Nov 26, 2023 9:28 pm
by computeraddict
As I understand it the discrepancy comes from the rail cars being visually longer than the space they take up in a block, and the block visualizer using the visual bounding box instead of the pathfinding bounding box.
Could the visualizer cheat and squish the previewed bounding boxes by a fraction so that it is car-count accurate without overflowing into blocks it isn't supposed to? Or could the visualized boxes just be shrunk to be accurate to their pathfinding joints and the visual overhang of real stock beyond the joint bounding box be ignored? I think ignoring the graphics extending past the joint boundaries like the pathfinding system does is preferable to misrepresenting capacity of blocks by a system that is designed for visualizing the capacity of blocks.