From 3bd0e1713d484e66c952fc1be886b65da0051c49 Mon Sep 17 00:00:00 2001 From: Jerome Humbert Date: Sat, 2 Jul 2022 07:00:04 +0000 Subject: [PATCH] Add documentation to `VisibleEntities` and related (#5100) # Objective Add missing docs ## Solution Add documentation to the `VisibleEntities` component, its related `check_visibility()` system, and that system's label. See Discord discussion here : https://discord.com/channels/691052431525675048/866787577687310356/990432663921901678 --- crates/bevy_render/src/view/visibility/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 795a860bd0e49b..ef859404a2b729 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -49,6 +49,18 @@ impl Default for ComputedVisibility { #[derive(Component)] pub struct NoFrustumCulling; +/// Collection of entities visible from the current view. +/// +/// This component contains all entities which are visible from the currently +/// rendered view. The collection is updated automatically by the [`check_visibility()`] +/// system, and renderers can use it to optimize rendering of a particular view, to +/// prevent drawing items not visible from that view. +/// +/// This component is intended to be attached to the same entity as the [`Camera`] and +/// the [`Frustum`] defining the view. +/// +/// Currently this component is ignored by the sprite renderer, so sprite rendering +/// is not optimized per view. #[derive(Clone, Component, Default, Debug, Reflect)] #[reflect(Component)] pub struct VisibleEntities { @@ -76,6 +88,8 @@ pub enum VisibilitySystems { UpdateOrthographicFrusta, UpdatePerspectiveFrusta, UpdateProjectionFrusta, + /// Label for the [`check_visibility()`] system updating each frame the [`ComputedVisibility`] + /// of each entity and the [`VisibleEntities`] of each view. CheckVisibility, } @@ -149,6 +163,11 @@ pub fn update_frusta( } } +/// System updating the visibility of entities each frame. +/// +/// The system is labelled with [`VisibilitySystems::CheckVisibility`]. Each frame, it updates the +/// [`ComputedVisibility`] of all entities, and for each view also compute the [`VisibleEntities`] +/// for that view. pub fn check_visibility( mut thread_queues: Local>>>, mut view_query: Query<(&mut VisibleEntities, &Frustum, Option<&RenderLayers>), With>,