-
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
Heinous Junction Restrictions overlay #845
Conversation
Probably out of scope of that PR, but why we are showing pedestrian crossing icon if it's not possible to change its state? Highway roads doesn't have pedestrian lanes and also cannot have pedestrian crossing, obviously. I'll try to test it later today. |
This is looking a lot better, I can now clearly see which road the 'enter blocked junction' icons are relating to. In this case it also seems to be putting them on the correct side of the road (left hand traffic map) which is awesome! However, there's some cases where it seems to put the icons on the other side of the road, like this: I thought it might be something to do with 1-way roads, but on same type of road it sometimes puts them in correct side like so: It's only very minor point; I'm already happy with the big improvement from this PR and we could look at further refinements at a later date. |
CS has calculated the middle position between two corners like this //psudo-code:
pointA, tanA = NetSegment.CalculateCorner(junctionID, left side )
pointB, tanB = NetSegment.CalculateCorner(junctionID, right side)
centerPos = (postA+pointB)/2
//the original code can be find in this overloaded method:
//private void RefreshJunctionData(ushort nodeID, int segmentIndex, ushort nodeSegment, Vector3 centerPos, ref uint instanceIndex, ref RenderManager.Instance data) you can use dirA and dirB from code above to align the signs. if you want to be even more thorough than that you should travel across curved road using I think calculating the tangent is going to be more complicated. In any case this is just in case you were interested. I don't think it is so important to put the signs at super accurate place. |
I don't know if this fits the scope of this review but there is no point to show pedestrian crossing overlays on roads without pedestrian crossing. So In future when we have Pedestrian tool (#40) then we can show a disabled pedestrian overlay and show a guide message to the user if he tries to click it. but here ... its too much info. this is particularly important on roundabouts where there are a lot of traffic rules to set. |
I had good results in the past when calculating tangent as a vector between 0.9f point and 1.0f point (or 0f and 0.1f if inverted direction).
The actual rendering code will render if debug is enabled. Where debug is The logic where its displayed in |
Several issues that is probably outside of the scope of this review and exists in your branch as well as in master:
|
@kianzarrin yes you can copy this comment later to the future PR when i'll be working on the LaneConnectors refactoring, it makes sense to fix those problems then. |
Regarding the hide crossings mod: Note that some roads (eg. UK Roads assets) don't have zebra crossings so the only way to see if there is a crossing is via the overlay icons. |
i said its no longer THAT necessary. meaning that it is necessary but not necessary enough to show it in persistent overlay. at the very least it would be nice to have the option to turn it off.
in any case there are a lot of urban roads without pedestrian crossings. |
@kvakvs I noticed that the sprites are always in the same place regardless of junction size: you should move the sprites further back as the junction gets bigger. so i think using |
int numSignsPerRow, | ||
float signSize, | ||
bool viewOnly) { | ||
// Vector3 centerStart = nodePos + (yu * (viewOnly ? 5f : 14f)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out code
|
||
this.zero_ = GetZeroPosition( | ||
nodePos: nodePos, | ||
xu: this.yBasis, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again x and y are swapping!
@kianzarrin the C:S code for calculating corners is not used anywhere in TM:PE, there's no example of its meaning. Also the source is massive like 5 pages of dense vector calculations, it can't be fast or simple. I almost matched everything to your suggestion but this will be called for each segment each frame... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I agree with what Kian is saying regarding corner radius; if there was some way to ensure the icons do not appear inside the node but instead get pushed outwards so they are over the road segment, that would help with visual comprehension of what roads they relate to. That being said, this is still major improvement over what it used to be; the corner radius stuff could come as subsequent PR?
Suggest @kianzarrin either add commit to this, or merge and come with your change later. I am literally down to experimentation if i try that corner calculation. That takes significant effort from me while you seem to know what is needed exactly. |
@kvakvs sorry for the late response. I lost the review! In NetNodeRenderInstance corner is calculated in every call to render instance. I guess all those pages of calculation is not as slow as you think because there are so many branches and only one branch is taken. (i guess branching makes code even slower). In any case I think we should cache this stuff.
Calculating the corner looks scare but it's disappointingly easy once you get to it (disappointing in case you want a challenge). Sure I can write some code and commit that in. BTW its nice that I can (for some reason) see the conflict. its helpful to know that its nothing. |
-define constants to make sure sign sizes have harmony in both normal mode and view mode. - simplified the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kvakvs Overlay.cs should move to UI.Helpers ( I didn't do it my self because it would have made it difficult for you to see what exactly have I changed).
In the picture bellow my FPS dropped from 25(no overlay) to 20 (a lot of overlay). This is far slower than @kvakvs code that drops FPS from 25 to 24 |
|
f2b9ed7
to
b3e7150
Compare
Not doing any caching at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kvakvs This was intended to be a bugfix here not a huge rework
This would be a good argument if this PR (mainly my corner calculations) was not dropping FPS. The FPS does not drop too much so I its tolerable. Tell you what I i'll cache corner calculations and upload it to this PR. That will fix the FPS issue.
I added calculate corner cache, renamed priority signs overlay to traffic signs overlay (because it is only used for junction restriction for now) and changed a couple of comments. dirX_ is not perpendicular to dirY_ (and I added a comment for that). hopefully that is not confusing. in any case there are axis systems without perpendicular axis so I think that is fine. |
Calculate corner is being cached to soon returning |
I added patch to Calculate corners after |
Created #872 to discuss further when and where to perform recalculations. |
Fixes #633
Problem
Different display style of Junction Restrictions overlay was very confusing see #633
⚠ Please note that the code is using segment middle point as the direction, and it is not a bug that on curved segments the signs look a bit off to the side. If this is undesired, i can calculate more precise endpoint tangent which will look better.
Solution