Skip to content

Commit

Permalink
Fix issue : ue5 crashed when using kawaiiPhysics and ControlRig in le…
Browse files Browse the repository at this point in the history
…velSsquence

When used with LevelSequence, GetSkeletalMeshComponent is null and it occurs crash(ensure)
#94
  • Loading branch information
[email protected] authored and [email protected] committed Aug 11, 2023
1 parent 602d478 commit 5a2fd86
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ void FAnimNode_KawaiiPhysics::Initialize_AnyThread(const FAnimationInitializeCon
DeltaTimeOld = 1.0f / TargetFramerate;

bResetDynamics = false;

#if WITH_EDITOR
const UWorld* World = Context.AnimInstanceProxy->GetSkelMeshComponent()->GetWorld();
if (World->WorldType == EWorldType::Editor ||
World->WorldType == EWorldType::EditorPreview)
{
bEditing = true;
}
#endif
}

void FAnimNode_KawaiiPhysics::CacheBones_AnyThread(const FAnimationCacheBonesContext& Context)
Expand Down Expand Up @@ -170,6 +161,30 @@ bool FAnimNode_KawaiiPhysics::IsValidToEvaluate(const USkeleton* Skeleton, const
return RootBone.BoneName.IsValid();
}

bool FAnimNode_KawaiiPhysics::HasPreUpdate() const
{
#if WITH_EDITOR
return true;
#endif

return false;
}

void FAnimNode_KawaiiPhysics::PreUpdate(const UAnimInstance* InAnimInstance)
{
#if WITH_EDITOR
if(const UWorld* World = InAnimInstance->GetWorld())
{
if (World->WorldType == EWorldType::Editor ||
World->WorldType == EWorldType::EditorPreview)
{
bEditing = true;
}
}
#endif
}


void FAnimNode_KawaiiPhysics::InitializeBoneReferences(const FBoneContainer& RequiredBones)
{
RootBone.Initialize(RequiredBones);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ struct KAWAIIPHYSICS_API FAnimNode_KawaiiPhysics : public FAnimNode_SkeletalCont
// FAnimNode_SkeletalControlBase interface
virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms) override;
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
virtual bool HasPreUpdate() const override;
virtual void PreUpdate(const UAnimInstance* InAnimInstance) override;
virtual void UpdateInternal(const FAnimationUpdateContext& Context) override;
// End of FAnimNode_SkeletalControlBase interface

Expand Down

0 comments on commit 5a2fd86

Please sign in to comment.