Description

After remove control rig track from the skeletal mesh, Linked Anim Graph in Post Process Anim BP of the SK Mesh does NOT work.

This issue can be fixed by the following code.

// add 
#include "Animation/AnimNode_LinkedInputPose.h"

void FControlRigBindingHelper::UnBindFromSequencerInstance(UControlRig* ControlRig)
{
	check(ControlRig);	if (!ControlRig->IsValidLowLevel() ||
	    ControlRig->HasAnyFlags(RF_BeginDestroyed) ||
		!IsValid(ControlRig))
	{
		return;
	}
	
	if (UControlRigComponent* ControlRigComponent = Cast<UControlRigComponent>(ControlRig->GetObjectBinding()->GetBoundObject()))
	{
		// todo: how do we reset the state?
		//ControlRig->Initialize();
	}
	else if (USkeletalMeshComponent* SkeletalMeshComponent = Cast<USkeletalMeshComponent>(ControlRig->GetObjectBinding()->GetBoundObject()))
	{
		if (!SkeletalMeshComponent->IsValidLowLevel() ||
			SkeletalMeshComponent->HasAnyFlags(RF_BeginDestroyed) ||
			!IsValid(SkeletalMeshComponent))
		{
			return;
		}		UControlRigLayerInstance* AnimInstance = Cast<UControlRigLayerInstance>(SkeletalMeshComponent->GetAnimInstance());
		if (AnimInstance)
		{
			if (!AnimInstance->IsValidLowLevel() ||
                AnimInstance->HasAnyFlags(RF_BeginDestroyed) ||
                !IsValid(AnimInstance))
			{
				return;
			}			AnimInstance->ResetNodes();
			AnimInstance->RecalcRequiredBones();
			AnimInstance->RemoveControlRigTrack(ControlRig->GetUniqueID());
		}		FAnimCustomInstanceHelper::UnbindFromSkeletalMeshComponent< UControlRigLayerInstance>(SkeletalMeshComponent);		
                ////////
		// add 
		if (UAnimInstance* postProcessAnimInstance = SkeletalMeshComponent->PostProcessAnimInstance)
		{
			postProcessAnimInstance->InitializeAnimation();
			if (FAnimNode_LinkedInputPose* inputNode = postProcessAnimInstance->GetLinkedInputPoseNode())
			{
				inputNode->CachedInputPose.SetBoneContainer(&postProcessAnimInstance->GetRequiredBones());
			}
		}
		////////
	}
	
}
Steps to Reproduce
  1. Open Repro proj
  2. Open LS_Repro
  3. Remove Control Rig Track

expect : There is no change.  The SkeletalMesh's head size does not change from (3,3,3).
result : The SkeletalMesh's head return to normal size ( 1, 1 ,1 )

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-166721 in the post.

0
Login to Vote

Unresolved
ComponentUE - Anim - Rigging - Control Rig
Affects Versions5.0.35.1
Target Fix5.5
CreatedOct 11, 2022
UpdatedJan 16, 2024