-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix NodeOneShot doesn't respect fade-out when aborting and improvement #74190
Fix NodeOneShot doesn't respect fade-out when aborting and improvement #74190
Conversation
aed2cce
to
0ffd382
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.
In terms of the implementation and fade out curve, I see nothing wrong here.
I'm assuming the main bugfix here is due to calling blend_input(1, ...
even while fading, rather than short circuiting with return blend_input(0...)
which prevented 1 from being evaluated in the old version.
However, my personal preference is to avoid renames if possible. I cannot evaluate the necessity of renaming against the compatibility breakage in 4.1, so I will leave this to Godot devs who have more experience with backwards compatibility decisions.
if (clear_remaining_fade) { | ||
os_seek = false; | ||
cur_fade_out_remaining = 0; |
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.
Should clear_remaining_fade
also set is_shooting = false
?
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.
There can be a condition where the shoot is being performed while clearing the old fade in the first frame of the shoot, so we will not do that here.
If we do not change the NodeOneShot API name now, we will have to set some bad name APIs like I also believe that these are generally configured from the GUI and it is not frequent to configure them directly in scripts. So I guess it would be quite unlikely to break the project. |
9776e3e
to
bad2353
Compare
Note that these renames not only break GDScript scripts, but also compatability with GDExtension and C#. Ideally, these renames should have happened before 4.0 final release; now we really need to consider how critical these are, and if in doubt strive to keep compatibility. |
Certainly it should not be changed in a patch release like 4.0.x. However, I think it should be changed as needed in minor releases like 4.x, rather than continuing to accumulate badly named APIs until 5.0. Also, it may not be good to just rename PR, but this PR breaks compatibility since it changes not only the method name but also the behavior of the original functionality in the first place. The behavior of the project will change before and after this PR, and may break projects that depend on the bug (the previous behavior where fades are not reset)1 or use hacks that workaround the bug. In such cases, I believe it is acceptable to rename to let them know that changing the behavior (though the renaming should only be an extra bonus). Footnotes
|
Is it possible to use a complete new set of names for the changed functionality? That would be compatible. We can then deprecate the old functionality. |
bad2353
to
9e0a1a7
Compare
I had already supported that migration as deprecated for properties' setter/getter, but I followed @fire's suggestion and added deprecated methods with the old method names bound to them. void AnimationNodeOneShot::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_fadein_time", "time"), &AnimationNodeOneShot::set_fade_in_time);
ClassDB::bind_method(D_METHOD("get_fadein_time"), &AnimationNodeOneShot::get_fade_in_time);
ClassDB::bind_method(D_METHOD("set_fadeout_time", "time"), &AnimationNodeOneShot::set_fade_out_time);
ClassDB::bind_method(D_METHOD("get_fadeout_time"), &AnimationNodeOneShot::get_fade_out_time);
... This should temporarily ensure script compatibility, but I also thought it might be better to add an ClassDB::bind_method_deprecated(D_METHOD("set_fadein_time", "time"), &AnimationNodeOneShot::set_fade_in_time); |
008c877
to
3c15f9d
Compare
modules/mono/utils/naming_utils.cpp
Outdated
{ "FADEIN", "FadeIn" }, | ||
{ "FADEOUT", "FadeOut" }, |
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.
@mhilbrunner The CSharp test has an error, so I looked into it, and it seems that your point is partially incorrect.
It seems that the method get_fade_in_time
(same for get_fade_out_time
) has already been converted to the method GetFadeInTime
by naming_utils.cpp
. However, since the other part naming in CPP are consistent with fade_in
, so this "fadein -> FadeIn" conversion seems to be currently only used for NodeOneShot and it looks entirely like a hack.
In summary:
-
I added
set_fade_in_time
in this PR, which is converted correctly toSetFadeInTime
withoutnaming_utils.cpp
in CSharp. -
Also, I remain the deprecated method
set_fadein_time
for compatibility. However,naming_utils.cpp
will convert it toSetFadeInTime
, which will result in duplicated declarations and errors, so we need to remove it (and again, this is only used for NodeOneShot, so removing it here should not be a problem). One problem that occurs as a side effect of that is the addition of a deprecated methodSetFadeinTime
newly to CSharp.
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.
Since this is just a rename and doesn't break compat, I think it's fine for the C# implementation to call the new get_fade_in_time
.
As for the new deprecated SetFadeinTime
method, it'd be nice to avoid generating it. We can probably skip it like we do with some classes but this can probably be done in a separate PR as long as it gets merged before the new API ships. But I don't think it would be a big deal even if we end up shipping the new deprecated API.
I think this PR is going overkill on cosmetic compat breakage of the API where it's not needed. I understand that you might feel that I'm not fully closing the door to figuring out a proper way to let the API evolve in 4.x minor releases where it's very needed (fixing outright wrong names or bogus APIs), but this is not the case here. And that way would still need to be defined, agreed upon, and documented, and that's fully outside the scope of this PR. So I'd appreciate if this PR was amended not to break compatibility, as I don't see why it's justified here. |
I would argue that the method conversion hack for CSharp there indicates that the original method name is incorrect and that this should be justified to remove such hacks.
This is already done by binding the old methods so old scripts will not be broken, but has the side effect of adding deprecated methods to CSharp as raulsntos concerned #74190 (comment). This is caused by the hack being implemented only for CSharp, even though it should have corrected the core method name. |
Whatever hack was added in the C# bindings to make the API nicer for C# users is not a justification for breaking compat. We released 4.0 with this API, it's not wrong, there's no reason to break compat or introduce a ton of duplicated deprecated methods because you don't like the look of "fadeout". Nobody asked for this change. This PR claims to be fixing a logic bug - that's all it should do. But we can't merge that fix because it's being mixed with opinionated compat breakage when we made clear that this was not an option after the 4.0 release. |
For now, I will be separating only the PR for the renaming. |
3c15f9d
to
f4036f6
Compare
@akien-mga Modified the old bound method names to leave them unchanged. |
f4036f6
to
238bc9f
Compare
Thanks! |
Fixes: #53947
Fixes: #73113
Apply same fix to NodeOneShot with #73120.
Also, add a request
ONE_SHOT_REQUEST_FADE_OUT
to NodeOneshot to Abort with respect to the fade-out time.This changes the transition timing of the active state. This means that the transition to the next state will occur at the start of the fade in the same way as NodeTransition and NodeState.
However, for the Active state, it should be true if OneShot is still in effect. Also for compatibility.
Therefore, the display (retrieve-able) active state and the internal active state are separated as:
active
andinternal_active
.In addition, the xfade curve can be set as in NodeTransition and StateMachine.
Godot.2023.03.02.-.06.40.14.03.mp4