Skip to content

Commit

Permalink
Allow users to override SkeletonModifier3D._process_modification
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuma committed May 8, 2024
1 parent 03e6fbb commit fbc599a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
20 changes: 20 additions & 0 deletions doc/classes/SkeletonModifier3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@
<description>
[SkeletonModifier3D] retrieves a target [Skeleton3D] by having a [Skeleton3D] parent.
If there is [AnimationMixer], modification always performs after playback process of the [AnimationMixer].
This node should be used to implement custom IK solvers, constraints or skeleton physics
</description>
<tutorials>
</tutorials>
<methods>
<method name="_process_modification" qualifiers="virtual">
<return type="void" />
<param index="0" name="delta" type="float" />
<description>
Override this virtual method to implement a custom skeleton modifier. You should do things like get the [Skeleton3D]'s current pose and apply the pose here.
[code]_process_modification[/code] must not apply [member influence] to bone poses becuase the [Skeleton3D] automatically applies influence to all bone poses set by the modifier.
</description>
</method>
<method name="process_modification" is_experimental="true">
<return type="void" />
<param index="0" name="delta" type="float" />
<description>
Manually advance the modifications by the specified time (in seconds).
When invoked manually, modifiers currently ignore [member influence] and apply with full influence.
[b]Experimental:[/b] The behavior of manually processing modifications is subject to change in future engine versions.
</description>
</method>
</methods>
<members>
<member name="active" type="bool" setter="set_active" getter="is_active" default="true">
If [code]true[/code], the [SkeletonModifier3D] will be processing.
Expand Down
5 changes: 4 additions & 1 deletion scene/3d/skeleton_modifier_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void SkeletonModifier3D::process_modification() {
}

void SkeletonModifier3D::_process_modification() {
//
GDVIRTUAL_CALL(_process_modification);
}

void SkeletonModifier3D::_notification(int p_what) {
Expand All @@ -129,10 +129,13 @@ void SkeletonModifier3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_influence", "influence"), &SkeletonModifier3D::set_influence);
ClassDB::bind_method(D_METHOD("get_influence"), &SkeletonModifier3D::get_influence);

ClassDB::bind_method(D_METHOD("process_modification"), &SkeletonModifier3D::process_modification);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "influence", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_influence", "get_influence");

ADD_SIGNAL(MethodInfo("modification_processed"));
GDVIRTUAL_BIND(_process_modification);
}

SkeletonModifier3D::SkeletonModifier3D() {
Expand Down
1 change: 1 addition & 0 deletions scene/3d/skeleton_modifier_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SkeletonModifier3D : public Node3D {
virtual void _set_active(bool p_active);

virtual void _process_modification();
GDVIRTUAL0(_process_modification);

public:
virtual PackedStringArray get_configuration_warnings() const override;
Expand Down
2 changes: 1 addition & 1 deletion scene/register_scene_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void register_scene_types() {
GDREGISTER_CLASS(CPUParticles3D);
GDREGISTER_CLASS(Marker3D);
GDREGISTER_CLASS(RootMotionView);
GDREGISTER_ABSTRACT_CLASS(SkeletonModifier3D);
GDREGISTER_VIRTUAL_CLASS(SkeletonModifier3D);

OS::get_singleton()->yield(); // may take time to init

Expand Down

0 comments on commit fbc599a

Please sign in to comment.