-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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 animation node extension #99181
base: master
Are you sure you want to change the base?
Add animation node extension #99181
Conversation
AnimationNode::NodeTimeInfo node_time_info; | ||
}; | ||
|
||
class PlaybackInfoRC : public RefCounted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same criticism of RC suffix as the last comment.
I have concerns about future compatibility breakdown if struct is implemented in GDScript. We will need to consider whether we need to rush. |
61f3ab5
to
b764317
Compare
@TokageItLab what were your concerns? I don't have any strong opinions, I though this was the cleanest of the ways to do this but I'm open to suggestions! |
b764317
to
69c6e4a
Compare
More specifically, I am concerned that I guess that GDScript struct will not be implemented as refcounted (maybe it should be one of the Variant types) in the future. In the discussion regarding the implementation of struct, there was mention of it being implemented as a similar to a typed Dictionary. NodeTimeInfo is composed of several properties and a get_remain_time() method that returns a value based on them. It is like a combination of a typed Dictionary and a Callable, but both are built-in types in the variant, not extends RefCounted class. So what you are trying to do should actually be one of the struct as one of the Variant types, not Refcounted. Even if we rush to merge this with inheriting Refcounted because we don't have struct, we will still need to replace it with struct in the future. Then it is doubtful that we can migrate Refcounted into Variant since base classes are fundamentally different. |
@TokageItLab are you suggesting waiting until structs are implemented? That might not be coming to the engine any time soon, and I wouldn't mind refactoring this code once it is available. Another idea would be to do what the AudioStreamPlayback _mix method does and use pointers instead. That way it wouldn't be exposed to GDScript, and would be easy to convert to using structs once avaiable. |
Right, that's the direction that should be most recommended. Insteads, you can use the custom module.
Since the PR is already there #82198, you could help with that work and feedback to support it. Then, it is fine to include that PR before this PR and mentions " If we are in a hurry to implement something, we will need to expose NodeTimeInfo as some Variant type instead of RefCounted. RefCounted is referential, so compatibility will be hard broken in the future if there are scripts that reference the same NodeTimeInfo. From a performance point of view, we should avoid this but you can use Dictionary in some cases, but there is a problem that the get_remain() method is not available. Or you can use a encoded PackedByteArray, or a Callable object to exchange information. Strictly, these are also referential, but since they are Variant types, if a reference is broken, only the Initial value is passed, allowing for relatively safe compatibility breaking and migration. |
69c6e4a
to
389180c
Compare
Hi @TokageItLab! I updated this PR before having read your comment! You make very valid points, and I think you might prefer these last changes I pushed, I'm no longer using ref counted objects and instead encoding the return value on a As for the struct PR, I do like the idea you suggested. I'm not familiar with the struct changes, but I can least help with feedback. Nonetheless, if possible I'd like to submit these changes first, and later refactor the return value to use a struct instead. |
PackedFloat32Array looks fine than RefCounted. This is not a blocking opinion of this PR in particular, but I have two more concerns (as above your comment, probably do you work in progress?)
|
8baefdb
to
8c3c569
Compare
@TokageItLab agree with all your comments, just updated the PR to include them. |
ea20df2
to
5a56fe1
Compare
The documentation changed and requires to be generated with --doctool. |
5a56fe1
to
93582fe
Compare
We want to add the experimental flag to this class, but I forgot the process—@AThousandShips and maybe others. |
93582fe
to
e2dca01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably unneeded.
e2dca01
to
c130306
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These must be implemented in the base class AnimationNode. BTW, process_state is also a struct, it will probably need to be a PackedArray if it is to be exposed.
However, since all we need is the tree
and is_testing
, I agree that we should expose those two as get methods to the AnimationNode class, but I think the AnimationTree should be returned as either NodePath or ObjectID, as it is unsafe to return the AnimationTree pointer directly.
2b99218
to
b17daf8
Compare
Updated the PR. @TokageItLab I'm running into an issue, unless I'm missing something I don't think plugins can extend abstract native classes. I even tried making an abstract base class on the plugin before making the actual extended class in C++, but no luck. |
@GuilhermeGSousa It is the expected behavior that it cannot be called from the scene dock, but I assume it could be called if class_name is assigned (same with https://godotengine.org/article/design-of-the-skeleton-modifier-3d/#1-create-a-script). is there an error before the extending it with class_name is added? |
@TokageItLab I meant to extend it in a GDExtension, in C++. As far as I can tell, it doesn't seem to be possible to register a class that inherits directly or indirectly from a native abstract class. Unless there's maybe an equivalent way of setting the "class_name" for a C++ class? This is the error I run into at registration:
|
How about |
b17daf8
to
64e39ed
Compare
@TokageItLab that works great! I can extend the class and it can't be instantiated from the resources dialog window. |
64e39ed
to
a339573
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, those API should be almost identical to the virtual function of the AnimationNode class provided in cpp, except for the struct format.
We don't know what struct will be in the future, but it is probably a Variant type, so it should be able to provide a migration path.
a339573
to
b808b97
Compare
TODO:
Bugsquad edit:
Fixes: godotengine/godot-proposals#11123