-
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
Better segment hovering raycast #576
Comments
This would be great when camera is looking downwards, but what happens if user has camera tilted upwards (looking more towards horizon) and tries to select a segment on the far side of a junction? EDIT: Anything that makes node/segment selection easier is a win from my perspective. |
I haven't done casting before but if we could cast the mouse on the terrain and find the coordinates that would be great. Don't we already do the same thing about lane markers? |
The terrain can be uneven, streets will approach the junction from all 3d directions. So yes, cast to the terrain, and then solve in 3d space. |
Note, however, that transition (including between segments of different direction of same type of asymmetric road) and junction (including level crossings) nodes always flatten terrain, regardless of existing terrain or slope of segments connected to them. (It's why doing junctions on sloped rail tracks is such a nightmare). |
Random idea: Could we buff the clickability of segments based on their length? So the shortest segment is easier to select via the node (it's 'select triangle' within the node would be enlarged slightly)? |
I got this working on my test tool: https://github.com/kianzarrin/KianHoverTool/blob/450a5bf42b43e4361b2f9d5b4530780b21b18022/KianHoverElements/Tool/KianToolBase.cs#L169 |
I integrated it into @aubergine10 I managed to "buff the clickability of segments based on their length" as you suggested. easy peasy fun! But do you think I should do it? I will make it depend on a boolean so that we can switch forth and back at will. |
I tested this on roads with bridges over. It works no-problem! |
I tested this with trains. No improvements with regards to level crossings. I will look into this. |
The reason why it does not work on level crossing is that this code does not find nodes of level crossing: // find train nodes
nodeInput.m_netService.m_itemLayers =
ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels ;
nodeInput.m_netService.m_service = ItemClass.Service.PublicTransport;
nodeInput.m_netService.m_subService = ItemClass.SubService.PublicTransportTrain;
nodeInput.m_ignoreNodeFlags = NetNode.Flags.None;
// nodeInput.m_ignoreNodeFlags = NetNode.Flags.Untouchable;
if (RayCast(nodeInput, out nodeOutput))
{ I did not manage to hover level crossing nodes. TMPE hover such nodes by first finding the hovered segment and then looking at segment ends. It feels weird to find the node based on segment and then find segment based on node. but its worth a shot. To |
my pull request #615 is merged in but I am having second thoughts about it! In particular this:https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/pull/615/files/ced446c5fbf2ca559049df904f7eb56f25479d03#r368252980 I am looking at segment end to mouse pointer angle even when the mouse pointer is not at node but rather in the middle of a segment. Now that I think about it maybe it is possible to bend the roads so extremely to make the wrong segment selected. ~~I tried but did not managed to find a way to make the code fail. does not mean that it can't ~~ I manged to reproduce the problem using move it mod: |
in #564 I made it easier to hover over small segment. Even so hovering can still be hard for small junctions. I think this is a caveat with skylines built-in ray-cast but I think I have a work around.
Here is the problem:
In the picture above I have demonstrated a situation in which its very hard to select the highlighted segment end. In fact the 2 mouse positions in the picture above are the only places the mouse can be to select the desired segment end. You notice that the mouse is near the right segment but still the left segment is selected. This is not right. I think that the selection areas should be like this:
Terminology:
Note that I want to change the hover area only. The highlight shape is and shall remain half sausage.
The text was updated successfully, but these errors were encountered: