Skip to content

Commit 3bd0e17

Browse files
djeedaiItsDoot
authored andcommitted
Add documentation to VisibleEntities and related (bevyengine#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
1 parent 3fc2b59 commit 3bd0e17

File tree

1 file changed

+19
-0
lines changed
  • crates/bevy_render/src/view/visibility

1 file changed

+19
-0
lines changed

crates/bevy_render/src/view/visibility/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ impl Default for ComputedVisibility {
4949
#[derive(Component)]
5050
pub struct NoFrustumCulling;
5151

52+
/// Collection of entities visible from the current view.
53+
///
54+
/// This component contains all entities which are visible from the currently
55+
/// rendered view. The collection is updated automatically by the [`check_visibility()`]
56+
/// system, and renderers can use it to optimize rendering of a particular view, to
57+
/// prevent drawing items not visible from that view.
58+
///
59+
/// This component is intended to be attached to the same entity as the [`Camera`] and
60+
/// the [`Frustum`] defining the view.
61+
///
62+
/// Currently this component is ignored by the sprite renderer, so sprite rendering
63+
/// is not optimized per view.
5264
#[derive(Clone, Component, Default, Debug, Reflect)]
5365
#[reflect(Component)]
5466
pub struct VisibleEntities {
@@ -76,6 +88,8 @@ pub enum VisibilitySystems {
7688
UpdateOrthographicFrusta,
7789
UpdatePerspectiveFrusta,
7890
UpdateProjectionFrusta,
91+
/// Label for the [`check_visibility()`] system updating each frame the [`ComputedVisibility`]
92+
/// of each entity and the [`VisibleEntities`] of each view.
7993
CheckVisibility,
8094
}
8195

@@ -149,6 +163,11 @@ pub fn update_frusta<T: Component + CameraProjection + Send + Sync + 'static>(
149163
}
150164
}
151165

166+
/// System updating the visibility of entities each frame.
167+
///
168+
/// The system is labelled with [`VisibilitySystems::CheckVisibility`]. Each frame, it updates the
169+
/// [`ComputedVisibility`] of all entities, and for each view also compute the [`VisibleEntities`]
170+
/// for that view.
152171
pub fn check_visibility(
153172
mut thread_queues: Local<ThreadLocal<Cell<Vec<Entity>>>>,
154173
mut view_query: Query<(&mut VisibleEntities, &Frustum, Option<&RenderLayers>), With<Camera>>,

0 commit comments

Comments
 (0)