Skip to content

Commit cb61c6e

Browse files
committed
Force update RetargetModifier3D's child skeletons on save
1 parent 21a6bd8 commit cb61c6e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

scene/3d/retarget_modifier_3d.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ void RetargetModifier3D::_reset_child_skeletons() {
213213
child_skeletons.clear();
214214
}
215215

216+
#ifdef TOOLS_ENABLED
217+
void RetargetModifier3D::_force_update_child_skeletons() {
218+
for (const RetargetInfo &E : child_skeletons) {
219+
Skeleton3D *c = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(E.skeleton_id));
220+
if (!c) {
221+
continue;
222+
}
223+
c->force_update_all_dirty_bones();
224+
c->emit_signal(SceneStringName(skeleton_updated));
225+
}
226+
}
227+
#endif // TOOLS_ENABLED
228+
216229
/// General functions
217230

218231
void RetargetModifier3D::add_child_notify(Node *p_child) {
@@ -452,9 +465,12 @@ void RetargetModifier3D::_notification(int p_what) {
452465
case NOTIFICATION_ENTER_TREE: {
453466
_update_child_skeletons();
454467
} break;
468+
#ifdef TOOLS_ENABLED
455469
case NOTIFICATION_EDITOR_PRE_SAVE: {
456470
_reset_child_skeleton_poses();
471+
_force_update_child_skeletons();
457472
} break;
473+
#endif // TOOLS_ENABLED
458474
case NOTIFICATION_EXIT_TREE: {
459475
_reset_child_skeletons();
460476
} break;

scene/3d/retarget_modifier_3d.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class RetargetModifier3D : public SkeletonModifier3D {
7070
void _reset_child_skeleton_poses();
7171
void _reset_child_skeletons();
7272

73+
#ifdef TOOLS_ENABLED
74+
void _force_update_child_skeletons();
75+
#endif // TOOLS_ENABLED
76+
7377
void cache_rests_with_reset();
7478
void cache_rests();
7579
Vector<RetargetBoneInfo> cache_bone_global_rests(Skeleton3D *p_skeleton);

0 commit comments

Comments
 (0)