Skip to content
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

Processing diagram #9305

Open
berarma opened this issue Apr 30, 2024 · 2 comments
Open

Processing diagram #9305

berarma opened this issue Apr 30, 2024 · 2 comments

Comments

@berarma
Copy link

berarma commented Apr 30, 2024

I needed to know the order things happen inside the Godot engine to better write code for it. I don't think there's something similar in the documentation. There are some pages which can give a grasp but not the whole picture:

I don't know of any more. Since they're scattered I might have missed some.

I've made a very simple diagram by looking at the code, mostly copying from it. I'd be willing to improve it and adding it to the documentation, but I don't know where or how. For now, I want to make sure it's correct and add a bit more info.

Please, add corrections, criticism and any useful info in the comments. Thanks.

If it already existed then I'll feel dumb but don't worry, it didn't take too long.


Processing diagram for Godot 4.3

The scene tree object is an instance of MainLoop. In the default
configuration it's an SceneTree object, thus MainLoop could be replaced by
SceneTree.

  • Call MainLoop._initialize().
    • Call DisplayServer::process_events(). Processes window manager events
      including input.
    • Process joystick/gamepad events (only on Linux/udev).
    • Physics processing step (run as many times as needed).
      • Flush input buffered events when agile_event_flushing is true (Android only).
      • Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
      • Call MainLoop._physics_process().
      • Send signal SceneTree.physics_frame.
      • Process object picking.
      • Call _physics_process() in the scene nodes.
      • Flush unique calls to groups.
      • Process timers in physics processing mode.
      • Process tweens in physics processing mode.
      • Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
      • Process queue_delete()/queue_free() calls.
      • Process deferred calls.
      • Physics server step.
    • Flush input buffered events when agile_event_flushing is true (Android only).
    • Idle processing step.
      • Call MainLoop._process().
      • Automatic polling of MultiplayerAPI.
      • Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
      • Call _process() in the scene nodes.
      • Flush unique calls to groups.
      • Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
      • Process queue_delete()/queue_free() calls.
      • Change scene if requested.
      • Process timers in idle processing mode.
      • Process tweens in idle processing mode.
      • Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
      • Process deferred calls.
    • Rendering.
    • Audio update.
    • Debugger iteration.
    • Flush input buffered events when agile_event_flushing is false (Android only).
    • Add frame to MovieWriter if used.
    • Optional frame delay to achieve target fps.
  • Call MainLoop._finalize().
@berarma
Copy link
Author

berarma commented Apr 30, 2024

Related: #9204.

@berarma
Copy link
Author

berarma commented May 6, 2024

Additional information: #5492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant