Skip to content

Commit

Permalink
Fixed compilation errors on UE4.27
Browse files Browse the repository at this point in the history
  • Loading branch information
hfjooste committed Nov 25, 2023
1 parent 7a3c203 commit 5acd5fe
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void FUSKAnimNode_LayeredBoneBlend::Update_AnyThread(const FAnimationUpdateConte
CurrentBoneBlendWeights, BlendWeights);
bHasRelevantPoses = true;

if (bBlendRootMotionBasedOnRootBone && !CurrentBoneBlendWeights.IsEmpty())
if (bBlendRootMotionBasedOnRootBone && CurrentBoneBlendWeights.Num() > 0)
{
const float NewRootMotionWeight = CurrentBoneBlendWeights[0].BlendWeight;
if(NewRootMotionWeight > ZERO_ANIMWEIGHT_THRESH)
Expand Down Expand Up @@ -153,8 +153,13 @@ void FUSKAnimNode_LayeredBoneBlend::Evaluate_AnyThread(FPoseContext& Output)
TArray<FBlendedCurve> TargetBlendCurves;
TargetBlendCurves.SetNum(NumPoses);

#if ENGINE_MAJOR_VERSION == 4
TArray<FStackCustomAttributes> TargetBlendAttributes;
TargetBlendAttributes.SetNum(NumPoses);
#else
TArray<UE::Anim::FStackAttributeContainer> TargetBlendAttributes;
TargetBlendAttributes.SetNum(NumPoses);
#endif

for (int ChildIndex = 0; ChildIndex < NumPoses; ++ChildIndex)
{
Expand Down Expand Up @@ -188,12 +193,21 @@ void FUSKAnimNode_LayeredBoneBlend::Evaluate_AnyThread(FPoseContext& Output)
continue;
}

#if ENGINE_MAJOR_VERSION == 4
BasePoseContext.Curve.Set(UIDIndex, 0.0f);
#else
BasePoseContext.Curve.InvalidateCurveWeight(UIDIndex);
#endif

for (int ChildIndex = 0; ChildIndex < NumPoses; ++ChildIndex)
{
if (SourceIndex != ChildIndex)
{
#if ENGINE_MAJOR_VERSION == 4
TargetBlendCurves[ChildIndex].Set(UIDIndex, 0.0f);
#else
TargetBlendCurves[ChildIndex].InvalidateCurveWeight(UIDIndex);
#endif
}
}
}
Expand Down Expand Up @@ -316,6 +330,9 @@ void FUSKAnimNode_LayeredBoneBlend::RebuildPerBoneBlendWeights(const USkeleton*
return;
}

#if ENGINE_MAJOR_VERSION == 4
FAnimationRuntime::CreateMaskWeights(PerBoneBlendWeights, LayerSetup, InSkeleton);
#else
if (BlendMode == EUSKLayeredBoneBlendMode::BranchFilter)
{
FAnimationRuntime::CreateMaskWeights(PerBoneBlendWeights, LayerSetup, InSkeleton);
Expand All @@ -324,6 +341,7 @@ void FUSKAnimNode_LayeredBoneBlend::RebuildPerBoneBlendWeights(const USkeleton*
{
FAnimationRuntime::CreateMaskWeights(PerBoneBlendWeights, BlendMasks, InSkeleton);
}
#endif

SkeletonGuid = InSkeleton->GetGuid();
VirtualBoneGuid = InSkeleton->GetVirtualBoneGuid();
Expand All @@ -336,10 +354,12 @@ void FUSKAnimNode_LayeredBoneBlend::RebuildPerBoneBlendWeights(const USkeleton*
*/
void FUSKAnimNode_LayeredBoneBlend::UpdateCachedBoneData(const FBoneContainer& RequiredBones, const USkeleton* Skeleton)
{
#if ENGINE_MAJOR_VERSION >= 5
if (RequiredBones.GetSerialNumber() == RequiredBonesSerialNumber)
{
return;
}
#endif

if (!ArePerBoneBlendWeightsValid(Skeleton) || !bBonesInitialized)
{
Expand Down Expand Up @@ -398,8 +418,13 @@ void FUSKAnimNode_LayeredBoneBlend::UpdateCachedBoneData(const FBoneContainer& R

if (DesiredBoneBlendWeights[CompactPoseIndex.GetInt()].BlendWeight > 0.f)
{
#if ENGINE_MAJOR_VERSION == 4
CurvePoseSourceIndices[CurrentPoseIndex] =
DesiredBoneBlendWeights[CompactPoseIndex.GetInt()].SourceIndex;
#else
CurvePoseSourceIndices[CurrentPoseIndex] =
IntCastChecked<uint8>(DesiredBoneBlendWeights[CompactPoseIndex.GetInt()].SourceIndex);
#endif
}
}
}
Expand All @@ -409,7 +434,9 @@ void FUSKAnimNode_LayeredBoneBlend::UpdateCachedBoneData(const FBoneContainer& R
CurvePoseSourceIndices.Reset();
}

#if ENGINE_MAJOR_VERSION >= 5
RequiredBonesSerialNumber = RequiredBones.GetSerialNumber();
#endif
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct USK_API FUSKAnimNode_LayeredBoneBlend : public FAnimNode_Base
UPROPERTY(EditAnywhere, BlueprintReadWrite, EditFixedSize, Category = "Ultimate Starter Kit|Animation",
meta=(BlueprintCompilerGeneratedDefaults))
TArray<FPoseLink> BlendPoses;

/**
* @brief Whether to use branch filters or a blend mask to specify an input pose per-bone influence
*/
Expand All @@ -49,7 +49,7 @@ struct USK_API FUSKAnimNode_LayeredBoneBlend : public FAnimNode_Base
*/
UPROPERTY(EditAnywhere, EditFixedSize, Category = "Ultimate Starter Kit|Animation",
meta=(UseAsBlendMask=true))
TArray<TObjectPtr<UBlendProfile>> BlendMasks;
TArray<UBlendProfile*> BlendMasks;

/**
* @brief Configuration for the parts of the skeleton to blend for each layer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "ScopedTransaction.h"
#include "AnimNodes/AnimNode_LayeredBoneBlend.h"
#include "Kismet2/CompilerResultsLog.h"
#include "UObject/UE5ReleaseStreamObjectVersion.h"

/**
* @brief Create a new instance of the animation node
Expand All @@ -24,7 +23,8 @@ UUSKAnimGraphNode_LayeredBoneBlend::UUSKAnimGraphNode_LayeredBoneBlend(const FOb
void UUSKAnimGraphNode_LayeredBoneBlend::PostLoad()
{
Super::PostLoad();


#if ENGINE_MAJOR_VERSION >= 5
if (Node.BlendMode != EUSKLayeredBoneBlendMode::BlendMask)
{
return;
Expand All @@ -39,6 +39,7 @@ void UUSKAnimGraphNode_LayeredBoneBlend::PostLoad()
BlendMask->ConditionalPostLoad();
}
}
#endif
}

/**
Expand All @@ -48,7 +49,16 @@ void UUSKAnimGraphNode_LayeredBoneBlend::PostLoad()
*/
FText UUSKAnimGraphNode_LayeredBoneBlend::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
return FText::FromString("[USK] Transform Bone");
return FText::FromString("[USK] Layered Bone Blend");
}

/**
* @brief Get the category used by the node
* @return The category used by the node
*/
FString UUSKAnimGraphNode_LayeredBoneBlend::GetNodeCategory() const
{
return "Ultimate Starter Kit";
}

/**
Expand All @@ -66,6 +76,7 @@ FText UUSKAnimGraphNode_LayeredBoneBlend::GetTooltipText() const
*/
void UUSKAnimGraphNode_LayeredBoneBlend::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
#if ENGINE_MAJOR_VERSION >= 5
const FName PropertyName = PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_LayeredBoneBlend, BlendMode))
{
Expand All @@ -86,6 +97,7 @@ void UUSKAnimGraphNode_LayeredBoneBlend::PostEditChangeProperty(FPropertyChanged

FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint());
}
#endif

Super::PostEditChangeProperty(PropertyChangedEvent);
}
Expand All @@ -99,7 +111,8 @@ void UUSKAnimGraphNode_LayeredBoneBlend::ValidateAnimNodeDuringCompilation(USkel
FCompilerResultsLog& MessageLog)
{
UAnimGraphNode_Base::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);


#if ENGINE_MAJOR_VERSION >= 5
bool bCompilationError = false;
if (Node.BlendMode == EUSKLayeredBoneBlendMode::BlendMask)
{
Expand All @@ -125,6 +138,7 @@ void UUSKAnimGraphNode_LayeredBoneBlend::ValidateAnimNodeDuringCompilation(USkel
{
return;
}
#endif

if (!Node.ArePerBoneBlendWeightsValid(ForSkeleton))
{
Expand All @@ -137,6 +151,7 @@ void UUSKAnimGraphNode_LayeredBoneBlend::ValidateAnimNodeDuringCompilation(USkel
*/
void UUSKAnimGraphNode_LayeredBoneBlend::PreloadRequiredAssets()
{
#if ENGINE_MAJOR_VERSION >= 5
if (Node.BlendMode == EUSKLayeredBoneBlendMode::BlendMask)
{
const int NumBlendMasks = Node.BlendMasks.Num();
Expand All @@ -146,6 +161,7 @@ void UUSKAnimGraphNode_LayeredBoneBlend::PreloadRequiredAssets()
PreloadObject(BlendMask);
}
}
#endif

Super::PreloadRequiredAssets();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class USKEDITOR_API UUSKAnimGraphNode_LayeredBoneBlend : public UAnimGraphNode_B
*/
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;

/**
* @brief Get the category used by the node
* @return The category used by the node
*/
virtual FString GetNodeCategory() const override;

/**
* @brief Get the tooltip text displayed by the node
* @return The tooltip text displayed by the node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ FText UUSKAnimGraphNode_ModifyBone::GetNodeTitle(ENodeTitleType::Type TitleType)
return CachedNodeTitles[TitleType];
}

/**
* @brief Get the category used by the node
* @return The category used by the node
*/
FString UUSKAnimGraphNode_ModifyBone::GetNodeCategory() const
{
return "Ultimate Starter Kit";
}

/**
* @brief Get the tooltip text displayed by the node
* @return The tooltip text displayed by the node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class USKEDITOR_API UUSKAnimGraphNode_ModifyBone : public UAnimGraphNode_Skeleta
*/
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;

/**
* @brief Get the category used by the node
* @return The category used by the node
*/
virtual FString GetNodeCategory() const override;

/**
* @brief Get the tooltip text displayed by the node
* @return The tooltip text displayed by the node
Expand Down

0 comments on commit 5acd5fe

Please sign in to comment.