Don't crash when building lighting for a level with a Cesium3DTileset #1181
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.
Fixes #1180
UnrealLightmass.exe is a separate process run via Swarm when building lighting. As reported in #1180, it (always? usually?) crashes when we attempt to build lighting (Build -> Build Lighting Only) for a level that has a Cesium3DTileset in it. Unfortunately it's build without any debug symbols, so I had to build it myself to debug it.
Having done that, I learned that the problem is that every
FStaticMeshLightingMesh
pointed to the sameFStaticMesh
instance, which really couldn't be right. And I learned that that was happening because, on import, all the static mesh references had the same GUID (all zeros!). Ok, so the problem seemed to be back in the Unreal Editor on the export side.So, I traced through the code that exported the lightmass data, and yep, it was writing a GUID of all zeros. It got that GUID from a property on the
UStaticMesh
calledLightingGuid
. So how is that property set? I searched for it in the UE source code, and saw that things likeDatasmithStaticMeshImporter
callSetLightingGuid
on the static just before they calledInitResources
. I added the same to our code that creates the static mesh in CesiumGltfComponent, and the lightmass crash went away.I'll spare everyone the rant about how ridiculous it is that we have to call some random undocumented method on every static mesh we create in order to prevent UE's static lighting baking system from crashing. 🤷