Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt changes to bevy v0.15.0-rc.2 #255

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog

## 0.13.0-rc.1
- Support for Bevy 0.15.0-rc.2.
- Removed deprecated `SpatialBundle` from `ShapeBundle`: `Transform` and `Visibility` are now added separately.

## 0.12.0
- Support for Bevy 0.14.

Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ license = "MIT OR Apache-2.0"
name = "bevy_prototype_lyon"
readme = "README.md"
repository = "https://github.com/Nilirad/bevy_prototype_lyon/"
version = "0.12.0"
version = "0.13.0-rc.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15.0-rc.2", default-features = false, features = [
"bevy_sprite",
"bevy_render",
"bevy_core_pipeline",
"bevy_asset",
] }
lyon_tessellation = "1"
lyon_algorithms = "1"
svgtypes = "0.12"
svgtypes = "0.15"

[dev-dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15.0-rc.2", default-features = false, features = [
"x11",
"bevy_asset",
] }
11 changes: 5 additions & 6 deletions examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use bevy_prototype_lyon::prelude::*;

fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins((DefaultPlugins, ShapePlugin))
.add_systems(Startup, setup_system)
.add_systems(Update, change_draw_mode_system)
Expand All @@ -18,16 +17,16 @@ fn main() {
struct ExampleShape;

fn rotate_shape_system(mut query: Query<&mut Transform, With<ExampleShape>>, time: Res<Time>) {
let delta = time.delta_seconds();
let delta = time.delta_secs();

for mut transform in query.iter_mut() {
transform.rotate(Quat::from_rotation_z(0.2 * delta));
}
}

fn change_draw_mode_system(mut query: Query<(&mut Fill, &mut Stroke)>, time: Res<Time>) {
let hue = (time.elapsed_seconds_f64() * 50.0) % 360.0;
let outline_width = 2.0 + time.elapsed_seconds_f64().sin().abs() * 10.0;
let hue = (time.elapsed_secs_f64() * 50.0) % 360.0;
let outline_width = 2.0 + time.elapsed_secs_f64().sin().abs() * 10.0;

for (mut fill_mode, mut stroke_mode) in query.iter_mut() {
fill_mode.color = Color::hsl(hue as f32, 1.0, 0.5);
Expand All @@ -36,7 +35,7 @@ fn change_draw_mode_system(mut query: Query<(&mut Fill, &mut Stroke)>, time: Res
}

fn change_number_of_sides(mut query: Query<&mut Path>, time: Res<Time>) {
let sides = ((time.elapsed_seconds_f64() - PI * 2.5).sin() * 2.5 + 5.5).round() as usize;
let sides = ((time.elapsed_secs_f64() - PI * 2.5).sin() * 2.5 + 5.5).round() as usize;

for mut path in query.iter_mut() {
let polygon = shapes::RegularPolygon {
Expand All @@ -56,7 +55,7 @@ fn setup_system(mut commands: Commands) {
..shapes::RegularPolygon::default()
};

commands.spawn(Camera2dBundle::default());
commands.spawn((Camera2d, Msaa::Sample4));
commands.spawn((
ShapeBundle {
path: GeometryBuilder::build_as(&shape),
Expand Down
9 changes: 3 additions & 6 deletions examples/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use bevy_prototype_lyon::prelude::*;

fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins((DefaultPlugins, ShapePlugin))
.add_systems(Startup, setup_system)
.run();
Expand All @@ -25,14 +24,12 @@ fn setup_system(mut commands: Commands) {
path_builder.close();
let path = path_builder.build();

commands.spawn(Camera2dBundle::default());
commands.spawn((Camera2d, Msaa::Sample4));
commands.spawn((
ShapeBundle {
path,
spatial: SpatialBundle {
transform: Transform::from_xyz(0., 75., 0.),
..default()
},
transform: Transform::from_xyz(0., 75., 0.),
visibility: default(),
..default()
},
Stroke::new(BLACK, 10.0),
Expand Down
3 changes: 1 addition & 2 deletions examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use bevy_prototype_lyon::prelude::*;

fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins((DefaultPlugins, ShapePlugin))
.add_systems(Startup, setup_system)
.run();
Expand All @@ -19,7 +18,7 @@ fn setup_system(mut commands: Commands) {
..shapes::RegularPolygon::default()
};

commands.spawn(Camera2dBundle::default());
commands.spawn((Camera2d, Msaa::Sample4));
commands.spawn((
ShapeBundle {
path: GeometryBuilder::build_as(&shape),
Expand Down
3 changes: 1 addition & 2 deletions examples/rounded_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use bevy_prototype_lyon::prelude::*;

fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins((DefaultPlugins, ShapePlugin))
.add_systems(Startup, setup_system)
.run();
Expand All @@ -27,7 +26,7 @@ fn setup_system(mut commands: Commands) {
closed: false,
};

commands.spawn(Camera2dBundle::default());
commands.spawn((Camera2d, Msaa::Sample4));
commands.spawn((
ShapeBundle {
path: GeometryBuilder::build_as(&shape),
Expand Down
22 changes: 8 additions & 14 deletions examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use bevy_prototype_lyon::prelude::*;

fn main() {
App::new()
//Added msaa to reduce aliasing
.insert_resource(Msaa::Sample4)
.add_plugins((DefaultPlugins, ShapePlugin))
.add_systems(Startup, setup_system)
.run();
Expand All @@ -17,16 +15,14 @@ struct BlacksmithMarker;
struct ToolShackMarker;

fn setup_system(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn((Camera2d, Msaa::Sample4));

commands
.spawn((
Name::new("Blacksmith"),
BlacksmithMarker,
SpatialBundle {
transform: Transform::from_translation(Vec3::new(-50., 0., 0.)),
..default()
},
Transform::from_translation(Vec3::new(-50., 0., 0.)),
Visibility::default(),
))
//we split our art in this example to two children because our art is made out of 2 paths,
//one path who's width is 4,
Expand Down Expand Up @@ -60,14 +56,12 @@ fn setup_system(mut commands: Commands) {
.spawn((
Name::new("Shack"),
ToolShackMarker,
SpatialBundle {
transform: Transform {
translation: Vec3::new(375., 0., 0.),
scale: Vec3::new(0.1, 0.1, 1.),
..Default::default()
},
..default()
Transform {
translation: Vec3::new(375., 0., 0.),
scale: Vec3::new(0.1, 0.1, 1.),
..Default::default()
},
Visibility::default(),
))
//we split our art in this example to two children because our art is made out of 2 paths,
//one path who's width is 4,
Expand Down
14 changes: 8 additions & 6 deletions src/entity.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Custom Bevy ECS bundle for shapes.

use bevy::{prelude::*, sprite::Mesh2dHandle};
use bevy::prelude::*;
use lyon_tessellation::{self as tess};

use crate::{geometry::Geometry, plugin::COLOR_MATERIAL_HANDLE};
Expand All @@ -10,18 +10,20 @@ use crate::{geometry::Geometry, plugin::COLOR_MATERIAL_HANDLE};
#[derive(Bundle, Clone)]
pub struct ShapeBundle {
pub path: Path,
pub mesh: Mesh2dHandle,
pub material: Handle<ColorMaterial>,
pub spatial: SpatialBundle,
pub mesh: Mesh2d,
pub material: MeshMaterial2d<ColorMaterial>,
pub transform: Transform,
pub visibility: Visibility,
}

impl Default for ShapeBundle {
fn default() -> Self {
Self {
path: default(),
mesh: default(),
material: COLOR_MATERIAL_HANDLE,
spatial: default(),
material: MeshMaterial2d(COLOR_MATERIAL_HANDLE),
transform: default(),
visibility: default(),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use bevy::{
color::palettes,
prelude::*,
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
sprite::Mesh2dHandle,
};
use lyon_tessellation::{self as tess, BuffersBuilder};

Expand Down Expand Up @@ -69,7 +68,7 @@ fn mesh_shapes_system(
mut fill_tess: ResMut<FillTessellator>,
mut stroke_tess: ResMut<StrokeTessellator>,
mut query: Query<
(Option<&Fill>, Option<&Stroke>, &Path, &mut Mesh2dHandle),
(Option<&Fill>, Option<&Stroke>, &Path, &mut Mesh2d),
Or<(Changed<Path>, Changed<Fill>, Changed<Stroke>)>,
>,
) {
Expand Down
Loading