Simplify transform code by using cache instead of partial objects #1406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The core problem of transforming objects is that references in an object graph that were the same before transformation must be the same after transformation. For example, if the two vertices of a half-edge reference a single curve (which they must, otherwise the half-edge is invalid), then after transforming the half-edge, the vertices of the transformed half-edge must still reference a single (now transformed) curve.
Previously, this was achieved by converting full objects into partial objects before transformation, then transforming those, updating them as necessary (e.g. make sure the two vertices reference the same curve), then convert that back into a full object. In fact, this was the first use case for the partial object API.
This pull request changes that, making the transform logic much simpler. Instead of making the detour through partial objects, a simple cache is used, to make sure that each object in the object graph results in exactly one transformed object in the transformed object graph. The new transform code is extremely simple and hard to get wrong.
Beyond the benefits for the transform code itself, this pull request assists in advancing #1249, by taking some pressure off the partial object API. Although I haven't looked into it yet, I assume that some cleanup attempts that have previously stalled can now be made, as the partial object API has to support fewer use cases.