From 9c1f23c3db377bdeac4a643b1986170a788fe063 Mon Sep 17 00:00:00 2001
From: "Silc Lizard (Tokage) Renew"
<61938263+TokageItLab@users.noreply.github.com>
Date: Sat, 13 Jul 2024 09:20:40 +0900
Subject: [PATCH] Re-add Skeleton3D::animate_physical_bones
---
doc/classes/Skeleton3D.xml | 17 ++++-------------
.../4.2-stable.expected | 7 -------
scene/3d/skeleton_3d.cpp | 10 +++++-----
scene/3d/skeleton_3d.h | 2 +-
4 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml
index 5829a787a15..cc3f61e1b29 100644
--- a/doc/classes/Skeleton3D.xml
+++ b/doc/classes/Skeleton3D.xml
@@ -57,11 +57,6 @@
Force updates the bone transform for the bone at [param bone_idx] and all of its children.
-
-
-
-
-
@@ -239,14 +234,6 @@
Sets all bone poses to rests.
-
-
-
-
- This method exists for compatibility with old structures in which the [Skeleton3D] does not have a [PhysicalBoneSimulator3D] as a child, but directly has [PhysicalBone3D]s as children.
- In case you need to raycast to it without running [method physical_bones_start_simulation], call this method with [code]enabled == true[/code].
-
-
@@ -342,6 +329,10 @@
+
+ If you follow the recommended workflow and explicitly have [PhysicalBoneSimulator3D] as a child of [Skeleton3D], you can control whether it is affected by raycasting without running [method physical_bones_start_simulation], by its [member SkeletonModifier3D.active].
+ However, for old (deprecated) configurations, [Skeleton3D] has an internal virtual [PhysicalBoneSimulator3D] for compatibility. This property controls the internal virtual [PhysicalBoneSimulator3D]'s [member SkeletonModifier3D.active].
+
Sets the processing timing for the Modifier.
diff --git a/misc/extension_api_validation/4.2-stable.expected b/misc/extension_api_validation/4.2-stable.expected
index 4b0d22a1aa5..50695cb0b1b 100644
--- a/misc/extension_api_validation/4.2-stable.expected
+++ b/misc/extension_api_validation/4.2-stable.expected
@@ -254,13 +254,6 @@ Validate extension JSON: API was removed: classes/VisualShaderNodeComment/method
Validate extension JSON: API was removed: classes/VisualShaderNodeComment/properties/title
-GH-87888
---------
-Validate extension JSON: API was removed: classes/Skeleton3D/properties/animate_physical_bones
-
-These base class is changed to SkeletonModifier3D which is processed by Skeleton3D with the assumption that it is Skeleton3D's child.
-
-
GH-90575
--------
Validate extension JSON: API was removed: classes/BoneAttachment3D/methods/on_bone_pose_update
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index b5263add48b..3d24b3bbe9c 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -301,6 +301,7 @@ void Skeleton3D::setup_simulator() {
sim->is_compat = true;
sim->set_active(false); // Don't run unneeded process.
add_child(simulator);
+ set_animate_physical_bones(animate_physical_bones);
}
#endif // _DISABLE_DEPRECATED
@@ -1097,6 +1098,9 @@ void Skeleton3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("physical_bones_start_simulation", "bones"), &Skeleton3D::physical_bones_start_simulation_on, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("physical_bones_add_collision_exception", "exception"), &Skeleton3D::physical_bones_add_collision_exception);
ClassDB::bind_method(D_METHOD("physical_bones_remove_collision_exception", "exception"), &Skeleton3D::physical_bones_remove_collision_exception);
+
+ ADD_GROUP("Deprecated", "");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones");
#endif // _DISABLE_DEPRECATED
}
@@ -1136,19 +1140,15 @@ Node *Skeleton3D::get_simulator() {
}
void Skeleton3D::set_animate_physical_bones(bool p_enabled) {
+ animate_physical_bones = p_enabled;
PhysicalBoneSimulator3D *sim = cast_to(simulator);
if (!sim) {
return;
}
- animate_physical_bones = p_enabled;
sim->set_active(animate_physical_bones || sim->is_simulating_physics());
}
bool Skeleton3D::get_animate_physical_bones() const {
- PhysicalBoneSimulator3D *sim = cast_to(simulator);
- if (!sim) {
- return false;
- }
return animate_physical_bones;
}
diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h
index 2d70aafcadb..a009383f45c 100644
--- a/scene/3d/skeleton_3d.h
+++ b/scene/3d/skeleton_3d.h
@@ -67,7 +67,7 @@ class Skeleton3D : public Node3D {
GDCLASS(Skeleton3D, Node3D);
#ifndef DISABLE_DEPRECATED
- bool animate_physical_bones = false;
+ bool animate_physical_bones = true;
Node *simulator = nullptr;
void setup_simulator();
#endif // _DISABLE_DEPRECATED