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

Fix consistency of GradientTexture changes #81137

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Aug 29, 2023

Gradient texture queues an update when a property changes, EXCEPT in set_gradient() in GradientTexture2D, which calls the update immediately and emits the changed signal twice. Another weird thing is that gradient texture changes would queue the update and the changed signal would be emitted in the _update() method. That's not how this signal works.

This PR removes the inconsistency and _queue_update() is now called for every change, but the deferred emit_changed() is removed. Instead the signal is emitted right in the setter. I also added a public (not exposed) method update_now(), which forces the pending texture update to be done right now. It's automatically called when you attempt to get the image.

@YuriSizov
Copy link
Contributor

EXCEPT in set_gradient() in GradientTexture2D

Just for future readers, this except comes from #60361.

@KoBeWi
Copy link
Member Author

KoBeWi commented Aug 29, 2023

The interesting part is that this change wasn't done in GradientTexture1D.
EDIT:
Right, it was already like that...

@akien-mga akien-mga merged commit d2f76e8 into godotengine:master Aug 29, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the gradiEND branch August 29, 2023 21:10
@Calinou
Copy link
Member

Calinou commented Aug 29, 2023

Does this PR supersede #80855?

@KoBeWi
Copy link
Member Author

KoBeWi commented Aug 29, 2023

Yes.
EDIT:
Not entirely. I'll leave a comment.

@kleonc
Copy link
Member

kleonc commented Aug 30, 2023

This PR removes the inconsistency and _queue_update() is now called for every change

Some leftovers (for whatever reason it's connecting to GradientTexture1D::_update instead of GradientTexture1D::_queue_update):

if (gradient.is_valid()) {
gradient->disconnect_changed(callable_mp(this, &GradientTexture1D::_update));
}
gradient = p_gradient;
if (gradient.is_valid()) {
gradient->connect_changed(callable_mp(this, &GradientTexture1D::_update));
}

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

Successfully merging this pull request may close these issues.

6 participants