2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-10-02 17:27:26 -04:00
|
|
|
|
|
|
|
|
#include "ClothLODData.h"
|
2019-12-10 05:02:44 -05:00
|
|
|
#include "ClothPhysicalMeshData.h"
|
2020-04-02 14:15:35 -04:00
|
|
|
#include "ClothingAssetCustomVersion.h"
|
2019-10-02 17:27:26 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITORONLY_DATA
|
2020-04-02 14:15:35 -04:00
|
|
|
void FClothLODDataCommon::GetParameterMasksForTarget(
|
2019-10-02 17:27:26 -04:00
|
|
|
const uint8 InTarget,
|
|
|
|
|
TArray<FPointWeightMap*>& OutMasks)
|
|
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
for(FPointWeightMap& Mask : PointWeightMaps)
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
|
|
|
|
if(Mask.CurrentTarget == InTarget)
|
|
|
|
|
{
|
|
|
|
|
OutMasks.Add(&Mask);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
|
|
2020-04-02 14:15:35 -04:00
|
|
|
bool FClothLODDataCommon::Serialize(FArchive& Ar)
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
Ar.UsingCustomVersion(FClothingAssetCustomVersion::GUID);
|
2019-10-02 17:27:26 -04:00
|
|
|
|
2020-04-02 14:15:35 -04:00
|
|
|
// Serialize normal tagged property data
|
2021-06-10 13:13:24 -04:00
|
|
|
if (Ar.IsLoading() || Ar.IsSaving())
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
UScriptStruct* const Struct = FClothLODDataCommon::StaticStruct();
|
|
|
|
|
Struct->SerializeTaggedProperties(Ar, (uint8*)this, Struct, nullptr);
|
|
|
|
|
}
|
2019-10-02 17:27:26 -04:00
|
|
|
|
|
|
|
|
// Serialize the mesh to mesh data (not a USTRUCT)
|
|
|
|
|
Ar << TransitionUpSkinData
|
|
|
|
|
<< TransitionDownSkinData;
|
|
|
|
|
|
2021-07-21 14:52:47 -04:00
|
|
|
#if WITH_EDITORONLY_DATA
|
2020-04-02 14:15:35 -04:00
|
|
|
const int32 ClothingCustomVersion = Ar.CustomVer(FClothingAssetCustomVersion::GUID);
|
|
|
|
|
if (ClothingCustomVersion < FClothingAssetCustomVersion::MovePropertiesToCommonBaseClasses)
|
2019-12-10 05:02:44 -05:00
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
// Migrate maps
|
|
|
|
|
PhysicalMeshData.GetWeightMap(EWeightMapTargetCommon::MaxDistance).Values = MoveTemp(PhysicalMeshData.MaxDistances_DEPRECATED);
|
|
|
|
|
PhysicalMeshData.GetWeightMap(EWeightMapTargetCommon::BackstopDistance).Values = MoveTemp(PhysicalMeshData.BackstopDistances_DEPRECATED);
|
|
|
|
|
PhysicalMeshData.GetWeightMap(EWeightMapTargetCommon::BackstopRadius).Values = MoveTemp(PhysicalMeshData.BackstopRadiuses_DEPRECATED);
|
2021-02-18 18:13:28 -04:00
|
|
|
PhysicalMeshData.GetWeightMap(EWeightMapTargetCommon::AnimDriveStiffness).Values = MoveTemp(PhysicalMeshData.AnimDriveMultipliers_DEPRECATED);
|
2020-04-02 14:15:35 -04:00
|
|
|
|
|
|
|
|
// Migrate editor maps
|
|
|
|
|
PointWeightMaps.SetNum(ParameterMasks_DEPRECATED.Num());
|
|
|
|
|
for (int32 i = 0; i < PointWeightMaps.Num(); ++i)
|
|
|
|
|
{
|
|
|
|
|
ParameterMasks_DEPRECATED[i].MigrateTo(PointWeightMaps[i]);
|
|
|
|
|
}
|
|
|
|
|
ParameterMasks_DEPRECATED.Empty();
|
|
|
|
|
|
2021-04-08 14:32:07 -04:00
|
|
|
// Migrate Convex Planes from the legacy Apex collision (used for box collision)
|
|
|
|
|
// Note: This code is not enough to get Apex convex working (it's missing surface points and face indices),
|
|
|
|
|
// but it is better to keep the data alive for now in case the Apex deprecation causes any issues.
|
|
|
|
|
for (FClothCollisionPrim_Convex& Convex : CollisionData.Convexes)
|
2020-04-02 14:15:35 -04:00
|
|
|
{
|
2021-04-08 14:32:07 -04:00
|
|
|
const int32 NumDeprecatedPlanes = Convex.Planes_DEPRECATED.Num();
|
|
|
|
|
if (NumDeprecatedPlanes)
|
2020-04-02 14:15:35 -04:00
|
|
|
{
|
2021-04-08 14:32:07 -04:00
|
|
|
Convex.Faces.SetNum(NumDeprecatedPlanes);
|
|
|
|
|
for (int32 FaceIndex = 0; FaceIndex < NumDeprecatedPlanes; ++FaceIndex)
|
|
|
|
|
{
|
|
|
|
|
Convex.Faces[FaceIndex].Plane = Convex.Planes_DEPRECATED[FaceIndex];
|
|
|
|
|
}
|
|
|
|
|
Convex.Planes_DEPRECATED.Empty();
|
2020-04-02 14:15:35 -04:00
|
|
|
}
|
|
|
|
|
}
|
2019-12-10 05:02:44 -05:00
|
|
|
}
|
2021-07-21 14:52:47 -04:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
2020-04-02 14:15:35 -04:00
|
|
|
return true;
|
2019-12-10 05:02:44 -05:00
|
|
|
}
|
|
|
|
|
|
2019-10-02 17:27:26 -04:00
|
|
|
#if WITH_EDITOR
|
2020-04-02 14:15:35 -04:00
|
|
|
void FClothLODDataCommon::PushWeightsToMesh()
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
PhysicalMeshData.ClearWeightMaps();
|
|
|
|
|
for (const FPointWeightMap& Weights : PointWeightMaps)
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
2019-12-10 05:02:44 -05:00
|
|
|
if (Weights.bEnabled)
|
2019-10-02 17:27:26 -04:00
|
|
|
{
|
2020-04-02 14:15:35 -04:00
|
|
|
FPointWeightMap& TargetWeightMap = PhysicalMeshData.FindOrAddWeightMap(Weights.CurrentTarget);
|
2019-12-10 05:02:44 -05:00
|
|
|
TargetWeightMap.Values = Weights.Values;
|
2019-10-02 17:27:26 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|