-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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 changing physics interpolation in SceneTree at runtime #101245
Fix changing physics interpolation in SceneTree at runtime #101245
Conversation
0559b0a
to
69e2c17
Compare
I want to have a proper look at this, I'm not sure this will be most appropriate fix yet. |
I had a look and although the gist is correct as we discussed, there a number of problems here that would be nice to avoid, so I would prefer to fix as in #101218 . NOTIFICATIONAdding an extra Updating hidden itemsI'm not keen on the approach of trying to update the Instead what we tend to use is updating |
Does having an extra NOTIFICATION enum hurt anything here? We already have
The update is only performed when the setting is switched, not on every frame. Again, the reason I went with a separate notification is so that regular resets can still ignore invisible items for performance. However, updates need to be sent to the
This will be an end-user nightmare. We don't ask users to remember and manually reset every individual object in the game every time someone toggles V-Sync or anti-aliasing. We shouldn't ask them to do it for the global physics interpolation setting either. |
I would also prefer to keep things simple and not add another notification when it isn't really needed, it just clutters the API. Not updating invisible items was an intentional optimization, so the solution to stale data should be to do a reset when unhiding. I don't have time to look into things in detail now, but as far as I can tell your issue can be solved by @lawnjelly's PR plus a reset when unhiding. |
@rburing This misses the point as far as why I'm introducing a new notification, why the bug occurs, and why the PR solves the bug this way. Also worth mentioning that #101218 does not completely fix the issue. Please see the original bug here: #101192 See also this comment where I mention that the workaround (and thus the proposed alternate fix) does not address the issue if objects start out invisible: #101192 (comment) Essentially, we have a bug that is occurring because of said optimization. We don't initialize or update the interpolation information if physics interpolation is disabled, or the object is invisible. This is a reasonable assumption to make if the user always has physics interpolation enabled or disabled, because you don't pay for what you don't use. However, this assumption falls apart if you change the physics interpolation setting in Basically, here's what's going on:
This can be partially worked around using
Yes, you can work around this by calling And the user will have to do this for every single node in their game that could potentially be invisible when the physics interpolation setting is changed in Also, there really should be some way to force a physics interpolation reset even if the node is invisible. I can understand wanting to optimize for the general case, but users need some form of escape hatch to force a reset for all nodes. I don't like that I can't force a full reset even if I want to.
While implementing this fix, I didn't see a better way. There needs to be some way to reset invisible nodes, but I didn't want to break the existing logic. Ideally, the I can think of two other ways about this, though. One is to introduce a second notification like before, but have it going the other direction. That is, the second notification is The other idea is to handle this without notifications, by introducing a function call that itself propagates to child nodes. My concern with this however, is that the logic will be too separate from the existing reset logic (for example, 3D needs some special code to perform the reset, and it's better to have all that stuff in one place, because DRY principle). |
We really appreciate your investment in this issue, but it would be best to close this particular proposal now. As the physics interpolation maintainers, @rburing and myself have decided to go with the other PR to fix the issue, as it works better for overall plan for physics interpolation rollout. Thank you for your time nonetheless, and we hope to see you contribute again in the future! See: #102652 (comment) Just to reiterate, we are aware that auto-resets on unhiding some nodes are not yet performed, that decision has been purposefully deferred so we can look at them on a case by case basis. It may well be we can address these soon, so any MRPs for unhiding nodes with moving starts would be welcome. |
Fixes #101192
Fixes #101195
If physics interpolation is disabled, newly created and updated objects don't update their interpolation data, which can cause severe problems if the setting is enabled globally via
SceneTree::set_physics_interpolation_enabled()
at runtime. This PR adds a notification,NOTIFICATION_TREE_PHYSICS_INTERPOLATION_CHANGED
, which is used to perform a full interpolation reset on the nodes in the tree regardless of their visibility. SinceSceneTree::set_physics_interpolation_enabled()
is likely to only be called when changing in-game graphics settings, the performance cost of updating everything shouldn't be an issue. The existing physics interpolation reset functionality is unaffected.This PR also fixes the camera no longer updating after
SceneTree::set_physics_interpolation_enabled()
is called.