TheDuckCow / godot-road-generator

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

Save children to scene to avoid subscene reloading #173

Open TheDuckCow opened 2 weeks ago

TheDuckCow commented 2 weeks ago

This PR primarily adds a new setting to cache or save internal auto generator nodes to the scene tree. By being added to the scene tree, things like the mesh array actually get saved. The intent is this means that for instanced scenes, we don't need regenerate roads or anything on the fly such as during transform. This also helps get around the issue of #169 since we'll just make sure the curves don't get regenerated. We'll just recommend that people don't rotate RoadContainers inside dynamic scenes.

This is still a WIP and some things are broken, such as the connection tool going from a dynamic RP to a saved scene (but the other way around works). I'm having to revisit some fundamentals on things like the names of RoadSegments, and I'm also playing with locked settings to help encourage users to not touch what was previously intentionally hidden. But for saved scenes to work as intended, everything needs to be added to the scene.

Closes https://github.com/TheDuckCow/godot-road-generator/issues/109

For reference, what this check box does is described by this image - except one further improvement of this branch is that the RoadLanes pictured below are no longer constantly created and destroyed, which helps with performance and not accidentally deleting users' stuff.

Screen Shot 2024-06-11 at 6 11 46 PM
TheDuckCow commented 2 weeks ago

To be clear, this pushed change doesn't yet have the code which actually prevents regeneration in other loaded scenes. While I have that mostly working locally, there are other issues I want to see about addressing first which include making the connection tools work. We have to balance the skipping of loading data with also still building up things like the segment map so that the connection tool can work. Might need some new accessors and abstraction utilities to fetch things like start/end points unfortunately.