Skip to content

Commit

Permalink
Squash commit (updates for Bevy 0.13)
Browse files Browse the repository at this point in the history
* Use GitHub Actions config from master branch

* Fix formatting

* Fix deprecation warnings on add_plugin

Fix CI (#218)

Fix shader (#219)

Suggest to use `cargo add` in README.md (#222)

Use `SpatialBundle` (#221)

Use `configure_sets` API (#223)

Use `MaterialMesh2dBundle` with `ColorMaterial` (#224)

* Use `MaterialMesh2dBundle` with `ColorMaterial`

* clippy

* Fix green channel filtering bug

* Clippy again

Fix clippy (#229)

* Add `RenderAssetPersistencePolicy` to `Mesh::new` call

* Use built-in `Name` component in `svg` example

Fix CI (#234)

* Use `RenderAssetUsages`

* Specify which `RegularPolygon` to use

Fix CI (#237)

Update Cargo.toml

Update `README.md`

Update CHANGELOG.md
  • Loading branch information
Nilirad committed Feb 19, 2024
1 parent 057f3e8 commit fc3a9a7
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 154 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI-cron

on:
schedule:
- cron: 0 9 * * *

env:
CARGO_TERM_COLOR: always

jobs:

build:
strategy:
matrix:
toolchain: [stable, nightly]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: bevy-main

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: fmt
if: ${{ matrix.toolchain == 'nightly' && runner.os == 'linux' }}
run: cargo fmt --all -- --check

- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
if: runner.os == 'linux'

- name: lint
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings -A unknown-lints

- name: Build & run tests
run: cargo test --workspace
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
18 changes: 6 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: CI

on:
pull_request:
branches: [master]
branches: [master, bevy-main]
push:
branches: [master]
schedule:
- cron: 0 9 * * *
branches: [master, bevy-main]

env:
CARGO_TERM_COLOR: always
Expand All @@ -20,20 +18,16 @@ jobs:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
override: true
- name: fmt
if: ${{ matrix.toolchain == 'nightly' && runner.os == 'linux' }}
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

run: cargo fmt --all -- --check

- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
if: runner.os == 'linux'
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
check-advisories:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
with:
ref: bevy-main
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- name: Install cargo-deny
run: cargo install cargo-deny
- name: Check for security advisories and unmaintained crates
Expand All @@ -37,11 +38,12 @@ jobs:
check-bans:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
with:
ref: bevy-main
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- name: Install cargo-deny
run: cargo install cargo-deny
- name: Check for banned and duplicated dependencies
Expand All @@ -50,11 +52,12 @@ jobs:
check-licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
with:
ref: bevy-main
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- name: Install cargo-deny
run: cargo install cargo-deny
- name: Check for unauthorized licenses
Expand All @@ -63,11 +66,12 @@ jobs:
check-sources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
with:
ref: bevy-main
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- name: Install cargo-deny
run: cargo install cargo-deny
- name: Checked for unauthorized crate sources
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.11.0
- Support for Bevy 0.13

## 0.10.0
- Support for Bevy 0.12

## 0.9.0
- `ShapeBundle` now contains the `spatial: SpatialBundle` field,
which bundles together
`Transform`,
`GlobalTransform`,
`Visibility`
and `InheritedVisibility`.

## 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.11.0"

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

[dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = ["bevy_sprite", "bevy_render", "bevy_core_pipeline", "bevy_asset"] }
bevy = { version = "0.13", 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 = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = ["x11", "bevy_asset"] }
bevy = { version = "0.13", default-features = false, features = ["x11", "bevy_asset"] }
11 changes: 7 additions & 4 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 cargo project:

```TOML
bevy_prototype_lyon = "0.8.0"
```shell
cargo add bevy_prototype_lyon
```

Then, you can start by drawing simple shapes:
Expand All @@ -34,7 +34,7 @@ fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.run();
}
Expand Down Expand Up @@ -68,6 +68,9 @@ The following table shows the latest version of `bevy_prototype_lyon` that suppo

|bevy|bevy_prototype_lyon|license|
|---|---|---|
|0.13|0.11|MIT/Apache 2.0|
|0.12|0.10|MIT/Apache 2.0|
|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
2 changes: 1 addition & 1 deletion examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.add_systems(Update, change_draw_mode_system)
.add_systems(Update, change_number_of_sides)
Expand Down
7 changes: 5 additions & 2 deletions examples/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.run();
}
Expand All @@ -30,7 +30,10 @@ fn setup_system(mut commands: Commands) {
commands.spawn((
ShapeBundle {
path,
transform: Transform::from_xyz(0., 75., 0.),
spatial: SpatialBundle {
transform: Transform::from_xyz(0., 75., 0.),
..default()
},
..default()
},
Stroke::new(Color::BLACK, 10.0),
Expand Down
2 changes: 1 addition & 1 deletion examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.run();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/rounded_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.run();
}
Expand Down
9 changes: 3 additions & 6 deletions examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ fn main() {
//Added msaa to reduce aliasing
.insert_resource(Msaa::Sample4)
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_plugins(ShapePlugin)
.add_systems(Startup, setup_system)
.run();
}

#[derive(Component)]
struct Name(String);

#[derive(Component)]
struct BlacksmithMarker;

Expand All @@ -25,7 +22,7 @@ fn setup_system(mut commands: Commands) {

commands
.spawn((
Name("Blacksmith".to_owned()),
Name::new("Blacksmith"),
BlacksmithMarker,
SpatialBundle {
transform: Transform::from_translation(Vec3::new(-50., 0., 0.)),
Expand Down Expand Up @@ -62,7 +59,7 @@ fn setup_system(mut commands: Commands) {

commands
.spawn((
Name("Shack".to_owned()),
Name::new("Shack"),
ToolShackMarker,
SpatialBundle {
transform: Transform {
Expand Down
28 changes: 9 additions & 19 deletions src/entity.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
//! Custom Bevy ECS bundle for shapes.

use bevy::{
ecs::{bundle::Bundle, component::Component},
prelude::{ComputedVisibility, GlobalTransform, Handle, Transform, Visibility},
sprite::Mesh2dHandle,
};
use bevy::{prelude::*, sprite::Mesh2dHandle};
use lyon_tessellation::{self as tess};

use crate::{prelude::Geometry, render::ShapeMaterial};
use crate::{geometry::Geometry, plugin::COLOR_MATERIAL_HANDLE};

/// A Bevy `Bundle` to represent a shape.
#[allow(missing_docs)]
#[derive(Bundle)]
pub struct ShapeBundle {
pub path: Path,
pub mesh: Mesh2dHandle,
pub material: Handle<ShapeMaterial>,
pub transform: Transform,
pub global_transform: GlobalTransform,
pub visibility: Visibility,
pub computed_visibility: ComputedVisibility,
pub material: Handle<ColorMaterial>,
pub spatial: SpatialBundle,
}

impl Default for ShapeBundle {
fn default() -> Self {
Self {
path: Path(tess::path::Path::new()),
mesh: Mesh2dHandle::default(),
material: Handle::<ShapeMaterial>::default(),
transform: Transform::default(),
global_transform: GlobalTransform::default(),
visibility: Visibility::default(),
computed_visibility: ComputedVisibility::default(),
path: default(),
mesh: default(),
material: COLOR_MATERIAL_HANDLE,
spatial: default(),
}
}
}

#[allow(missing_docs)]
#[derive(Component)]
#[derive(Component, Default)]
pub struct Path(pub tess::path::Path);

impl Geometry for Path {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub mod entity;
pub mod geometry;
pub mod path;
pub mod plugin;
pub mod render;
pub mod shapes;

mod utils;
Expand Down
4 changes: 2 additions & 2 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl ShapePath {
///
/// ```
/// # use bevy::prelude::*;
/// # use bevy_prototype_lyon::prelude::*;
/// # use bevy_prototype_lyon::prelude::{RegularPolygon, *};
/// #
/// # #[derive(Component)]
/// # struct Player;
Expand Down Expand Up @@ -73,7 +73,7 @@ impl ShapePath {
///
/// ```
/// # use bevy::prelude::*;
/// # use bevy_prototype_lyon::prelude::*;
/// # use bevy_prototype_lyon::prelude::{RegularPolygon, *};
/// #
/// # #[derive(Component)]
/// # struct Player;
Expand Down
Loading

0 comments on commit fc3a9a7

Please sign in to comment.