Looking at the code in SkeletalMeshImportUtils::RestoreExistingSkelMeshData… it looks like we should just call empty on the array (SkeletalMesh->GetMeshOnlySocketList().Empty()) before calling this code
// Assign sockets from old version of this SkeletalMesh.
// Only copy ones for bones that exist in the new mesh.
for (int32 i = 0; i < MeshData->ExistingSockets.Num(); i++)
{
const int32 BoneIndex = SkeletalMesh->GetRefSkeleton().FindBoneIndex(MeshData->ExistingSockets[i]->BoneName);
if (BoneIndex != INDEX_NONE)
{
SkeletalMesh->GetMeshOnlySocketList().Add(MeshData->ExistingSockets[i]);
}
}
I tested this and it works and it solves the bug. However, I was wondering if I am missing something.
I have put breakpoint in the code and it looks like this will save the existing socket array.
ExistSkelMeshDataPtr = SkeletalMeshImportUtils::SaveExistingSkelMeshData(ExistingSkelMesh, !ImportOptions->bImportMaterials, ImportSkeletalMeshArgs.LodIndex);
Later the call to SkeletalMeshImportUtils::RestoreExistingSkelMeshData will copy it back into the array… which does not make sense (unless we empty the array first).
We found few SkeletalMesh that had a lot of duplicates in the array… There was even one asset that had 1572861 items in the Socket array. I had to write a commandlet to clear the duplicates because the editor would freeze when trying to show sockets in the Skeletal Mesh editor.
Let me know if emptying the array is the right thing to do… I would like to avoid causing bigger problems. To be honest, I find it weird to find this kind of bug in 5.6, I think that SkeletalMeshImportUtils code dates from the UE4 era.
Thank you for your help.
[Attachment Removed]