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

More Accurate Lane Connection Arcs #282

Closed
wants to merge 2 commits into from

Conversation

krzychu124
Copy link
Member

@krzychu124 krzychu124 commented Apr 13, 2019

Key changes:

  • greatly improved shape of lane connection. Now it should be almost equal to path of moving vehicle 😉
  • removed rendering of gray circles from all intersections (still visible on intersection with lane connection set - todo)
  • improved drawing performance in edit and preview mode (little game hang when switching from preview -> edit - todo)

I think this could be the first new enhancement pushed to LABS first before moving to STABLE but we will see 😉

PR set as draft for now until I'll fix those problems 😃

lane connections

Fixes #3

@krzychu124 krzychu124 added enhancement Improve existing feature LABS TM:PE LABS branch labels Apr 13, 2019
@krzychu124 krzychu124 self-assigned this Apr 13, 2019
@krzychu124 krzychu124 changed the title #3 More accurate lane connection arcs #3: More accurate lane connection arcs Apr 13, 2019
@originalfoo
Copy link
Member

testing :)

@originalfoo
Copy link
Member

originalfoo commented Apr 13, 2019

Looking good!

I noticed that, in edit mode, when mouse is over a road segment, the node-selection circles hide the lines as shown below:

blank

This makes it hard to see the existing connections.

When mouse is not over a road segment, the lines show normally through the circle.

Also, the brown line colour is difficult to see close to twilight hours when not using Daylight Classic mod.

@krzychu124
Copy link
Member Author

Yeah some colors has to be changed.

I will check what can be done with that circle on hover.
Would be nice to add transparency to it and make it appear on hover in edit mode only, to be consistent with other tools involving node selection.

BTW. There is an array with colours at the bottom of that class. You can play with those colors if you find some time 😉

@originalfoo
Copy link
Member

I think part of the problem with the colours at the moment is that it tries to give each lane entering the junction its own colour, which can be a huge number of colours on complex junctions. If there is viability to get some of the other lane connector UI improvements in we might be able to simplify some aspects of that.

Copy link
Collaborator

@FireController1847 FireController1847 left a comment

Choose a reason for hiding this comment

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

Honestly, it looks amazing. I kind of like the behavior of the lines being unable to be seen on hover (when selecting the node). It helps identify the node that you're trying to focus and makes it clear and concise what's going to be edited. Viewing the lines should be done within the actual edit, not before.

I also didn't notice many issues with colors, however I do agree that in the image posted the brown kind of contrasts, but that's a minor detail that can be easily fixed.

I'm unsure of what this "game hang" you're talking about is, as on my laptop (I run the game at 720p lowest settings for reference, get 20 fps) I did not get ANY lag whatsoever using the tool after building this branch.

Overall, looks amazing, and imho, is pretty ready for merging. What can I say? It's really, really good.

@originalfoo
Copy link
Member

I kind of like the behavior of the lines being unable to be seen on hover

The lines get hidden when the mouse is over any road segment, not just the node.

I don't use the overlays to keep fps high (a habit I got in to when I was back on the old potato computer), so when I want to check my lane connections I activate the lane tool and look around the map. Having lines disappear if the mouse hovers a road breaks that use case, a use case that's important for people with potato computers.

If we wanted to show feedback when mouse is over a node, the circle could just change colour.

I'm unsure of what this "game hang" you're talking about is

I also did not notice any lag, however my current computer is pretty good spec and while testing I was just in small city with few roads and fewer lane connectors active. I assume the issue becomes prevalent in larger cities, slower computers, or just with more lane connections?

@krzychu124
Copy link
Member Author

There is an issue when you set lane connections at complex intersection Lane connections preview is not refreshed after removing segments. Currently lane connection arcs are rebuild only after switching from preview to edit... I'll have to add some listeners for that.

@originalfoo
Copy link
Member

originalfoo commented Apr 19, 2019

Can this line be altered:

https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/blob/4b68e8939c6d94b2e466d814568ae75c86b4800c/TLM/TLM/UI/SubTools/LaneConnectorTool.cs#L492

So that if isTarget is true it uses white color (ideally from a constant as I plan to remove white from the list of colors at bottom of file). This will ensure all target nodes are white by default.

Just noticed there is this:

https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/blob/4b68e8939c6d94b2e466d814568ae75c86b4800c/TLM/TLM/UI/SubTools/LaneConnectorTool.cs#L27

@originalfoo
Copy link
Member

I converted the colors array to fake CSS so I could use pigments plugin, here are the colors visualised:

colors

There are several that are too dark. Before I get started working on new colors palette, do we need 48 colours?

@krzychu124
Copy link
Member Author

There are several that are too dark. Before I get started working on new colors palette, do we need 48 colours?

Honestly I think we don't.
48 colors means - 48 incoming lanes to intersection node.
That has to be 6 segments with 8 lane one-way road each.

@krzychu124
Copy link
Member Author

krzychu124 commented Apr 19, 2019

I've created simple 'sigh!' performance test setup 😄 Notice FPS gain on my not so potato computer

  • ~30-31FPS
    no connection rendered
    Zrzut ekranu (162)

  • ~15-18 FPS
    [Stable] Lane connections - Preview mode
    Zrzut ekranu (164)

  • ~13-15 FPS
    [Stable] Lane connections - Edit mode
    Zrzut ekranu (165)

  • ~25-27 FPS
    [Labs - current PR version] Lane connections - Preview mode no difference between Edit mode
    Zrzut ekranu (163)

I will add savegame link after unsubscribe 7583 mods 😄

@originalfoo
Copy link
Member

So the penalty we pay for better lane routing arcs is a performance increase. 😀

48 colors means - 48 incoming lanes to intersection node.

Currently color choice is based on nodeMarkers.Count % colors.Length (line 492 as mentioned in earlier comment). If we have a counter that tracks number of isSource nodes, that would be better metric than nodeMarkers.Count as it will avoid skipping colors in the palette due to isTarget nodes, so less chance of reusing same colour on the soon-to-be reduced colors palette.

@originalfoo
Copy link
Member

https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/blob/4b68e8939c6d94b2e466d814568ae75c86b4800c/TLM/TLM/UI/SubTools/LaneConnectorTool.cs#L481-L483

Would it be better to just update the .y of the existing vector? Will reduce number of new vectors created = less garbage collection.

@krzychu124
Copy link
Member Author

I will try to hardcode target markers to be white.

Some thoughts about performance 😃

The funny thing is that there is still room for improvements with regards to rendering performance 😄

Current lane connections and markers are rendered using the same shader that is used to render blue placeholder when placing road segments, selecting buildings, cars etc...

I was digging through code and I think that removing unnecessary calculations (rounded ends and transparent filling) should boost rendering speed.

Additionally we can increase performance even more by writing simple custom shader which job would be only to draw arc with some width with lower resolution (it's not a rocket science 😄 ).
Collisions for conflict points could be calculated using bezier curves then add to list of shapes to render

After that I will try to create shader for square and triangle #41 lane connectors because it seems to be better tool for rendering those shapes with nice anti-aliased lines than using complex mesh or texture 🙃

Good catch with this Vector3 👍 I am sure there are more issues like this.

@originalfoo
Copy link
Member

Research on color alphabet for lane connector: #287

@krzychu124
Copy link
Member Author

Lane connections test setup save

@originalfoo
Copy link
Member

originalfoo commented Apr 20, 2019

Testing that save...

Stable 10.18:

  • No overlay: 42fps
  • Preview: 24-30fps
  • Edit: 24-30fps

Labs PR 282:

  • No overlay: 42fps
  • Preview: 38fps
  • Edit: 38fps

So, new version is 8 to 14 fps faster than current release :D

One thing that became very apparent while in edit mode is that it's difficult to see which node is being edited. Would it be possible to "thin" the lines of other nodes, or maybe make them slightly transparent? That way the node being edited will have visual difference to the non-editing nodes.

EDIT: I can confirm the problem with node selection circle (hiding lines) is resolved.

There is an issue when you set lane connections at complex intersection Lane connections preview is not refreshed after removing segments. Currently lane connection arcs are rebuild only after switching from preview to edit... I'll have to add some listeners for that.

I wasn't able to reproduce either of those, but not sure I fully understand what the issue is so might not have actually tested properly lol.

@originalfoo
Copy link
Member

originalfoo commented Apr 20, 2019

Heading to bed, but some things I realised need testing....

  • Lane connections underground (in tunnels)
  • Lane connections on other networks (do they even apply to other networks? rail, metro, tram, monorail, paths?)
  • Lane connections on junction under elevated/bridge, and on elevated/bridge

@krzychu124
Copy link
Member Author

To test issue with refreshing preview, just build big intersection using wide segment e.g. 6-lane 2-way (node will be bigger) then connect outer lanes of near segments and after that change segments type to smaller e.g. rural road or basic 2-way one-lane. Lane connections will stay the same in preview mode. Refresh is performed only when you switch to edit mode (bezier arcs cache is rebuild there)

Yeah... I think I will add one more color but half transparent. Original for preview all or belonging to currently edited node and half transparent to preview other from not selected nodes

@originalfoo originalfoo added this to the 10.20 milestone Apr 20, 2019
Copy link
Collaborator

@FireController1847 FireController1847 left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure what's going on, but I cloned and attempted to use this on my laptop, and now the lines are not showing up at all. The nodes are there and I am able to connect lanes, but the lines themselves do not appear.
ezgif-1-89107f8ddd79

On a somewhat unrelated note, would it be possible to look into and fix #293 while we're messing with the lane connectors?

@originalfoo
Copy link
Member

originalfoo commented Apr 21, 2019

There is another issue in the GIF above, that the outgoing connector for u-turn is not appearing on monorail roads (see: #293).

@FireController1847 Does the issue in your GIF only happen on monorail roads, or does it happen on normal roads as well?

@originalfoo
Copy link
Member

originalfoo commented Apr 21, 2019

Oh, yeah, that's another thing.... Some networks are nodeless.... Like several of the CSUR roads, and several of the Railway rail networks.

So that might throw a huge spanner in the works. I'll ask on the asset creator discourse to see if anyone is aware of any networks that create non-flat junctions.

BTW, remember that the lane connector tool also has to work on 'non-junction nodes' between segments etc.

@originalfoo
Copy link
Member

Junctions and corners are flat.

node flat

Not sure what the score is with inter-segment nodes (that don't really appear as nodes, they're just join between two segments). I guess in that instance you could just angle the rectangular surface that you're drawing on?

@krzychu124
Copy link
Member Author

I am asking about that because I don't want to create situation where part of that rectangular plane would be overlapped by segment/node texture.

@originalfoo
Copy link
Member

If you can get a filled rectangle rendering then should be possible to splat those over all types of node where lane connector can be used, to see if any are at weird angles or if they are all flat.

@FireController1847
Copy link
Collaborator

FireController1847 commented Apr 21, 2019

@aubergine10 Specs are the following:

  • OS: Windows 10 Home 64-Bit, Build 17763
  • CPU: 8-Core Intel i7-4700MQ @ 2.4GHz
  • GPU1: Intel Graphics 4600
  • GPU2: nVIDIA GeForce GT 740M
  • GRAM: 2 GB
  • RAM: 12 GB, Page: 12 GB
  • DXv: DirectX 12

The launch flag does not make a difference (other than making it run much worse).

EDIT: Oddly enough, I've only had this happen on the "Grand River." I did not build a complex road network, just a simple quick drag right off the freeway. Using other maps makes it work just fine.

EDIT2: Did more testing. Have now had it happen with "Grand River" and "Foggy Hills." It's not due to altitude, I used Move It! to try and move the node and it worked fine on "Cliffside Bay." Is it a shader issue?

@originalfoo originalfoo modified the milestones: 10.20, 10.21 May 10, 2019
@FireController1847 FireController1847 changed the title #3: More accurate lane connection arcs More accurate lane connection arcs May 14, 2019
@VictorPhilipp
Copy link
Collaborator

VictorPhilipp commented May 27, 2019

@aubergine10

Testing lane connector in tunnels:
While it works, there are some obvious issues:

1. I can't see the roads (I had to just move mouse randomly until node selector appeared)

You can press "Page Down" to switch to underground view.

@VictorPhilipp
Copy link
Collaborator

I think this could be the first new enhancement pushed to LABS first before moving to STABLE but we will see 😉

So the milestone should be 11.0 then?

@originalfoo
Copy link
Member

@VictorPhilipp

You can press "Page Down" to switch to underground view.

Is that hard-coded to PageDown key or is it based on whatever key is assigned to one of the standard game shortcuts (eg. lower road, or whatever)?

@FireController1847 FireController1847 changed the title More accurate lane connection arcs More Accurate Lane Connection Arcs May 28, 2019
@kvakvs
Copy link
Collaborator

kvakvs commented Jun 24, 2019

When measuring performance please refer to micro/milliseconds per frame, not the FPS or FPS drop
It is more precise and allows to remove the the rest of the game logic and render from the measurement.
60 fps is 16.67 ms/frame, not all of it is available for TM:PE, game needs time too.

@krzychu124 krzychu124 force-pushed the 3-more-accurate-lane-routing-arcs branch from c923e5d to 969d3b8 Compare August 4, 2019 16:41
@originalfoo originalfoo added Overlays Overlays, data vis, etc. LANE ROUTING Feature: Lane arrows / connectors labels Aug 13, 2019
@originalfoo originalfoo deleted the 3-more-accurate-lane-routing-arcs branch February 28, 2022 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing feature LABS TM:PE LABS branch LANE ROUTING Feature: Lane arrows / connectors Overlays Overlays, data vis, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI: More accurate lane routing arcs
5 participants