Skip to content

Commit

Permalink
Update 0.9.0 (#220)
Browse files Browse the repository at this point in the history
* Update code after changes of systems api in bevy (#208)

Breaking changes were introduced in
bevyengine/bevy#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 <[email protected]>
  • Loading branch information
Nilirad and iwek7 authored Jul 10, 2023
1 parent 949c352 commit 2d4de13
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.9.0
- Support for Bevy 0.11.

## 0.8.0
- Support for Bevy 0.10.
- Uses original render.
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
}

Expand Down Expand Up @@ -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|
Expand Down
10 changes: 5 additions & 5 deletions examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/rounded_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
19 changes: 10 additions & 9 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand All @@ -72,7 +73,7 @@ fn mesh_shapes_system(
Or<(Changed<Path>, Changed<Fill>, Changed<Stroke>)>,
>,
) {
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 {
Expand Down
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Plugin for ShapeMaterialPlugin {
Shader::from_wgsl
);

app.add_plugin(Material2dPlugin::<ShapeMaterial>::default())
app.add_plugins(Material2dPlugin::<ShapeMaterial>::default())
.register_asset_reflect::<ShapeMaterial>();

app.world
Expand All @@ -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 {}
9 changes: 3 additions & 6 deletions src/render/shape_material.wgsl
Original file line number Diff line number Diff line change
@@ -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<f32>;
Expand All @@ -8,11 +9,7 @@ var texture_sampler: sampler;
@group(2) @binding(0)
var<uniform> mesh: Mesh2d;

struct FragmentInput {
#import bevy_sprite::mesh2d_vertex_output
};

@fragment
fn fragment(in: FragmentInput) -> @location(0) vec4<f32> {
fn fragment(in: MeshVertexOutput) -> @location(0) vec4<f32> {
return in.color;
}
6 changes: 3 additions & 3 deletions src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d4de13

Please sign in to comment.