From 5e6dace7911128484d49e307413c86da37a09c77 Mon Sep 17 00:00:00 2001 From: Luke Ingram Date: Wed, 15 Oct 2025 16:27:11 -0400 Subject: [PATCH] [godot] Adds physics support to translating SpineBoneNodes This commit makes it so that adding a SpineBoneNode as a child node to a SpineSprite node, selecting "Drive", and then adjusting the X/Y of the SpineBoneNode in Move mode will affect the Physics Constraints like a rotation already does. --- spine-godot/spine_godot/SpineBoneNode.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spine-godot/spine_godot/SpineBoneNode.cpp b/spine-godot/spine_godot/SpineBoneNode.cpp index 4d3b24604..56766345e 100644 --- a/spine-godot/spine_godot/SpineBoneNode.cpp +++ b/spine-godot/spine_godot/SpineBoneNode.cpp @@ -70,6 +70,7 @@ void SpineBoneNode::_notification(int what) { #else sprite->connect(SNAME("world_transforms_changed"), this, SNAME("_on_world_transforms_changed")); #endif + set_notify_local_transform(bone_mode == SpineConstant::BoneMode_Drive); update_transform(sprite); #if VERSION_MAJOR == 3 _change_notify("transform/translation"); @@ -97,6 +98,18 @@ void SpineBoneNode::_notification(int what) { } break; } + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { + if (bone_mode == SpineConstant::BoneMode_Drive && enabled) { + SpineSprite *sprite = find_parent_sprite(); + if (sprite) { + Ref bone = find_bone(); + if (bone.is_valid()) { + bone->set_global_transform(get_global_transform()); + } + } + } + break; + } case NOTIFICATION_DRAW: { draw(); break; @@ -247,6 +260,7 @@ SpineConstant::BoneMode SpineBoneNode::get_bone_mode() { void SpineBoneNode::set_bone_mode(SpineConstant::BoneMode _bone_mode) { if (bone_mode != _bone_mode) { bone_mode = _bone_mode; + set_notify_local_transform(bone_mode == SpineConstant::BoneMode_Drive); SpineSprite *sprite = find_parent_sprite(); init_transform(sprite); }