-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
RID: Change comparison operators to use RID_Data id instead of address #59234
Conversation
This should helps making sorting more deterministic in physics and rendering. The same change was done for 4.0 in 4f16397.
Imo this is probably a slight improvement (as far as repeatibility when opening the same project). However anything using this method of sorting is pretty dodgy imo, as there is a certain amount of random chance involved here, depending on the historical order of RID allocation. It's just a very rough repeatable sort on the same run of the program. There is an extra level of indirection here, but unless it proves to be a problem we can probably ignore it (we could always revert if necessary but I doubt it will be a problem). Imo sorting on the RIDs might be okay for e.g. debugging logging but it is very questionable for anything gameplay wise, so we should be looking through with a fine toothed comb to see whether some better method of sorting could be employed. Canvas items for instance to be "correct" as far as the user is concerned should probably be maintaining an ID within the tree traversal, although perhaps that has been ruled expensive to update each time one of them is changed. Maybe it can be done with a dirty flag or something. |
This looks great. repeatable sort on the same run of the program is still valuable compared to totally random depending on what heap addresses your program receives each run, so still a net positive. FWIW this is exactly the type of issue that caused our physics simulation to go bananas for reproducibility when I first tried to use godot physics... (same inputs on subsequent runs on same binary & machine would result in different solver behaviour). |
Just to note in #67273 this PR proves to cause problems when This is all the more reason to consider the points at which this has been used, and reconsider whether using N.B.Also note there's a subtle difference between this PR (3.x) and the one for 4.x. The one for 4.x stores the id directly in the |
Reverted with #69946. |
This should helps making sorting more deterministic in physics and rendering.
The same change was done for 4.0 in 4f16397.
Alternative to #59192 fixing the issue as its root.
Helps with #25384 by making sorting deterministic - but I'm not sure it will make it predictable / as users expect it.
I could use help testing and making sure that this doesn't impact performance noticeably.
According to Sourcetrail, these operators are used like this:
RID::operator<
:Through
Comparator
this is also used inMap
andSet
RID::operator<=
: Used inVariant::evaluate
RID::operator>
: Never used.