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

Dead end connection #1613

Merged
merged 25 commits into from
Sep 30, 2022
Merged

Dead end connection #1613

merged 25 commits into from
Sep 30, 2022

Conversation

kianzarrin
Copy link
Collaborator

@kianzarrin kianzarrin commented Jul 15, 2022

fixes #1213: Connecting a lane to itself creates dead end

TMPE.zip

it looks like this:
image
Note: as it was the case already: if a lane cannot have a possible target, then laneEnd node maker will not be displayed.

data base:

  • I store it as a lane connection to the same lane.

lane arrows:

  • no lane arrows for dead ends
  • BONUS: lane arrows are reset when all outgoing lane connections are removed form the lane.

when user hovers over same lane :

  • it draws a lane curve to the same lane:
  • any other existing lane connections would hide to indicate what is the post condition of the action.
  • no mouse cursor is displayed to avoid confusion.

@kianzarrin kianzarrin self-assigned this Jul 15, 2022
@kvakvs
Copy link
Collaborator

kvakvs commented Jul 16, 2022

Tested and i love it.
The mouse cursor on loop lane does not change to (+)

split overlay code into smaller methods
use better render order
overDrawCode is more readable and consistent.
@kianzarrin kianzarrin changed the base branch from master to LCM-Cleanup July 17, 2022 19:46
Base automatically changed from LCM-Cleanup to master August 11, 2022 20:38
@kianzarrin
Copy link
Collaborator Author

The mouse cursor on loop lane does not change to (+)

its intentional. should it change to + ? Creating dead end removes all existing connections.

@kvakvs
Copy link
Collaborator

kvakvs commented Aug 12, 2022

The mouse cursor on loop lane does not change to (+)

its intentional. should it change to + ? Creating dead end removes all existing connections.

Maybe use some road sign like 🚫⛔ (easy to confuse with minus) or ❌or something

@kianzarrin
Copy link
Collaborator Author

@kvakvs Maybe use some road sign like 🚫⛔ (easy to confuse with minus) or ❌or something

I think there is no need for mouse sign in here. it only makes things more confusing.

@kianzarrin kianzarrin marked this pull request as ready for review August 12, 2022 22:33
Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting updated X texture plus editable SVG source, please drop them together in the same directory

@@ -423,6 +452,15 @@ public class LaneConnectionSubManager :
return true;
}

private void AssertLane(uint laneId, bool startNode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this function ends with Assert call, is that a debug assert? And in release will it do the calculations but no assert?
Declare this function as [Conditional("DEBUG")]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its only called when adding/removing lane connections so its not performance critical. therefore I decided to include it in release build. you never know .... it might help with debugging user errors.

Should I make it conditional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the assert function is marked debug only. i believe it is. So in release this code does nothing, just calculates values and returns.

Copy link
Collaborator Author

@kianzarrin kianzarrin Aug 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert is not marked as debug.
AssertNotNone is the only one that is marked as debug. its inconsistent with all the rest of the assert functions.
but that does not matter. I think its a good idea to execute assert in release mode here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the [Conditional("DEBUG")] from AssertNotNone() and instead added #if DEBUG around the usage. so now its consistent

if (!HasOutgoingConnections(laneId, startNode)) {
const bool RESET = false; // reset lane arrows when last lane connection is removed.

if (RESET && !HasOutgoingConnections(laneId, startNode)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if (false && is probably a source of a compiler warning

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not (and should not) cause compiler warnings. its a legit thing to do.
we do that all the time when logging:

#if DEBUG
        private bool verbose_ => DebugSwitch.LaneConnections.Get();
#else
        private const bool verbose_ = false;
#endif
if(verbose_ ) ....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I understand if you feel like its unnecessary code

@kvakvs
Copy link
Collaborator

kvakvs commented Aug 14, 2022

dead_end
dead_end

@DaEgi01 DaEgi01 self-requested a review August 20, 2022 11:19
Copy link
Contributor

@DaEgi01 DaEgi01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some small things. can't speak much for the logic itself since i m not deep enough in the details. krzy should def. check it out.

canConnect =
IsDirectionValid(ref sourceNetLane, sourceLaneInfo, nodeId, true) &&
IsDirectionValid(ref targetNetLane, targetLaneInfo, nodeId, false);
canConnect = IsDirectionValid(ref sourceNetLane, sourceLaneInfo, nodeId, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternary expression for the win

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notice the &= operator. won't fit well with ternary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true! I didn't see that at first.
wouldn't it be better to encapsulate the logic in the isdirectionvalid method itself?
since the method with the change now only does a "90% job".

if (sourceLaneId == targetLaneId) {
return false;
}
bool deadEnd = sourceLaneId == targetLaneId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd move it down where its used first. just a small thing.

@@ -392,8 +393,36 @@ public class LaneConnectionSubManager :
}
}

var connections = GetLaneConnections(sourceLaneId, sourceStartNode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be its own method right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what can be its own method?

Copy link
Contributor

@DaEgi01 DaEgi01 Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically the whole block that was added.
than again, I can't think of a good name, probably because these are actually two different things that are happening here based on deadEnd. I'd do it the other way around.
if (deadEnd)
removeNonDeadEndConnections()
else
removeDeadEndConnection()
and move the laneId loop inside.

or something like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be two one line functions (unless if you count in the verbose log). Not sure this is a good idea.

if (!HasOutgoingConnections(laneId, startNode)) {
const bool RESET = false; // reset lane arrows when last lane connection is removed.

if (RESET && !HasOutgoingConnections(laneId, startNode)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also dont get the point of this code. i understand it for #ifdef but whats the point here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool I remove it.

@@ -423,6 +452,15 @@ public class LaneConnectionSubManager :
return true;
}

private void AssertLane(uint laneId, bool startNode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably AssertDeadEndConnection would be a better method name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i should also add IsValidWithSegment() too. i mean if we are asserting stuff we might as well do it right.

@kianzarrin kianzarrin requested a review from DaEgi01 September 7, 2022 22:36
@krzychu124 krzychu124 added this to the 11.7.1 milestone Sep 14, 2022
@krzychu124
Copy link
Member

@kianzarrin dead end icon is not visible if you close tool and open again.

Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks ok, I hadn't got a chance to test it in game yet.

@krzychu124 krzychu124 changed the title dead end connection Dead end connection Sep 26, 2022
@kianzarrin
Copy link
Collaborator Author

Code looks ok, I hadn't got a chance to test it in game yet.

should I wait?

@krzychu124
Copy link
Member

Yeah, you can wait, I'll do a quick test later today. Do you have any other plans with this feature or something else?

@kianzarrin
Copy link
Collaborator Author

nope this is the last one in the series of the lane connection EPIC issue #1479.
There are also few optional issues over there about minor ascetics improvements but I can't fix them.

@krzychu124 krzychu124 self-requested a review September 28, 2022 21:09
Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backspace/Delete does not reset lane arrows on dead-end lanes just like removing dead-end manually does

@kianzarrin
Copy link
Collaborator Author

OK I reset all lane arrow for node regardless of whether or not it had lane connection.

Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to be working now

@kianzarrin kianzarrin merged commit 5ae6ed4 into master Sep 30, 2022
@kianzarrin kianzarrin deleted the LCM-dead-end branch September 30, 2022 10:22
@krzychu124 krzychu124 mentioned this pull request Oct 2, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set dead ends for lanes using lane connector
4 participants