Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/AnimNodes/AnimNode_MultiWayBlend.h
Thomas Sarkanen fb5f8e12c0 Fixed ensure/crash when using details panel to edit multi way blend weights
#jira UE-122147 - Ensure/Crash: Anim graph multi blend
#rb Jurre.deBaare

[CL 17367747 by Thomas Sarkanen in ue5-main branch]
2021-08-31 09:57:22 -04:00

91 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Animation/AnimNodeBase.h"
#include "Animation/InputScaleBias.h"
#include "AnimNode_MultiWayBlend.generated.h"
// This represents a baked transition
USTRUCT(BlueprintInternalUseOnly)
struct ANIMGRAPHRUNTIME_API FAnimNode_MultiWayBlend : public FAnimNode_Base
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Links)
TArray<FPoseLink> Poses;
UPROPERTY(EditAnywhere, EditFixedSize, BlueprintReadWrite, Category=Settings, meta=(PinShownByDefault))
TArray<float> DesiredAlphas;
private:
TArray<float> CachedAlphas;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Settings)
FInputScaleBias AlphaScaleBias;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Settings)
bool bAdditiveNode;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Settings)
bool bNormalizeAlpha;
public:
FAnimNode_MultiWayBlend()
: bAdditiveNode(false)
, bNormalizeAlpha(true)
{
}
// FAnimNode_Base interface
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
virtual void Evaluate_AnyThread(FPoseContext& Output) override;
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
// End of FAnimNode_Base interface
int32 AddPose()
{
Poses.AddDefaulted();
DesiredAlphas.AddZeroed();
UpdateCachedAlphas();
return Poses.Num();
}
void RemovePose(int32 PoseIndex)
{
Poses.RemoveAt(PoseIndex);
CachedAlphas.RemoveAt(PoseIndex);
DesiredAlphas.RemoveAt(PoseIndex);
}
void ResetPoses()
{
Poses.Reset();
CachedAlphas.Reset();
DesiredAlphas.Reset();
}
float GetTotalAlpha() const
{
float TotalAlpha = 0.f;
for (float Alpha : DesiredAlphas)
{
TotalAlpha += Alpha;
}
return TotalAlpha;
}
private:
// process new weights and then return out
void UpdateCachedAlphas();
};