Making the dream Animation API for GDExtension #52
GuilhermeGSousa
started this conversation in
Ideas
Replies: 1 comment 30 replies
-
Upcoming work that'll allow compiling godot-cpp gdextensions as a module. 💯 |
Beta Was this translation helpful? Give feedback.
30 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So right now, there are no good ways to making motion matching as a GDExtension. There are some features missing that prevent us from extending certain engine functionalities. In this post I'll go into detail of what would be required on the engine side to do this. For each point I'll go over what we're trying to do and what the ideal engine API would look like to be able to support it.
Motion Matching Animation Node
What we want to do
From implementing it in an engine module, its has become clear that the best way of implementing motion matching in Godot is as an
AnimationNode
. Doing so comes with multiple advantages compared to other approaches we've tried:What we need from Godot
The
_process
method, arguments and return valuesProbably the most important part of this section, to be able to extend a
AnimationRootNode
, bothAnimationMixer::PlaybackInfo
andAnimationNode::NodeTimeInfo
need to be ref counted, so that the following function can have aGDVIRTUAL
equivalent:Accessing the
AnimationTree
During
_process
,AnimationNode::get_animation_tree()
can be used to access theAnimationTree
that owns the node. We'd need this same function exposed to extensions to be able to create a Motion Matching animation node.At editor time (outside the
_process
function), that same method will always return null. In order to be able to implement a similar property validator as the one used byAnimationNodeAnimation
, we'd need a way of accessing the animation tree from_validate_property
. From a module, this can be done the following way:We'd need that same API exposed to gd extensions as well.
Inertialization Blending Skeleton Modifier
What we want to do
Inertialization blending is a technique used to blend animations together, developed by the teams at Microsoft Studios for Gears of War 4. One of its characteristics is that the rate of change of the bones preserve some of their inertia when swapping animations, resulting in more fluid and realistic motion. It can also be more performant than "regular" track blending, as it is not required to evaluate two tracks simultaneously to compute the resulting blend.
Since this blending technique requires modifying the skeleton bone's position and rotations, implementing this as a
SkeletonModifier3D
is ideal. However, there are still a couple of missing pieces to the puzzle.What we need from Godot
Signals from
AnimationNode
sThe inertialization blending algorithm needs to run specific calculations when animations change (i.e. when motion matching run a query and selects an animation). We therefore need a way for animation nodes to be able to signal outside systems when something happens. An idea of how to do it would be to have a similar method as
AnimationNode::get_parameter_list
that would expose signals instead:(similar to the method with the same name of
Object
).Beta Was this translation helpful? Give feedback.
All reactions