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

Store UI render target info locally per node #17579

Merged
merged 95 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
742fccc
Added `NodeContext` and `NodeScaleFactor` components.
ickshonpe Jan 16, 2025
f57864a
Added system to update roots nodes with the new components.
ickshonpe Jan 16, 2025
201e3bc
Require `NodeContext` and `NodeScaleFactor` on `Node`.
ickshonpe Jan 16, 2025
0894770
Added resolved target camera
ickshonpe Jan 16, 2025
8fa931c
Added `ResolvedTargetCamera` component, required it on `Node`
ickshonpe Jan 16, 2025
e59fc97
Changed queries to use the `ResolvedTargetCamera`
ickshonpe Jan 16, 2025
e4dc3e0
Fixed imports
ickshonpe Jan 16, 2025
9a671a8
Use ResolvedCameraTarget in text and layout modules
ickshonpe Jan 16, 2025
ee223cc
Updated split_screen example
ickshonpe Jan 16, 2025
691287c
Fixed interaction
ickshonpe Jan 16, 2025
d5dec43
Merge branch 'node-scale' into resolved-ui-context
ickshonpe Jan 17, 2025
ebb980c
Update widgets to use node scale factor
ickshonpe Jan 17, 2025
1b5e292
migrate box shadow module
ickshonpe Jan 17, 2025
c8f4633
migrate debug overlay module
ickshonpe Jan 17, 2025
bd3e211
Removed windowing code from layout module
ickshonpe Jan 18, 2025
991e8d0
Renamed `NodeContext` -> `ResolvedTargetSize`
ickshonpe Jan 20, 2025
7a46e16
Renamed `TargetCamera` -> `UiTargetCamera`. Fixed layout.
ickshonpe Jan 20, 2025
48684e1
Removed event handling code from layout system
ickshonpe Jan 20, 2025
79af6c3
Removed `DefaultUiCamera` query from `ui_layout_system`
ickshonpe Jan 20, 2025
cd39de6
Cleaned up imports
ickshonpe Jan 20, 2025
4eec458
Merge branch 'main' into resolved-ui-context
ickshonpe Jan 20, 2025
9022369
Fixed import in debug_overlay
ickshonpe Jan 20, 2025
e3cca8f
Merge branch 'main' into resolved-ui-context
ickshonpe Jan 24, 2025
6128422
Fixes after merge
ickshonpe Jan 24, 2025
7c79031
Rename camera_data to camera_query and remove rebinding
ickshonpe Jan 24, 2025
96ce71a
Removed unneeded camera cache
ickshonpe Jan 27, 2025
4593d41
removed more references to cameras, restructured layout updates
ickshonpe Jan 27, 2025
86147de
Removed UiLayoutSystemBuffers
ickshonpe Jan 28, 2025
f866169
flatten update layout loop, cleaned up more unused
ickshonpe Jan 28, 2025
faa7ded
cleanup
ickshonpe Jan 28, 2025
61b69b6
Removed `UiLayoutSystemRenivedComponentParam`
ickshonpe Jan 28, 2025
0929135
Removed unused import
ickshonpe Jan 28, 2025
4ba5914
Renamed `ResolvedScaleFactor` to `ResolvedUiScale`.
ickshonpe Jan 28, 2025
af42369
Merge branch 'main' into resolved-ui-context
ickshonpe Jan 28, 2025
6f82d43
Fixed spelling mistake
ickshonpe Jan 28, 2025
9f6b405
Merge branch 'main' into resolved-ui-context
ickshonpe Jan 28, 2025
acdfbcd
Fixed camera mapping for shadows
ickshonpe Jan 28, 2025
b8642fa
Merge branch 'main' into resolved-ui-context
ickshonpe Jan 30, 2025
3e1537a
Add viewport node leak tests
ickshonpe Feb 5, 2025
bb6e5e4
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 5, 2025
ffe81de
Fix for merge
ickshonpe Feb 5, 2025
28b5492
Set root viewport_id's so implicit root removal works again.
ickshonpe Feb 5, 2025
0fabc39
Renamings `ResolvedUi*` to `ComputedNode*`
ickshonpe Feb 5, 2025
1e2570a
Fixed `require` for `ComputedNode`
ickshonpe Feb 5, 2025
19fa743
clean up
ickshonpe Feb 5, 2025
eb33f37
cargo fmt --all
ickshonpe Feb 5, 2025
be63706
Required UI context components on `GhostNode`, try to only update con…
ickshonpe Feb 5, 2025
20c8035
return on already visited
ickshonpe Feb 5, 2025
d73131f
undo renaming
ickshonpe Feb 5, 2025
f229188
Fixed renaming
ickshonpe Feb 5, 2025
eb953ef
Fixed debug overlay
ickshonpe Feb 5, 2025
7b9b429
Fix system abiguities
ickshonpe Feb 5, 2025
0e0d3e7
use viewport not target size from camera
ickshonpe Feb 5, 2025
959fc67
Clean up
ickshonpe Feb 5, 2025
f135853
Fixed `measure_text_system`'s doc comments
ickshonpe Feb 5, 2025
af6a15b
Replaced `set_root_children` with `get_or_insert_implicit_root`.
ickshonpe Feb 5, 2025
d27c2bd
Reworked `computer_camera_layouts` method.
ickshonpe Feb 5, 2025
c5ea0fe
Removed `UiSurface::remove_camera_entities` method.
ickshonpe Feb 5, 2025
02b21a3
Removed debug
ickshonpe Feb 5, 2025
b1da871
Cleaned up imports
ickshonpe Feb 5, 2025
2375837
Fix errors in tests
ickshonpe Feb 5, 2025
54dceb2
Call `get_or_insert_implicit_root` in `compute_layout`
ickshonpe Feb 5, 2025
250030b
Cleanup unused for tests.
ickshonpe Feb 5, 2025
5977531
Removed `camera_entity_to_taffy` map from `UiSurface`
ickshonpe Feb 5, 2025
e5eabea
Removed `ui_camera_roots` map from `UiSurface`
ickshonpe Feb 5, 2025
9f7701d
Fixed `print_ui_layout_tree`
ickshonpe Feb 5, 2025
6cd0aff
Removed `ui_surface_tracks_camera_entities` test
ickshonpe Feb 5, 2025
268f5ef
remove more redundant test code
ickshonpe Feb 5, 2025
93c707c
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 5, 2025
544c970
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 5, 2025
a0c9a45
Fix imports
ickshonpe Feb 5, 2025
42bdc9e
Added tests for `update_ui_context_system`
ickshonpe Feb 6, 2025
9904e37
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 6, 2025
af5f7fb
Added comments to example.
ickshonpe Feb 6, 2025
b23b37e
Merge branch 'resolved-ui-context' of https://github.com/ickshonpe/be…
ickshonpe Feb 6, 2025
c3a24d5
Another test.
ickshonpe Feb 6, 2025
fc38d8d
Cleand up schedule
ickshonpe Feb 6, 2025
f323fc3
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 8, 2025
1176e32
Combine all computed target components into one component `ComputedNo…
ickshonpe Feb 8, 2025
5e6412d
Update crates/bevy_ui/src/lib.rs
ickshonpe Feb 8, 2025
5bb06c1
fixed GhostNode requirements
ickshonpe Feb 8, 2025
c57f5fc
Merge branch 'resolved-ui-context' of https://github.com/ickshonpe/be…
ickshonpe Feb 8, 2025
c0acc45
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 8, 2025
5f86ead
fixed debug overlay module
ickshonpe Feb 8, 2025
1ecd9a2
fixed imports
ickshonpe Feb 8, 2025
4d043f3
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 8, 2025
f8dc5ea
Fixed import
ickshonpe Feb 8, 2025
61568d2
Merge branch 'resolved-ui-context' of https://github.com/ickshonpe/be…
ickshonpe Feb 8, 2025
a352c7b
fixed split screen example
ickshonpe Feb 8, 2025
a3006ad
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 9, 2025
4742081
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 9, 2025
041a27e
moved update system to Prepare
ickshonpe Feb 9, 2025
d3bbe8d
fixed doc comment link
ickshonpe Feb 9, 2025
e848031
Improve ComputedNodeTarget docs
alice-i-cecile Feb 10, 2025
d7ce302
Merge branch 'main' into resolved-ui-context
ickshonpe Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/bevy_ui/src/experimental/ghost_hierarchy.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! This module contains [`GhostNode`] and utilities to flatten the UI hierarchy, traversing past ghost nodes.

#[cfg(feature = "ghost_nodes")]
use crate::ui_node::ComputedNodeTarget;
use crate::Node;
use bevy_ecs::{prelude::*, system::SystemParam};

#[cfg(feature = "ghost_nodes")]
use bevy_reflect::prelude::*;
#[cfg(feature = "ghost_nodes")]
Expand All @@ -11,7 +12,6 @@ use bevy_render::view::Visibility;
use bevy_transform::prelude::Transform;
#[cfg(feature = "ghost_nodes")]
use smallvec::SmallVec;

/// Marker component for entities that should be ignored within UI hierarchies.
///
/// The UI systems will traverse past these and treat their first non-ghost descendants as direct children of their first non-ghost ancestor.
Expand All @@ -21,7 +21,7 @@ use smallvec::SmallVec;
#[derive(Component, Debug, Copy, Clone, Reflect)]
#[cfg_attr(feature = "ghost_nodes", derive(Default))]
#[reflect(Component, Debug)]
#[require(Visibility, Transform)]
#[require(Visibility, Transform, ComputedNodeTarget)]
pub struct GhostNode;

#[cfg(feature = "ghost_nodes")]
Expand Down
14 changes: 3 additions & 11 deletions crates/bevy_ui/src/focus.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
CalculatedClip, ComputedNode, DefaultUiCamera, ResolvedBorderRadius, UiStack, UiTargetCamera,
};
use crate::{CalculatedClip, ComputedNode, ComputedNodeTarget, ResolvedBorderRadius, UiStack};
use bevy_ecs::{
change_detection::DetectChangesMut,
entity::{Entity, EntityBorrow},
Expand Down Expand Up @@ -141,7 +139,7 @@ pub struct NodeQuery {
focus_policy: Option<&'static FocusPolicy>,
calculated_clip: Option<&'static CalculatedClip>,
inherited_visibility: Option<&'static InheritedVisibility>,
target_camera: Option<&'static UiTargetCamera>,
target_camera: &'static ComputedNodeTarget,
}

/// The system that sets Interaction for all UI elements based on the mouse cursor activity
Expand All @@ -150,7 +148,6 @@ pub struct NodeQuery {
pub fn ui_focus_system(
mut state: Local<State>,
camera_query: Query<(Entity, &Camera)>,
default_ui_camera: DefaultUiCamera,
primary_window: Query<Entity, With<PrimaryWindow>>,
windows: Query<&Window>,
mouse_button_input: Res<ButtonInput<MouseButton>>,
Expand Down Expand Up @@ -212,8 +209,6 @@ pub fn ui_focus_system(
})
.collect();

let default_camera_entity = default_ui_camera.get();

// prepare an iterator that contains all the nodes that have the cursor in their rect,
// from the top node to the bottom one. this will also reset the interaction to `None`
// for all nodes encountered that are no longer hovered.
Expand All @@ -237,10 +232,7 @@ pub fn ui_focus_system(
}
return None;
}
let camera_entity = node
.target_camera
.map(UiTargetCamera::entity)
.or(default_camera_entity)?;
let camera_entity = node.target_camera.camera()?;

let node_rect = Rect::from_center_size(
node.global_transform.translation().truncate(),
Expand Down
23 changes: 11 additions & 12 deletions crates/bevy_ui/src/layout/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ pub fn print_ui_layout_tree(ui_surface: &UiSurface) {
.iter()
.map(|(entity, node)| (node.id, *entity))
.collect();
for (&entity, roots) in &ui_surface.camera_roots {
for (&entity, &viewport_node) in &ui_surface.root_entity_to_viewport_node {
let mut out = String::new();
for root in roots {
print_node(
ui_surface,
&taffy_to_entity,
entity,
root.implicit_viewport_node,
false,
String::new(),
&mut out,
);
}
print_node(
ui_surface,
&taffy_to_entity,
entity,
viewport_node,
false,
String::new(),
&mut out,
);

tracing::info!("Layout tree for camera entity: {entity}\n{out}");
}
}
Expand Down
Loading
Loading