Reduce redraws in editor - #657
Conversation
Previously `viewfinder.gd`'s `_process()` and `_physics_process()` functions were called once per frame, regardless of whether the viewfinder panel is visible. At least one will `return` immediately, depending on the value of `_physics_based`, and both will return immediately if `_has_pcam_host` is false. Use `set_process()` and `set_physics_process()` to control which (if either) of the methods will be called. Update whenever `_has_pcam_host` or `_physics_based` changes.
Otherwise, the SubViewportContainer gets rerendered once per frame, even when the panel is closed or there is no pcam in the current scene.
|
Draft for 2 reasons:
|
Phantom Camera: Reduce unnecessary processing Apply the changes I have submitted upstream in ramokz/phantom-camera#657 to avoid processing every frame in the editor, even when the open scene does not use PhantomCamera. As detailed in that PR and in ramokz/phantom-camera#649, I haven't figured out how to avoid the PhantomCameraHost node processing every frame even when the viewfinder is closed. And as also detailed there: any inactive PhantomCamera2D still _process()es every frame, and the PlayerHook has an inactive PhantomCamera2D, so... However in most scenes containing the player we have at least one moving tree or water ripple animation, which causes the scene to render at 60fps anyway. So, oh well!
|
Just checking in, has the change worked as expected in your 2D project(s)? |
|
Sort of... I get this warning when switching in the editor from a scene that does not use pcam to a scene which does: And we also have a strange issue that we have not yet debugged where limits are applied incorrectly when switching camera, but only in (some) exported builds. endlessm/threadbare#2393 I haven't had a chance to test whether these are also reproducible without this stack of patches. |
|
For some reason I cannot replicate the warning you're seeing, but I am encountering an error in Though it's pretty easy to fix by just adding a check and additional assignment. Another side effect I'm seeing from this PR is when using framed_follow_dot.mp4
The issue in that post has been a problem before in general runtime situations (editor included), but should have been fixed quite a while back at this point. But it's very odd that it's seemingly only happening in some build targets and not consistently... My only hunch is the limit bounds are smaller than the PCam2D's viewport and so the camera doesn't quite know where to position itself. recording_15_07_26.mp4 |
Fixes #649