// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. /** * Abstract base class for a skeletal controller. * A SkelControl is a module that can modify the position or orientation of a set of bones in a skeletal mesh in some programmatic way. */ #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "BonePose.h" #include "Animation/AnimNodeBase.h" #include "Animation/InputScaleBias.h" #include "AnimNode_SkeletalControlBase.generated.h" class USkeletalMeshComponent; USTRUCT() struct ANIMGRAPHRUNTIME_API FAnimNode_SkeletalControlBase : public FAnimNode_Base { GENERATED_USTRUCT_BODY() // Input link UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Links) FComponentSpacePoseLink ComponentPose; // Current strength of the skeletal control UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Settings, meta=(PinShownByDefault)) mutable float Alpha; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Settings) FInputScaleBias AlphaScaleBias; /* * Max LOD that this node is allowed to run * For example if you have LODThreadhold to be 2, it will run until LOD 2 (based on 0 index) * when the component LOD becomes 3, it will stop update/evaluate * currently transition would be issue and that has to be re-visited */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Performance, meta = (DisplayName = "LOD Threshold")) int32 LODThreshold; UPROPERTY(Transient) float ActualAlpha; public: FAnimNode_SkeletalControlBase() : Alpha(1.0f) , LODThreshold(INDEX_NONE) , ActualAlpha(0.f) { } public: #if WITH_EDITORONLY_DATA // forwarded pose data from the wired node which current node's skeletal control is not applied yet FCSPose ForwardedPose; #endif //#if WITH_EDITORONLY_DATA // FAnimNode_Base interface virtual void Initialize(const FAnimationInitializeContext& Context) override; virtual void CacheBones(const FAnimationCacheBonesContext& Context) override; virtual void Update(const FAnimationUpdateContext& Context) final; virtual void EvaluateComponentSpace(FComponentSpacePoseContext& Output) final; // End of FAnimNode_Base interface protected: // Interface for derived skeletal controls to implement // use this function to update for skeletal control base virtual void UpdateInternal(const FAnimationUpdateContext& Context); // use this function to evaluate for skeletal control base virtual void EvaluateComponentSpaceInternal(FComponentSpacePoseContext& Context); DEPRECATED(4.16, "Please use EvaluateSkeletalControl_AnyThread.") virtual void EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose& MeshBases, TArray& OutBoneTransforms) {} // Evaluate the new component-space transforms for the affected bones. virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray& OutBoneTransforms); // return true if it is valid to Evaluate virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) { return false; } // initialize any bone references you have virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones){}; /** Allow base to add info to the node debug output */ void AddDebugNodeData(FString& OutDebugData); private: // Resused bone transform array to avoid reallocating in skeletal controls TArray BoneTransforms; };