Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BoneAttachment3D.get_external_skeleton_path, deprecate get_external_skeleton #96649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions doc/classes/BoneAttachment3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
<tutorials>
</tutorials>
<methods>
<method name="get_external_skeleton" qualifiers="const">
<method name="get_external_skeleton" qualifiers="const" deprecated="Use [method get_external_skeleton_path] instead.">
<return type="NodePath" />
<description>
Returns the [NodePath] to the external [Skeleton3D] node, if one has been set.
</description>
</method>
<method name="get_external_skeleton_path" qualifiers="const">
<return type="NodePath" />
<description>
Returns the [NodePath] to the external [Skeleton3D] node, if one has been set.
Expand All @@ -33,18 +39,25 @@
A function that is called automatically when the [Skeleton3D] is updated. This function is where the [BoneAttachment3D] node updates its position so it is correctly bound when it is [i]not[/i] set to override the bone pose.
</description>
</method>
<method name="set_external_skeleton">
<method name="set_external_skeleton" deprecated="Use [method set_external_skeleton_path] instead.">
Flynsarmy marked this conversation as resolved.
Show resolved Hide resolved
<return type="void" />
<param index="0" name="external_skeleton" type="NodePath" />
<description>
Sets the [NodePath] to the external skeleton that the BoneAttachment3D node should use. See [method set_use_external_skeleton] to enable the external [Skeleton3D] node.
</description>
</method>
<method name="set_external_skeleton_path">
<return type="void" />
<param index="0" name="external_skeleton_path" type="NodePath" />
<description>
Sets the [NodePath] to the external skeleton that the BoneAttachment3D node should use. See [method set_use_external_skeleton] to enable the external [Skeleton3D] node.
</description>
</method>
<method name="set_use_external_skeleton">
<return type="void" />
<param index="0" name="use_external_skeleton" type="bool" />
<description>
Sets whether the BoneAttachment3D node will use an external [Skeleton3D] node rather than attempting to use its parent node as the [Skeleton3D]. When set to [code]true[/code], the BoneAttachment3D node will use the external [Skeleton3D] node set in [method set_external_skeleton].
Sets whether the BoneAttachment3D node will use an external [Skeleton3D] node rather than attempting to use its parent node as the [Skeleton3D]. When set to [code]true[/code], the BoneAttachment3D node will use the external [Skeleton3D] node set in [method set_external_skeleton_path].
</description>
</method>
</methods>
Expand Down
2 changes: 1 addition & 1 deletion modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6126,7 +6126,7 @@ void GLTFDocument::_convert_bone_attachment_to_gltf(BoneAttachment3D *p_bone_att
Skeleton3D *skeleton;
// Note that relative transforms to external skeletons and pose overrides are not supported.
if (p_bone_attachment->get_use_external_skeleton()) {
skeleton = Object::cast_to<Skeleton3D>(p_bone_attachment->get_node_or_null(p_bone_attachment->get_external_skeleton()));
skeleton = Object::cast_to<Skeleton3D>(p_bone_attachment->get_node_or_null(p_bone_attachment->get_external_skeleton_path()));
} else {
skeleton = Object::cast_to<Skeleton3D>(p_bone_attachment->get_parent());
}
Expand Down
3 changes: 3 additions & 0 deletions scene/3d/bone_attachment_3d.compat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ void BoneAttachment3D::_on_bone_pose_update_bind_compat_90575(int p_bone_index)

void BoneAttachment3D::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("on_bone_pose_update", "bone_index"), &BoneAttachment3D::_on_bone_pose_update_bind_compat_90575);

ClassDB::bind_method(D_METHOD("set_external_skeleton", "external_skeleton"), &BoneAttachment3D::set_external_skeleton_path);
ClassDB::bind_method(D_METHOD("get_external_skeleton"), &BoneAttachment3D::get_external_skeleton_path);
}

#endif // DISABLE_DEPRECATED
24 changes: 18 additions & 6 deletions scene/3d/bone_attachment_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ void BoneAttachment3D::_validate_property(PropertyInfo &p_property) const {
bool BoneAttachment3D::_set(const StringName &p_path, const Variant &p_value) {
if (p_path == SNAME("use_external_skeleton")) {
set_use_external_skeleton(p_value);
#ifndef DISABLE_DEPRECATED
} else if (p_path == SNAME("external_skeleton")) {
Flynsarmy marked this conversation as resolved.
Show resolved Hide resolved
set_external_skeleton(p_value);
set_external_skeleton_path(p_value);
#endif // DISABLE_DEPRECATED
} else if (p_path == SNAME("external_skeleton_path")) {
set_external_skeleton_path(p_value);
}

return true;
Expand All @@ -66,8 +70,12 @@ bool BoneAttachment3D::_set(const StringName &p_path, const Variant &p_value) {
bool BoneAttachment3D::_get(const StringName &p_path, Variant &r_ret) const {
if (p_path == SNAME("use_external_skeleton")) {
r_ret = get_use_external_skeleton();
#ifndef DISABLE_DEPRECATED
} else if (p_path == SNAME("external_skeleton")) {
r_ret = get_external_skeleton();
r_ret = get_external_skeleton_path();
#endif // DISABLE_DEPRECATED
} else if (p_path == SNAME("external_skeleton_path")) {
r_ret = get_external_skeleton_path();
}

return true;
Expand All @@ -76,7 +84,10 @@ bool BoneAttachment3D::_get(const StringName &p_path, Variant &r_ret) const {
void BoneAttachment3D::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, "use_external_skeleton", PROPERTY_HINT_NONE, ""));
if (use_external_skeleton) {
#ifndef DISABLE_DEPRECATED
p_list->push_back(PropertyInfo(Variant::NODE_PATH, "external_skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton3D"));
#endif
p_list->push_back(PropertyInfo(Variant::NODE_PATH, "external_skeleton_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton3D"));
}
}

Expand Down Expand Up @@ -277,13 +288,13 @@ bool BoneAttachment3D::get_use_external_skeleton() const {
return use_external_skeleton;
}

void BoneAttachment3D::set_external_skeleton(NodePath p_path) {
void BoneAttachment3D::set_external_skeleton_path(NodePath p_path) {
external_skeleton_node = p_path;
_update_external_skeleton_cache();
notify_property_list_changed();
}

NodePath BoneAttachment3D::get_external_skeleton() const {
NodePath BoneAttachment3D::get_external_skeleton_path() const {
return external_skeleton_node;
}

Expand Down Expand Up @@ -384,8 +395,9 @@ void BoneAttachment3D::_bind_methods() {

ClassDB::bind_method(D_METHOD("set_use_external_skeleton", "use_external_skeleton"), &BoneAttachment3D::set_use_external_skeleton);
ClassDB::bind_method(D_METHOD("get_use_external_skeleton"), &BoneAttachment3D::get_use_external_skeleton);
ClassDB::bind_method(D_METHOD("set_external_skeleton", "external_skeleton"), &BoneAttachment3D::set_external_skeleton);
ClassDB::bind_method(D_METHOD("get_external_skeleton"), &BoneAttachment3D::get_external_skeleton);

ClassDB::bind_method(D_METHOD("set_external_skeleton_path", "external_skeleton_path"), &BoneAttachment3D::set_external_skeleton_path);
ClassDB::bind_method(D_METHOD("get_external_skeleton_path"), &BoneAttachment3D::get_external_skeleton_path);

ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bone_name"), "set_bone_name", "get_bone_name");
ADD_PROPERTY(PropertyInfo(Variant::INT, "bone_idx"), "set_bone_idx", "get_bone_idx");
Expand Down
4 changes: 2 additions & 2 deletions scene/3d/bone_attachment_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class BoneAttachment3D : public Node3D {

void set_use_external_skeleton(bool p_external_skeleton);
bool get_use_external_skeleton() const;
void set_external_skeleton(NodePath p_skeleton);
NodePath get_external_skeleton() const;
void set_external_skeleton_path(NodePath p_skeleton);
NodePath get_external_skeleton_path() const;

virtual void on_skeleton_update();

Expand Down
Loading