From e85390e360d09d001ec1521823975f52bb125565 Mon Sep 17 00:00:00 2001 From: James Gayfer <10660608+jgayfer@users.noreply.github.com> Date: Wed, 4 Dec 2024 21:37:00 -0800 Subject: [PATCH] Update to Bevy 0.15 (#39) * Initial 0.15 support More work needed to move things over to required components and to ensure extraction is done correctly, but gets us to the point where bevy_light_2d is usable with bevy 0.15. * Migrate to required components Required components allow us to move away from bundles (yay!) and into a much simpler API. I've always disliked how much of Bevy's internal components we need to have in our bundles. * Update README.md example for required components * Deprecate bundles We can get away with inserting only components now. * Update README.md for 0.5 * Update CHANGELOG.md * Cut first 0.5 release candidate * Update the build * Add bevy_window feature flag * Add tracker links for feature flag workarounds. * Relax Bevy requirements * Update CHANGELOG.md --- CHANGELOG.md | 18 +++++++ Cargo.toml | 14 +++-- README.md | 20 ++++--- examples/basic.rs | 11 ++-- examples/dungeon.rs | 59 ++++++++++---------- examples/multiple.rs | 38 ++++++------- examples/occlusion.rs | 93 +++++++++++++------------------- src/lib.rs | 1 + src/light.rs | 11 +++- src/occluder.rs | 11 +++- src/render/extract.rs | 57 +++++++++++++------- src/render/light_map/pipeline.rs | 1 + src/render/lighting/pipeline.rs | 3 +- src/render/sdf/pipeline.rs | 1 + 14 files changed, 185 insertions(+), 153 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff124d9..c035c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.0] - 2024-12-04 + +### Added + +- Added required component support for `PointLight2d` (#39). +- Added required component support for `LightOccluder2d` (#39). + +### Changed + +- Updated Bevy version from `0.14` to `0.15` (#39). +- Deprecated `PointLight2dBundle` in favour of `PointLight2d` (#39). +- Deprecated `LightOccluder2dBundle` in favour of `LightOccluder2d` (#39). + +### Migration guide + +- Replace all uses of `PointLight2dBundle` with `PointLight2d`. +- Replace all uses of `LightOccluder2dBundle` with `LightOccluder2d`. + ## [0.4.2] - 2024-10-25 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 80e236a..cff38b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_light_2d" -version = "0.4.2" +version = "0.5.0" edition = "2021" categories = ["game-engines", "graphics", "rendering"] description = "General purpose 2d lighting for the Bevy game engine." @@ -11,22 +11,28 @@ readme = "README.md" exclude = ["assets/*", "static/*"] [dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15", default-features = false, features = [ "bevy_render", "bevy_core_pipeline", "bevy_winit", "x11", + # TODO: Remove when https://github.com/bevyengine/bevy/issues/16568 is resolved. + "bevy_window", + # TODO: Remove when https://github.com/bevyengine/bevy/issues/16563 is resolved. + "png" ] } smallvec = "1.13" [dev-dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15", default-features = false, features = [ "bevy_render", "bevy_core_pipeline", "bevy_winit", "bevy_sprite", "png", - "x11" + "x11", + # TODO: Remove when https://github.com/bevyengine/bevy/issues/16568 is resolved. + "bevy_window" ] } [lints.clippy] diff --git a/README.md b/README.md index e885706..56a6c47 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ In the [`basic`](https://github.com/jgayfer/bevy_light_2d/blob/main/examples/bas ```toml # Cargo.toml [dependencies] -bevy = "0.14" -bevy_light_2d = "0.4" +bevy = "0.15" +bevy_light_2d = "0.5" ``` ```rust @@ -41,18 +41,15 @@ fn main() { App::new() .add_plugins((DefaultPlugins, Light2dPlugin)) .add_systems(Startup, setup) - .run() + .run(); } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); - - commands.spawn(PointLight2dBundle { - point_light: PointLight2d { - radius: 100.0, - intensity: 3.0, - ..default() - }, + commands.spawn(Camera2d); + + commands.spawn(PointLight2d { + intensity: 3.0, + radius: 100.0, ..default() }); } @@ -74,6 +71,7 @@ general application over depth of features. | bevy | bevy_light_2d | |------|---------------| +| 0.15 | 0.5 | | 0.14 | 0.2..0.4 | | 0.13 | 0.1 | diff --git a/examples/basic.rs b/examples/basic.rs index 1829db6..2779883 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -9,14 +9,11 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); - commands.spawn(PointLight2dBundle { - point_light: PointLight2d { - intensity: 3.0, - radius: 100.0, - ..default() - }, + commands.spawn(PointLight2d { + intensity: 3.0, + radius: 100.0, ..default() }); } diff --git a/examples/dungeon.rs b/examples/dungeon.rs index 48166da..e03b5f9 100644 --- a/examples/dungeon.rs +++ b/examples/dungeon.rs @@ -38,10 +38,11 @@ struct Candle; struct AnimationTimer(Timer); fn setup_camera(mut commands: Commands) { - let mut camera = Camera2dBundle::default(); - camera.projection.scale = 0.25; + let mut projection = OrthographicProjection::default_2d(); + projection.scale = 0.25; commands.spawn(( - camera, + Camera2d, + projection, AmbientLight2d { brightness: 0.1, ..default() @@ -55,44 +56,44 @@ fn set_clear_color(mut clear_color: ResMut) { fn animate_candles( time: Res