From 5a6c38c97eae5485b60e459c66d921f3dc774ca7 Mon Sep 17 00:00:00 2001 From: "Spencer C. Imbleau" Date: Tue, 26 Mar 2024 08:56:25 -0400 Subject: [PATCH] refactor: cleanup --- examples/scene/Cargo.toml | 3 --- examples/scene/src/main.rs | 5 +---- src/render/systems.rs | 13 +++++++------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/examples/scene/Cargo.toml b/examples/scene/Cargo.toml index 97a0be7..7a46511 100644 --- a/examples/scene/Cargo.toml +++ b/examples/scene/Cargo.toml @@ -10,6 +10,3 @@ publish = false [dependencies] bevy_vello = { path = "../../" } bevy = { workspace = true } -bevy_pancam = { version = "0.11", features = ["bevy_egui"] } -bevy_egui = "0.25" -console_error_panic_hook = "0.1" diff --git a/examples/scene/src/main.rs b/examples/scene/src/main.rs index 57cf987..0a7ef5c 100644 --- a/examples/scene/src/main.rs +++ b/examples/scene/src/main.rs @@ -1,6 +1,5 @@ use bevy::asset::AssetMetaCheck; use bevy::prelude::*; -use bevy_egui::EguiPlugin; use bevy_vello::prelude::*; use bevy_vello::vello::{kurbo, peniko}; @@ -8,16 +7,14 @@ fn main() { let mut app = App::new(); app.insert_resource(AssetMetaCheck::Never) .add_plugins(DefaultPlugins) - .add_plugins(EguiPlugin) .add_plugins(VelloPlugin) - .add_plugins(bevy_pancam::PanCamPlugin) .add_systems(Startup, setup_vector_graphics) .add_systems(Update, simple_animation); app.run(); } fn setup_vector_graphics(mut commands: Commands) { - commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default())); + commands.spawn(Camera2dBundle::default()); commands.spawn(VelloSceneBundle { transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), ..default() diff --git a/src/render/systems.rs b/src/render/systems.rs index eeb22a2..4bc88a1 100644 --- a/src/render/systems.rs +++ b/src/render/systems.rs @@ -71,14 +71,14 @@ pub fn render_scene( let mut scene = Scene::new(); enum RenderItem<'a> { - Vector(&'a ExtractedRenderAsset), + Asset(&'a ExtractedRenderAsset), Scene(&'a ExtractedRenderScene), Text(&'a ExtractedRenderText), } let mut render_queue: Vec<(f32, CoordinateSpace, (&PreparedAffine, RenderItem))> = render_vectors .iter() - .map(|(a, b)| (b.z_index, b.render_mode, (a, RenderItem::Vector(b)))) + .map(|(a, b)| (b.z_index, b.render_mode, (a, RenderItem::Asset(b)))) .collect(); render_queue.extend(query_render_texts.iter().map(|(a, b)| { ( @@ -111,7 +111,7 @@ pub fn render_scene( // scene to be rendered for (_, _, (&PreparedAffine(affine), render_item)) in render_queue.iter_mut() { match render_item { - RenderItem::Vector(ExtractedRenderAsset { + RenderItem::Asset(ExtractedRenderAsset { asset, theme, alpha, @@ -150,11 +150,12 @@ pub fn render_scene( } } + // TODO: Vello should be ignoring 0-sized buffers in the future, so this could go away. // Prevent a panic in the vello renderer if all the items contain empty encoding data let empty_encodings = render_queue .iter() - .filter(|(_, _, (_, it))| match it { - RenderItem::Vector(a) => match &a.asset.data { + .filter(|(_, _, (_, item))| match item { + RenderItem::Asset(a) => match &a.asset.data { VectorFile::Svg { scene: svg, .. } => svg.encoding().is_empty(), VectorFile::Lottie { composition } => composition.layers.is_empty(), }, @@ -173,7 +174,7 @@ pub fn render_scene( &scene, &gpu_image.texture_view, &RenderParams { - base_color: vello::peniko::Color::BLACK.with_alpha_factor(0.0), + base_color: vello::peniko::Color::TRANSPARENT, width: gpu_image.size.x as u32, height: gpu_image.size.y as u32, antialiasing_method: vello::AaConfig::Area,