-
Notifications
You must be signed in to change notification settings - Fork 85
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
Hilight problematic short segments when mouse hovers node #1229
Comments
Honestly I will see is as a new overlay/icon layer just for warnings. Could be enabled and filtered based on active tool or something. Similar to what we see when one-way has a dead end, trolleybus/tram segment end is not connected, etc. |
I've reviewed the code and found one big bug 😱 or I would say huge design flaw that makes junction features to work only when segment is long enough... segment length doesn't really matter if you know what you are doing and how simulation works (yes I've spent few days figuring out how simulation works in tiny details while working on EVE revival and improvements recently). Test case (impossible to handle correctly running any version of the mod - yes, they have green here but as described, it doesn't matter - try yourself) : 2021-12-12_05-41-06.mp4Here the same scenario but with one little change in the code: 2021-12-12_05-42-27.mp4Bonus points: Big downside of the change: Important note:Game can process even multiple segments/nodes per each simulation step for each vehicle in chunk (1024/step), number of processed segments is correlated with vehicle speed, speed limit and segments length. |
How much impact is there in relation to "a lot slower"? Is there some way we could embed "junction coming up, enable extra checks" in to the path units? That way the vehicle AI isn't doing all the extra work while driving down long stretches of road, it's only doing heavy lifting a few segments from a junction? |
Each simulation step vehicle calculates 4 next positions (circles). Between steps it travels between current and next frame (rectangles) not further than to the first target, in the next step target0 is usually "converted" to "next" frame if speed is constant. 130 km/h (cur. segment is the segment of current pathUnit) 40 km/h That change shouldn't have big impact for highways since segments are pretty long and also roads where junction node connects only two segments. I need to do some benchmarking, but keeping in mind user "cried" that simulation accuracy at very high was forced some time ago, this will be like multiple times of it if you place a lot of short segments and set medium speed (50-70km/h) with either traffic lights or priority signs. |
Could it scale based on vehicle speed? So slower vehicle speed = less look-ahead? EDIT: Also, are those diagrams rendered in game (the circles/squares, not the text/arrows heh)? |
Distance between target positions is dynamic, based on vehicle speed, ability to brake and some other minor details.
It's a part of my Pathfind Sandbox (will be). I found nice and clean way to select/follow instance you want to observe so I started attaching more stuff to it in form of overlays. |
Regarding EVE, there might be some possibility to use |
Used in vanilla to force despawn vehicle approaching congested segment to prevent making longer traffic jams XD
Used when vehicle use emergency signal lights
Used in special cases, e.g. when fire truck stopped near the burning building and is extinguishing fire, similar for the fire copter, maintenance trucks when they maintain road, water trucks when pumping water, disaster response units searching for "problems" etc.
Is applied unconditionally to every vehicle that enter segment, problem is it is per netInfo, so for all segment instances on the map. Good to help with deciding if effects like dust should be rendered, but not that useful for EVE (need to think about that). I've been testing different approach with better results. |
Created wiki article to collate infos about |
I was experimenting with priority signs code and I think we could improve some behaviour, especially when vehicle is driving off main road (yield other vehicles incoming from the front). Default behaviour, they will run into each other, ignoring priorities One way to fix it, but may introduce problem/unwanted yield for traffic going straight Blue truck will patiently wait for enough space or a gap in incoming traffic because of congested exit of intersection What I would like to see:
Probably there are other cases where vehicles should yield. I noticed in code that once vehicle enter intersection area only vehicle collision is calculated - no further priority checks, so at big intersections or roundabouts it increases a chance of causing fake congestion on main road (going around the roundabout) blocking the traffic (yielding traffic will start entering intersection because of traffic gap mentioned above) Maybe I'm blind, do we have any thread/issue with regards to problems/suggestions about priorities/priority signs, similar to those for traffic lights, parking AI etc.? |
I remember some discussion of this, give me a few mins and I'll see if I can find it. |
It would be super-useful if we could set priority by lane, rather than segment. That way the far-side turn lane could be given a stop/yield and the straight-on lanes could be priority to allow smooth traffic flow. There's some other stuff relating to T-junctions and Y-junctions (forks) that needs considering which I don't think is directly mentioned in the linked issues above, I'll try and jot down some thoughts on those in an hour or so. |
This is what I meant, but for all cases without even touching intersection with TM:PE settings. Traffic Priority feature should be ON at Maintenance tab, Sim Accuracy at least High since checking priorities at every intersection may cause small slowdown (maybe check only in 300-500m from camera or reuse 0,1,2 LOD levels of vehicle simulation) 2022-02-06.21-52-53.mp4 |
that's freaking awesome! |
Priorities are not tested at node so they behave a bit rough, 2022-02-06.22-01-50.mp4 |
That's still a good improvement on what currently happens IMO In terms of simulation workload, what's the "LOD level of vehicle simulation"? I assume the game is reducing complexity based on how far away the camera is? EDIT: possibly related: |
Yes there are 3 LOD levels, at level 2 all collision checks are skipped, at level 1 only vehicle-pedestrian iirc |
More "unprotected" turns. Scenario:
2022-02-07.03-44-50.mp42022-02-07.03-44-00.mp42022-02-07.03-41-18.mp4 |
For deadlock issues, some ideas:
As mentioned above we could also have pecking order based on |
Yeah, we should write down info about priorities somewhere, maybe in the wiki as upcoming feature then just implement missing bits.
Yes it does not make sense if you put priority signs. I would apply it automatically under the hood e.g. for transition nodes when e.g.: road with median is connected to basic road.
|
Yeah, I remember Hehe, I'm watching how they move... it's so satisfying to look at 😄 |
For deadlock I also think what would happen IRL... Usually bigger vehicles can muscle in (and are used to doing so if you've ever known a lorry driver lol - they still do it when driving cars), so things like service and transport. But also you could get things like reckless drivers pushing in, and people on way to work might be more likely to enter junction, etc. For cars in particular we could possibly have it affected by individual driving style feature? I still think individual driving style should be on by default and use the driver id as if it were a randomised bitmask defining traits of the driver, including how they behave at junctions (are they more passive or aggressive, etc). Driver age could also affect their behaviour. |
Another thing with individual styles, some drivers might be more willing to let others go first - eg. if there's a big queue they might flash lights to let car at front enter junction (or exit junction if they were part entered). |
Btw, now as I watch they wait for their turn I started thinking about fixing blinkers so even if vehicle does not move and e.g.: waiting to turn left it could have blink left ON (that's possible, just require a tiny patch).
Yeah, I thought about that too. At worst we can select them by ID -> decision is taken every sim step so every 1024/4096(MV) vehicles - we can "push" first found vehicle from current chunk 🙃 |
Additionally, it would be great if they didn't use blinkers when simply driving round a curved segment (unless it's one-way street where it might be roundabout heh). I have some really bendy roads snaking through mountains and it always irrates me how vehicles indicate round sharp bends lol. |
Fully manual prototype 2022-02-07.22-17-40_Trim.mp4 |
Ooh, can we make it so if a vehicle breaks fast it puts both indicators on to warn other traffic? |
Could also do both indicators when vehicles are pulled in to a building to load/unload/etc. |
I have no idea how to detect it.
Will be the easiest thing actually 😄 I was thinking about bus tops - emergency when boarding then turn to join traffic. Since most calls are invoked 4 times/per vehicle/per step it's not obvious where to put 'start' and 'reset' triggers 🤔 |
omg, wat?! |
Movement is interpolated between frames (last and next - rectangles). Next calculation occurs when vehicle is about to hit next frame. It needs to calculate 4 target positions (circles), they are used as next position (target0, closest), other to determine if vehicle will accelerate or slow down/ stop. Most of TM:PE methods, like eg. 5% speed: 2022-02-08.00-33-58.mp42022-02-08.00-37-30.mp4Normal speed XD 2022-02-08.00-39-17.mp4 |
More or less _blinking_😄 2022-02-08.04-11-35.mp42022-02-08.04-09-24.mp4 |
nice! How is the blinking done? Is it just a flag that gets set and the game does the rest, or do you have to write code to keep turning it on/off? |
Currently I'm checking direction between current and next segment. If |
Can nodes store arbitrary metadata? |
The way lane changes are limited to nodes, and the speed at which vehicles just jolt in to next lane would make indicators look weird in that context anyway IMO. It would be interesting to see the vehicle frames overlay (or whatever it's called) at 5% speed as a vehicle encounters a lane change.
Very basic solution would be based on which side of road traffic drives on for the current city - internal static bool LHT => Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;
internal static bool RHT => !LHT; But there are situations where bus stop is on a median, or even other side of road (in case of 1-way busways) - to discern that you'd need list of sorted lanes (there's already code for that) but ideally cached because it would be ludicrous to keep recalculating when segments very rarely change (geometry observer can help invalidate cache where necessary - this is also something desperately needed for overlays and which I'll probably make a start on after mod options chainsawing). With cached list of sorted lanes for segment, it's simple case of checking if lane Also would need to skip the whole thing if bus is stopping in a building (eg. bus terminal). Actually, it doesn't matter if the code to determine which side the bus stop is on is bloaty and slow - it only needs to run once when the stop is created/moved. We need |
Oh, one other scenario for which side bus is on that breaks my earlier assertion that we can just check a single lane position... Roads with central bus lanes separated from normal road lanes by median, eg: various BRT roads like this one in workshop: There are also inverted versions of that: |
I just need a way to say that lane is directly connected or connection requires changing to the left or right.
Not at all. Just was clip with overlays - notice that gray lane marks current lane and I can add code for testing lane change at each circle (in the first clip after few sec. first yellow circle is calculating position on the next segment) so depends on speed I can turn on indicator even one or two segments before actual lane change occurs and even better, when congested you will see them blinking way before they actually change lane. It will be nice addition. I can also inject same thing into DLS code, so when TM:PE decide there is a better lane I can turn on signal in that case too - again segment or even multiple before lane change. Notice how far vehicle needs to move after turning left till signal stops blinking. IMO, pretty nice. 2022-02-08.20-49-16.mp4At 99% because of DLS but still, lane change is not instant. You can detect is pretty long ahead 2022-02-08.20-56-23.mp42022-02-08.21-02-09.mp4 |
Describe your idea
Very short segments cause vehicle AIs to behave unexpectedly when connected to nodes customised with the following tools:
MaxYieldVelocity
#686Those tools all require user to first select a node to edit before they can customise it; we can warn user about short node prior to selecting the node:
See also: #698
Screenshots?
n/a
Notes or questions?
Broken Nodes Detector mod has code that scans for short segments; could use that code but only check segments attached to the hovered node to reduce overheads.
Code for checking the segments attached to a node, and showing/clearing the warning could be centralised making it easier to incorporate in to any tools that need it. If memory serves, all those tools change the node highlight when mouse is over the node, so it would just be a case of adding maybe 1 line of code to the tools' node hover/leave/select handling methods.
The class should probably cache the node it just checked (and the result) so that it doesn't need to do expensive checks every frame. The cache would be cleared when the mouse leaves a node, or the node is selected for editing.
User could still select the node and customise it if they want to take the risk, but at least now they'll know what's causing problems if vehicles are ignoring their customisations.
Additional future enhancements:
The text was updated successfully, but these errors were encountered: