Update BoneAttachment3D transform when setting the bone index

This commit is contained in:
Aaron Franke
2025-03-15 16:12:47 -07:00
parent e37c6261ea
commit 4eba6d1892

View File

@ -143,7 +143,7 @@ void BoneAttachment3D::_check_bind() {
if (bone_idx != -1) {
sk->connect(SceneStringName(skeleton_updated), callable_mp(this, &BoneAttachment3D::on_skeleton_update));
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();
if (sk) {
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;
} else {
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()) {
_check_bind();
} else {
on_skeleton_update();
}
notify_property_list_changed();
@ -336,6 +338,7 @@ void BoneAttachment3D::on_skeleton_update() {
}
updating = false;
}
#ifdef TOOLS_ENABLED
void BoneAttachment3D::notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map) {
const Skeleton3D *parent = nullptr;