TheDuckCow / godot-road-generator

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

Auto clean up geometry after delete RoadPoint #77

Closed TheDuckCow closed 1 year ago

TheDuckCow commented 1 year ago

Right now, if a child RoadPoint is deleted, geometry gets left behind until the whole road network (and also some odd unexpected geoemtry is added).

Ideally we can detect a delete signal, and automatically clean up any references to points. This may be tightly coupled to: https://github.com/TheDuckCow/godot-road-generator/issues/64

bdog2112 commented 1 year ago

This problem was bad in the past. But, it seemed much improved, lately. My first attempt at recreating the problem failed. (Segments updated just fine.) So, I brainstormed and came up with some steps that exhibited problems. Please let me know if this is not the problem you're describing.

Steps to recreate problem:

bdog2112 commented 1 year ago

Presumably, the initial errors have something to do with Segments trying to redraw deleted RoadPoints. Then, Undo/Redo also has a problem dealing with deleted RoadPoints.

In order for Undo/Redo to work, we may need to keep "deleted" objects in memory rather than actually deleting them. They could be purged at some arbitrary later time such as on save.

Also, have to look and see what kind of control Godot gives us to manage/prevent the actual deletion of objects.

TheDuckCow commented 1 year ago

Regarding "need to keep "deleted" objects in memory", there are actually handles for this in the undo/redo class, but I was not successful in getting it to work fully or at least was a challenge to wrangle (add_do_reference and add_undo_reference). For simplicity, we can leave out undo/redo considerations for this task.

I do also agree that I recently improved this quite a bit with this commit https://github.com/TheDuckCow/godot-road-generator/pull/83/commits/949159444d2bd34c2c456916789955b02102b973 (merged), this issue was created before that time but indeed there's still a ton of errors that print out right now. Ideally we can find a way to eliminate those. I'm fine for that to be the scope of this task if you're aligned, I'll rename it accordingly.

... oddly for me, when I undo after a delete, the node comes back into the dock and it somes redraws the geometry in the scene (though with lots of reference errors). First time it did, second time not. Happy to defer that to another out of scope task.