Merge pull request #104209 from aaronfranke/bone-attach-update

Update BoneAttachment3D transform when setting the bone index
This commit is contained in:
Thaddeus Crews
2025-04-27 19:21:13 -05:00

View File

@ -143,7 +143,7 @@ void BoneAttachment3D::_check_bind() {
if (bone_idx != -1) { if (bone_idx != -1) {
sk->connect(SceneStringName(skeleton_updated), callable_mp(this, &BoneAttachment3D::on_skeleton_update)); sk->connect(SceneStringName(skeleton_updated), callable_mp(this, &BoneAttachment3D::on_skeleton_update));
bound = true; bound = true;
callable_mp(this, &BoneAttachment3D::on_skeleton_update); on_skeleton_update();
} }
} }
} }
@ -220,7 +220,7 @@ void BoneAttachment3D::set_bone_idx(const int &p_idx) {
Skeleton3D *sk = get_skeleton(); Skeleton3D *sk = get_skeleton();
if (sk) { if (sk) {
if (bone_idx <= -1 || bone_idx >= sk->get_bone_count()) { if (bone_idx <= -1 || bone_idx >= sk->get_bone_count()) {
WARN_PRINT("Bone index out of range! Cannot connect BoneAttachment to node!"); WARN_PRINT("Bone index " + itos(bone_idx) + " out of range! Cannot connect BoneAttachment to node!");
bone_idx = -1; bone_idx = -1;
} else { } else {
bone_name = sk->get_bone_name(bone_idx); bone_name = sk->get_bone_name(bone_idx);
@ -229,6 +229,8 @@ void BoneAttachment3D::set_bone_idx(const int &p_idx) {
if (is_inside_tree()) { if (is_inside_tree()) {
_check_bind(); _check_bind();
} else {
on_skeleton_update();
} }
notify_property_list_changed(); notify_property_list_changed();
@ -336,6 +338,7 @@ void BoneAttachment3D::on_skeleton_update() {
} }
updating = false; updating = false;
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
void BoneAttachment3D::notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map) { void BoneAttachment3D::notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map) {
const Skeleton3D *parent = nullptr; const Skeleton3D *parent = nullptr;