[3.x] Physics Interpolation - Fix global switch hidden nodes#102755
[3.x] Physics Interpolation - Fix global switch hidden nodes#102755lawnjelly wants to merge 1 commit intogodotengine:3.xfrom
Conversation
kiroxas
left a comment
There was a problem hiding this comment.
I do not know how nodes and physics works internally, so feel free to ignore if this makes little sense. However this seems like it could have complications if some node have some costly code in response to when setVisible is called. Seems like you are targeting some specific nodes, which I assume does not have this property right now, but this use case ( toggle on then off in the same frame) is not something people will think of when adding new features, so that could easily bite them. Is there really no way to add a parameter to reset_physics_interpolation() so it consider the hidden nodes too? That would seem to be the way with less collateral damage.
Side effects is always a concern, but this is very rarely called function (like maybe called once if at all, it's effectively a global on / off switch for game settings menu), so it can be hideously inefficient and there is no problem. So in this case simplicity and code maintenance is a more important concern than efficiency. I did think of putting a note on this (visibility enablers, user scripts responding to visibility changes), but if there is evidence of side effects in the wild, there are plenty of other approaches that are available. I do subscribe to KISS principle unless there is evidence of a need for more engineering here, I feel going further for such a rare use case at this stage is over-engineering. There are several reasons to prefer not calling reset on hidden nodes:
I'm not sure I understand what you are saying here. If anything, it's the opposite, see above. (Toggling node visibilties within the frame many times (in any combination) is guaranteed to be supported, as users can do this in their own scripts. It is by definition safe, although not guaranteed to be efficient. ) |
Ensure hidden nodes get reset when switching global physics interpolation on / off.
02fc2b7 to
7c670f4
Compare
|
I'm inclined to agree with @kiroxas. This behavior introduces side-effects that could cause problems for anything that handles visibility notifications. How would you be able to differentiate between a visibility change done as a result of a settings change? All visibility change logic would need knowledge of a seemingly unrelated system to avoid issues.
IMO users shouldn't have to read the docs to know about implementation side-effects.
As the one user asking for this feature, I am willing to take on that code and maintenance burden :) |
|
Actually to some extent this PR is outdated now as we are moving to scene side interpolation. In fact I'm pretty sure I already fixed this up (or one aspect of it) in the new code. So I'll close and we can revisit after that is done. |
Ensure hidden nodes get reset when switching global physics interpolation on / off.
Fixes #101192 for hidden nodes.
Notes
SceneTreeso no changes are needed within nodes.Discussion
Another alternative (as @akien-mga suggested) is just to unexpose the function which allows changing physics interpolation at runtime, and withdraw support, and get users to restart the engine with a cfg file.
That alternative is available in #102762 .
Similar problems could also theoretically occur when changing branches interpolation mode at runtime, but this is intended to be design time decision (I'll probably look at adding this to the docs), I'm not sure there is a use case for this at runtime.
It is also possible to put logic in the nodes themselves just for this settings change (e.g. checking a global state before checking visibility), but imo it would be better to avoid complicating the code and maintenance for such a rare use case (we only have one user asking for the feature).