Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lane arrow tool detection of bidirectional lane connections has a bug. #738

Closed
kianzarrin opened this issue Feb 25, 2020 · 7 comments · Fixed by #856
Closed

lane arrow tool detection of bidirectional lane connections has a bug. #738

kianzarrin opened this issue Feb 25, 2020 · 7 comments · Fixed by #856
Labels
BUG Defect detected confirmed Represents confirmed issue or bug LANE ROUTING Feature: Lane arrows / connectors
Milestone

Comments

@kianzarrin
Copy link
Collaborator

Lane arrow tool does not reset lane arrows for lanes that have lane connections.
but the code to detect lane connections has a bug if the lane is bidirectional:

        /// <summary>
        /// determines whether or not the input lane is heading toward a start node.
        /// </summary>
        /// <returns>true if heading toward and start node.</returns>
        private bool IsHeadingTowardsStartNode(uint sourceLaneId) {
            NetLane[] laneBuffer = NetManager.instance.m_lanes.m_buffer;
            ushort segmentId = laneBuffer[sourceLaneId].m_segment;
            NetSegment segment = GetSeg(segmentId);
            uint laneId = segment.m_lanes;
            bool inverted = (segment.m_flags & NetSegment.Flags.Invert) != 0;

            foreach (var laneInfo in segment.Info.m_lanes) {
                if (laneId == sourceLaneId) {
///////////////////////////////
// what if laneInfo.m_direction is both
///////////////////////////////
                    return (laneInfo.m_direction == NetInfo.Direction.Forward) ^ !inverted;
                }
                laneId = laneBuffer[laneId].m_nextLane;
            }
            throw new Exception($"Unreachable code. sourceLaneId:{sourceLaneId}, segmentId:{segmentId} ");
        }

This means if the there is a segment with junctions at both ends, and one side of it has lane connections, it can confuse lane arrow tool.

@kianzarrin kianzarrin added BUG Defect detected triage Awaiting issue categorisation labels Feb 25, 2020
@originalfoo
Copy link
Member

I imagine this is particularly problematic when it comes to things like single train tracks that allow bidirectional traffic with the Single Train Track AI?

@originalfoo originalfoo added the LANE ROUTING Feature: Lane arrows / connectors label Feb 25, 2020
@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 25, 2020

Lane arrow tool does not support tracks

EDIT: Network extension 2 has some roads with turning lane. the turning lane is bidirectional. For a small segment I have seen cars moving on it in both directions going through each other! I don't know if mass transit DLC would fix this.

@originalfoo
Copy link
Member

Network extension 2 has some roads with turning lane. the turning lane is bidirectional. For a small segment I have seen cars moving on it in both directions going through each other! I don't know if mass transit DLC would fix this.

No, Mass Transit doesn't resolve those issues. Maybe we need a "Single Road Track AI" 😄

From vague memory there are a few other workshop road assets that use 'both' for their "turning lanes", although many use a different trick: Two directional lanes (one forward, one backward) on top of each other lol.

Lane arrow tool does not support tracks

True, although once #734 is done we could potentially add lane arrow suport as a "direction-based alternative" to lane connectors?

@originalfoo originalfoo added confirmed Represents confirmed issue or bug and removed triage Awaiting issue categorisation labels Feb 26, 2020
@kianzarrin
Copy link
Collaborator Author

Silly me! I should have tested things before speculating.
I tested my code is working fine. NExt2 does not use bidirectional lanes but rather two single directional lanes on the top of each other.

If any road does use bidirectional road lanes (i don't even know if that is possible) then TMPE will be unable to store the flags for both ends (because there is only memory allocated for one lane).

@kianzarrin
Copy link
Collaborator Author

the NExt2 turning lane only has left turn prop but cars do go straight:
Screenshot (892)
Screenshot (890)
but that is an issue for NExt2

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Apr 20, 2020

I found a new issue though. I cannot reset lane arrows after I remove the lane connection.
How to reproduce:
1- make a lane connection (observe that lane arrow changes to follow the lane connection).
2- remove lane connection
3- try to reset lane arrows using lane arrow tool. lane arrows won't reset to default.

@originalfoo
Copy link
Member

Is that only for NExt2 roads or all roads?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Defect detected confirmed Represents confirmed issue or bug LANE ROUTING Feature: Lane arrows / connectors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants