Procházet zdrojové kódy

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

Update BoneAttachment3D transform when setting the bone index
Thaddeus Crews před 4 měsíci
rodič
revize
31a0c68b14
1 změnil soubory, kde provedl 5 přidání a 2 odebrání
  1. 5 2
      scene/3d/bone_attachment_3d.cpp

+ 5 - 2
scene/3d/bone_attachment_3d.cpp

@@ -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;