diff --git a/crates/bevy_ecs/hecs/src/query.rs b/crates/bevy_ecs/hecs/src/query.rs index 9374c9eb56b64..992166caa7129 100644 --- a/crates/bevy_ecs/hecs/src/query.rs +++ b/crates/bevy_ecs/hecs/src/query.rs @@ -240,7 +240,9 @@ impl<'a, T: Component> Fetch<'a> for FetchMut { } } -#[allow(missing_docs)] +/// Query transformer that skips entities that have a `T` component that has +/// not been mutated since the last pass of the system. This does not include +/// components that were added in since the last pass. pub struct Mutated<'a, T> { value: &'a T, } @@ -368,7 +370,8 @@ impl<'a, T: Component> Fetch<'a> for FetchAdded { } } -#[allow(missing_docs)] +/// Query transformer skipping entities that have not been either mutated or added +/// since the last pass of the system pub struct Changed<'a, T> { value: &'a T, } diff --git a/crates/bevy_sprite/src/entity.rs b/crates/bevy_sprite/src/entity.rs index af97fd7caba1a..126fc68edf080 100644 --- a/crates/bevy_sprite/src/entity.rs +++ b/crates/bevy_sprite/src/entity.rs @@ -63,10 +63,15 @@ impl Default for SpriteComponents { } } +/// A Bundle of components for drawing a single sprite from a sprite sheet (also referred +/// to as a `TextureAtlas`) #[derive(Bundle)] pub struct SpriteSheetComponents { + /// The specific sprite from the texture atlas to be drawn pub sprite: TextureAtlasSprite, + /// A handle to the texture atlas that holds the sprite images pub texture_atlas: Handle, + /// Data pertaining to how the sprite is drawn on the screen pub draw: Draw, pub render_pipelines: RenderPipelines, pub main_pass: MainPass, diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index 5858672692f35..df6f3ef989988 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -9,11 +9,14 @@ use bevy_render::{ }; use std::collections::HashMap; +/// An atlas containing multiple textures (like a spritesheet or a tilemap) #[derive(RenderResources)] pub struct TextureAtlas { + /// The handle to the texture in which the sprites are stored pub texture: Handle, // TODO: add support to Uniforms derive to write dimensions and sprites to the same buffer pub size: Vec2, + /// The specific areas of the atlas where each texture can be found #[render_resources(buffer)] pub textures: Vec, #[render_resources(ignore)] @@ -48,6 +51,8 @@ impl TextureAtlasSprite { } impl TextureAtlas { + /// Create a new `TextureAtlas` that has a texture, but does not have + /// any individual sprites specified pub fn new_empty(texture: Handle, dimensions: Vec2) -> Self { Self { texture, @@ -57,6 +62,8 @@ impl TextureAtlas { } } + /// Generate a `TextureAtlas` by splitting a texture into a grid where each + /// cell of the grid is one of the textures in the atlas pub fn from_grid( texture: Handle, size: Vec2, @@ -85,10 +92,17 @@ impl TextureAtlas { } } + /// Add a sprite to the list of textures in the `TextureAtlas` + /// + /// # Arguments + /// + /// * `rect` - The section of the atlas that contains the texture to be added, + /// from the top-left corner of the texture to the bottom-right corner pub fn add_texture(&mut self, rect: Rect) { self.textures.push(rect); } + /// How many textures are in the `TextureAtlas` pub fn len(&self) -> usize { self.textures.len() }