-
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
Parking restrictions - lane highlight not working #827
Comments
@kvakvs could this be caused by similar tool controller issue that affected traffic lights? |
I did not change anything in the Parking tool, but what I did change is that there are now Legacy style tool classes and new tool classes, and they coexist. While the functionality is mostly retained compared to the release before, there seems to be some problems related to rendering order (such as # 824 always rendering above all UI). |
Yes, it was me that reported it heh. I'll test again with current master but it was certainly not working with 11.3.0 last night. |
I'm running @kvakvs main menu PR, maybe he fixed something there (I remember that something was missing in Lane Arrows facelift)? |
Ok, so this is odd... It works in some places, but not others: Apologies for dark images, it's nearly nighttime in my city and a thunderstorm just started. These two image illustrate better (TMPE menu placed above the (P) icon I am hovering): So maybe it is specific to certain roads or something? Not working on Olive Street: Works fine on Pine Street: If you want to test with those roads, they are from UK Roads: Small Roads pack. |
Would bus stops have any effect? Do they add additional lane and the overlays don't notice the change in lanes? |
I modified method in ParkingRestrictionsTool.cs to log some debug trace when Alt key pressed: private void RenderSegmentParkings(RenderManager.CameraInfo cameraInfo) {
bool allowed = parkingManager.IsParkingAllowed(renderInfo_.SegmentId, renderInfo_.FinalDirection);
bool pressed = Input.GetMouseButton(0);
bool debug = Input.GetKey(KeyCode.LeftAlt);
if (debug) {
Log.Info($"[Segment: {renderInfo_.SegmentId}] allowed: {allowed}, pressed: {pressed}");
}
Color color;
if (pressed) {
color = MainTool.GetToolColor(true, false);
} else if (allowed) {
color = Color.green;
} else {
color = Color.red;
}
Bezier3 bezier = default;
netService.IterateSegmentLanes(
renderInfo_.SegmentId,
(uint laneId,
ref NetLane lane,
NetInfo.Lane laneInfo,
ushort _,
ref NetSegment segment,
byte laneIndex) => {
bool isParking = laneInfo.m_laneType.IsFlagSet(NetInfo.LaneType.Parking);
if (debug) {
Log.Info($" - [Lane: {laneId}] isParking: {isParking}, laneDir: {laneInfo.m_finalDirection}, renderDir: {renderInfo_.FinalDirection}");
}
if (isParking && (laneInfo.m_finalDirection & renderInfo_.FinalDirection) != 0) {
bezier = lane.m_bezier;
laneMarker_ = new SegmentLaneMarker(bezier);
laneMarker_.RenderOverlay(cameraInfo, color, enlarge: pressed);
}
return true;
});
} On this segment, highlighting works: Trace: + Info 801.2018646: [Segment: 29732] allowed: True, pressed: False
Info 801.2027105: - [Lane: 238241] isParking: False, laneDir: None, renderDir: Backward
Info 801.2032626: - [Lane: 242835] isParking: False, laneDir: None, renderDir: Backward
Info 801.2037823: - [Lane: 67437] isParking: False, laneDir: None, renderDir: Backward
Info 801.2043326: - [Lane: 126872] isParking: False, laneDir: None, renderDir: Backward
Info 801.2048620: - [Lane: 18803] isParking: False, laneDir: None, renderDir: Backward
Info 801.2053869: - [Lane: 116100] isParking: False, laneDir: Backward, renderDir: Backward
+ Info 801.2059225: - [Lane: 140059] isParking: True, laneDir: Backward, renderDir: Backward
+ Info 801.2065133: - [Lane: 175182] isParking: True, laneDir: Backward, renderDir: Backward
Info 801.2070670: - [Lane: 243009] isParking: False, laneDir: Both, renderDir: Backward
Info 801.2077417: - [Lane: 144102] isParking: False, laneDir: Both, renderDir: Backward On this segment, highlighting fails: + Info 1,183.9462637: [Segment: 14454] allowed: True, pressed: False
Info 1,183.9471625: - [Lane: 242170] isParking: False, laneDir: None, renderDir: Backward
Info 1,183.9478688: - [Lane: 158510] isParking: False, laneDir: None, renderDir: Backward
Info 1,183.9484980: - [Lane: 206640] isParking: False, laneDir: None, renderDir: Backward
Info 1,183.9490779: - [Lane: 185764] isParking: False, laneDir: None, renderDir: Backward
Info 1,183.9496771: - [Lane: 112831] isParking: False, laneDir: None, renderDir: Backward
Info 1,183.9502507: - [Lane: 141908] isParking: False, laneDir: Backward, renderDir: Backward
Info 1,183.9508148: - [Lane: 163894] isParking: False, laneDir: Forward, renderDir: Backward
- Info 1,183.9513744: - [Lane: 127260] isParking: True, laneDir: Both, renderDir: Backward
- Info 1,183.9519440: - [Lane: 141601] isParking: True, laneDir: Both, renderDir: Backward
Info 1,183.9525139: - [Lane: 63506] isParking: False, laneDir: Both, renderDir: Backward
Info 1,183.9530717: - [Lane: 22135] isParking: False, laneDir: Both, renderDir: Backward So the issue seems to be that the lane dir and render dir mismatch (due to bad road asset; it's parking lanes have dir This is the line that's preventing the lane highlighting: if (isParking && laneInfo.m_finalDirection == renderInfo_.FinalDirection) { That line is required because when a road has parking in two directions, there will be two parking icons (as shown in image above), one for each direction, so depending on which icon is hovered (ie. which direction user wants to alter) we need to filter out the other direction. Maybe it could be changed to: if (isParking && (laneInfo.m_finalDirection & renderInfo_.FinalDirection) != 0) { That should work due to the way the Will test that now... If it works, next step will be to only show one parking icon if any parking lane has dir |
Ok, that got the lane highlighting working again. @kianzarrin Any suggestions on how to do next step:
|
It looks like What I suspect to be happening:
Regardless, the dictionary Also, looking at the code, I notice that we're iterating all lanes in the segment several times. Maybe it would be better to iterate lanes once to create a list of parking lanes for the segment, then pass that list around. During that iteration we could also identify if any are parking lanes. I need to get some sleep, but will have a try and doing that tomorrow. |
this is related to #516
@aubergine10 if you recall we had a in-depth discussion about this in #516 (comment) |
This piece of code may have something to do with it (check for inconsistent int dirIndex = GetDirIndex(finalDir);
parkingAllowed[segmentId][dirIndex] = flag;
if (!flag || !parkingAllowed[segmentId][1 - dirIndex]) {// WHY 1 - dirIndex ?!!!!
Services.SimulationService.AddAction(
() => {
// force relocation of illegaly parked vehicles
Services.NetService.ProcessSegment(
segmentId,
(ushort segId, ref NetSegment segment) => {
segment.UpdateSegment(segmentId);
return true;
});
});
} EDIT: on the second thought, this might prevent a lane update, but it should not influence the highlighting. |
It's also creating excessive GC, due to all the throwaway methods, etc. I will be reviewing all that code when I eradicate the old game bridge. |
In LABS 11.3.0 release (or maybe earlier?) the parking restrictions lane highlight is no longer working.
Related PR where it was added: #708
Parking signs still show and can be toggled and seem to be functional. So it seems it's just the lane highlight that's gone.
The text was updated successfully, but these errors were encountered: