I have a generator that contains an InExclude list where I can add polygons, and I create my own mesh over those polygons. When a polygon from my list is deleted from the scene, it is not deleted from the list, and my mesh becomes outdated, it has some faces that should not exist anymote. Anyone would expect my mesh to be updated right away, so I need to manually check if there's any null object in the list, remove it, delete some data that was generated for that polygon, and recompute my mesh. I'm doing this in Execute() and is working good.
The problem is when the user hits Undo after that. The original polygon is back, but the operation I did on my generator (delete the polygon from the list and updated data) is not.
When I'm updating my list, BaseDocument:: GetUndoPtr() returns nothing (and would not be of great help).
Adding a new Undo step triggers a debug breakpoint (CRITICAL: Stop), and the step is not created.
I need some understanding how can I not lose any data when that original polygon is deleted.
Is there a better way to catch the delete?
Is there a way to catch that polygon Undo and add my generator to it? The polygons are added as dependencies but no messages are sent to my generator.
Should I add a new undo step? Where?