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

Add an AnimationNodeExtension node #11123

Closed
GuilhermeGSousa opened this issue Nov 9, 2024 · 2 comments · Fixed by godotengine/godot#99181
Closed

Add an AnimationNodeExtension node #11123

GuilhermeGSousa opened this issue Nov 9, 2024 · 2 comments · Fixed by godotengine/godot#99181

Comments

@GuilhermeGSousa
Copy link

GuilhermeGSousa commented Nov 9, 2024

Describe the project you are working on

Implementing a Motion Matching extension

Describe the problem or limitation you are having in your project

After working on implementing motion matching for a few months, I believe the best way to set it up is as an animation node. Doing so allows the user to take the full benefit of the animation tree and its existing nodes, and combine those with motion matching.

Currently AnimationNodeRoot cannot be extended in GDExtensions (which is why I've been working on this as a custom engine module).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The proposed feature would be to create an AnimationNodeExtension, whose purpose would be to allows users to implement their own logic of animation nodes, exposing the APIs required for extension without having to modify internal animation node interfaces.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The main point of this node would be to expose a GDVIRTUAL version of AnimationNode::_process that users can override. An idea would be to keep a function signature similar to the current one:

void _process(const Ref<PlaybackInfo> p_playback_info, Ref<NodeTimeInfo > p_node_time_info, bool p_test_only = false)

while making sure to reuse instantiated PlaybackInfo and NodeTimeInfo.

Other ideas include passing all the parameters of PlaybackInfo and returning NodeTimeInfo as a packed float array:

PackedFloat32 MMAnimationNodeExtensions::_process(
    double time = 0.0,
    double delta = 0.0,
    double start = 0.0,
    double end = 0.0,
    bool seeked = false,
    bool is_external_seeking = false,
    Animation::LoopedFlag looped_flag = Animation::LOOPED_FLAG_NONE,
    real_t weight = 0.0,
    Vector<real_t> track_weights,
    bool p_test_only = false)

or, in a less GDScript/C# friendly way, reusing the patterns of some rendering APIs, using void* to pass the necessary structs without having to use ref counted types.:

void _process(const void* p_playback_info, void* p_node_time_info, bool p_test_only = false)

Other methods would also be needed for animation nodes to be fully extendable:

  • AnimationNode::get_animation_tree (and possibly an equivalent one that gets the animation tree currently selected by the animation tree editor)
  • NodeTimeInfo AnimationNode::get_node_time_info()

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, animation nodes cannot be extended in eithe GDScript of GDExtension

Is there a reason why this should be core and not an add-on in the asset library?

This should be core so that my projects (and others) can be addons on the asset library.

@CarpenterBlue
Copy link

Is SkeletonModifier3D of any use?

@GuilhermeGSousa
Copy link
Author

Is SkeletonModifier3D of any use?

It definitely is useful for other aspects that relate to motion matching, like IK and inertial blending.

For selecting and playing animations using motion matching however, extending an animation node is the best way to do it. Conceptually, motion matching is similar to the way a state machine node works, both select an animation to play based on a set of inputs. So implementing it this way brings all the benefits of using an animation tree, like being able to blend the result of motion matching with other animations, or filtering it to specific bones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants