TheDuckCow / godot-road-generator

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

RoadPoint gizmo geo visible on startup until interacted #3

Closed TheDuckCow closed 1 year ago

TheDuckCow commented 1 year ago

We use Immediate Geometry as a simple way to draw the custom "handles" onto the RoadPoints, which are used to imply their directionality as well as lane width. Eventually, we could extend it to further help indicate lane directions and so forth.

However, ImmediateGeometry is not very efficient since it draws on every frame. It's used for UI controls typically or very simple geo (in fact, all 3D gizmos in godot's editor are built using ImmediateGeometry). The key is that we should only draw the geometry needed at a given moment in time. In our context, this means only drawing the currently selected (if any) RoadPoint, and all others shouldn't be drawn unless they are selected. If you select multiple RoadPoints, they too should be selected. This behavior all works.

The current problem, is that when a scene first opens, it seems all RoadPoints are initially added in a state where their immediate geometry is on. It resets and then behaviors as intended once you've selected and deselected each roadpoint once. This video demos it:

https://user-images.githubusercontent.com/2958461/198504807-39e52ead-a1af-410a-944e-e8e61edaf009.mp4

TheDuckCow commented 1 year ago

Updated the description to narrow this issue to be more specific.

TheDuckCow commented 1 year ago

Actually I may have found the workaround here of adding

if not is_instance_valid(network):
    return  # might not be initialized yet

...in front of all setter's in the RoadPoint class. Putting more info inside: https://github.com/TheDuckCow/godot-road-generator/issues/8 soon.