CitiesSkylinesMods / TMPE

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

Pedestrian crossings review #854

Open originalfoo opened 4 years ago

originalfoo commented 4 years ago

Need to check that our pedestrian crossing logic is correct. Triggered by this image - why are there ped crossings on highway roads that don't have pedestrian lanes?

img

In https://github.com/CitiesSkylinesMods/TMPE/issues/578#issuecomment-616089662 , @kianzarrin said:

I did brought this up int he pull request https://github.com/CitiesSkylinesMods/TMPE/pull/845#issuecomment-615114683.

Fixing it would be as easy as setting IsPedestrianCrossingAllowedConfigurable() to false

if the road does has 2+ pedestrian lanes:
    IsPedestrianCrossingAllowedConfigurable = true
    GetDefaultPedestrianCrossingAllowed = true
else if the road to the right has pedestrian lanes AND the road to the left has pedestrian lanes
    // maybe this logic should be more sophisticated to check that the pedestrian lanes is on inner/outter side of the road
    IsPedestrianCrossingAllowedConfigurable = true
    GetDefaultPedestrianCrossingAllowed = true
else
    IsPedestrianCrossingAllowedConfigurable =  false
    GetDefaultPedestrianCrossingAllowed =  false

The GUI automatically does not show pedestrian crossing overlays if they are disabled. Actually in my mod I have patched TMPE to hide pedestrian crossing overlays when appropriate.

kianzarrin commented 4 years ago

Screenshot (951) updated algorithm to handle special case like urban highway connection above. even if the road does not have pedestrian lanes pedestrian can cross.:

//psudo code

segment.SortedLanes[0] is pedestrian => segment has pedestrian lane on the right (going toward the junction).
segment.SortedLanes[count-1] is pedestrian => segment has pedestrian lane on the left(going toward the junction).
bool HasPedestiransOnRight = segment has pedestrian lane on the right OR segment.RightSegment has pedestrian on the left
bool HasPedestiransOnLeft = segment has pedestrian lane on the left OR segment.RightSegment has pedestrian on the right

IsPedestrianCrossingAllowedConfigurable = HasPedestiransOnRight and HasPedestiransOnLeft
GetDefaultPedestrianCrossingAllowed = 2+ pedestrian lanes

So the highway-urban junction above pedestrian crossing is configurable but is banned by default.


Screenshot (955)

I also would like to avoid ugly wierd junction transitions like above:

if node has two segments:
    GetDefaultPedestrianCrossingAllowed &= segment.size < otherSegment.size // pedestrian corssing is allowed on the smaller segment only.
    for equal segments only the first one gets pedestrian crossings by default.

With this code (and the hide crossings mod) the zebra crossings will look like this by default but both are configurable: Screenshot (952)

@aubergine10 what do you think? should we ban crossings across highway-urban junction by default? in a node with two segments, should we remove crossing on the bigger segment by default?

originalfoo commented 4 years ago

Yes, that looks good. IMO we could probably ban crossings on any road with 4+ lanes (medium/large/highway roads) unless there is a traffic light to ensure safety of pedestrians.

However... I think we will need to look carefully at pathfinder to ensure that cims with check other side of a node. In the image directly above this comment, a cim walking along the road with grass verges hoping to cross to other side is likely to assume there is no crossing rather than notice the crossing on the smaller road. I'm not sure if that issue ever got fixed: https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/168