From cb7ef2b8de2e0234f2085c23a97a6bf64ef936d7 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Tue, 16 Apr 2024 21:44:44 -0700 Subject: [PATCH] Add SkeletonIK3D get/set_interpolation compat from #87888 --- doc/classes/SkeletonIK3D.xml | 3 +++ .../extension_api_validation/4.2-stable.expected | 3 --- scene/3d/skeleton_ik_3d.cpp | 16 ++++++++++++++++ scene/3d/skeleton_ik_3d.h | 5 +++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml index 6de6d9d186c6..4858a6ce228f 100644 --- a/doc/classes/SkeletonIK3D.xml +++ b/doc/classes/SkeletonIK3D.xml @@ -55,6 +55,9 @@ + + Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of [code]1.0[/code] will overwrite all skeleton bone transforms completely while a value of [code]0.0[/code] will visually disable the SkeletonIK. + Secondary target position (first is [member target] property or [member target_node]) for the IK chain. Use magnet position (pole target) to control the bending of the IK chain. Only works if the bone chain has more than 2 bones. The middle chain bone position will be linearly interpolated with the magnet position. diff --git a/misc/extension_api_validation/4.2-stable.expected b/misc/extension_api_validation/4.2-stable.expected index 6471c5a142fe..05b2cec687ea 100644 --- a/misc/extension_api_validation/4.2-stable.expected +++ b/misc/extension_api_validation/4.2-stable.expected @@ -264,9 +264,6 @@ Removed VisualShaderNodeComment, which is replaced by VisualShaderNodeFrame. GH-87888 -------- Validate extension JSON: API was removed: classes/Skeleton3D/properties/animate_physical_bones -Validate extension JSON: API was removed: classes/SkeletonIK3D/methods/get_interpolation -Validate extension JSON: API was removed: classes/SkeletonIK3D/methods/set_interpolation -Validate extension JSON: API was removed: classes/SkeletonIK3D/properties/interpolation These base class is changed to SkeletonModifier3D which is processed by Skeleton3D with the assumption that it is Skeleton3D's child. diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index 9581ae58d8c7..78a21ba9e1cf 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -366,6 +366,12 @@ void SkeletonIK3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "target_node"), "set_target_node", "get_target_node"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "min_distance", PROPERTY_HINT_NONE, "suffix:m"), "set_min_distance", "get_min_distance"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_iterations"), "set_max_iterations", "get_max_iterations"); + +#ifndef DISABLE_DEPRECATED + ClassDB::bind_method(D_METHOD("set_interpolation", "interpolation"), &SkeletonIK3D::_set_interpolation); + ClassDB::bind_method(D_METHOD("get_interpolation"), &SkeletonIK3D::_get_interpolation); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "interpolation", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_NONE), "set_interpolation", "get_interpolation"); +#endif } void SkeletonIK3D::_process_modification() { @@ -415,6 +421,16 @@ StringName SkeletonIK3D::get_tip_bone() const { return tip_bone; } +#ifndef DISABLE_DEPRECATED +void SkeletonIK3D::_set_interpolation(real_t p_interpolation) { + set_influence(p_interpolation); +} + +real_t SkeletonIK3D::_get_interpolation() const { + return get_influence(); +} +#endif + void SkeletonIK3D::set_target_transform(const Transform3D &p_target) { target = p_target; reload_goal(); diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index eff018f2ccd7..5d6020194e14 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -134,6 +134,11 @@ class SkeletonIK3D : public SkeletonModifier3D { Variant target_node_override_ref = Variant(); FabrikInverseKinematic::Task *task = nullptr; +#ifndef DISABLE_DEPRECATED + void _set_interpolation(real_t p_interpolation); + real_t _get_interpolation() const; +#endif // DISABLE_DEPRECATED + protected: void _validate_property(PropertyInfo &p_property) const;