Skip to content

UAnimInstance::ResetDynamics(ETeleportType::ResetPhysics)呼び出しでのリセットに対応しました #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ void FAnimNode_KawaiiPhysics::Initialize_AnyThread(const FAnimationInitializeCon
// For Avoiding Zero Divide in the first frame
DeltaTimeOld = 1.0f / TargetFramerate;

bResetDynamics = false;

#if WITH_EDITOR
auto World = Context.AnimInstanceProxy->GetSkelMeshComponent()->GetWorld();
if (World->WorldType == EWorldType::Editor ||
Expand All @@ -46,6 +48,11 @@ void FAnimNode_KawaiiPhysics::CacheBones_AnyThread(const FAnimationCacheBonesCon

}

void FAnimNode_KawaiiPhysics::ResetDynamics(ETeleportType InTeleportType)
{
bResetDynamics |= (ETeleportType::ResetPhysics == InTeleportType);
}

void FAnimNode_KawaiiPhysics::UpdateInternal(const FAnimationUpdateContext& Context)
{
FAnimNode_SkeletalControlBase::UpdateInternal(Context);
Expand All @@ -61,6 +68,12 @@ void FAnimNode_KawaiiPhysics::EvaluateSkeletalControl_AnyThread(FComponentSpaceP

check(OutBoneTransforms.Num() == 0);

if(bResetDynamics)
{
ModifyBones.Empty(ModifyBones.Num());
bResetDynamics = false;
}

const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
FTransform ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ struct KAWAIIPHYSICS_API FAnimNode_KawaiiPhysics : public FAnimNode_SkeletalCont
FQuat SkelCompMoveRotation;
float DeltaTime;
float DeltaTimeOld;
bool bResetDynamics;

public:
FAnimNode_KawaiiPhysics();
Expand All @@ -338,6 +339,8 @@ struct KAWAIIPHYSICS_API FAnimNode_KawaiiPhysics : public FAnimNode_SkeletalCont
//virtual void GatherDebugData(FNodeDebugData& DebugData) override;
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
virtual bool NeedsDynamicReset() const override { return true; }
virtual void ResetDynamics(ETeleportType InTeleportType) override;
// End of FAnimNode_Base interface

// FAnimNode_SkeletalControlBase interface
Expand Down