Make MeshLibrary export do recursive depth-search for MeshInstance3D nodes #87923
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.
Makes MeshLibrary export do recursive depth-search for MeshInstance3D nodes.
Fixes #85085
Fixes #81850
Likely other issues as it has been a long-standing issue with the MeshLibrary exporter.
Would supersede #82792 and #87651 that increases the number of searched child tiers to a hard-coded higher number.
The current MeshLibrary export has the limitation of only searching 2 node child tiers.
In the wild there are often convoluted files (e.g. GLTF import) with far more nested child nodes so those mesh items would not be detected and exported.
This pr now makes the export do a recursive depth-search until a MeshInstance3D is encountered. At this point it stops searching further children of that node and instead proceeds as normal. It will still process all sibling nodes for more items, just stop the search for the children of that specific MeshInstance3D node.
This means users can still add supporting nodes in their export scenes below their mesh instances that are not exported. E.g. the source geometry to bake the navigation mesh that gets exported. This also means very convoluted and exaggerated tree setups like this now can work in the MeshLibrary export:
As far as compatibility is concerned I think the only way that things break with this recursive search is if users had a MeshInstance3D in their scenes that was already not exported correctly. If exported now this would obviously change the id numbers of the MeshLibrary. I would assume that any dev worth their salt already fixed their export scenes if they encountered such an export bug with a missing mesh so this is imo only a hypothetical concern and they can easy fix it by moving that suspicious node at the end of the tree so it receives an unused id.