From b7f8a857be7a8cd16022e910da341bda3688d4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=BChlem?= <konstantin@koeln.de> Date: Fri, 16 May 2025 11:59:38 +0200 Subject: [PATCH] fix: ResetFace() was called every tick (depending on options) even if not needed, resulting in major performance penalty --- .../Private/FaceAnimation/VHFaceAnimation.cpp | 16 ++++++++-------- .../Public/FaceAnimation/VHFaceAnimation.h | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/CharacterPlugin/Private/FaceAnimation/VHFaceAnimation.cpp b/Source/CharacterPlugin/Private/FaceAnimation/VHFaceAnimation.cpp index 80b0fd9b..3e70d76e 100644 --- a/Source/CharacterPlugin/Private/FaceAnimation/VHFaceAnimation.cpp +++ b/Source/CharacterPlugin/Private/FaceAnimation/VHFaceAnimation.cpp @@ -190,16 +190,16 @@ void UVHFaceAnimation::TickComponent(float DeltaTime, ELevelTick TickType, LastFrameNr = FrameNr; ApplyFrameData(FrameNr); + bIsFaceReset = false; } - else + else if (bResetFaceAfterFinish && !bIsFaceReset) { - if (bResetFaceAfterFinish) - { - //in case this is used together with a FacialExpression - //we have to do this, so that the right data is pulled from the - // FacialExpression component every frame (especially before staring that actual animation) - ResetFace(); - } + //in case this is used together with a FacialExpression + //we have to do this, so that the right data is pulled from the + // FacialExpression component every frame (especially before staring that actual animation) + ResetFace(); + + bIsFaceReset = false; } } diff --git a/Source/CharacterPlugin/Public/FaceAnimation/VHFaceAnimation.h b/Source/CharacterPlugin/Public/FaceAnimation/VHFaceAnimation.h index aa3ca176..5f6e287c 100644 --- a/Source/CharacterPlugin/Public/FaceAnimation/VHFaceAnimation.h +++ b/Source/CharacterPlugin/Public/FaceAnimation/VHFaceAnimation.h @@ -124,11 +124,13 @@ protected: TMap<FString, FAnimationData> CachedAnimationData; bool bCurrentlyPlaying = false; + /** Essentially indicates whether the face has not been reset i.e. whether it is considered 'dirty' */ + bool bIsFaceReset = true; float CurrentPlayTime = 0.0f; float FadeFraction = 0.0f; int LastFrameNr = 0; - UVHAnimInstance* AnimInstance; + UPROPERTY() UVHAnimInstance* AnimInstance; bool UseMorphs = true; public: -- GitLab