Skip to content

Commit 8fe6781

Browse files
authored
Update the doc comments for UiCameraMap and UiCameraMapper. (#20521)
# Objective The docs comments for `UiCameraMap` and `UiCameraMapper` are out of date and incorrectly refer to a default camera and `UiTargetCamera` that aren't present. ## Solution Update the doc comments
1 parent f5363c6 commit 8fe6781

File tree

1 file changed

+9
-2
lines changed
  • crates/bevy_ui_render/src

1 file changed

+9
-2
lines changed

crates/bevy_ui_render/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ pub struct UiCameraMap<'w, 's> {
301301
}
302302

303303
impl<'w, 's> UiCameraMap<'w, 's> {
304-
/// Get the default camera and create the mapper
304+
/// Creates a [`UiCameraMapper`] for performing repeated camera-to-render-entity lookups.
305+
///
306+
/// The last successful mapping is cached to avoid redundant queries.
305307
pub fn get_mapper(&'w self) -> UiCameraMapper<'w, 's> {
306308
UiCameraMapper {
307309
mapping: &self.mapping,
@@ -311,14 +313,18 @@ impl<'w, 's> UiCameraMap<'w, 's> {
311313
}
312314
}
313315

316+
/// Helper for mapping UI target camera entities to their corresponding render entities,
317+
/// with caching to avoid repeated lookups for the same camera.
314318
pub struct UiCameraMapper<'w, 's> {
315319
mapping: &'w Query<'w, 's, RenderEntity>,
320+
/// Cached camera entity from the last successful `map` call.
316321
camera_entity: Entity,
322+
/// Cached camera entity from the last successful `map` call.
317323
render_entity: Entity,
318324
}
319325

320326
impl<'w, 's> UiCameraMapper<'w, 's> {
321-
/// Returns the render entity corresponding to the given `UiTargetCamera` or the default camera if `None`.
327+
/// Returns the render entity corresponding to the given [`ComputedUiTargetCamera`]'s camera, or none if no corresponding entity was found.
322328
pub fn map(&mut self, computed_target: &ComputedUiTargetCamera) -> Option<Entity> {
323329
let camera_entity = computed_target.camera()?;
324330
if self.camera_entity != camera_entity {
@@ -330,6 +336,7 @@ impl<'w, 's> UiCameraMapper<'w, 's> {
330336
Some(self.render_entity)
331337
}
332338

339+
/// Returns the cached camera entity from the last successful `map` call.
333340
pub fn current_camera(&self) -> Entity {
334341
self.camera_entity
335342
}

0 commit comments

Comments
 (0)