[Backout] - CL18545668

[FYI] Alexis.Matte
Original CL Desc
-----------------------------------------------------------------
Fix a lock issue in CopyStructure, bulkdata are not playing well with thread so I prefer not using them for such small amount of editor data.
Removing them remove the following debug assert in LinkerLoad.h that happen when we copy FSkeletalMeshLODModel structure.

checkSlow(FPlatformTLS::GetCurrentThreadId() == OwnerThread);

It should also prevent a crash with file handle since we cannot lock two different bulk data in separate thread if the two bulk data are store in the same package since they will share a file handle

#jira UE-137959
#rb danny.couture
#rnx
#preflight 61d86521430de36baa5c471f

#ROBOMERGE-AUTHOR: alexis.matte
#ROBOMERGE-SOURCE: CL 18548323 in //UE5/Release-5.0/... via CL 18548343
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18548359 by alexis matte in ue5-release-engine-test branch]
This commit is contained in:
alexis matte
2022-01-07 13:37:19 -05:00
parent 2f6c97167c
commit 94f7c4797e
8 changed files with 78 additions and 75 deletions
@@ -2457,7 +2457,7 @@ class FAsyncImportMorphTargetWork : public FNonAbandonableTask
{
public:
FAsyncImportMorphTargetWork(FSkeletalMeshLODModel* InLODModel, const FReferenceSkeleton& InRefSkeleton, const FSkeletalMeshImportData& InBaseImportData, TArray<FVector3f>&& InMorphLODPoints,
TArray< FMorphTargetDelta >& InMorphDeltas, TArray<uint32>& InBaseIndexData, const TArray< uint32 >& InBaseWedgePointIndices,
TArray< FMorphTargetDelta >& InMorphDeltas, TArray<uint32>& InBaseIndexData, TArray< uint32 >& InBaseWedgePointIndices,
TMap<uint32, uint32>& InWedgePointToVertexIndexMap, const FOverlappingCorners& InOverlappingCorners,
const TSet<uint32> InModifiedPoints, const TMultiMap< int32, int32 >& InWedgeToFaces, const FMeshDataBundle& InMeshDataBundle, const TArray<FVector3f>& InTangentZ,
bool InShouldImportNormals, bool InShouldImportTangents, bool InbUseMikkTSpace, const FOverlappingThresholds InThresholds)
@@ -2688,7 +2688,7 @@ private:
TArray< FMorphTargetDelta >& MorphTargetDeltas;
TArray< uint32 >& BaseIndexData;
const TArray< uint32 >& BaseWedgePointIndices;
TArray< uint32 >& BaseWedgePointIndices;
TMap<uint32, uint32>& WedgePointToVertexIndexMap;
const FOverlappingCorners& OverlappingCorners;
@@ -2732,6 +2732,15 @@ void FLODUtilities::BuildMorphTargets(USkeletalMesh* BaseSkelMesh, FSkeletalMesh
TArray<FVector3f> TangentZ;
MeshUtilities.CalculateNormals(MeshDataBundle.Vertices, MeshDataBundle.Indices, MeshDataBundle.UVs, MeshDataBundle.SmoothingGroups, TangentOptions, TangentZ);
TArray< uint32 > BaseWedgePointIndices;
if (BaseLODModel.RawPointIndices.GetBulkDataSize())
{
BaseWedgePointIndices.Empty(BaseLODModel.RawPointIndices.GetElementCount());
BaseWedgePointIndices.AddUninitialized(BaseLODModel.RawPointIndices.GetElementCount());
FMemory::Memcpy(BaseWedgePointIndices.GetData(), BaseLODModel.RawPointIndices.Lock(LOCK_READ_ONLY), BaseLODModel.RawPointIndices.GetBulkDataSize());
BaseLODModel.RawPointIndices.Unlock();
}
TArray<uint32> BaseIndexData = BaseLODModel.IndexBuffer;
TMap<uint32, uint32> WedgePointToVertexIndexMap;
@@ -2852,7 +2861,7 @@ void FLODUtilities::BuildMorphTargets(USkeletalMesh* BaseSkelMesh, FSkeletalMesh
TArray< FMorphTargetDelta >* Deltas = Results[NewMorphDeltasIdx];
FAsyncTask<FAsyncImportMorphTargetWork>* NewWork = new FAsyncTask<FAsyncImportMorphTargetWork>(&BaseLODModel, BaseSkelMesh->GetRefSkeleton(), BaseImportData,
MoveTemp(ShapeImportData.Points), *Deltas, BaseIndexData, BaseLODModel.GetRawPointIndices(), WedgePointToVertexIndexMap, OverlappingVertices, MoveTemp(ModifiedPoints), WedgeToFaces, MeshDataBundle, TangentZ,
MoveTemp(ShapeImportData.Points), *Deltas, BaseIndexData, BaseWedgePointIndices, WedgePointToVertexIndexMap, OverlappingVertices, MoveTemp(ModifiedPoints), WedgeToFaces, MeshDataBundle, TangentZ,
ShouldImportNormals, ShouldImportTangents, bUseMikkTSpace, Thresholds);
PendingWork.Add(NewWork);
@@ -3305,8 +3314,17 @@ bool FLODUtilities::StripLODGeometry(USkeletalMesh* SkeletalMesh, const int32 LO
return true;
};
const TArray< uint32 >& SoftVertexIndexToImportDataPointIndex = LODModel.GetRawPointIndices();
TArray< uint32 > SoftVertexIndexToImportDataPointIndex;
if (LODModel.RawPointIndices.GetBulkDataSize())
{
SoftVertexIndexToImportDataPointIndex.Empty(LODModel.RawPointIndices.GetElementCount());
SoftVertexIndexToImportDataPointIndex.AddUninitialized(LODModel.RawPointIndices.GetElementCount());
FMemory::Memcpy(SoftVertexIndexToImportDataPointIndex.GetData(), LODModel.RawPointIndices.Lock(LOCK_READ_ONLY), LODModel.RawPointIndices.GetBulkDataSize());
LODModel.RawPointIndices.Unlock();
}
TMap<uint64, TArray<int32>> OptimizedFaceFinder;
auto GetMatchFaceIndex = [&OptimizedFaceFinder, &ImportedData](const int32 FaceVertexA, const int32 FaceVertexB, int32 FaceVertexC)->int32