Add AnimationUpdated event to Animated Model

This commit is contained in:
Wojtek Figat
2021-05-13 13:00:57 +02:00
parent e267583bad
commit 9a3884636b
3 changed files with 13 additions and 26 deletions

View File

@@ -86,7 +86,7 @@ void AnimationManagerService::Update()
// Update gameplay
const bool usePrevFrameBones = animatedModel->PerBoneMotionBlur;
animatedModel->_skinningData.SetData(UpdateBones.Get(), !usePrevFrameBones);
animatedModel->OnAnimUpdate();
animatedModel->OnAnimationUpdated();
}
}
UpdateList.Clear();

View File

@@ -422,12 +422,13 @@ void AnimatedModel::UpdateBounds()
BoundingSphere::FromBox(_box, _sphere);
}
void AnimatedModel::OnAnimUpdate()
void AnimatedModel::OnAnimationUpdated()
{
UpdateBounds();
UpdateSockets();
ApplyRootMotion(GraphInstance.RootMotion);
_blendShapes.Update(SkinnedModel.Get());
AnimationUpdated();
}
void AnimatedModel::OnSkinnedModelChanged()

View File

@@ -7,6 +7,7 @@
#include "Engine/Content/Assets/AnimationGraph.h"
#include "Engine/Graphics/Models/SkinnedMeshDrawData.h"
#include "Engine/Renderer/DrawCall.h"
#include "Engine/Core/Delegate.h"
/// <summary>
/// Performs an animation and renders a skinned model.
@@ -166,9 +167,14 @@ public:
API_FUNCTION() void ResetAnimation();
/// <summary>
/// Performs the full animation update.
/// Performs the full animation update. The actual update will be performed during gameplay tick.
/// </summary>
API_FUNCTION() void UpdateAnimation();
/// <summary>
/// Called after animation gets updated (new skeleton pose).
/// </summary>
API_EVENT() Action AnimationUpdated;
/// <summary>
/// Validates and creates a proper skinning data.
@@ -180,11 +186,6 @@ public:
/// </summary>
API_FUNCTION() void PreInitSkinningData();
/// <summary>
/// Updates the child bone socket actors.
/// </summary>
API_FUNCTION() void UpdateSockets();
/// <summary>
/// Gets the per-node final transformations.
/// </summary>
@@ -284,27 +285,14 @@ public:
private:
/// <summary>
/// Applies the root motion delta to the target actor.
/// </summary>
void ApplyRootMotion(const RootMotionData& rootMotionDelta);
/// <summary>
/// Synchronizes the parameters collection (may lost existing params data on collection change detected).
/// </summary>
void SyncParameters();
/// <summary>
/// Updates the local bounds of the actor.
/// </summary>
void Update();
void UpdateLocalBounds();
void UpdateBounds();
/// <summary>
/// Called after animation graph update.
/// </summary>
void OnAnimUpdate();
void UpdateSockets();
void OnAnimationUpdated();
void OnSkinnedModelChanged();
void OnSkinnedModelLoaded();
@@ -312,8 +300,6 @@ private:
void OnGraphChanged();
void OnGraphLoaded();
void Update();
public:
// [ModelInstanceActor]