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

Re-add Skeleton3D::animate_physical_bones property #94291

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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
17 changes: 4 additions & 13 deletions doc/classes/Skeleton3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@
Force updates the bone transform for the bone at [param bone_idx] and all of its children.
</description>
</method>
<method name="get_animate_physical_bones" qualifiers="const" deprecated="">
<return type="bool" />
<description>
</description>
</method>
<method name="get_bone_children" qualifiers="const">
<return type="PackedInt32Array" />
<param index="0" name="bone_idx" type="int" />
Expand Down Expand Up @@ -239,14 +234,6 @@
Sets all bone poses to rests.
</description>
</method>
<method name="set_animate_physical_bones" deprecated="">
<return type="void" />
<param index="0" name="enabled" type="bool" />
<description>
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].
</description>
</method>
<method name="set_bone_enabled">
<return type="void" />
<param index="0" name="bone_idx" type="int" />
Expand Down Expand Up @@ -342,6 +329,10 @@
</method>
</methods>
<members>
<member name="animate_physical_bones" type="bool" setter="set_animate_physical_bones" getter="get_animate_physical_bones" default="true" deprecated="">
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].
</member>
<member name="modifier_callback_mode_process" type="int" setter="set_modifier_callback_mode_process" getter="get_modifier_callback_mode_process" enum="Skeleton3D.ModifierCallbackModeProcess" default="1">
Sets the processing timing for the Modifier.
</member>
Expand Down
7 changes: 0 additions & 7 deletions misc/extension_api_validation/4.2-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scene/3d/skeleton_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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");
TokageItLab marked this conversation as resolved.
Show resolved Hide resolved
#endif // _DISABLE_DEPRECATED
}

Expand Down Expand Up @@ -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<PhysicalBoneSimulator3D>(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<PhysicalBoneSimulator3D>(simulator);
if (!sim) {
return false;
}
return animate_physical_bones;
}

Expand Down
2 changes: 1 addition & 1 deletion scene/3d/skeleton_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading