Skip to content

Commit

Permalink
doc: view_visibility docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyHappening committed May 26, 2024
1 parent 9696982 commit 8e20192
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct MaterialMeshBundle<M: Material> {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand Down Expand Up @@ -91,7 +91,7 @@ pub struct PointLightBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand All @@ -107,7 +107,7 @@ pub struct SpotLightBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand All @@ -125,6 +125,6 @@ pub struct DirectionalLightBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/meshlet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct MaterialMeshletMeshBundle<M: Material> {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy_ecs::{prelude::*, query::QueryFilter};
use bevy_hierarchy::{Children, Parent};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_transform::{components::GlobalTransform, TransformSystem};
use bevy_utils::{Parallel, TypeIdMap};
use bevy_utils::{include_doc, Parallel, TypeIdMap};

use crate::{
camera::{Camera, CameraProjection},
Expand Down Expand Up @@ -141,11 +141,11 @@ impl ViewVisibility {
/// * You may use the [`VisibilityBundle`] to guarantee this.
#[derive(Bundle, Debug, Clone, Default)]
pub struct VisibilityBundle {
/// The visibility of the entity.
#[doc = include_doc!(visibility)]
pub visibility: Visibility,
// The inherited visibility of the entity.
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
// The computed visibility of the entity.
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct SpriteBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}

Expand Down Expand Up @@ -65,6 +65,6 @@ pub struct SpriteSheetBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
}
2 changes: 1 addition & 1 deletion crates/bevy_text/src/text2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct Text2dBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Contains the size of the text and its glyph's position and scale data. Generated via [`TextPipeline::queue_text`]
pub text_layout_info: TextLayoutInfo,
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_ui/src/node_bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct NodeBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down Expand Up @@ -116,7 +116,7 @@ pub struct ImageBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down Expand Up @@ -166,7 +166,7 @@ pub struct AtlasImageBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down Expand Up @@ -207,7 +207,7 @@ pub struct TextBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down Expand Up @@ -335,7 +335,7 @@ pub struct ButtonBundle {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down Expand Up @@ -391,7 +391,7 @@ pub struct MaterialNodeBundle<M: UiMaterial> {
pub visibility: Visibility,
#[doc = include_doc!(inherited_visibility)]
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[doc = include_doc!(view_visibility)]
pub view_visibility: ViewVisibility,
/// Indicates the depth at which the node should appear in the UI
pub z_index: ZIndex,
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_utils/src/include_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ macro_rules! include_doc {
env!("CARGO_MANIFEST_DIR"),
"/../../inline-docs/visibility.md"
))
};
(view_visibility) => {
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../inline-docs/view_visibility.md"
))
};
}
11 changes: 11 additions & 0 deletions inline-docs/view_visibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering

Each frame, this will be reset to `false` during [`VisibilityPropagate`] systems in [`PostUpdate`].
Later in the frame, systems in [`CheckVisibility`] will mark any visible entities using [`ViewVisibility::set`](`bevy_render::view::visibility::ViewVisibility::set`).
Because of this, values of this type will be marked as changed every frame, even when they do not change.

If you wish to add custom visibility system that sets this value, make sure you add it to the [`CheckVisibility`] set.

[`VisibilityPropagate`]: bevy_render::view::visibility::VisibilitySystems::VisibilityPropagate
[`CheckVisibility`]: bevy_render::view::visibility::VisibilitySystems::CheckVisibility
[`PostUpdate`]: bevy_app::PostUpdate

0 comments on commit 8e20192

Please sign in to comment.