From d27fb9b15a264b5a092eb5b45ab90c353492b2b4 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 31 Oct 2025 23:56:25 +0100 Subject: [PATCH] Remove default skeleton path in MeshInstance3D --- core/config/project_settings.cpp | 3 +++ doc/classes/MeshInstance3D.xml | 3 ++- doc/classes/ProjectSettings.xml | 3 +++ scene/3d/mesh_instance_3d.cpp | 5 +++++ scene/3d/mesh_instance_3d.h | 6 +++++- scene/register_scene_types.cpp | 3 +++ 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 078baf0e3ca..37e40c83783 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1648,6 +1648,9 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); GLOBAL_DEF("animation/warnings/check_invalid_track_paths", true); GLOBAL_DEF("animation/warnings/check_angle_interpolation_type_conflicting", true); +#ifndef DISABLE_DEPRECATED + GLOBAL_DEF_RST("animation/compatibility/default_parent_skeleton_in_mesh_instance_3d", false); +#endif GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "audio/buses/default_bus_layout", PROPERTY_HINT_FILE, "*.tres"), "res://default_bus_layout.tres"); GLOBAL_DEF(PropertyInfo(Variant::INT, "audio/general/default_playback_type", PROPERTY_HINT_ENUM, "Stream,Sample"), 0); diff --git a/doc/classes/MeshInstance3D.xml b/doc/classes/MeshInstance3D.xml index 9bdab5b753c..edf6f0dd16c 100644 --- a/doc/classes/MeshInstance3D.xml +++ b/doc/classes/MeshInstance3D.xml @@ -128,8 +128,9 @@ The [Mesh] resource for the instance. - + [NodePath] to the [Skeleton3D] associated with the instance. + [b]Note:[/b] The default value of this property has changed in Godot 4.6. Enable [member ProjectSettings.animation/compatibility/default_parent_skeleton_in_mesh_instance_3d] if the old behavior is needed for compatibility. The [Skin] to be used by this instance. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index d74b67cae02..7a5ffe3199d 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -269,6 +269,9 @@ The number of accessibility information updates per second. + + If [code]true[/code], [member MeshInstance3D.skeleton] will point to the parent node ([code]..[/code]) by default, which was the behavior before Godot 4.6. It's recommended to keep this setting disabled unless the old behavior is needed for compatibility. + If [code]true[/code], [AnimationMixer] prints the warning of interpolation being forced to choose the shortest rotation path due to multiple angle interpolation types being mixed in the [AnimationMixer] cache. diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 3c6f60f290a..e1378398fd3 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -926,6 +926,11 @@ void MeshInstance3D::_bind_methods() { MeshInstance3D::MeshInstance3D() { _define_ancestry(AncestralClass::MESH_INSTANCE_3D); +#ifndef DISABLE_DEPRECATED + if (use_parent_skeleton_compat) { + skeleton_path = NodePath(".."); + } +#endif } MeshInstance3D::~MeshInstance3D() { diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index 68c60b69b28..fe0f8993053 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -49,7 +49,7 @@ protected: Ref skin; Ref skin_internal; Ref skin_ref; - NodePath skeleton_path = NodePath(".."); + NodePath skeleton_path; LocalVector blend_shape_tracks; HashMap blend_shape_properties; @@ -73,6 +73,10 @@ protected: public: static constexpr AncestralClass static_ancestral_class = AncestralClass::MESH_INSTANCE_3D; +#ifndef DISABLE_DEPRECATED + static inline bool use_parent_skeleton_compat = false; +#endif + void set_mesh(const Ref &p_mesh); Ref get_mesh() const; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 0ecd1d2c4a3..f83a8de802b 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -607,6 +607,9 @@ void register_scene_types() { GDREGISTER_CLASS(Camera3D); GDREGISTER_CLASS(AudioListener3D); GDREGISTER_CLASS(MeshInstance3D); +#ifndef DISABLE_DEPRECATED + MeshInstance3D::use_parent_skeleton_compat = GLOBAL_GET("animation/compatibility/default_parent_skeleton_in_mesh_instance_3d"); +#endif GDREGISTER_CLASS(OccluderInstance3D); GDREGISTER_ABSTRACT_CLASS(Occluder3D); GDREGISTER_CLASS(ArrayOccluder3D);