Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Classes/AnimPreviewInstance.h
Martin Wilson ae71a8cca5 Added FCompactPose, contains only the bone transforms needed by RequiredBones. Allows us to do animation evaluation without having to refer to required bones array all the time
API Breaking Changes

Removed Functions:
FA2CSPose::SafeSetCSBoneTransforms
FA2CSPose::LocalBlendCSBoneTransforms

Member Type Changes:
- int32 -> FCompactPoseBoneIndex
--- FBoneTransform::BoneIndex
--- FABRIKChainLink::BoneIndex
- FA2CSPose -> FCSPose<FCompactPose>
--- FAnimNode_SkeletalControlBase::ForwardedPose
--- FComponentSpacePoseContext::Pose
- FA2Pose -> FCompactPose
--- FSlotEvaluationPose::Pose
--- FAnimNode_TransitionPoseEvaluator::CachedPose
--- FAnimNode_SaveCachedPose::CachedPose
--- FPoseContext::Pose

Paramater Changes:
- FA2Pose& -> FCompactPose&
--- UAnimSingleNodeInstance::InternalBlendSpaceEvaluatePose (FA2Pose& Pose -> FCompactPose&)
--- UAnimInstance::SequenceEvaluatePose
--- UAnimInstance::BlendSequences
--- UAnimInstance::CopyPose
--- UAnimInstance::ApplyAdditiveSequence
--- UAnimInstance::BlendSpaceEvaluatePose
--- UAnimInstance::BlendRotationOffset
--- UAnimInstance::GetSlotWeight
--- UAnimInstance::SlotEvaluatePose
- FA2CSPose& -> FCSPose<FCompactPose>&
--- FAnimNode_SkeletalControlBase::EvaluateBoneTransforms
--- UAnimGraphNode_SkeletalControlBase::ConvertCSVectorToBoneSpace
--- UAnimGraphNode_SkeletalControlBase::ConvertCSRotationToBoneSpace
--- UAnimGraphNode_SkeletalControlBase::ConvertWidgetLocation
--- UAnimPreviewInstance::ApplyBoneControllers
- TArray<FTransform> -> FCompactPose
--- UAnimPreviewInstance::SetKeyImplementation
--- UAnimSequence::GetAnimationPose
--- UAnimSequence::GetBonePose
--- UAnimSequence::GetBonePose_Additive
--- UAnimSequence::GetAdditiveBasePose
--- UAnimSequence::GetBonePose_AdditiveMeshRotationOnly
--- FAnimationRuntime::BlendPosesTogether ( + Removed NumPoses and RequiredBones )
--- FAnimationRuntime::BlendPosesTogetherPerBone  ( + Removed NumPoses and RequiredBones )
--- FAnimationRuntime::BlendPosesTogetherPerBoneInMeshSpace ( + Removed NumPoses and RequiredBones )
--- FAnimationRuntime::BlendPosesPerBoneFilter ( + Removed Skeleton and RequiredBones )
--- FAnimationRuntime::GetPoseFromSequence ( + Removed  RequiredBones )
--- FAnimationRuntime::GetPoseFromAnimTrack ( + Removed  RequiredBones )
--- FAnimationRuntime::FillWithRetargetBaseRefPose ( + Removed  RequiredBones )
--- FAnimationRuntime::ConvertPoseToAdditive ( + Removed  RequiredBones )
--- FAnimationRuntime::ConvertPoseToMeshRotation ( + Removed  RequiredBones )
--- FAnimationRuntime::BlendPosesAccumulate ( + Removed  RequiredBones )
--- FAnimationRuntime::BlendAdditivePose ( + Removed  RequiredBones )
--- FAnimationRuntime::GetPoseFromBlendSpace ( + Removed  RequiredBones )
--- FAnimationRuntime::ConvertCSTransformToBoneSpace
--- FAnimationRuntime::ConvertBoneSpaceTransformToCS
--- FAnimationRuntime::BlendMeshPosesPerBoneWeights ( + Removed Skeleton and RequiredBones )
--- FAnimationRuntime::BlendLocalPosesPerBoneWeights ( + Removed Skeleton and RequiredBones )
- TArray<FTransform> -> FTransform
--- UAnimSequence::ResetRootBoneForRootMotion
- int32 -> FCompactPoseBoneIndex
--- UAnimSequence::RetargetBoneTransform

FAnimationRuntime: Many changes to animation operation functions, removal of NumPoses and RequiredBones, conversion of TArray<FTransform> to FCompactPose

Removed USTRUCT markup from FBoneTransform
Removed UPROPERTY markup from FAnimNode_TransitionPoseEvaluator::CachedPose

[CL 2556671 by Martin Wilson in Main branch]
2015-05-19 06:19:22 -04:00

188 lines
6.1 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "BlueprintGraphDefinitions.h"
#include "AnimGraphNode_ModifyBone.h"
#include "Animation/AnimSingleNodeInstance.h"
#include "Animation/BoneControllers/AnimNode_ModifyBone.h"
#include "AnimPreviewInstance.generated.h"
/** Enum to know how montage is being played */
UENUM()
enum EMontagePreviewType
{
/** Playing montage in usual way. */
EMPT_Normal,
/** Playing all sections. */
EMPT_AllSections,
EMPT_MAX,
};
/**
* This Instance only contains one AnimationAsset, and produce poses
* Used by Preview in AnimGraph, Playing single animation in Kismet2 and etc
*/
UCLASS(transient, NotBlueprintable, noteditinlinenew)
class ANIMGRAPH_API UAnimPreviewInstance : public UAnimSingleNodeInstance
{
GENERATED_UCLASS_BODY()
/** Controllers for individual bones */
UPROPERTY(transient)
TArray<FAnimNode_ModifyBone> BoneControllers;
/** Curve modifiers */
UPROPERTY(transient)
TArray<FAnimNode_ModifyBone> CurveBoneControllers;
/** Shared parameters for previewing blendspace or animsequence **/
UPROPERTY(transient)
float SkeletalControlAlpha;
/** Shared parameters for previewing blendspace or animsequence **/
UPROPERTY(transient)
TEnumAsByte<enum EMontagePreviewType> MontagePreviewType;
UPROPERTY(transient)
int32 MontagePreviewStartSectionIdx;
// Begin UAnimInstance interface
virtual void NativeInitializeAnimation() override;
virtual void NativeUpdateAnimation(float DeltaTimeX) override;
virtual bool NativeEvaluateAnimation(FPoseContext& Output) override;
// End UAnimInstance interface
/** Set SkeletalControl Alpha**/
void SetSkeletalControlAlpha(float SkeletalControlAlpha);
UAnimSequence* GetAnimSequence();
// Begin UAnimSingleNodeInstance interface
virtual void RestartMontage(UAnimMontage* Montage, FName FromSection = FName()) override;
virtual void SetAnimationAsset(UAnimationAsset* NewAsset, bool bIsLooping = true, float InPlayRate = 1.f) override;
// End UAnimSingleNodeInstance interface
/** Montage preview functions */
void MontagePreview_JumpToStart();
void MontagePreview_JumpToEnd();
void MontagePreview_JumpToPreviewStart();
void MontagePreview_Restart();
void MontagePreview_PreviewNormal(int32 FromSectionIdx = INDEX_NONE);
void MontagePreview_SetLoopNormal(bool bIsLooping, int32 PreferSectionIdx = INDEX_NONE);
void MontagePreview_PreviewAllSections();
void MontagePreview_SetLoopAllSections(bool bIsLooping);
void MontagePreview_SetLoopAllSetupSections(bool bIsLooping);
void MontagePreview_ResetSectionsOrder();
void MontagePreview_SetLooping(bool bIsLooping);
void MontagePreview_SetPlaying(bool bIsPlaying);
void MontagePreview_SetReverse(bool bInReverse);
void MontagePreview_StepForward();
void MontagePreview_StepBackward();
void MontagePreview_JumpToPosition(float NewPosition);
int32 MontagePreview_FindFirstSectionAsInMontage(int32 AnySectionIdx);
int32 MontagePreview_FindLastSection(int32 StartSectionIdx);
float MontagePreview_CalculateStepLength();
void MontagePreview_RemoveBlendOut();
bool IsPlayingMontage() { return GetActiveMontageInstance() != NULL; }
/**
* Finds an already modified bone
* @param InBoneName The name of the bone modification to find
* @return the bone modification or NULL if no current modification was found
*/
FAnimNode_ModifyBone* FindModifiedBone(const FName& InBoneName, bool bCurveController=false);
/**
* Modifies a single bone. Create a new FAnimNode_ModifyBone if one does not exist for the passed-in bone.
* @param InBoneName The name of the bone to modify
* @return the new or existing bone modification
*/
FAnimNode_ModifyBone& ModifyBone(const FName& InBoneName, bool bCurveController=false);
/**
* Removes an existing bone modification
* @param InBoneName The name of the existing modification to remove
*/
void RemoveBoneModification(const FName& InBoneName, bool bCurveController=false);
/**
* Reset all bone modified
*/
void ResetModifiedBone(bool bCurveController=false);
#if WITH_EDITORONLY_DATA
bool bForceRetargetBasePose;
#endif
/**
* Convert current modified bone transforms (BoneControllers) to transform curves (CurveControllers)
* it does based on CurrentTime. This function does not set key directly here.
* It does wait until next update, and it gets the delta of transform before applying curves, and
* creates curves from it, so you'll need delegate if you'd like to do something after
*
* @param Delegate To be called once set key is completed
*/
void SetKey(FSimpleDelegate InOnSetKeyCompleteDelegate);
/**
* Refresh Curve Bone Controllers based on TransformCurves from Animation data
*/
void RefreshCurveBoneControllers();
/**
* Apply all Transform Curves to the RawAnimationData of the animation
*/
void BakeAnimation();
/**
* Enable Controllers
* This is used by when editing, when controller has to be disabled
*/
void EnableControllers(bool bEnable);
private:
/**
* Apply Bone Controllers to the Outpose
*
* @param Component Component to apply bone controller to
* @param BoneControllers List of Bone Controllers to apply
* @param OutMeshPose Outpose in Mesh Space once applied
*/
void ApplyBoneControllers(USkeletalMeshComponent* Component, TArray<FAnimNode_ModifyBone> &BoneControllers, FCSPose<FCompactPose>& OutMeshPose);
/**
* Update CurveControllers based on TransformCurves of Animation
*/
void UpdateCurveController();
/*
* Set Key Implementation function
* It gets Pre Controller Local Space and gets Post Controller Local Space, and add the key to the curve
*/
void SetKeyImplementation(const FCompactPose& PreControllerInLocalSpace, const FCompactPose& PostControllerInLocalSpace);
/**
* Add Key to the Sequence
* Now Additive Key is generated, add to the curves
*/
void AddKeyToSequence(UAnimSequence* Sequence, float Time, const FName& BoneName, const FTransform& AdditiveTransform);
/*
* When this flag is true, it sets key
*/
bool bSetKey;
/*
* Used to determine if controller has to be applied or not
* Used to disable controller during editing
*/
bool bEnableControllers;
/**
* Delegate to call after Key is set
*/
FSimpleDelegate OnSetKeyCompleteDelegate;
};