TheDuckCow / godot-road-generator

A godot plugin for creating 3D highways and streets.
MIT License
316 stars 16 forks source link

55 one click road network setups #59

Closed bdog2112 closed 1 year ago

bdog2112 commented 1 year ago

Hey Patrick,

Please checkout this WIP for one-click road setups. Also, please let me know if you have any additional requirements not explicitly captured in Issue #55.

As a first step, I recommend trying 2 things:

  1. Move existing geometry away from World Origin. Then, select an existing RoadNetwork and click "Create>2x2" road.
  2. Move existing geometry away from World Origin. Select root node in Scene dock and create a new RoadNetwork. Select new RoadNetwork and click "Create>2x2 road".

You should observe a new Segment being created at the World Origin in both cases. Also, "points" and "segments" nodes are automatically added to RoadNetworks if they don't already exist and a road material is also assigned.

If the user deletes "points" and/or "segments", they will be re-created when "Create>2x2 road" is clicked.

We may want to remove "points" and "segments" from the export variables since users probably shouldn't be messing with them.

Also, currently, nothing happens if a RoadPoint is selected and the user clicks "Create>2x2 road". Please let me know if you have additional requirements in this area.

In other news, the approach to Lane Widget hiding had to be updated in conjunction with showing/hiding the new "Create" menu in the 3D viewport. This eliminated the need to find the "points" node in plugin.gd._on_selection_changed.

Following this post, I will post a series of test cases that I am using for testing. You're welcome to follow along if you wish.

bdog2112 commented 1 year ago

One-click Road Network Setup Tests:

  1. Test: Open project in Godot. Outcome: Project opens successfully and no error messages pertaining to the custom menu are displayed.
  2. Test: Open scene containing RoadPoints and RoadNetworks. Make sure NOTHING is selected. Outcome: Custom menu is hidden.
  3. Test: Select a RoadPoint. Outcome: Custom menu is shown.
  4. Test: Deselect the RoadPoint. Outcome: Custom menu is hidden.
  5. Test: Select RoadNetwork. Outcome: Custom menu is shown.
  6. Test: Create a new blank 2D scene. Outcome: Custom menu is hidden.
  7. Test: Switch back to 3D scene where RoadNetwork is selected. Outcome: Custom menu is shown.
  8. Test: Click "Create>2x2 road" Outcome: 2x2 Segment is created at World Origin.
bdog2112 commented 1 year ago

RoadPoint Edit Panel Tests:

  1. Test: Select a RoadPoint between other RoadPoints. Outcome: Edit Panel upper button says "Select Next RoadPoint".
  2. Test: Click upper button. Outcome: Selection moves to next RoadPoint in the chain.
  3. Test: Select last RoadPoint in the chain. Outcome: Edit Panel upper button says "+ Next RoadPoint".
  4. Test: Click upper button. Outcome: A new RoadPoint is added a distance of 4 lane widths along RoadPoint's Z-axis.
  5. Test: Select a RoadPoint between other RoadPoints. Outcome: Edit Panel lower button says "Select Prior RoadPoint".
  6. Test: Click lower button. Outcome: Selection moves to prior RoadPoint in the chain.
  7. Test: Select first RoadPoint in the chain. Outcome: Edit Panel lower button says "+ Prior RoadPoint".
  8. Test: Click lower button. Outcome: A new RoadPoint is added a distance of 4 lane widths along RoadPoint's Z-axis.
bdog2112 commented 1 year ago

Lane Widget Tests:

  1. Test: Deselect everything in the Scene. Outcome: Lane Widget is not shown.
  2. Test: Select a single RoadPoint. Outcome: Gizmo Handles and Lane Widget are displayed on selection. Lane Widget is aligned to RoadPoint's X-axis.
  3. Test: Select a non-RoadPoint. Outcome: Gizmo Handles and Lane Widget are not shown.
  4. Test: Select multiple RoadPoints. Outcome: Gizmo Handles and Lane Widget are not shown.
  5. Test: Select RoadPoint in Scene dock. Then left click a different RoadPoint in the Scene dock. But, don't release the mouse button. Observe state of Gizmo Handles and Lane Widget. Then, release mouse button and, again, observe state of Gizmo Handles and Lane Widget. Outcome: When second RoadPoint is clicked and mouse button is held, Lane Widget is hidden. Meanwhile, gizmo handles still remain on previous selection. When mouse button is released, Gizmo Handles and Lane Widget are shown on new selection.
  6. Test: Duplicate current scene, open duplicate, and select a different RoadPoint. Then, switch back and forth between scenes. Outcome: Each scene shows Gizmo Handles and Lane Widget on the RoadPoint that was explicitly selected in that scene.
  7. Test: Close all scenes. Outcome: Gizmo handles and Lane Widget are no longer shown.
bdog2112 commented 1 year ago

The above tests are, by no means, exhaustive. Many other things could be checked including: Adding/Removing Lanes via panel and widget, Adjusting Mag Handles, RoadPoint naming conventions and so on... But, hey, it's a start. :-)

TheDuckCow commented 1 year ago

FYI also for context, so you are aware where these issues are being tracked:

... or just search recent issues, I've created a bunch (a mix of bugs and feature improvements). In all cases, the crux is merging this branch first so let's see if we can get to it!

TheDuckCow commented 1 year ago

Also will be good to get in a habit of running the tests whenever we make changes, all looking good right now thought:

Warnings/Errors:
* 2 Warnings.

4 passed 0 failed.  Tests finished in 0.0s

[Orphans]:  68 new orphans in total.
Note:  This count does not include GUT objects that will be freed upon exit.
       It also does not include any orphans created by global scripts
       loaded before tests were ran.
Total orphans = 70
TheDuckCow commented 1 year ago

FYI @bdog2112 would be good to prioritize anything remaining in this PR, so we can merge it and I can launch 0.3.0 (the alpha will launch with 0.3.1)

bdog2112 commented 1 year ago

All tests pass. Merging 3...2...1...