Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/AnimNodes/AnimNode_ModifyCurve.h
bojan brankov 7c5f8992a1 Added new functionality to ModifyCurve anim node that allows curve manipulation via a name-value map
#jira UE-117365
#rb thomas.sarkanen

[CL 16622472 by bojan brankov in ue5-main branch]
2021-06-10 09:35:31 -04:00

78 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Animation/AnimNodeBase.h"
#include "AnimNode_ModifyCurve.generated.h"
UENUM()
enum class EModifyCurveApplyMode : uint8
{
/** Add new value to input curve value */
Add,
/** Scale input value by new value */
Scale,
/** Blend input with new curve value, using Alpha setting on the node */
Blend,
/** Blend the new curve value with the last curve value using Alpha to determine the weighting (.5 is a moving average, higher values react to new values faster, lower slower) */
WeightedMovingAverage,
/** Remaps the new curve value between the CurveValues entry and 1.0 (.5 in CurveValues makes 0.51 map to 0.02) */
RemapCurve
};
/** Easy way to modify curve values on a pose */
USTRUCT(BlueprintInternalUseOnly)
struct ANIMGRAPHRUNTIME_API FAnimNode_ModifyCurve : public FAnimNode_Base
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, EditFixedSize, BlueprintReadWrite, Category = Links)
FPoseLink SourcePose;
UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category = ModifyCurve, meta = (PinHiddenByDefault))
TMap<FName, float> CurveMap;
UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category = ModifyCurve, meta = (PinShownByDefault))
TArray<float> CurveValues;
UPROPERTY()
TArray<FName> CurveNames;
TArray<float> LastCurveValues;
TMap<FName, float> LastCurveMapValues;
bool bInitializeLastValuesMap;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ModifyCurve, meta = (PinShownByDefault))
float Alpha;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ModifyCurve)
EModifyCurveApplyMode ApplyMode;
FAnimNode_ModifyCurve();
// FAnimNode_Base interface
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
virtual void Evaluate_AnyThread(FPoseContext& Output) override;
virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
// End of FAnimNode_Base interface
#if WITH_EDITOR
/** Add new curve being modified */
void AddCurve(const FName& InName, float InValue);
/** Remove a curve from being modified */
void RemoveCurve(int32 PoseIndex);
#endif // WITH_EDITOR
private:
void ProcessCurveOperation(const EModifyCurveApplyMode& InApplyMode, FPoseContext& Output, const SmartName::UID_Type& NameUID, float CurrentValue, float NewValue);
void ProcessCurveWMAOperation(FPoseContext& Output, const SmartName::UID_Type& NameUID, float CurrentValue, float NewValue, float& InOutLastValue);
};