Skip to content

Commit e40606b

Browse files
committed
Fix static mesh cyclic dependency
1 parent 5d965f5 commit e40606b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

AssetDumper/Source/AssetDumper/Private/Toolkit/AssetTypes/FbxMeshExporter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ void FFbxMeshExporter::ExportSkeletalMesh(const FSkeletalMeshLODRenderData& Skel
860860
const uint32 NumTriangles = MeshSection.NumTriangles;
861861
const uint32 StartVertexIndex = MeshSection.BaseIndex;
862862

863+
if (!ensure(ReferencedMaterials.IsValidIndex(MeshSection.MaterialIndex)))
864+
continue;
865+
863866
//Create dummy material for this section
864867
const FString MaterialSlotName = ReferencedMaterials[MeshSection.MaterialIndex].MaterialSlotName.ToString();
865868
const int32 MaterialIndex = ExportDummyMaterialIntoFbxScene(MaterialSlotName, MeshNode);

AssetGenerator/Source/AssetGenerator/Private/Toolkit/AssetTypeGenerator/StaticMeshGenerator.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,23 @@ void UStaticMeshGenerator::PopulateStageDependencies(TArray<FPackageDependency>&
206206
const TArray<TSharedPtr<FJsonValue>>& Materials = AssetData->GetArrayField(TEXT("Materials"));
207207
const int32 NavCollisionObjectIndex = AssetData->GetIntegerField(TEXT("NavCollision"));
208208
const int32 BodySetupObjectIndex = AssetData->GetIntegerField(TEXT("BodySetup"));
209+
210+
const TArray<TSharedPtr<FJsonValue>> AssetUserDataObjects = AssetObjectProperties->GetArrayField(TEXT("AssetUserData"));
211+
212+
TArray<int32> AssetUserDataObjectIndices;
213+
for (const TSharedPtr<FJsonValue>& ObjectIndexValue : AssetUserDataObjects) {
214+
AssetUserDataObjectIndices.Add((int32) ObjectIndexValue->AsNumber());
215+
}
209216

210217
TArray<FString> OutReferencedPackages;
211-
GetObjectSerializer()->CollectReferencedPackages(ReferencedObjects, OutReferencedPackages);
218+
for (const TSharedPtr<FJsonValue>& ObjectIndexValue : ReferencedObjects) {
219+
const int32 ObjectIndex = (int32) ObjectIndexValue->AsNumber();
220+
221+
if (!AssetUserDataObjectIndices.Contains(ObjectIndex)) {
222+
GetObjectSerializer()->CollectObjectPackages(ObjectIndex, OutReferencedPackages);
223+
}
224+
}
225+
212226
GetObjectSerializer()->CollectObjectPackages(NavCollisionObjectIndex, OutReferencedPackages);
213227
GetObjectSerializer()->CollectObjectPackages(BodySetupObjectIndex, OutReferencedPackages);
214228

0 commit comments

Comments
 (0)