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

Add, delete, and dissolve roadpoint buttons in 3D menu #64

Closed
4 tasks done
TheDuckCow opened this issue Mar 14, 2023 · 7 comments · Fixed by #129 or #131
Closed
4 tasks done

Add, delete, and dissolve roadpoint buttons in 3D menu #64

TheDuckCow opened this issue Mar 14, 2023 · 7 comments · Fixed by #129 or #131
Labels
enhancement New feature or request

Comments

@TheDuckCow
Copy link
Owner

TheDuckCow commented Mar 14, 2023

We want to try and emulate much of the 3D path's functionality, including a quick way to click to add points, as well as easily delete a point without much consequence.

It would be good to implement both of these at once, so that that join the menu at the same time.

  • Delete point:
    • This should mostly be a queue free/remove operaiton, like any other node. Ideally, the roadpoint itself better handles on its own how to connect any two roadpoints on either side and do a better job of telling the roadnetwork to clean up old RoadSegment meshes left behind
  • Dissolve Point:
    • Similar to the delete operation, but with this tool active it wouldn't create a cut or break the road into pieces, similar to how deleting a point in a path/curve object maintains the end to end connection (though that's mostly because curves have no concept of having broken segments).
  • Select Point: While this tool is "active" (?):
    • Essentially it is the current functionality. Clicking off anywhere will result in a deselection. Clicking on a RoadPoint blue square will result in it being selected.
    • We could consider even changing this further by having a click which lands on a RoadSegment update to assign the selection of the nearest RoadPoint connected to it. If we are aligned on doing this, would be its own task though.
  • Add point: While this tool is "active" (?)
    • If you click somewhere, raycast down to a surface to find a 3D point; if no intersection, rayast into the xz place of the roadnetworks position itself.
    • If you had a roadpoint selected initially that wasn't "fully connected", the newly added roadpoint should be oriented to "face" the initially selected roadpoint, and have them both connect to each other.
    • Should be able insert additional points between existing roadpoints, if the placement of the cursor is "close enough" to where the curve of that according road segment is (effectively splitting this road into two segments).

Pulled out of this task to be on its own: #5

@TheDuckCow TheDuckCow added the enhancement New feature or request label Mar 14, 2023
@TheDuckCow TheDuckCow changed the title Create add and delete roadpoint buttons in create menu Add, delete, and dissolve roadpoint buttons in 3D menu Mar 28, 2023
@TheDuckCow
Copy link
Owner Author

TheDuckCow commented Jun 11, 2023

Initial priority is to focus on the low hanging fruit: the delete and dissolve buttons. Add RP will require some more RD (but well worth it).

Remember that we are operating in "modes", not buttons that directly perform an action. See curve behavior for reference:

Image

@TheDuckCow
Copy link
Owner Author

Moving this to unassigned and back into the backlog for now.

@TheDuckCow
Copy link
Owner Author

TheDuckCow commented Jul 8, 2023

This video shows a unity asset with some useful controls it has for adding and extending road points. Noting down what I find interesting, but we'd synthesize what of this we would want to adopt and how to make it feel a bit more native to Godot.

  • They used a similar approach of being a layer on top of an empty/spatial primitive, so the base unity controls for movement and rotation work well
    • One difference is that they have it so the "rotate" mode is how you tweak the node layout itself, while we have to awkward fight against the built in spatial gizmo which overlaps our gizmo points.
  • Control click to add another point; with a mode to copy normal from last road, or to use normal of the hit location
    • There is a tool settings option for "use raycast" (for click placement I gather)
    • As you hold control, it shows a linear line from the end of the last point to the one you are about to place, making it clear what will be connected.
  • Clicking to extend a road will place it in 3D space based on where the intersection with another mesh happens, very useful
  • To add new points in the middle of an existing road, hold shift to preview where the new point will be added, then click to add. This is while a road (or also maybe the road system?) is selected. Though this one does a terrible job at creating new bezier handles with this newly added point, changes the overall shape noticeably.
  • Deleting a roadpoint is as simple as pressing backspace, one button; deleting a roadpoint auto selects the next connected one so you can use this operation recursively.
  • They created a shortcut toggle to switch between local and global gizmo handles, x to toggle. Not sure if that's a built in Unity thing
  • Interesting tool to make it easier to add new points stuck into the xz plane or local plane, not sure we'd go this far though
  • And intersections? See here
    • They are using prefabs for the intersection pieces, and these are assigned in some more global project settings (not even local to a specific scene!)
    • Also creating the road network initially is only selecting a specific prefab of a road size, it's not a dynamic/procedural road. Then again, this could be a "pro" since it means anyone can easily customize and create their own road by modifying the prefab.
    • The intersection prefabs are directly parented to the RoadNetwork.
    • Pressing l toggles to show all the anchor points you can connect to. You can click on these anchor points, and they become selected (even though it's in a prefab). After you select an anchor point you go into a prefab and select the road to add, and it just adds a shortened road into the scene connected to that anchor.
    • It's actually a different tool mode, to connect an existing road to an anchor of an intersection, you have to use the "road link tool" which toggles to show all anchors. You hold shift to keep an initial anchor selected and then selecting another one. Though this has the result of moving the endpoint to that location (instead of creating a new segments in the middle). Different combination of shortcut keys lets you extend instead.
  • Can use control click (with the link tool active) to disconnect a road point, sort of like "ripping" a vertex in Blender. <- that's a useful idea.
  • Adding AI/cars to navigate on the road
    • They have a "construct graph" feature to generated edges and weights, for AI routing presumedly. Where the cost of each edge is the length of the spline of that road. You have to manually run this operation.
    • They have a navigator script which you can directly add onto a character as a component. With a mode to add navigator debug info.
    • You can set the "goal" of the character programmatically, but it nicely shows a route/line in the actual editor of where your character would be going.
    • This was just for a generic capsule, not sure how he uses it to connect to actual vehicles. But also it seems evident this only defines a single "lane" for the entire road, with no directionality. So much more simplified than what we are working with here.

@TheDuckCow
Copy link
Owner Author

On this page there's a likely useful function _forward_3d_draw_over_viewport which we could also use to draw or paint around the curser on or before clicks, perhaps to help indicate when and where connections are going to happen.

@TheDuckCow
Copy link
Owner Author

See also this demo which shows something very similar to likely what we might want, regarding the drawing of new roadpoints simultaneously with snapping and recognizing when to merge road points together to form a new intersection.

https://twitter.com/Nothke/status/1066506754794635264

In the context of adding road points and how this will fit together:

  • With the new structure of RoadContainers, we need a way to let users, who are authoring roads, seamlessly split them into multiple RoadContainers in moments like displayed - ie when overlapping or connecting more than one road point together at once
  • For adding another point, there's a few scenarios that can happen:
    • Placing the first RoadPoint: should set up a RoadContainer if needed. Initial rotation can either be random, or track the mouse until a second click or enter key confirms placement orientation and magnitude. Alternatively, it could be a click and hold to drag to rotate the point and set the in/out magnitude.
    • After confirming the placement by letting it go, the user should automatically be in a "continuation" mode where we automatically see new roads being placed and moved around under the cursor until clicking again.
      • If "use lowpoly preview" is active, then the road will actually be dynamically created as the user is moving around. If this setting is off, then just some kind of 2D line should be drawn on screen and a point around the mouse to clarify the user is still in this selection mode.
    • If the click is within the radius of a road point (radius defined as half of the current total road width which is based on the number of lanes), then it should form an intersection. Ideally we can visualize this in some way
  • if the user presses esc, or selection in the side bar is changed, then the selection mode is ended (and the temp one not yet added will be removed and meshes cleaned up)

Forming an intersection will take some extra logic beyond this, but this is the initial idea of the interaction.

@TheDuckCow
Copy link
Owner Author

This task is now in progress, and I've basically completed the toolbar UI part. Works exactly and is styled exactly the same as the editor (in fact, no style overrides or custom icons used, I managed to get the source icons).

Screen Shot 2023-10-09 at 10 19 02 PM

I've introduced a mode value, but no functionality based off of it yet.

Next steps will be the actual functionality of these defined tickboxes.

@TheDuckCow TheDuckCow linked a pull request Oct 14, 2023 that will close this issue
@TheDuckCow TheDuckCow linked a pull request Oct 24, 2023 that will close this issue
@TheDuckCow
Copy link
Owner Author

With the latest commits, we have a functional-enough dissolve/delete command. So will be marking this as done shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants