Potential new KSP bugfix : ReRootPreserveSurfaceAttach #142
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.
Our dear friend Lisias has uncovered a strange behavior on re-rooting crafts.
In KSP 1.8.0, a change was introduced to the
Part.SetHierarchyRoot()
method. This method is called when the user uses the re-rooting tool in the editor, but also in flight when docking/undocking. It's a recursive method responsible for reshuffling the part hierarchy according to the modified root part.The implementation was pretty straightforward prior to 1.8.0, but for some reason (the
Fix re-rooting of surface attach nodes
entry in the KSP changelog doesn't explain much) they added a weird behavior to it altering surface attachment nodes position and orientation. When the re-rooting operation results in an inversion of the parent-child relationship, the intent seems to be to alter the nodes as if the craft was initially built in that reversed order. There are multiple issues with that :So that leaves us with two options :
I'm quite tempted to just push solution 2 (which is what this PR currently does), but I fear I might have missed something about what this whole thing is trying to do, especially because it is also applied in flight. So I'm gonna sleep on it for a while.
Example of the surface attach node being altered even when the part isn't actually surface attached :
2023-04-27.17-50-18-999.mp4
Another example showing how the nodes are moved to nonsensical positions/directions when re-rooting :
2023-04-27.17-54-54-162.mp4