Skip to content

Commit 5a2fd86

Browse files
Fix issue : ue5 crashed when using kawaiiPhysics and ControlRig in levelSsquence
When used with LevelSequence, GetSkeletalMeshComponent is null and it occurs crash(ensure) #94
1 parent 602d478 commit 5a2fd86

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

Plugins/KawaiiPhysics/Source/KawaiiPhysics/Private/AnimNode_KawaiiPhysics.cpp

+24-9
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ void FAnimNode_KawaiiPhysics::Initialize_AnyThread(const FAnimationInitializeCon
3636
DeltaTimeOld = 1.0f / TargetFramerate;
3737

3838
bResetDynamics = false;
39-
40-
#if WITH_EDITOR
41-
const UWorld* World = Context.AnimInstanceProxy->GetSkelMeshComponent()->GetWorld();
42-
if (World->WorldType == EWorldType::Editor ||
43-
World->WorldType == EWorldType::EditorPreview)
44-
{
45-
bEditing = true;
46-
}
47-
#endif
4839
}
4940

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

164+
bool FAnimNode_KawaiiPhysics::HasPreUpdate() const
165+
{
166+
#if WITH_EDITOR
167+
return true;
168+
#endif
169+
170+
return false;
171+
}
172+
173+
void FAnimNode_KawaiiPhysics::PreUpdate(const UAnimInstance* InAnimInstance)
174+
{
175+
#if WITH_EDITOR
176+
if(const UWorld* World = InAnimInstance->GetWorld())
177+
{
178+
if (World->WorldType == EWorldType::Editor ||
179+
World->WorldType == EWorldType::EditorPreview)
180+
{
181+
bEditing = true;
182+
}
183+
}
184+
#endif
185+
}
186+
187+
173188
void FAnimNode_KawaiiPhysics::InitializeBoneReferences(const FBoneContainer& RequiredBones)
174189
{
175190
RootBone.Initialize(RequiredBones);

Plugins/KawaiiPhysics/Source/KawaiiPhysics/Public/AnimNode_KawaiiPhysics.h

+2
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ struct KAWAIIPHYSICS_API FAnimNode_KawaiiPhysics : public FAnimNode_SkeletalCont
402402
// FAnimNode_SkeletalControlBase interface
403403
virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms) override;
404404
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
405+
virtual bool HasPreUpdate() const override;
406+
virtual void PreUpdate(const UAnimInstance* InAnimInstance) override;
405407
virtual void UpdateInternal(const FAnimationUpdateContext& Context) override;
406408
// End of FAnimNode_SkeletalControlBase interface
407409

0 commit comments

Comments
 (0)