TheDuckCow / godot-road-generator

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

Adding dirty flag to fix duplicate rebuilds on scene open. #107

Closed TheDuckCow closed 1 year ago

TheDuckCow commented 1 year ago

Introduces a _dirty flag in the road network, to manage when to trigger rebuilding of all road segments. This was getting to be problematic, as I noticed roads would be regenerated as many as 5x times in a row during scene open (and possible on save, too). Even though each inspector property setter function was initially doing a deferred called to rebuild, they were each triggering it 1x. It now functions on seeing whether it's still "dirty" so they don't overlap.

All 4 tests pass, and no more repeat generations of roads.

There is a potential consequence that this means we can't depend on roads being there in the first frame after _ready, but there's already evidence to believe that this was not reliable anyways. Another PR is focussing on adding necessary signals for that purpose.

Closes #106