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 AnimationTrackFilter and implement filter as an AnimationNode's parameter. #76788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Daylily-Zeleen
Copy link
Contributor

@Daylily-Zeleen Daylily-Zeleen commented May 6, 2023

Implement #6808.

  • Add resource type AnimationTrackFilter, remove AnimationNode menbers:
    • filter, filter_enabled
    • _get_filters(), _set_filters(), has_filter(), set_filter_path(), set_filter_path(),
  • Implement filter like other AnimationNode's parameters.
  • Modify AnimationNodeBlendTreeEditor to adapt to first change.
  • Implement AnimationTrackFilterEditorPlugin to edit filter tracks in inspector.
2023-10-02.11-58-11.mp4

This pr implement filter for AnimationNodeBlend3, will close #76506.

The filter is implemented as gradual style, will close #7578.

Bugsquad Edited:
Closes godotengine/godot-proposals#7896

@Daylily-Zeleen Daylily-Zeleen requested review from a team as code owners May 6, 2023 18:56
@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 9 times, most recently from 7dfccbb to ba2a36e Compare May 6, 2023 19:38
@Daylily-Zeleen
Copy link
Contributor Author

How to fix this static checks?

@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 3 times, most recently from c51ea17 to 5fdc92e Compare May 6, 2023 19:54
@warriormaster12
Copy link
Contributor

You basically add whatever is marked green to your code. If you have line of code that is marked red and right below it is the same line of code that is marked green then that means that you have to edit the line of code to look like the green one.

In your case you seem to be missing license related comments so adding those should fix static checking.

@Daylily-Zeleen
Copy link
Contributor Author

Daylily-Zeleen commented May 7, 2023

You basically add whatever is marked green to your code. If you have line of code that is marked red and right below it is the same line of code that is marked green then that means that you have to edit the line of code to look like the green one.

In your case you seem to be missing license related comments so adding those should fix static checking.

You can my changed files, I already add the lisence info.

@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 8 times, most recently from 386ba01 to f81fce7 Compare May 7, 2023 08:16
@Daylily-Zeleen
Copy link
Contributor Author

Can someone help me?

Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At any rate, the file must end with a new line.

scene/resources/animation_track_filter.h Show resolved Hide resolved
scene/resources/animation_track_filter.cpp Show resolved Hide resolved
@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 3 times, most recently from e8606f8 to caf4962 Compare October 1, 2023 12:32
@AThousandShips AThousandShips changed the title Add AnimationTrackFilter and implemte filter as an AnimationNode's parameter. Add AnimationTrackFilter and implement filter as an AnimationNode's parameter. Oct 1, 2023
@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 3 times, most recently from 2597e17 to e3d7409 Compare October 2, 2023 03:51
@Daylily-Zeleen Daylily-Zeleen marked this pull request as ready for review October 2, 2023 04:11
@Daylily-Zeleen
Copy link
Contributor Author

Refactor is done, please review again.

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes which break API compatibility. This is a hard blocker for merging this PR. It is okay to mark functions deprecated, but existing methods, including virtual methods, must not be removed between Godot 4 versions.

EDIT: See Godot's policy on compatibility across engine versions.

Comment on lines 46 to 51
<method name="_has_filter" qualifiers="virtual const">
<return type="bool" />
<description>
When inheriting from [AnimationRootNode], implement this virtual method to return whether the blend tree editor should display filter editing on this animation node.
</description>
</method>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: Validate extension JSON: API was removed: classes/AnimationNode/methods/_has_filter

It is not permitted to remove public APIs, such as AnimationNode.is_path_filtered(path:NodePath), AnimationNode.set_filter_path(path:NodePath,enable:bool), AnimationNode.set_filter_enabled(enable:bool), AnimationNode.is_filter_enabled() or the virtual function AnimationNode._has_filter(). The property filter_enabled may also be kept for script compatibility, but it is not required to do so for GDExtension support.

These AnimationNode methods must be kept but marked deprecated, such as using is_deprecated="true" in this documentation XML. I would suggest that it would be good practice to implement them if possible, for example accessing the attached AnimationTrackFilter if possible, or returning empty if this is not possible.

@@ -247,6 +249,7 @@ void AnimationNodeOneShot::get_parameter_list(List<PropertyInfo> *r_list) const
r_list->push_back(PropertyInfo(Variant::FLOAT, remaining, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE));
r_list->push_back(PropertyInfo(Variant::FLOAT, fade_out_remaining, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE));
r_list->push_back(PropertyInfo(Variant::FLOAT, time_to_restart, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE));
APPEND_FILTER_PARAMETER(r_list);
Copy link
Contributor

@lyuma lyuma Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do some animation nodes have a filter and some don't?

I find this use of macro really confusing. Why can't we have the "filter" parameter in the base class AnimationNode?

If we do have a special type of "filterable" animationnode, perhaps we should add an abstract class / level of inheritance to indicate the filterability (having the "filter" parameter).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I "filter" just a normal parameter like "add_amount" in AnimationNodeAdd2, I think it should be added where they need in get_parameter_list(), this macros just for copying duplicate code and avoiding stupid mistake.

However, if user create their own AnimationNode in GDScript (godot/pull/69641) and need filter, it may not work expectantly because of misspell.
For user friendly, I readd has_filter() now.

But I am not sure which way is more reasonable.


public:
StringName filter = PNAME("filter");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having a member variable named the same as its string constant value. If this is effectively a constant, it should be marked const and made capital, or renamed to _string or _parameter to indicate that it refers to the parameter / string constant, and it isn't itself a filter object or a time value.

The existing code is also bad practice and should be fixed in a separate PR. In particular, the use of time as a member variable name shadows the C library's time(time_t*) function. I wouldn't have as much of an issue with this additional parameter as long as it is next to the other PNAME values, namely time, remaining and so on.

This issue isn't a sticking point, just something I observed that made it especially difficult for me to read and follow the property list code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree your opinion, here I just abey the existing code.

scene/register_scene_types.cpp Outdated Show resolved Hide resolved
@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch 4 times, most recently from e28643a to 4db5943 Compare October 2, 2023 07:13
@Daylily-Zeleen Daylily-Zeleen requested review from a team as code owners October 2, 2023 07:13
@SaracenOne
Copy link
Member

SaracenOne commented Oct 17, 2023

I like this PR, I think its the right direction to go for both ease of use and memory saving. Regarding the deprecation thing, the way I would suggest implementing this without breaking compat is keeping the old filter function, but marking them as deprecated as per the deprecation system we introduced for 4.x. You can then make the existing functions, for example, for when setting the filters property, generate a unique filter resource for them. This will ensure backwards compatibility with the old system and allow this to be introduced without breaking existing trees.

@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch from 4db5943 to 0e11e55 Compare October 17, 2023 18:08
@Daylily-Zeleen Daylily-Zeleen force-pushed the daylily-zeleen/animation_track_filter_and_preset branch from 0e11e55 to bc51e2b Compare October 17, 2023 18:13
@Daylily-Zeleen
Copy link
Contributor Author

I like this PR, I think its the right direction to go for both ease of use and memory saving. Regarding the deprecation thing, the way I would suggest implementing this without breaking compat is keeping the old filter function, but marking them as deprecated as per the deprecation system we introduced for 4.x. You can then make the existing functions, for example, for when setting the filters property, generate a unique filter resource for them. This will ensure backwards compatibility with the old system and allow this to be introduced without breaking existing trees.

"filter" in this pr is not belong to AnimationNode and should be referenced by specific AnimationTree nodes, unless we can find out correct AnimationTree nodes when loading an AnimationNode, it is impossible to keep old filter info from old resources datas.
Although I add filter, _set_filter(), _get_filter() to pass compat check, old filter info will be lost when opening old scenes.

@DucktatorQuack
Copy link

The filter_enabled doesn't work from code.
filter_enabled

I've tried to trigger it in multiple ways, but in 4.3 it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

Add amount option to animation track filter
6 participants