-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMorphTargetCurveAction.h
More file actions
82 lines (68 loc) · 2.67 KB
/
Copy pathMorphTargetCurveAction.h
File metadata and controls
82 lines (68 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "Tickable.h"
#include "MorphTargetCurveAction.generated.h"
class USkeletalMeshComponent;
UENUM(BlueprintType)
enum class EMorphInterpCurve : uint8
{
Linear UMETA(DisplayName = "Linear"),
EaseIn UMETA(DisplayName = "Ease In (Quadratic)"),
EaseOut UMETA(DisplayName = "Ease Out (Quadratic)"),
EaseInOut UMETA(DisplayName = "Ease In Out (Quadratic)"),
CubicInOut UMETA(DisplayName = "Cubic In Out"),
Sine UMETA(DisplayName = "Sine In Out"),
Overshoot UMETA(DisplayName = "Back Out (Overshoot)"),
Elastic UMETA(DisplayName = "Elastic Out (Spring)"),
Bounce UMETA(DisplayName = "Bounce Out")
};
UENUM(BlueprintType)
enum class EMorphCurveDirection : uint8
{
Open UMETA(DisplayName = "Open (0 -> 1)"),
Close UMETA(DisplayName = "Close (1 -> 0)")
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMorphCurveValue, float, Value);
UCLASS()
class AGILE_API UMorphTargetCurveAction
: public UBlueprintAsyncActionBase
, public FTickableGameObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable) FMorphCurveValue OnUpdate;
UPROPERTY(BlueprintAssignable) FMorphCurveValue OnFinished;
UFUNCTION(BlueprintCallable,
meta = (BlueprintInternalUseOnly = "true",
WorldContext = "WorldContextObject",
DisplayName = "Set Morph Target",
ToolTip = "Animate a skeletal mesh morph target with a built-in interpolation curve over Duration. Direction picks Open (0->1) or Close (1->0)."),
Category = "Animation|Morph Target")
static UMorphTargetCurveAction* SetMorphTarget(
UObject* WorldContextObject,
USkeletalMeshComponent* Target,
FName MorphTargetName,
EMorphInterpCurve Curve,
EMorphCurveDirection Direction = EMorphCurveDirection::Open,
float Duration = 0.5f);
virtual void Activate() override;
virtual void Tick(float DeltaTime) override;
virtual TStatId GetStatId() const override;
virtual bool IsTickable() const override { return bActive; }
virtual UWorld* GetTickableGameObjectWorld() const override { return WorldPtr.Get(); }
virtual ETickableTickType GetTickableTickType() const override { return ETickableTickType::Conditional; }
UFUNCTION(BlueprintCallable, Category = "Animation|Morph Target")
void Cancel();
static float EvaluateCurve(EMorphInterpCurve Curve, float Alpha);
private:
void Finish(float FinalValue);
UPROPERTY() TWeakObjectPtr<USkeletalMeshComponent> TargetComp;
TWeakObjectPtr<UWorld> WorldPtr;
FName MorphName;
float DurationSec = 0.5f;
float ElapsedSec = 0.f;
EMorphInterpCurve CurveType = EMorphInterpCurve::EaseInOut;
EMorphCurveDirection Dir = EMorphCurveDirection::Open;
bool bActive = false;
};