Skip to content

Ensure default Gizmos start rendering the same frame they are requested (Take 2)#22964

Open
kfc35 wants to merge 7 commits intobevyengine:mainfrom
kfc35:22438_gizmo_single_frame_take_2
Open

Ensure default Gizmos start rendering the same frame they are requested (Take 2)#22964
kfc35 wants to merge 7 commits intobevyengine:mainfrom
kfc35:22438_gizmo_single_frame_take_2

Conversation

@kfc35
Copy link
Contributor

@kfc35 kfc35 commented Feb 15, 2026

Objective

Solution

  • Adds the ability to initialize gizmo config groups with one of two different schedules for its “prepare gizmos for rendering” step (aka GizmoMeshSystems): In PostUpdate before AssetEventSystems (new scheduling) or In Last (previous scheduling). Preparing the gizmos for rendering before AssetEventSystems ensures that that asset extractor receives an asset event message about a newly added gizmo asset within the same frame.
  • The DefaultGizmoConfigGroup uses the new schedule to ensure its gizmos can be drawn in the same frame they are requested (provided the request is before GizmoMeshSystems in PostUpdate)

I was unsuccessful in trying to port over Aabb, Frustum, and Light gizmos to this new schedule. If their PostUpdate systems were requested to run before GizmoMeshSystems, it would cause a cycle in the PostUpdate schedule, although the error message was completely unhelpful in this regard (there’s probably a bug in there somewhere):

Error when initializing schedule PostUpdate: schedule has 0 before/after cycle(s):

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I was able to manually verify that Aabb would definitely have a cycle, but was unable to deduce the same for Frustum and Light gizmos. Since Aabb, Frustum, and Light gizmos work satisfactorily using the Last schedule without issue...

  • Aabb, Frustum, and Light gizmos still use the Last schedule for GizmoMeshSystems (the previous scheduling). They function just fine, it is just that they start rendering one frame later, which I presume does not matter as much since they would usually be rendering for more than one frame anyway. I added a comment about them still using the Last schedule.
  • Global gizmos now flush before GizmoMeshSystems in PostUpdate since its gizmos are part of the DefaultGizmoConfigGroup.

I’m open to hearing better names for init_gizmo_group_delayed_render

Testing

  • After modifying the split_screen example to ShowFrustumGizmo’s for each camera, ran cargo run --example split_screen. The frustum gizmos look fine and does not lag when rotating the camera.
  • cargo run --example debug_frustum_culling --features="free_camera” still looks good. Aabb’s correctly contain the shapes.
  • The reproduction example in Gizmos render unreliably #22438 works as expected. After pressing D to hide the constant gizmo, Pressing A or S for the one frame gizmos renders for the frame.

.init_resource::<GizmoStorage<Config, Swap<Fixed>>>()
// This ensures gizmos in this GizmoConfigGroup that are configured to update
// meshes in `PostUpdate` are rendered in the same frame.
.configure_sets(PostUpdate, GizmoMeshSystems.before(AssetEventSystems))
Copy link
Contributor Author

@kfc35 kfc35 Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first of two differences between init_group_with_mesh_sys_schedule and the former init_gizmo_group

.in_set(bevy_app::RunFixedMainLoopSystems::AfterFixedMainLoop),
)
.add_systems(
mesh_sys_schedule,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

& this is the second difference

@kfc35 kfc35 added A-Gizmos Visual editor and debug gizmos S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Feb 15, 2026
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22964

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@kfc35 kfc35 force-pushed the 22438_gizmo_single_frame_take_2 branch from 570e820 to 6f68625 Compare February 15, 2026 04:36
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22964

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

1 similar comment
@github-actions
Copy link
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22964

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@kfc35 kfc35 added the C-Bug An unexpected or incorrect behavior label Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gizmos render unreliably

1 participant