From 2d4de13724b4f8b465feaa7c322cbfc0c61f9913 Mon Sep 17 00:00:00 2001 From: Federico Rinaldi Date: Mon, 10 Jul 2023 16:47:26 +0200 Subject: [PATCH] Update 0.9.0 (#220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update code after changes of systems api in bevy (#208) Breaking changes were introduced in https://github.com/bevyengine/bevy/pull/8079 * Use GitHub Actions config from master branch (#217) * Use GitHub Actions config from master branch * Fix formatting * Fix deprecation warnings on add_plugin * Fix CI (#218) * Fix shader (#219) * Depend on Bevy 0.11 * Bump version to v0.9.0 * Use cargo add instruction in README * Update README * Update CHANGELOG --------- Co-authored-by: Michał Iwańczuk --- CHANGELOG.md | 3 +++ Cargo.toml | 6 +++--- README.md | 11 ++++++----- examples/dynamic_shape.rs | 10 +++++----- examples/path.rs | 4 ++-- examples/readme.rs | 4 ++-- examples/rounded_polygon.rs | 4 ++-- examples/svg.rs | 4 ++-- src/plugin.rs | 19 ++++++++++--------- src/render/mod.rs | 4 ++-- src/render/shape_material.wgsl | 9 +++------ src/shapes.rs | 6 +++--- 12 files changed, 43 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca26417..58e0ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.9.0 +- Support for Bevy 0.11. + ## 0.8.0 - Support for Bevy 0.10. - Uses original render. diff --git a/Cargo.toml b/Cargo.toml index f45b3df..048f84c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,15 +8,15 @@ license = "MIT OR Apache-2.0" name = "bevy_prototype_lyon" readme = "README.md" repository = "https://github.com/Nilirad/bevy_prototype_lyon/" -version = "0.8.0" +version = "0.9.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = { version = "0.10", default-features = false, features = ["bevy_sprite", "bevy_render", "bevy_core_pipeline", "bevy_asset"] } +bevy = { version = "0.11", default-features = false, features = ["bevy_sprite", "bevy_render", "bevy_core_pipeline", "bevy_asset"] } lyon_tessellation = "1" lyon_algorithms = "1" svgtypes = "0.8" [dev-dependencies] -bevy = { version = "0.10", default-features = false, features = ["x11", "bevy_asset"] } +bevy = { version = "0.11", default-features = false, features = ["x11", "bevy_asset"] } diff --git a/README.md b/README.md index 6e813d1..69415aa 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ Currently Bevy does not support drawing custom shapes in an easy way. This crate ## Usage -Add the following line in your `cargo.toml` manifest file, under the `[dependencies]` section: +Add `bevy_prototype_lyon` to your package's dependencies: -```TOML -bevy_prototype_lyon = "0.8.0" +```shell +cargo add bevy_prototype_lyon ``` Then, you can start by drawing simple shapes: @@ -34,8 +34,8 @@ fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) .run(); } @@ -68,6 +68,7 @@ The following table shows the latest version of `bevy_prototype_lyon` that suppo |bevy|bevy_prototype_lyon|license| |---|---|---| +|0.11|0.9|MIT/Apache 2.0| |0.10|0.8|MIT/Apache 2.0| |0.9|0.7|MIT/Apache 2.0| |0.8|0.6|MIT/Apache 2.0| diff --git a/examples/dynamic_shape.rs b/examples/dynamic_shape.rs index e80923c..01813bd 100644 --- a/examples/dynamic_shape.rs +++ b/examples/dynamic_shape.rs @@ -7,11 +7,11 @@ fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) - .add_system(change_draw_mode_system) - .add_system(change_number_of_sides) - .add_system(rotate_shape_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) + .add_systems(Update, change_draw_mode_system) + .add_systems(Update, change_number_of_sides) + .add_systems(Update, rotate_shape_system) .run(); } diff --git a/examples/path.rs b/examples/path.rs index 990ac45..293497c 100644 --- a/examples/path.rs +++ b/examples/path.rs @@ -5,8 +5,8 @@ fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) .run(); } diff --git a/examples/readme.rs b/examples/readme.rs index 3578bfc..dda0f71 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -8,8 +8,8 @@ fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) .run(); } diff --git a/examples/rounded_polygon.rs b/examples/rounded_polygon.rs index f4bd17e..3fc9d2c 100644 --- a/examples/rounded_polygon.rs +++ b/examples/rounded_polygon.rs @@ -5,8 +5,8 @@ fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) .run(); } diff --git a/examples/svg.rs b/examples/svg.rs index 49fc272..27d77b8 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -6,8 +6,8 @@ fn main() { //Added msaa to reduce aliasing .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) - .add_plugin(ShapePlugin) - .add_startup_system(setup_system) + .add_plugins(ShapePlugin) + .add_systems(Startup, setup_system) .run(); } diff --git a/src/plugin.rs b/src/plugin.rs index bfe9a69..31484fe 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -19,7 +19,9 @@ use bevy::{ system::{Query, ResMut, Resource}, }, log::error, - prelude::{Color, CoreSet, Deref, DerefMut, IntoSystemConfig, IntoSystemSetConfig, SystemSet}, + prelude::{ + Color, Deref, DerefMut, IntoSystemConfigs, IntoSystemSetConfig, PostUpdate, SystemSet, + }, render::{ mesh::{Indices, Mesh}, render_resource::PrimitiveTopology, @@ -46,17 +48,16 @@ impl Plugin for ShapePlugin { app.insert_resource(FillTessellator(fill_tess)) .insert_resource(StrokeTessellator(stroke_tess)) .configure_set( - BuildShapes - .in_base_set(CoreSet::PostUpdate) - .after(bevy::transform::TransformSystem::TransformPropagate), + PostUpdate, + BuildShapes.after(bevy::transform::TransformSystem::TransformPropagate), ) - .add_system(mesh_shapes_system.in_set(BuildShapes)) - .add_plugin(ShapeMaterialPlugin); + .add_systems(PostUpdate, mesh_shapes_system.in_set(BuildShapes)) + .add_plugins(ShapeMaterialPlugin); } } -/// [`SystemLabel`] for the system that builds the meshes for newly-added -/// or changed shapes. Resides in [`PostUpdate`](CoreStage::PostUpdate). +/// [`SystemSet`] for the system that builds the meshes for newly-added +/// or changed shapes. Resides in [`PostUpdate`] schedule. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] pub struct BuildShapes; @@ -72,7 +73,7 @@ fn mesh_shapes_system( Or<(Changed, Changed, Changed)>, >, ) { - for (maybe_fill_mode, maybe_stroke_mode, path, mut mesh) in query.iter_mut() { + for (maybe_fill_mode, maybe_stroke_mode, path, mut mesh) in &mut query { let mut buffers = VertexBuffers::new(); if let Some(fill_mode) = maybe_fill_mode { diff --git a/src/render/mod.rs b/src/render/mod.rs index bca31a3..95335c6 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -24,7 +24,7 @@ impl Plugin for ShapeMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(Material2dPlugin::::default()) + app.add_plugins(Material2dPlugin::::default()) .register_asset_reflect::(); app.world @@ -40,7 +40,7 @@ impl Material2d for ShapeMaterial { } /// A simple `Material2d` that renders with vertex colors. -#[derive(Default, AsBindGroup, Reflect, FromReflect, Debug, Clone, TypeUuid)] +#[derive(Default, AsBindGroup, Reflect, Debug, Clone, TypeUuid)] #[reflect(Default, Debug)] #[uuid = "ab2e068e-0cca-4941-a114-524af2c431bb"] pub struct ShapeMaterial {} diff --git a/src/render/shape_material.wgsl b/src/render/shape_material.wgsl index e674195..99b965f 100644 --- a/src/render/shape_material.wgsl +++ b/src/render/shape_material.wgsl @@ -1,5 +1,6 @@ -#import bevy_sprite::mesh2d_types +#import bevy_sprite::mesh2d_types Mesh2d #import bevy_sprite::mesh2d_view_bindings +#import bevy_sprite::mesh2d_vertex_output MeshVertexOutput @group(1) @binding(1) var texture: texture_2d; @@ -8,11 +9,7 @@ var texture_sampler: sampler; @group(2) @binding(0) var mesh: Mesh2d; -struct FragmentInput { - #import bevy_sprite::mesh2d_vertex_output -}; - @fragment -fn fragment(in: FragmentInput) -> @location(0) vec4 { +fn fragment(in: MeshVertexOutput) -> @location(0) vec4 { return in.color; } diff --git a/src/shapes.rs b/src/shapes.rs index f7ade2a..69ee0b6 100644 --- a/src/shapes.rs +++ b/src/shapes.rs @@ -291,12 +291,12 @@ impl Geometry for Line { ///offset the coordinates of the paths /// ///In inkscape for example, to turn your units into pixels, you: -///1) Go to File>Document Properties>General>Display Units and set it to px +/// 1) Go to File>Document Properties>General>Display Units and set it to px /// -///2) In File>Document Properties>Custom Size>Units set it to px, also, this +/// 2) In File>Document Properties>Custom Size>Units set it to px, also, this /// size would be used for `svg_doc_size_in_px` /// -///3) In File>Document Properties>Scale>Scale x make sure it is set to 1 User +/// 3) In File>Document Properties>Scale>Scale x make sure it is set to 1 User /// unit per px /// ///Example exists in the examples folder