
* delegate layout reflection to RenderResourceContext Also: * auto-reflect DynamicBindings * use RenderPipeline::new, update dynamic_bindings linting. * add dynamic binding generation Co-authored-by: Carter Anderson <mcanders1@gmail.com>
83 lines
2.6 KiB
Rust
83 lines
2.6 KiB
Rust
use crate::{
|
|
render::SPRITE_PIPELINE_HANDLE, sprite::Sprite, ColorMaterial, TextureAtlas,
|
|
TextureAtlasSprite, QUAD_HANDLE, SPRITE_SHEET_PIPELINE_HANDLE,
|
|
};
|
|
use bevy_asset::Handle;
|
|
use bevy_ecs::Bundle;
|
|
use bevy_render::{
|
|
mesh::Mesh,
|
|
pipeline::{RenderPipeline, RenderPipelines},
|
|
prelude::Draw,
|
|
render_graph::base::MainPass,
|
|
};
|
|
use bevy_transform::prelude::{GlobalTransform, Transform};
|
|
|
|
#[derive(Bundle)]
|
|
pub struct SpriteComponents {
|
|
pub sprite: Sprite,
|
|
pub mesh: Handle<Mesh>, // TODO: maybe abstract this out
|
|
pub material: Handle<ColorMaterial>,
|
|
pub main_pass: MainPass,
|
|
pub draw: Draw,
|
|
pub render_pipelines: RenderPipelines,
|
|
pub transform: Transform,
|
|
pub global_transform: GlobalTransform,
|
|
}
|
|
|
|
impl Default for SpriteComponents {
|
|
fn default() -> Self {
|
|
Self {
|
|
mesh: QUAD_HANDLE,
|
|
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
|
SPRITE_PIPELINE_HANDLE,
|
|
)]),
|
|
draw: Draw {
|
|
is_transparent: true,
|
|
..Default::default()
|
|
},
|
|
sprite: Default::default(),
|
|
main_pass: MainPass,
|
|
material: Default::default(),
|
|
transform: Default::default(),
|
|
global_transform: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 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<TextureAtlas>,
|
|
/// Data pertaining to how the sprite is drawn on the screen
|
|
pub draw: Draw,
|
|
pub render_pipelines: RenderPipelines,
|
|
pub main_pass: MainPass,
|
|
pub mesh: Handle<Mesh>, // TODO: maybe abstract this out
|
|
pub transform: Transform,
|
|
pub global_transform: GlobalTransform,
|
|
}
|
|
|
|
impl Default for SpriteSheetComponents {
|
|
fn default() -> Self {
|
|
Self {
|
|
render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new(
|
|
SPRITE_SHEET_PIPELINE_HANDLE,
|
|
)]),
|
|
draw: Draw {
|
|
is_transparent: true,
|
|
..Default::default()
|
|
},
|
|
mesh: QUAD_HANDLE,
|
|
main_pass: MainPass,
|
|
sprite: Default::default(),
|
|
texture_atlas: Default::default(),
|
|
transform: Default::default(),
|
|
global_transform: Default::default(),
|
|
}
|
|
}
|
|
}
|