More DefaultUiCamera fixes (#17120)
# Objective Found more excessive `DefaultUiCamera` queries outside of extraction. The default UI camera lookup only needs to be done once. Do it first, not per node. --------- Co-authored-by: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com>
This commit is contained in:
parent
f61de1101c
commit
d220eccbb1
@ -213,6 +213,8 @@ pub fn ui_focus_system(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let default_camera_entity = default_ui_camera.get();
|
||||||
|
|
||||||
// prepare an iterator that contains all the nodes that have the cursor in their rect,
|
// 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`
|
// 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.
|
// for all nodes encountered that are no longer hovered.
|
||||||
@ -239,7 +241,7 @@ pub fn ui_focus_system(
|
|||||||
let camera_entity = node
|
let camera_entity = node
|
||||||
.target_camera
|
.target_camera
|
||||||
.map(TargetCamera::entity)
|
.map(TargetCamera::entity)
|
||||||
.or(default_ui_camera.get())?;
|
.or(default_camera_entity)?;
|
||||||
|
|
||||||
let node_rect = Rect::from_center_size(
|
let node_rect = Rect::from_center_size(
|
||||||
node.global_transform.translation().truncate(),
|
node.global_transform.translation().truncate(),
|
||||||
|
@ -72,6 +72,8 @@ pub fn ui_picking(
|
|||||||
// For each camera, the pointer and its position
|
// For each camera, the pointer and its position
|
||||||
let mut pointer_pos_by_camera = HashMap::<Entity, HashMap<PointerId, Vec2>>::default();
|
let mut pointer_pos_by_camera = HashMap::<Entity, HashMap<PointerId, Vec2>>::default();
|
||||||
|
|
||||||
|
let default_camera_entity = default_ui_camera.get();
|
||||||
|
|
||||||
for (pointer_id, pointer_location) in
|
for (pointer_id, pointer_location) in
|
||||||
pointers.iter().filter_map(|(pointer, pointer_location)| {
|
pointers.iter().filter_map(|(pointer, pointer_location)| {
|
||||||
Some(*pointer).zip(pointer_location.location().cloned())
|
Some(*pointer).zip(pointer_location.location().cloned())
|
||||||
@ -133,7 +135,7 @@ pub fn ui_picking(
|
|||||||
let Some(camera_entity) = node
|
let Some(camera_entity) = node
|
||||||
.target_camera
|
.target_camera
|
||||||
.map(TargetCamera::entity)
|
.map(TargetCamera::entity)
|
||||||
.or(default_ui_camera.get())
|
.or(default_camera_entity)
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@ -189,7 +191,7 @@ pub fn ui_picking(
|
|||||||
let Some(camera_entity) = node
|
let Some(camera_entity) = node
|
||||||
.target_camera
|
.target_camera
|
||||||
.map(TargetCamera::entity)
|
.map(TargetCamera::entity)
|
||||||
.or(default_ui_camera.get())
|
.or(default_camera_entity)
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -268,10 +268,12 @@ pub fn measure_text_system(
|
|||||||
) {
|
) {
|
||||||
scale_factors_buffer.clear();
|
scale_factors_buffer.clear();
|
||||||
|
|
||||||
|
let default_camera_entity = default_ui_camera.get();
|
||||||
|
|
||||||
for (entity, block, content_size, text_flags, computed, maybe_camera) in &mut text_query {
|
for (entity, block, content_size, text_flags, computed, maybe_camera) in &mut text_query {
|
||||||
let Some(camera_entity) = maybe_camera
|
let Some(camera_entity) = maybe_camera
|
||||||
.map(TargetCamera::entity)
|
.map(TargetCamera::entity)
|
||||||
.or(default_ui_camera.get())
|
.or(default_camera_entity)
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user