[2.0.14] Rail signal selection rectangle does not match actual selectable area
Posted: Mon Nov 04, 2024 4:23 pm
Summary of how it affects Vanilla:
When the rail signal selection box is shifted either by making selection_box offset from (0,0) or by making selection_box_shift values nonzero, the mouse-over area is correct but the highlight rectangles (and debug selection rectangle) are rendered incorrectly.
This bug can be directly observed in the vanilla rail-signal in orientations where the selection_box_shift value is significant. For example, this screenshot and clip shows the NorthEast rotation. You can see that the highlight box is centered on the tile center, not the area to the right where the mouse-over is detected. Normally this is nearly undetectable because the rail covers (and takes priority over) the part of the selection area not surrounded by the highlight box, and the vanilla selection_box_shift values are all small.
More detailed explanation:
The effect is very pronounced when using larger shifts, and makes them unusable.
What I did:
- Set rail signal selection_box = {{-1.5, -0.5}, {-0.5, 0.5}}, so that the box is offset from the center of the collision box and the rail. I rendered the sprite for 16 directions including shifts along the required vectors.
What works:
- This behaves as expected in the North, South, East, and West orientations.
- In diagonal directions, the mouse-over region is correctly centered and rotated to follow the graphics at the set distance from the rail.
- In diagonal directions, the selection outline is rotated about its center the correct amount.
- If I alter the selection_box_shift values for the RailSignalPictureStructure, the selectable mouse-over region shifts accordingly.
What doesn't work:
- In every diagonal direction, the selection rectangle (both the yellow/green/blue highlight and the debug selection rectangle) is drawn centered on the wrong point. It is always shifted 1 tile left, the correct shift for North, rather than by a rotated vector. It does not line up with the actual region where the entity can be selected.
Graphical evidence:
These screenshots and clips show the highlight shift behavior for every rotation (with selection_box_shift set to {0,0}). Observe that for the diagonal ones, the blue selection_rectangle is always 1 tile to the left of the collision_rectangle, even though the mouse-over area moves by the proper vector to follow the sprites.
When the rail signal selection box is shifted either by making selection_box offset from (0,0) or by making selection_box_shift values nonzero, the mouse-over area is correct but the highlight rectangles (and debug selection rectangle) are rendered incorrectly.
This bug can be directly observed in the vanilla rail-signal in orientations where the selection_box_shift value is significant. For example, this screenshot and clip shows the NorthEast rotation. You can see that the highlight box is centered on the tile center, not the area to the right where the mouse-over is detected. Normally this is nearly undetectable because the rail covers (and takes priority over) the part of the selection area not surrounded by the highlight box, and the vanilla selection_box_shift values are all small.
More detailed explanation:
The effect is very pronounced when using larger shifts, and makes them unusable.
What I did:
- Set rail signal selection_box = {{-1.5, -0.5}, {-0.5, 0.5}}, so that the box is offset from the center of the collision box and the rail. I rendered the sprite for 16 directions including shifts along the required vectors.
What works:
- This behaves as expected in the North, South, East, and West orientations.
- In diagonal directions, the mouse-over region is correctly centered and rotated to follow the graphics at the set distance from the rail.
- In diagonal directions, the selection outline is rotated about its center the correct amount.
- If I alter the selection_box_shift values for the RailSignalPictureStructure, the selectable mouse-over region shifts accordingly.
What doesn't work:
- In every diagonal direction, the selection rectangle (both the yellow/green/blue highlight and the debug selection rectangle) is drawn centered on the wrong point. It is always shifted 1 tile left, the correct shift for North, rather than by a rotated vector. It does not line up with the actual region where the entity can be selected.
Graphical evidence:
These screenshots and clips show the highlight shift behavior for every rotation (with selection_box_shift set to {0,0}). Observe that for the diagonal ones, the blue selection_rectangle is always 1 tile to the left of the collision_rectangle, even though the mouse-over area moves by the proper vector to follow the sprites.