Skip to content

Commit

Permalink
Add saving flag hack to Skeleton and revert reset timing of animation
Browse files Browse the repository at this point in the history
  • Loading branch information
TokageItLab committed Jan 25, 2025
1 parent 1b7b009 commit 42b37b6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 25 deletions.
6 changes: 2 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,14 +1913,12 @@ void EditorNode::_save_scene(String p_file, int idx) {
return;
}

List<Pair<AnimationMixer *, Ref<AnimatedValuesBackup>>> anim_backups;
_reset_animation_mixers(scene, &anim_backups);

scene->propagate_notification(NOTIFICATION_EDITOR_PRE_SAVE);

editor_data.apply_changes_in_editors();
save_default_environment();

List<Pair<AnimationMixer *, Ref<AnimatedValuesBackup>>> anim_backups;
_reset_animation_mixers(scene, &anim_backups);
_save_editor_states(p_file, idx);

Ref<PackedScene> sdata;
Expand Down
6 changes: 0 additions & 6 deletions scene/3d/retarget_modifier_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,6 @@ 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;
Expand Down
13 changes: 11 additions & 2 deletions scene/3d/skeleton_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,10 @@ void Skeleton3D::_notification(int p_what) {
} break;
#ifdef TOOLS_ENABLED
case NOTIFICATION_EDITOR_PRE_SAVE: {
force_update_all_dirty_bones();
emit_signal(SceneStringName(skeleton_updated));
saving = true;
} break;
case NOTIFICATION_EDITOR_POST_SAVE: {
saving = false;
} break;
#endif // TOOLS_ENABLED
case NOTIFICATION_UPDATE_SKELETON: {
Expand Down Expand Up @@ -940,6 +942,13 @@ void Skeleton3D::_make_dirty() {

void Skeleton3D::_update_deferred(UpdateFlag p_update_flag) {
if (is_inside_tree()) {
#ifdef TOOLS_ENABLED
if (saving) {
update_flags |= p_update_flag;
_notification(NOTIFICATION_UPDATE_SKELETON);
return;
}
#endif //TOOLS_ENABLED
if (update_flags == UPDATE_FLAG_NONE && !updating) {
notify_deferred_thread_group(NOTIFICATION_UPDATE_SKELETON); // It must never be called more than once in a single frame.
}
Expand Down
4 changes: 4 additions & 0 deletions scene/3d/skeleton_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class SkinReference : public RefCounted {
class Skeleton3D : public Node3D {
GDCLASS(Skeleton3D, Node3D);

#ifdef TOOLS_ENABLED
bool saving = false;
#endif //TOOLS_ENABLED

#ifndef DISABLE_DEPRECATED
bool animate_physical_bones = true;
Node *simulator = nullptr;
Expand Down
10 changes: 0 additions & 10 deletions scene/3d/spring_bone_collision_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,3 @@ Vector3 SpringBoneCollision3D::collide(const Transform3D &p_center, float p_bone
Vector3 SpringBoneCollision3D::_collide(const Transform3D &p_center, float p_bone_radius, float p_bone_length, const Vector3 &p_current) const {
return Vector3(0, 0, 0);
}

#ifdef TOOLS_ENABLED
void SpringBoneCollision3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_EDITOR_PRE_SAVE: {
sync_pose();
} break;
}
}
#endif // TOOLS_ENABLED
3 changes: 0 additions & 3 deletions scene/3d/spring_bone_collision_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class SpringBoneCollision3D : public Node3D {

void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
#ifdef TOOLS_ENABLED
virtual void _notification(int p_what);
#endif // TOOLS_ENABLED

virtual Vector3 _collide(const Transform3D &p_center, float p_bone_radius, float p_bone_length, const Vector3 &p_current) const;

Expand Down

0 comments on commit 42b37b6

Please sign in to comment.