-
-
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
Add property change guards to Sprite2D, Sprite3D and AnimatedSprite2D #85311
Add property change guards to Sprite2D, Sprite3D and AnimatedSprite2D #85311
Conversation
I have one really stupid question about code style. Suggested code follows pattern (And of course I support this guards addition, without it some users could have redraw spam without even knowing about it.) |
I checked some classes and we aren't ordering this consistently. |
I used the same ordering I had previously seen in some Control nodes. At least I tried to use the same ordering in every function :) I personally like this order as in the actual assignment the order is same, so it is (at least for me) easy to see how these two lines are connected. if (vflip == p_flip) {
...
}
vflip = p_flip; |
Yeah the order used here is the most common in my experience, and the most readable IMO. |
ad58035
to
48cce77
Compare
Could be also added to |
Also unify code in |
48cce77
to
36393c6
Compare
Done.
Done. I didn't add a change guard to Lines 324 to 328 in 84692c6
That function propagates the color to child nodes and I have no idea what would happen if you add new child nodes between setting modulation color like this: sprite3d.modulate = Color.RED
sprite3d.add_child(some_node)
sprite3d.modulate = Color.RED At least now without the change guard the color will be propagated to the child node. |
It doesn't actually propagate any values, it just triggers a redraw (which makes |
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.
Other than the above, seems good to me. Feel free to do the adjustments, and then it can be merged.
36393c6
to
5410553
Compare
Adjustments done. |
Good work, needs a rebase after #85317. I merged it first since it fixes a problem and is generally more involved. |
5410553
to
5b9e67e
Compare
Thanks! |
Implements this proposal: godotengine/godot-proposals#8510
If a property's setter is called with the property's current value, return immediately instead of doing anything costly.
My test creates 10000 Sprite2Ds.
Each sprite has a script which does some combination of these simple setters (or just
pass
).My test version was built with Visual Studio and it's performance seems to be a bit lower than the official version. "% compared to pass" numbers are calculated from release version fps numbers.
pass
flip_h = true
frame = 0
flip_h = true
andframe = 0
It may seem odd to just to set
flip_h = true
, but it is a very common practice to set sprite's direction in every frame like this:So there are a lot of 2D games which are setting
flip_h
in every frame without actually changing it.Production edit: Closes godotengine/godot-proposals#8510