From 0ffa8e33a7f379799dbbc2b014d14a22adddac1d Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 9 Aug 2022 22:05:43 +0200 Subject: [PATCH] Backporter from Godot 4: Unexpose methods and property for binding children to Bones. - madmiraal https://github.com/godotengine/godot/commit/65faa12fd3b58058482d46e9a14c99610e0ffd15 --- doc/classes/Skeleton.xml | 23 ----------------------- scene/3d/skeleton.cpp | 39 ++++++--------------------------------- scene/3d/skeleton.h | 12 ------------ 3 files changed, 6 insertions(+), 68 deletions(-) diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton.xml index ba314258e..7cae935b8 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton.xml @@ -20,14 +20,6 @@ Adds a bone, with name [code]name[/code]. [method get_bone_count] will become the bone index. - - - - - - [i]Deprecated soon.[/i] - - @@ -129,13 +121,6 @@ Returns the rest transform for a bone [code]bone_idx[/code]. - - - - - [i]Deprecated soon.[/i] - - @@ -261,14 +246,6 @@ Sets the rest transform for bone [code]bone_idx[/code]. - - - - - - [i]Deprecated soon.[/i] - - diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 908a3bfb7..f76e7c542 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -103,20 +103,6 @@ bool Skeleton::_set(const StringName &p_path, const Variant &p_value) { set_bone_pose_scale(which, p_value); } else if (what == "pose") { set_bone_pose(which, p_value); - } else if (what == "bound_children") { - Array children = p_value; - - if (is_inside_tree()) { - bones.write[which].nodes_bound.clear(); - - for (int i = 0; i < children.size(); i++) { - NodePath npath = children[i]; - ERR_CONTINUE(npath.operator String() == ""); - Node *node = get_node(npath); - ERR_CONTINUE(!node); - bind_child_node_to_bone(which, node); - } - } } else { return false; } @@ -152,19 +138,6 @@ bool Skeleton::_get(const StringName &p_path, Variant &r_ret) const { r_ret = get_bone_pose_scale(which); } else if (what == "pose") { r_ret = get_bone_pose(which); - } else if (what == "bound_children") { - Array children; - - for (const List::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); - ERR_CONTINUE(!obj); - Node *node = Object::cast_to(obj); - ERR_CONTINUE(!node); - NodePath npath = get_path_to(node); - children.push_back(npath); - } - - r_ret = children; } else { return false; } @@ -181,7 +154,6 @@ void Skeleton::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::QUAT, prep + "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children")); } } @@ -419,16 +391,21 @@ void Skeleton::set_bone_global_pose_override(int p_bone, const Transform &p_pose Transform Skeleton::get_bone_global_pose(int p_bone) const { ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); + if (dirty) { const_cast(this)->notification(NOTIFICATION_UPDATE_SKELETON); } + return bones[p_bone].pose_global; } Transform Skeleton::get_bone_global_pose_no_override(int p_bone) const { ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); - if (dirty) + + if (dirty) { const_cast(this)->notification(NOTIFICATION_UPDATE_SKELETON); + } + return bones[p_bone].pose_global_no_override; } @@ -1037,10 +1014,6 @@ void Skeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bone_disable_rest", "bone_idx", "disable"), &Skeleton::set_bone_disable_rest); ClassDB::bind_method(D_METHOD("is_bone_rest_disabled", "bone_idx"), &Skeleton::is_bone_rest_disabled); - ClassDB::bind_method(D_METHOD("bind_child_node_to_bone", "bone_idx", "node"), &Skeleton::bind_child_node_to_bone); - ClassDB::bind_method(D_METHOD("unbind_child_node_from_bone", "bone_idx", "node"), &Skeleton::unbind_child_node_from_bone); - ClassDB::bind_method(D_METHOD("get_bound_child_nodes_to_bone", "bone_idx"), &Skeleton::_get_bound_child_nodes_to_bone); - ClassDB::bind_method(D_METHOD("clear_bones"), &Skeleton::clear_bones); ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton::set_bone_pose); diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index a67b20edf..1d449f65e 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -144,18 +144,6 @@ private: uint64_t version; - // bind helpers - Array _get_bound_child_nodes_to_bone(int p_bone) const { - Array bound; - List children; - get_bound_child_nodes_to_bone(p_bone, &children); - - for (int i = 0; i < children.size(); i++) { - bound.push_back(children[i]); - } - return bound; - } - void _update_process_order(); protected: