You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Addresses curves all being set to NAME_None for pose assets saved between CLs 3002109 and 3026802. Fixes curve extraction in pose assets. Fixes pose driver not setting curves unless they already exist. Fixes instances where TBaseBlendedCurve::Set was being used incorrectly - this now inserts the element if it wasnt present before, potentially causing a re-sort but at least not behaving un unexpected ways compared to the old use case. #jira UE-179096 #preflight 640615ad0c7df1967f08e090 #rb Jurre.deBaare #preflight 640723e28c0039bbf79e25f3 [CL 24538171 by Thomas Sarkanen in ue5-main branch]
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "LiveLinkRetargetAsset.h"
|
|
|
|
#include "Animation/AnimCurveTypes.h"
|
|
#include "Animation/AnimTypes.h"
|
|
#include "Animation/Skeleton.h"
|
|
#include "BonePose.h"
|
|
#include "Animation/AnimCurveUtils.h"
|
|
#include "GenericPlatform/GenericPlatformMath.h"
|
|
#include "Roles/LiveLinkAnimationTypes.h"
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(LiveLinkRetargetAsset)
|
|
|
|
ULiveLinkRetargetAsset::ULiveLinkRetargetAsset(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
void ULiveLinkRetargetAsset::ApplyCurveValue(const USkeleton* Skeleton, const FName CurveName, const float CurveValue, FBlendedCurve& OutCurve) const
|
|
{
|
|
OutCurve.Set(CurveName, CurveValue);
|
|
}
|
|
|
|
void ULiveLinkRetargetAsset::BuildCurveData(const FLiveLinkSkeletonStaticData* InSkeletonData, const FLiveLinkAnimationFrameData* InFrameData, const FCompactPose& InPose, FBlendedCurve& OutCurve) const
|
|
{
|
|
const USkeleton* Skeleton = InPose.GetBoneContainer().GetSkeletonAsset();
|
|
|
|
if (InSkeletonData->PropertyNames.Num() == InFrameData->PropertyValues.Num())
|
|
{
|
|
auto GetCurveNameFromIndex = [InSkeletonData](int32 InCurveIndex)
|
|
{
|
|
return InSkeletonData->PropertyNames[InCurveIndex];
|
|
};
|
|
|
|
auto GetCurveValueFromIndex = [InFrameData](int32 InCurveIndex)
|
|
{
|
|
const float Curve = InFrameData->PropertyValues[InCurveIndex];
|
|
if (FMath::IsFinite(Curve))
|
|
{
|
|
return InFrameData->PropertyValues[InCurveIndex];
|
|
}
|
|
else
|
|
{
|
|
return 0.0f;
|
|
}
|
|
};
|
|
|
|
FBlendedCurve Curve;
|
|
UE::Anim::FCurveUtils::BuildUnsorted(Curve, InSkeletonData->PropertyNames.Num(), GetCurveNameFromIndex, GetCurveValueFromIndex);
|
|
OutCurve.Combine(Curve);
|
|
}
|
|
}
|
|
|
|
void ULiveLinkRetargetAsset::BuildCurveData(const TMap<FName, float>& CurveMap, const FCompactPose& InPose, FBlendedCurve& OutCurve) const
|
|
{
|
|
FBlendedCurve Curve;
|
|
UE::Anim::FCurveUtils::BuildUnsorted(Curve, CurveMap);
|
|
OutCurve.Combine(Curve);
|
|
}
|