Skip to content

Commit

Permalink
Merge pull request godotengine#101451 from TokageItLab/reset-retarget…
Browse files Browse the repository at this point in the history
…-in-the-child

Force update RetargetModifier3D's child skeletons on save
  • Loading branch information
akien-mga committed Jan 12, 2025
2 parents bb8001c + cb61c6e commit d79ff84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scene/3d/retarget_modifier_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Skeleton3D>(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) {
Expand Down Expand Up @@ -455,6 +468,7 @@ void RetargetModifier3D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_EDITOR_PRE_SAVE: {
_reset_child_skeleton_poses();
_force_update_child_skeletons();
} break;
#endif // TOOLS_ENABLED
case NOTIFICATION_EXIT_TREE: {
Expand Down
4 changes: 4 additions & 0 deletions scene/3d/retarget_modifier_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RetargetBoneInfo> cache_bone_global_rests(Skeleton3D *p_skeleton);
Expand Down

0 comments on commit d79ff84

Please sign in to comment.