Merge pull request #98536 from TokageItLab/fix-deactivation-modifier

Fix Skeleton doesn't update skin after deactivating modifiers when it has only one modifier
This commit is contained in:
Thaddeus Crews 2024-11-12 09:28:07 -06:00
commit cf160747a0
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
4 changed files with 22 additions and 0 deletions

View File

@ -1032,6 +1032,10 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
return skin_ref; return skin_ref;
} }
void Skeleton3D::force_update_deferred() {
_make_dirty();
}
void Skeleton3D::force_update_all_dirty_bones() { void Skeleton3D::force_update_all_dirty_bones() {
if (!dirty) { if (!dirty) {
return; return;

View File

@ -284,6 +284,7 @@ public:
void force_update_all_dirty_bones(); void force_update_all_dirty_bones();
void force_update_all_bone_transforms(); void force_update_all_bone_transforms();
void force_update_bone_children_transforms(int bone_idx); void force_update_bone_children_transforms(int bone_idx);
void force_update_deferred();
void set_modifier_callback_mode_process(ModifierCallbackModeProcess p_mode); void set_modifier_callback_mode_process(ModifierCallbackModeProcess p_mode);
ModifierCallbackModeProcess get_modifier_callback_mode_process() const; ModifierCallbackModeProcess get_modifier_callback_mode_process() const;

View File

@ -75,6 +75,17 @@ void SkeletonModifier3D::_skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new)
// //
} }
void SkeletonModifier3D::_force_update_skeleton_skin() {
if (!is_inside_tree()) {
return;
}
Skeleton3D *skeleton = get_skeleton();
if (!skeleton) {
return;
}
skeleton->force_update_deferred();
}
/* Process */ /* Process */
void SkeletonModifier3D::set_active(bool p_active) { void SkeletonModifier3D::set_active(bool p_active) {
@ -83,6 +94,7 @@ void SkeletonModifier3D::set_active(bool p_active) {
} }
active = p_active; active = p_active;
_set_active(active); _set_active(active);
_force_update_skeleton_skin();
} }
bool SkeletonModifier3D::is_active() const { bool SkeletonModifier3D::is_active() const {
@ -119,6 +131,10 @@ void SkeletonModifier3D::_notification(int p_what) {
case NOTIFICATION_PARENTED: { case NOTIFICATION_PARENTED: {
_update_skeleton(); _update_skeleton();
} break; } break;
case NOTIFICATION_EXIT_TREE:
case NOTIFICATION_UNPARENTED: {
_force_update_skeleton_skin();
} break;
} }
} }

View File

@ -50,6 +50,7 @@ protected:
void _update_skeleton(); void _update_skeleton();
void _update_skeleton_path(); void _update_skeleton_path();
void _force_update_skeleton_skin();
virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new); virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new);