From cb61c6e85291efc7cfa98708eafe706cdbc0e969 Mon Sep 17 00:00:00 2001 From: "Silc Lizard (Tokage) Renew" <61938263+TokageItLab@users.noreply.github.com> Date: Sun, 12 Jan 2025 07:22:51 +0900 Subject: [PATCH] Force update RetargetModifier3D's child skeletons on save --- scene/3d/retarget_modifier_3d.cpp | 16 ++++++++++++++++ scene/3d/retarget_modifier_3d.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/scene/3d/retarget_modifier_3d.cpp b/scene/3d/retarget_modifier_3d.cpp index 45e037532e88..f40af5dfd268 100644 --- a/scene/3d/retarget_modifier_3d.cpp +++ b/scene/3d/retarget_modifier_3d.cpp @@ -213,6 +213,19 @@ void RetargetModifier3D::_reset_child_skeletons() { child_skeletons.clear(); } +#ifdef TOOLS_ENABLED +void RetargetModifier3D::_force_update_child_skeletons() { + for (const RetargetInfo &E : child_skeletons) { + Skeleton3D *c = Object::cast_to(ObjectDB::get_instance(E.skeleton_id)); + if (!c) { + continue; + } + c->force_update_all_dirty_bones(); + c->emit_signal(SceneStringName(skeleton_updated)); + } +} +#endif // TOOLS_ENABLED + /// General functions void RetargetModifier3D::add_child_notify(Node *p_child) { @@ -452,9 +465,12 @@ void RetargetModifier3D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { _update_child_skeletons(); } break; +#ifdef TOOLS_ENABLED case NOTIFICATION_EDITOR_PRE_SAVE: { _reset_child_skeleton_poses(); + _force_update_child_skeletons(); } break; +#endif // TOOLS_ENABLED case NOTIFICATION_EXIT_TREE: { _reset_child_skeletons(); } break; diff --git a/scene/3d/retarget_modifier_3d.h b/scene/3d/retarget_modifier_3d.h index e38845102ba2..f3c46cffde69 100644 --- a/scene/3d/retarget_modifier_3d.h +++ b/scene/3d/retarget_modifier_3d.h @@ -70,6 +70,10 @@ class RetargetModifier3D : public SkeletonModifier3D { void _reset_child_skeleton_poses(); void _reset_child_skeletons(); +#ifdef TOOLS_ENABLED + void _force_update_child_skeletons(); +#endif // TOOLS_ENABLED + void cache_rests_with_reset(); void cache_rests(); Vector cache_bone_global_rests(Skeleton3D *p_skeleton);