You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Also fixes type conversions (first time I have tried to convert to a base class and found that my IsChildOf check was the wrong way around). Plus some extra accessors added for exec/update contexts. Found the need for these when doing show & tell prep. #rb Jurre.deBaare [CL 17367354 by Thomas Sarkanen in ue5-main branch]
63 lines
2.4 KiB
C++
63 lines
2.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimExecutionContextLibrary.h"
|
|
#include "Animation/AnimExecutionContext.h"
|
|
#include "Animation/AnimInstance.h"
|
|
#include "Animation/AnimNodeBase.h"
|
|
#include "Animation/AnimClassInterface.h"
|
|
#include "Animation/AnimInstanceProxy.h"
|
|
|
|
UAnimInstance* UAnimExecutionContextLibrary::GetAnimInstance(const FAnimExecutionContext& Context)
|
|
{
|
|
return CastChecked<UAnimInstance>(Context.GetBaseContext()->GetAnimInstanceObject());
|
|
}
|
|
|
|
FAnimNodeReference UAnimExecutionContextLibrary::GetAnimNodeReference(UAnimInstance* Instance, int32 Index)
|
|
{
|
|
IAnimClassInterface* AnimClassInterface = IAnimClassInterface::GetFromClass(Instance->GetClass());
|
|
const TArray<FStructProperty*>& AnimNodeProperties = AnimClassInterface->GetAnimNodeProperties();
|
|
|
|
// As the index is patched during compilation, it needs to be reversed here
|
|
int32 ReverseIndex = AnimNodeProperties.Num() - 1 - Index;
|
|
return FAnimNodeReference(Instance, ReverseIndex);
|
|
}
|
|
|
|
FAnimInitializationContext UAnimExecutionContextLibrary::ConvertToInitializationContext(const FAnimExecutionContext& Context, EAnimExecutionContextConversionResult& Result)
|
|
{
|
|
return FAnimExecutionContext::ConvertToType<FAnimInitializationContext>(Context, Result);
|
|
}
|
|
|
|
FAnimUpdateContext UAnimExecutionContextLibrary::ConvertToUpdateContext(const FAnimExecutionContext& Context, EAnimExecutionContextConversionResult& Result)
|
|
{
|
|
return FAnimExecutionContext::ConvertToType<FAnimUpdateContext>(Context, Result);
|
|
}
|
|
|
|
float UAnimExecutionContextLibrary::GetDeltaTime(const FAnimUpdateContext& UpdateContext)
|
|
{
|
|
if(FAnimationUpdateContext* Context = UpdateContext.GetContext())
|
|
{
|
|
return Context->GetDeltaTime();
|
|
}
|
|
|
|
return 0.0f;
|
|
}
|
|
|
|
float UAnimExecutionContextLibrary::GetCurrentWeight(const FAnimUpdateContext& UpdateContext)
|
|
{
|
|
if(FAnimationUpdateContext* Context = UpdateContext.GetContext())
|
|
{
|
|
return Context->GetFinalBlendWeight();
|
|
}
|
|
|
|
return 0.0f;
|
|
}
|
|
|
|
FAnimPoseContext UAnimExecutionContextLibrary::ConvertToPoseContext(const FAnimExecutionContext& Context, EAnimExecutionContextConversionResult& Result)
|
|
{
|
|
return FAnimExecutionContext::ConvertToType<FAnimPoseContext>(Context, Result);
|
|
}
|
|
|
|
FAnimComponentSpacePoseContext UAnimExecutionContextLibrary::ConvertToComponentSpacePoseContext(const FAnimExecutionContext& Context, EAnimExecutionContextConversionResult& Result)
|
|
{
|
|
return FAnimExecutionContext::ConvertToType<FAnimComponentSpacePoseContext>(Context, Result);
|
|
} |