You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added a PoseNode to the AnimInstanceProxy that we save a pose to right when we initialize the seuqencer proxy and then in RestoreState in the template we then link that anim pose to use that stored pose and then force an evaluation. #jira UE-70665 #rb max.chen, lina.halper [CL 5767595 by Mike Zyracki in Dev-Sequencer branch]
123 lines
3.6 KiB
C++
123 lines
3.6 KiB
C++
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Animation/AnimInstanceProxy.h"
|
|
#include "AnimNodes/AnimNode_SequenceEvaluator.h"
|
|
#include "AnimNodes/AnimNode_ApplyAdditive.h"
|
|
#include "AnimNodes/AnimNode_MultiWayBlend.h"
|
|
#include "AnimNodes/AnimNode_PoseSnapshot.h"
|
|
#include "AnimSequencerInstanceProxy.generated.h"
|
|
|
|
/** Base class for all 'players' that can attach to and be blended into a sequencer instance's output */
|
|
struct FSequencerPlayerBase
|
|
{
|
|
public:
|
|
FSequencerPlayerBase()
|
|
: PoseIndex(INDEX_NONE)
|
|
, bAdditive(false)
|
|
{}
|
|
|
|
template<class TType>
|
|
bool IsOfType() const
|
|
{
|
|
return IsOfTypeImpl(TType::GetTypeId());
|
|
}
|
|
|
|
/** Virtual destructor. */
|
|
virtual ~FSequencerPlayerBase() { }
|
|
|
|
public:
|
|
/** Index of this players pose in the set of blend slots */
|
|
int32 PoseIndex;
|
|
|
|
/** Whether this pose is additive or not */
|
|
bool bAdditive;
|
|
|
|
protected:
|
|
/**
|
|
* Checks whether this drag and drop operation can cast safely to the specified type.
|
|
*/
|
|
virtual bool IsOfTypeImpl(const FName& Type) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
};
|
|
|
|
/** Quick n dirty RTTI to allow for derived classes to insert nodes of different types */
|
|
#define SEQUENCER_INSTANCE_PLAYER_TYPE(TYPE, BASE) \
|
|
static const FName& GetTypeId() { static FName Type(TEXT(#TYPE)); return Type; } \
|
|
virtual bool IsOfTypeImpl(const FName& Type) const override { return GetTypeId() == Type || BASE::IsOfTypeImpl(Type); }
|
|
|
|
/** Player type that evaluates a sequence-specified UAnimSequence */
|
|
struct FSequencerPlayerAnimSequence : public FSequencerPlayerBase
|
|
{
|
|
SEQUENCER_INSTANCE_PLAYER_TYPE(FSequencerPlayerAnimSequence, FSequencerPlayerBase)
|
|
|
|
struct FAnimNode_SequenceEvaluator PlayerNode;
|
|
};
|
|
|
|
/** Proxy override for this UAnimInstance-derived class */
|
|
USTRUCT()
|
|
struct ANIMGRAPHRUNTIME_API FAnimSequencerInstanceProxy : public FAnimInstanceProxy
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
FAnimSequencerInstanceProxy()
|
|
{
|
|
}
|
|
|
|
FAnimSequencerInstanceProxy(UAnimInstance* InAnimInstance)
|
|
: FAnimInstanceProxy(InAnimInstance)
|
|
{
|
|
}
|
|
|
|
virtual ~FAnimSequencerInstanceProxy();
|
|
|
|
// FAnimInstanceProxy interface
|
|
virtual void Initialize(UAnimInstance* InAnimInstance) override;
|
|
virtual bool Evaluate(FPoseContext& Output) override;
|
|
virtual void UpdateAnimationNode(float DeltaSeconds) override;
|
|
|
|
/** Update an animation sequence player in this instance */
|
|
void UpdateAnimTrack(UAnimSequenceBase* InAnimSequence, uint32 SequenceId, float InPosition, float Weight, bool bFireNotifies);
|
|
|
|
/** Reset all nodes in this instance */
|
|
virtual void ResetNodes();
|
|
|
|
/** Reset the pose in this instance*/
|
|
virtual void ResetPose();
|
|
|
|
protected:
|
|
/** Find a player of a specified type */
|
|
template<typename Type>
|
|
Type* FindPlayer(uint32 SequenceId) const
|
|
{
|
|
FSequencerPlayerBase* Player = SequencerToPlayerMap.FindRef(SequenceId);
|
|
if (Player && Player->IsOfType<Type>())
|
|
{
|
|
return static_cast<Type*>(Player);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
/** Construct and link the base part of the blend tree */
|
|
void ConstructNodes();
|
|
|
|
/** custom root node for this sequencer player. Didn't want to use RootNode in AnimInstance because it's used with lots of AnimBP functionality */
|
|
struct FAnimNode_ApplyAdditive SequencerRootNode;
|
|
struct FAnimNode_MultiWayBlend FullBodyBlendNode;
|
|
struct FAnimNode_MultiWayBlend AdditiveBlendNode;
|
|
struct FAnimNode_PoseSnapshot SnapshotNode;
|
|
|
|
/** mapping from sequencer index to internal player index */
|
|
TMap<uint32, FSequencerPlayerBase*> SequencerToPlayerMap;
|
|
|
|
void InitAnimTrack(UAnimSequenceBase* InAnimSequence, uint32 SequenceId);
|
|
void EnsureAnimTrack(UAnimSequenceBase* InAnimSequence, uint32 SequenceId);
|
|
void ClearSequencePlayerMap();
|
|
};
|