Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/AnimNodes/AnimNode_CopyPoseFromMesh.h
daren cheng f6c564b03b Address multiple typos for UEFN localization
#jira UE-166004 UE-168317
#rb Robb.Surridge
#preflight 6360165b7e083afb290e187f

[CL 22889284 by daren cheng in ue5-main branch]
2022-11-01 15:30:54 -04:00

84 lines
3.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Animation/AnimNodeBase.h"
#include "AnimNode_CopyPoseFromMesh.generated.h"
class USkeletalMeshComponent;
struct FAnimInstanceProxy;
/**
* Simple controller to copy a bone's transform to another one.
*/
USTRUCT(BlueprintInternalUseOnly)
struct ANIMGRAPHRUNTIME_API FAnimNode_CopyPoseFromMesh : public FAnimNode_Base
{
GENERATED_USTRUCT_BODY()
/* This is used by default if it's valid */
UPROPERTY(BlueprintReadWrite, transient, Category=Copy, meta=(PinShownByDefault))
TWeakObjectPtr<USkeletalMeshComponent> SourceMeshComponent;
/* If SourceMeshComponent is not valid, and if this is true, it will look for attahced parent as a source */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Copy, meta = (NeverAsPin))
uint8 bUseAttachedParent : 1;
/* Copy curves also from SouceMeshComponent. This will copy the curves if this instance also contains curve attributes */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Copy, meta = (NeverAsPin))
uint8 bCopyCurves : 1;
/* Copy custom attributes from SouceMeshComponent */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Copy, meta = (NeverAsPin))
bool bCopyCustomAttributes;
/* Use root space transform to copy to the target pose. By default, it copies their relative transform (bone space)*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Copy, meta = (NeverAsPin))
uint8 bUseMeshPose : 1;
/* If you want to specify copy root, use this - this will ensure copy only below of this joint (inclusively) */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Copy, meta = (NeverAsPin))
FName RootBoneToCopy;
FAnimNode_CopyPoseFromMesh();
// 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;
virtual bool HasPreUpdate() const override { return true; }
virtual void PreUpdate(const UAnimInstance* InAnimInstance) override;
// End of FAnimNode_Base interface
private:
// this is source mesh references, so that we could compare and see if it has changed
TWeakObjectPtr<USkeletalMeshComponent> CurrentlyUsedSourceMeshComponent;
TWeakObjectPtr<USkeletalMesh> CurrentlyUsedSourceMesh;
TWeakObjectPtr<USkeletalMesh> CurrentlyUsedMesh;
// target mesh
TWeakObjectPtr<USkeletalMesh> CurrentlyUsedTargetMesh;
// cache of target space bases to source space bases
TMap<int32, int32> BoneMapToSource;
TMap<FName, SmartName::UID_Type> CurveNameToUIDMap;
TMap<int32, int32> SourceBoneToTarget;
// Cached transforms, copied on the game thread
TArray<FTransform> SourceMeshTransformArray;
// Cached curves, copied on the game thread
TMap<FName, float> SourceCurveList;
// Cached attributes, copied on the game thread
UE::Anim::FMeshAttributeContainer SourceCustomAttributes;
// reinitialize mesh component
void ReinitializeMeshComponent(USkeletalMeshComponent* NewSkeletalMeshComponent, USkeletalMeshComponent* TargetMeshComponent);
void RefreshMeshComponent(USkeletalMeshComponent* TargetMeshComponent);
};