CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
571 stars 85 forks source link

An option to enhance the behavior of the Can Cross Lanes road asset flag #1220

Closed Elesbaan70 closed 2 years ago

Elesbaan70 commented 2 years ago

I would like to see an optional setting which would alter the behavior of the Can Cross Lanes road asset flag as follows:

This is different from the standard behavior, in which vehicles simply cannot cross over the oncoming lanes to reach their destination, without going to an intersection.

This would allow the creation of roads with multiple medians, like Queens Blvd in NYC. Ramps connecting the express and local roadways could be configured using the lane connector, and rendered using the Intersection Marking Tool.

Screenshots?

image

Notes or questions?

Simply using the lane connector to restrict vehicles to the proper roadway wouldn't be any good, because emergency vehicles ignore it.

A possible alternative approach is to add a flag to the lane connector imposing its rule on emergency vehicles on a node-by-node basis. To really be usable, there would also need to be a shortcut similar to "Stay in lane" to easily set up lane connections that don't cross non-vehicle lanes.

Tagging #89 , #192 , #503 , #504 , #558 , #506 , #64 , #646

Elesbaan70 commented 2 years ago

I'm willing to actually do this work. I know what I'm doing, but I would need guidance in how CSL modding works and where the right pieces are to make this happen.

kianzarrin commented 2 years ago

Any non-vehicle lane that has vehicle lanes on both sides of it is considered a median.

Cool idea.

I also have a mod that can detect if there is median based on mesh. But I think your idea is good enough.

Elesbaan70 commented 2 years ago

Interesting. Does this mod achieve what I'm looking for, and is it compatible with TM:PE?

I think doing it based on lane configuration would have advantages. It's nice not to be dependent on the shape of the road surface (assuming that's what you mean).

originalfoo commented 2 years ago

Tagging #89 , #192 , #503 , #504 , #558 , #506 , #64 , #646

originalfoo commented 2 years ago

If this gets implemented (I hope so, love the idea - see tagged issues above) note that some roads have very strange lane configs, for example an empty lane that spans entire width of road, or empty lanes that just seem randomly placed... Would possibly need some way for user to interact with the lanes of a segment to indicate certain lanes should be ingored, etc. Width of lane would also need investigating, for example I suspect the UK roads with cat's eyes use prop lanes between each vehicle lane to place the props along the road; those should still be crossable.

kianzarrin commented 2 years ago

@aubergine10 for those weird roads we can use my median detection code based on mesh outline.

krzychu124 commented 2 years ago

I don't have much to add to what @aubergine10 already said. Many tried, everyone failed. It's way more complicated than you might think. Good luck 🤞🙃

originalfoo commented 2 years ago

243 was a past attempt, likely worth looking at in any future attempt

originalfoo commented 2 years ago

Regarding Qeens Blvd image in OP, how do we keep traffic out of the outer access lanes unless it's planning to park/deliver there? Otherwise there will be loads of traffic using those lanes as a through-route just like all the other lanes.

Maybe an "redsidents/deliveries only" vehicle restriction, or make the lanes appear congested so pathfinder generally tries to route around them?

originalfoo commented 2 years ago

@kianzarrin does this new mod cause issues with your median detection? curb height adjuster

kianzarrin commented 2 years ago

I thought of that too

Elesbaan70 commented 2 years ago

Regarding Qeens Blvd image in OP, how do we keep traffic out of the outer access lanes unless it's planning to park/deliver there? Otherwise there will be loads of traffic using those lanes as a through-route just like all the other lanes.

Does speed limit help with this? The speed limit will be lower on the local roadways than on the express roadways. It could be set quite low (within reason) if that would help.

Maybe an "redsidents/deliveries only" vehicle restriction

This won't work because the local roadway doesn't really work that way. For example, the express roadway may not allow a right turn; rather, you would have to take a ramp to the local roadway and turn right from there. Also, some minor cross streets only connect to the local roadways.

or make the lanes appear congested so pathfinder generally tries to route around them?

Sounds kludgy. ;-)

originalfoo commented 2 years ago

Slow speed limit would certainly help, and with the new speed limits UI that's currently being tested it will be vastly easier for users to set/change default speed limits of lanes (eg. so speed limit approach would work well for existing assets).

Elesbaan70 commented 2 years ago

Thanks for the feedback, everyone!

I want to avoid scope creep. It would be cool if this could solve all existing median-related problems, but I already suspected that it was just as likely to create problems as to solve them. That's why I proposed it as an optional setting.

This discussion, and #243, have shown me that there are too many things that could go wrong. This feature won't be much good if no one can enable it because of the problems it causes. My gut is telling me not to do it this way.

That leaves us with a couple of alternative options that I can think of:

Option 1: Just use the Lane Connector

In this case, the lane connector would need a flag on the node saying that it applies to all vehicles (including emergency vehicles and anything else otherwise exempt). And for usability, a shortcut to create sensible lane connections that don't cross non-vehicle lanes.

Option 2: Devise a way to configure the lanes on the road asset itself

This is by far the better solution, but I already know enough to know that it's not an easy one. The mods and assets I've seen suggest to me that we can't add our own properties to a road asset. I hope I'm wrong about this, because that would be the logical and straightforward way to do it.

Assuming that is not an option, I suggest that TM:PE add two dummy props at runtime: A Lane Movement Control prop, and a Delayed Lane Usage prop. Ideally these would get their own category in the Asset Importer dialog, but they could just be in the Roads category if necessary. They would render nothing, but TM:PE could detect them and use their settings as follows:

Lane Movement Control

Special attention to how this interacts with left-hand driving may be needed.

Delayed Lane Usage

This prop would also be great for center turning lanes.

Elesbaan70 commented 2 years ago

One more thought: It would probably make sense to automatically apply the Lane Movement Control prop's effect at runtime to the inner lanes of any road asset where Can Cross Lanes is unchecked. That way, the same logic can be used on all roads.

originalfoo commented 2 years ago

Adding props carries its own problems - eg. what if road is moved using Move It, or bulldozed, etc... props need to respond accordingly.

To avoid changes to pathfinder, the goal would be find some way to semi-automate (user would still need to choose where traffic can join/exit) lane connectors and speed limits in relation to medians and the distinction between local/regional traffic lanes.

I think Continues Junction Median and Adaptive Roads mods already cover some of the groundwork for what's required; namely being able to have custom road flags and toggle medians on/off.

Elesbaan70 commented 2 years ago

The idea for the props is that they are dummies, not rendering anything, which the person creating the road asset would add to the appropriate lanes to flag them as requiring special treatment by the pathfinder. They'd just be attached to the road asset itself, ready to be detected and acted upon by TM:PE, so moving and bulldozing wouldn't be an issue.

When placing the roads in your city, you wouldn't even be aware of them. You would just know that the medians are honored and the local roads used appropriately, and you would hopefully learn from the road asset descriptions that you should set up ramps using the Intersection Marking Tool, TM:PE's lane connector, and Node Controller Renewal. If this ever sees the light of day, I'll be creating guides and maybe YouTube videos for road asset creators and city creators.

I'll look more closely at the mods you mentioned, but I thought they were about rendering in response to TM:PE rules.

originalfoo commented 2 years ago

Rather than props, something like Adaptive Roads custom lane flags would probably be better approach; asset authors can specify flags, then AR mod lets users toggle the flags in-game, but the flags can also be read by mods. Flags can be used to toggle meshes, props, etc. - Kian will be best person to clarify that.

Looking at the road in google maps, it's a nightmare... There's so many junctions/filters to the central lanes that their whole purpose - to bypass local traffic - is utterly defeated. There's a major junction every 2 blocks, and often a filter junction between every major junction lolol.

image

Would there need to be multiple prefabs, eg. one (two?) with the filter lanes, one without filters? How are things like stop lines - but only on the filter lanes - going to work? Currently stop signs in CSL (and TMPE) affect all lanes in specific direction on the segment.

Elesbaan70 commented 2 years ago

It's more about separating the thru traffic from the vehicles that are picking up and dropping off or trying to parallel park, the pedestrians, bicyclists, etc., rather than actually eliminating cross streets.

The stop signs (there are stoplights in some cases too), if achievable at all, aren't something I'm looking at doing initially if ever. On the real street, they're a relatively recent addition. You can see the remnants of the old ramp design in the pavement structure.

The ramps, or filter lanes, would be at nodes. The lane connector would govern the vehicle movement, and the Intersection Marking Tool would paint it. Here's a proof of concept I did:

image

My objective isn't a perfect recreation, though I think that's what the person who put the idea in my head was hoping for. I just like the general concept.

krzychu124 commented 2 years ago

Ok, to clear up one thing because I see one thing confuse a bit:

Elesbaan70 commented 2 years ago

I'm going to step back from this and look for other smaller tasks to familiarize myself with modding Cities: Skylines before trying something this extensive.

I still want to come back to it, but I doubt that I would try to implement it as originally described. @aubergine10, since you liked the idea so much, does that mean it's all yours? 🤷‍♂️

originalfoo commented 2 years ago

See #1223 which gives rough idea (which may or may not be valid) of what might be involved - median detection, creating/associating lanes with medians, ordering lanes by position on road, grouping lanes between medians, etc. In addition to that, UI would need updating, eg. lane connectors/arrows would need to limit to connectable lanes.

kianzarrin commented 2 years ago

@aubergine10

@kianzarrin does this new mod cause issues with your median detection? curb height adjuster

Not that I know of.

kianzarrin commented 2 years ago

@aubergine10 can we use None lane as median at middle nodes? what about vertical offset? what about mesh outline? @Elesbaan70 said you know of examples that the above strategies will do more harm than good. but he cannot remember.

Someone came up with some examples of roads that had a "none" lane where there was no median intended. The most common example was roads with cat eyes, but when I suggested checking the vertical offset, someone had an example of that too. I'll have to go find the conversation in GitHub. Looking back at old discussions, I'm seeing a lot of me not knowing what I'm talking about 😆 and aubergine10 raising the concerns about using the "none" lane for median detection. But I'm not finding where I suggested checking the vertical offset. I could have sworn we talked about that. 🤔

originalfoo commented 2 years ago

None lanes are quite common - eg. in decorative networks, but also in roads such as those in UK Roads Revived assets - an example of running in to that issue here: https://github.com/CitiesSkylinesMods/TMPE/issues/1346

Elesbaan70 commented 2 years ago

None lanes are quite common

What about lanes (including pedestrian or bike lanes) that are at a different vertical offset? Do you know of a scenario where this would not indicate a median?

kianzarrin commented 2 years ago

@aubergine10 but is there any None lane in the middle of the road where the cars are supposed to cross? EDIT: and that has a vertical offset different than car lanes?

Elesbaan70 commented 2 years ago

and that has a vertical offset different than car lanes?

If vertical offset is an indicator of median, I think the lane type won't matter. But in this case there would need to be a limit--a range in which a median is indicated. Otherwise elevated tracks could become an issue in some cases. (I believe most of them have their supporting structure directly underneath so it would function as a median, but the supports could be off to one or both sides.)

kianzarrin commented 2 years ago

@Elesbaan70 what is supports?

Elesbaan70 commented 2 years ago

The structure that holds up (supports) the elevated track -- pillars, walls, etc.

originalfoo commented 2 years ago

@aubergine10 but is there any None lane in the middle of the road where the cars are supposed to cross?

Yes, sometimes

EDIT: and that has a vertical offset different than car lanes?

What about lanes (including pedestrian or bike lanes) that are at a different vertical offset? Do you know of a scenario where this would not indicate a median?

Not that I am aware of. But...

As you know, creators use existing road as template. If that road has lanes they don't want, they will get rid of them in various ways - eg. just removing meshes/textures, setting None on properties, etc., sometimes actually deleting the lane, other times just leave it sitting there untextured.

It is possible (but not visible to end users without detailed invetigation) that there are road assets with raised lanes that used to be a median, that the creator just unmeshed/textured etc - from creator and user perspective, the road works. From our perspective we now have something that looks like median that isn't a median. In this situation, is that "possibly median" over actual road vehicle lanes? If there is already traffic lanes driving "under" the "possibly median" then it's not a median from creator/user perspective.

Other random thoughts:

Elesbaan70 commented 2 years ago

My goodness, I was clueless when I created this issue!

What led to the conversation being reopened was this:

image

But as someone else pointed out on Discord, it's not really a good example of the median detection problem, because the cars are also crossing opposing traffic. The routing manager ought to be smart enough to prevent this when Can Cross Lanes is disabled, and I'll probably have a look at it myself at some point.

But I will eventually return to the Queens Blvd style roads, and would like to see some kind of solution to the median detection problem.

kianzarrin commented 2 years ago

@aubergine10 but is there any None lane in the middle of the road where the cars are supposed to cross?

Yes, sometimes

Can you please give me example? without example its hard to come up with a solution. never mind I just saw your examples.

kianzarrin commented 2 years ago

https://github.com/CitiesSkylinesMods/TMPE/issues/1220#issuecomment-1094122182 @Elesbaan70 one can argue the asset has a bug because it does not uncheck CanCrossLanes.

originalfoo commented 2 years ago

@aubergine10 but is there any None lane in the middle of the road where the cars are supposed to cross?

Yes, sometimes

Can you please give me example? without example its hard to come up with a solution.

I can't remember which asset it was. Next time I'm in game I'll test all the workshop roads I have - hopefully I still have it subscribed.

originalfoo commented 2 years ago

But as someone else pointed out on Discord, it's not really a good example of the median detection problem, because the cars are also crossing opposing traffic. The routing manager ought to be smart enough to prevent this when Can Cross Lanes is disabled, and I'll probably have a look at it myself at some point.

As an interim measure, could we determine how many oncoming lanes a vehicle is trying to cross? If more than 1 lane, it should be treated as highly dubious.

one can argue the asset has a bug because it does not uncheck CanCrossLanes.

Correct, but many asset creators have no clue what most of the properties do, especially if they haven't discovered sites like cslmodding.info. It's often case of just fudging a template asset in to something that works for them, then share to workshop. And most road assets never get updated after being published.

Elesbaan70 commented 2 years ago

one can argue the asset has a bug because it does not uncheck CanCrossLanes.

Except it does

image

I just realized I'm gonna have to address this in the displaced lanes feature, since the bug is only relevant as a bug in that context.

Elesbaan70 commented 2 years ago

As an interim measure, could we determine how many oncoming lanes a vehicle is trying to cross?

This probably needs to be moved to the displaced lanes discussion, but I think a lane change across any oncoming lanes is dubious.

For purposes of lane changes (not turns/connections), I'm thinking it should work something like this:

Correct, but many asset creators have no clue what most of the properties do, especially if they haven't discovered sites like cslmodding.info. It's often case of just fudging a template asset in to something that works for them, then share to workshop. And most road assets never get updated after being published.

I'm all for accounting for badly designed assets when we can, but we have to draw a line somewhere.

originalfoo commented 2 years ago

Yes, but what does "can cross lanes" mean to someone who does't currently know what it means. While the term makes sense to us, it doesn't necessarily make sense to everyone else. Do most users know what "enable bending nodes" means?

This probably needs to be moved to the displaced lanes discussion, but I think a lane change across any oncoming lanes is dubious.

If it's vehicle cutting across oncoming traffic to change to different origina-direction lane via a non-junction node, then yes, that is weird af and probably should never happen.

If it's making a delivery to building on other side of the road, then it's fairly common in UK and much of Europe.

For purposes of lane changes (not turns/connections), I'm thinking it should work something like this:

* CanCrossLanes==true, emergency vehicles can change lanes across oncoming traffic, others cannot

* CanCrossLanes==false, no vehicles can change lanes across oncoming traffic

I always thought the flag was about "can deliver to building on other side of road" / "can leave building and go directly to other side of road to start journey".

Elesbaan70 commented 2 years ago

Yes, but what does "can cross lanes" mean to someone who does't currently know what it means. While the term makes sense to us, it doesn't necessarily make sense to everyone else. Do most users know what "enable bending nodes" means?

We're talking about asset creators, not just anyone. Assuming that no one knows how anything works will cripple any future development.

If it's making a delivery to building on other side of the road, then it's fairly common in UK and much of Europe.

Over a median? That's what we're talking about. That's the proper use of the Can Cross Lanes flag.

I always thought the flag was about "can deliver to building on other side of road" / "can leave building and go directly to other side of road to start journey".

Yes, but bear in mind that this was CO's solution to the median problem. Rather than trying to work out the existence of an actual median, they made crossing oncoming traffic the determining factor, and put a flag on the road asset to indicate whether this should be allowed. So displaced lanes are a new use case they had not anticipated, but it still fits.

kianzarrin commented 2 years ago

@Elesbaan70 it seems like when I brought up median detection a few months ago, that idea got shot down.

@aubergine10 @Elesbaan70 All the issues you raised are all interesting and valid points. But none of them are serious enough to abandon this task all together.

Even if we cannot detect all medians, detecting some medians is an improvement that is easily achievable. At least it would make it possible for asset creators to make TMPE friendly roads.

What would be a serious (but even then I still don't think its a blocker) obstacle is a false positive. I have not seen any such example.

I think detecting medians using elevated None lanes is an easy yet effective phase 1 for this issue (you can do 80% of the work in 20% of the time). Currently no one can create assets that prevents cars from crossing medians. After completing phase 1 at least informed asset creators will have a way to solve this problem. dealing with uninformed/old assets can come in later phases of this operation.

it probably would take me less time to write the code than to discuss it!!!!

kianzarrin commented 2 years ago

I always thought the flag was about "can deliver to building on other side of road" / "can leave building and go directly to other side of road to start journey".

yes that is what it currently does. but it does not make too much sense because for the same reason (ie median) trucks cannot cross lane to access building, they cannot cross lane to do anything else either.

Elesbaan70 commented 2 years ago

@aubergine10 @Elesbaan70 All the issues you raised are all interesting and valid points. But none of them are serious enough to abandon this task all together.

Who, me? I'm actually in favor of this. I just want to pick it apart and make sure we aren't risking false positives.

I think detecting medians using elevated None lanes is an easy yet effective phase 1 for this issue

I don't even think you have to limit it to None lanes. but the elevation difference needs to fall within a range (even for None) to avoid false positives on lanes that are above the roadway and don't divide it. (see image below)

it probably would take me less time to write the code than to discuss it!!!!

In any case, this isn't really very urgent for me, since I'm gonna have to account for crossing oncoming lanes regardless of the presence of a median. 🤷‍♂️

Lanes above roadway that don't divide the road:

image

krzychu124 commented 2 years ago

I always thought the flag was about "can deliver to building on other side of road" / "can leave building and go directly to other side of road to start journey".

This and only this. There no other use of m_canCrossLanes in the whole game codebase (that's why vehicles can cross median when building ahead is on fire). It's used when StartPathfind is trying to find a position on lane for forward and backward starting/ending point so pathfinding will ignore all lanes going backward direction (those further away aka positionB) on the segment closest to the target building.

originalfoo commented 2 years ago

All the issues you raised are all interesting and valid points. But none of them are serious enough to abandon this task all together.

I'd hate to see th is abandoned. If we can get even a fraction of it working it will be huge improvement for creators and users alike.

I think detecting medians using elevated None lanes is an easy yet effective phase 1 for this issue

Assuming that there are no vehicle lanes overlapping them to a sufficient degree. But yes, if we can get this it will be awesome.

Elesbaan70 commented 2 years ago

@kianzarrin I think we should hold off on implementing this until displaced lanes are done. The two features have a lot of overlap, since we're basically talking about grouping lanes for lane transition rules, and we don't want a repeat of the LaneConnectionManager mix-up. ;-)

It might even turn out that combining the two features makes sense, but I won't know that until I get into it.

Elesbaan70 commented 2 years ago

I am closing this issue because I've formally defined an enhancement to achieve what it was after. #1528