I was trying to use one of the assets from the open world sample (HillTree02), and it took forever to load it.
When debugging it, I found out why it’s so slow. Not sure why it was programmed in such way though; Would love to hear why,
I could possibly try and fix that.
Stack Trace:
> [Inline Frame] UE4Editor-MeshUtilitiesCommon.dll!FAllocator2D::Test(FAllocator2D::FRect) Line 150 C++
UE4Editor-MeshUtilitiesCommon.dll!FAllocator2D::FindBitByBit(FAllocator2D::FRect & Rect, const FAllocator2D & Other) Line 94 C++
UE4Editor-MeshUtilitiesCommon.dll!FLayoutUV::PackCharts() Line 843 C++
UE4Editor-MeshUtilitiesCommon.dll!FLayoutUV::FindBestPacking() Line 604 C++
UE4Editor-MeshDescriptionOperations.dll!FMeshDescriptionOperations::CreateLightMapUVLayout(FMeshDescription & MeshDescription, int SrcLightmapIndex, int DstLightmapIndex, int MinLightmapResolution, ELightmapUVVersion LightmapUVVersion, const FOverlappingCorners & OverlappingCorners) Line 1191 C++
UE4Editor-MeshBuilder.dll!FMeshDescriptionHelper::GetRenderMeshDescription(UObject * Owner, const FMeshDescription & InOriginalMeshDescription, FMeshDescription & OutRenderMeshDescription) Line 138 C++
UE4Editor-MeshBuilder.dll!FStaticMeshBuilder::Build(FStaticMeshRenderData & StaticMeshRenderData, UStaticMesh * StaticMesh, const FStaticMeshLODGroup & LODGroup) Line 120 C++
UE4Editor-MeshBuilder.dll!FMeshBuilderModule::BuildMesh(FStaticMeshRenderData & OutRenderData, UObject * Mesh, const FStaticMeshLODGroup & LODGroup) Line 41 C++
UE4Editor-Engine.dll!FStaticMeshRenderData::Cache(UStaticMesh * Owner, const FStaticMeshLODSettings & LODSettings) Line 1643 C++
UE4Editor-Engine.dll!UStaticMesh::CacheDerivedData() Line 3270 C++
UE4Editor-Engine.dll!UStaticMesh::PostLoad() Line 3676 C++
bool FLayoutUV::PackCharts():
- 9793 times - for( int32 i = 0; i < Charts.Num(); i++ )
- 8 times - for( int32 Orientation = 0; Orientation < 8; Orientation++ )
- 1024x1024 (~) - bool FAllocator2D::FindBitByBit( FRect& Rect, const FAllocator2D& Other )
- 10 seconds for around 300 itereations for the first loop. It was manual timing, so not accurate at all,
but it gives some measure to the timing, so I’ll with that for now. Meaning 320 seconds for PackCharts()
bool FLayoutUV::FindBestPacking()
- First (while) loop: “// Linear search for first fit” - 1 time (minimum, mine took 2) * PackCharts()
- second loop - 6 times (const):
// Binary search for best fit
for( int32 i = 0; i < BinarySearchSteps; i++ )
- another PackCharts() at the end of it
- Minimum 8 times of PackCharts * 320 seconds = 2560 seconds = 42.666666666666666666666666666667 minutes.
So what is really going on here? which part of this code shouldn’t be done that is taking it so long?
p.s.
I have ROG STRIX GL702VS. Although it’s a laptop, it’s a really strong one, and I managed to run some heavy stuff so far.
Even if some stuff should be slower because it’s a laptop - loading a static mesh for 40 minutes - a definitely no.
p.s.2
Even if my timing for the loop in PackCharts() is a bit off, and it would take 5 seconds, it’s still 20 minutes for a static mesh. A tree.
Still way too long then it should be.