From ed546afa64ec7e5ac92238107604f325f7cce2c7 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 01:28:08 -0400 Subject: [PATCH 01/38] migration guide 0.8-0.9 --- .../book/migration-guides/0.8-0.9/_index.md | 341 ++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 content/learn/book/migration-guides/0.8-0.9/_index.md diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md new file mode 100644 index 0000000000..0072412c04 --- /dev/null +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -0,0 +1,341 @@ + ++++ +title = "0.8 to 0.9" +weight = 5 +sort_by = "weight" +template = "book-section.html" +page_template = "book-section.html" +insert_anchor_links = "right" +[extra] +long_title = "Migration Guide: 0.8 to 0.9" ++++ + +### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) + + + +### [Plugins own their settings. Rework PluginGroup trait.](https://github.com/bevyengine/bevy/pull/6336) + +The `WindowDescriptor` settings have been moved from a resource to `WindowPlugin::window`: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(WindowDescriptor { + width: 400.0, + ..default() + }) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + width: 400.0, + ..default() + }, + ..default() +})) +``` + +The `AssetServerSettings` resource has been removed in favor of direct `AssetPlugin` configuration: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(AssetServerSettings { + watch_for_changes: true, + ..default() + }) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() +})) +``` + +`add_plugins_with` has been replaced by `add_plugins` in combination with the builder pattern: + +```rust +// Old (Bevy 0.8) +app.add_plugins_with(DefaultPlugins, |group| group.disable::()); + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.build().disable::()); +``` + +### [Add a method for accessing the width of a `Table`](https://github.com/bevyengine/bevy/pull/6249) + +Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table::capacity` should now be `Table::entity_capacity`. + +### [Replace the `bool` argument of `Timer` with `TimerMode`](https://github.com/bevyengine/bevy/pull/6247) + +* Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`. +* Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`. +* Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`. +* Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. +* Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. + +### [Rename system chaining to system piping](https://github.com/bevyengine/bevy/pull/6230) + +The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. +The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struct is now `PipeSystem`. + +### [Make the default background color of `NodeBundle` transparent](https://github.com/bevyengine/bevy/pull/6211) + +If you want a `NodeBundle` with a white background color, you must explicitly specify it: + +Before: + +```rust +let node = NodeBundle { + ..default() +} +``` + +After: + +```rust +let node = NodeBundle { + background_color: Color::WHITE.into(), + ..default() +} +``` + +### [make `Handle::` field id private, and replace with a getter](https://github.com/bevyengine/bevy/pull/6176) + +* If you were accessing the value `handle.id`, you can now do so with `handle.id()` + +### [Add `TimeUpdateStrategy` resource for manual `Time` updating](https://github.com/bevyengine/bevy/pull/6159) + + + +### [Remove `Transform::apply_non_uniform_scale`](https://github.com/bevyengine/bevy/pull/6133) + +`Transform::apply_non_uniform_scale` has been removed. +It can be replaced with the following snippet: + +```rust +transform.scale *= scale_factor; +``` + +### [Rename `Transform::mul_vec3` to `transform_point` and improve docs](https://github.com/bevyengine/bevy/pull/6132) + + + +### [Make `raw_window_handle` field in `Window` and `ExtractedWindow` an `Option`.](https://github.com/bevyengine/bevy/pull/6114) + +`Window::raw_window_handle()` now returns `Option`. + +### [Rename `UiColor` to `BackgroundColor`](https://github.com/bevyengine/bevy/pull/6087) + +`UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. + +### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) + +`TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. + +```rust +// 0.8 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); +// 0.9 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, None, None) + +// 0.8 +TextureAtlas::from_grid_with_padding(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Vec2::new(4.0, 4.0)); +// 0.9 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Some(Vec2::new(4.0, 4.0)), None) +``` + +### [Spawn now takes a Bundle](https://github.com/bevyengine/bevy/pull/6054) + +```rust +// Old (0.8): +commands + .spawn() + .insert_bundle((A, B, C)); +// New (0.9) +commands.spawn((A, B, C)); + +// Old (0.8): +commands.spawn_bundle((A, B, C)); +// New (0.9) +commands.spawn((A, B, C)); + +// Old (0.8): +let entity = commands.spawn().id(); +// New (0.9) +let entity = commands.spawn_empty().id(); + +// Old (0.8) +let entity = world.spawn().id(); +// New (0.9) +let entity = world.spawn_empty(); +``` + +### [Accept Bundles for insert and remove. Deprecate insert/remove_bundle](https://github.com/bevyengine/bevy/pull/6039) + +Replace `insert_bundle` with `insert`: + +```rust +// Old (0.8) +commands.spawn().insert_bundle(SomeBundle::default()); +// New (0.9) +commands.spawn().insert(SomeBundle::default()); +``` + +Replace `remove_bundle` with `remove`: + +```rust +// Old (0.8) +commands.entity(some_entity).remove_bundle::(); +// New (0.9) +commands.entity(some_entity).remove::(); +``` + +Replace `remove_bundle_intersection` with `remove_intersection`: + +```rust +// Old (0.8) +world.entity_mut(some_entity).remove_bundle_intersection::(); +// New (0.9) +world.entity_mut(some_entity).remove_intersection::(); +``` + +Consider consolidating as many operations as possible to improve ergonomics and cut down on archetype moves: + +```rust +// Old (0.8) +commands.spawn() + .insert_bundle(SomeBundle::default()) + .insert(SomeComponent); + +// New (0.9) - Option 1 +commands.spawn().insert(( + SomeBundle::default(), + SomeComponent, +)) + +// New (0.9) - Option 2 +commands.spawn_bundle(( + SomeBundle::default(), + SomeComponent, +)) +``` + +### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) + +Query filter (`F`) generics are now bound by `ReadOnlyWorldQuery`, rather than `WorldQuery`. If for some reason you were requesting `Query<&A, &mut B>`, please use `Query<&A, With>` instead. + +### [Change UI coordinate system to have origin at top left corner](https://github.com/bevyengine/bevy/pull/6000) + +All flex layout should be inverted (ColumnReverse => Column, FlexStart => FlexEnd, WrapReverse => Wrap) +System where dealing with cursor position should be changed to account for cursor position being based on the top left instead of bottom left + +### [Clarify `bevy::ui::Node` field and documentation](https://github.com/bevyengine/bevy/pull/5995) + +All references to the old `size` name has been changed, to access `bevy::ui::Node` `size` field use `calculated_size` + +### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) + +`AssetServer::watch_for_changes()` was removed. +Instead, use the `AssetServerSettings` resource. + +```rust +app // AssetServerSettings must be inserted before adding the AssetPlugin or DefaultPlugins. + .insert_resource(AssetServerSettings { + watch_for_changes: true, + ..default() + }) +``` + +### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) + +Ambiguity sets have been removed. + +### [Remove ExactSizeIterator from QueryCombinationIter](https://github.com/bevyengine/bevy/pull/5895) + +* Switch to using other methods of getting the length. + +### [Support monitor selection for all window modes.](https://github.com/bevyengine/bevy/pull/5878) + +`MonitorSelection` was moved out of `WindowPosition::Centered`, into `WindowDescriptor`. +`MonitorSelection::Number` was renamed to `MonitorSelection::Index`. + +```rust +// Before +.insert_resource(WindowDescriptor { + position: WindowPosition::Centered(MonitorSelection::Number(1)), + ..default() +}) +// After +.insert_resource(WindowDescriptor { + monitor: MonitorSelection::Index(1), + position: WindowPosition::Centered, + ..default() +}) +``` + +`Window::set_position` now takes a `MonitorSelection` as argument. + +```rust +window.set_position(MonitorSelection::Current, position); +``` + +### [Miscellaneous code-quality improvements.](https://github.com/bevyengine/bevy/pull/5860) + + + +### [Add `pop` method for `List` trait.](https://github.com/bevyengine/bevy/pull/5797) + +* Any custom type that implements the `List` trait will now need to implement the `pop` method. + +### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) + +* `time.time_since_startup()` -> `time.elapsed()` +* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` +* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` + +If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. + +### [Move `sprite::Rect` into `bevy_math`](https://github.com/bevyengine/bevy/pull/5686) + +The `bevy::sprite::Rect` type moved to the math utility crate as +`bevy::math::Rect`. You should change your imports from `use bevy::sprite::Rect` to `use bevy::math::Rect`. + +### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) + + + +### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) + +* Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. + +### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) + +The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been deprecated. +Use the associated constant `IDENTITY` instead. + +### [`Gamepad` type is `Copy`; do not require / return references to it in `Gamepads` API](https://github.com/bevyengine/bevy/pull/5296) + +* `Gamepads::iter` now returns an iterator of `Gamepad`. rather than an iterator of `&Gamepad`. +* `Gamepads::contains` now accepts a `Gamepad`, rather than a `&Gamepad`. + +### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) + + + +### [Swap out num_cpus for std::thread::available_parallelism](https://github.com/bevyengine/bevy/pull/4970) + +`bevy_tasks::logical_core_count` and `bevy_tasks::physical_core_count` have been removed. `logical_core_count` has been replaced with `bevy_tasks::available_parallelism`, which works identically. If `bevy_tasks::physical_core_count` is required, the `num_cpus` crate can be used directly, as these two were just aliases for `num_cpus` APIs. + +### [Extract Resources into their own dedicated storage](https://github.com/bevyengine/bevy/pull/4809) + +Resources have been moved to `Resources` under `Storages` in `World`. All code dependent on `Archetype::unique_components(_mut)` should access it via `world.storages().resources()` instead. + +All APIs accessing the raw data of individual resources (mutable _and_ read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. + +### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) + + From e8c11399e02a02fe199c0f0107555471e39efd21 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 01:28:36 -0400 Subject: [PATCH 02/38] remove whitespace --- content/learn/book/migration-guides/0.8-0.9/_index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 0072412c04..5b7d265b3a 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -1,4 +1,3 @@ - +++ title = "0.8 to 0.9" weight = 5 From 3ff462587d93445014acb84c21a7407fcd67efaf Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 02:31:31 -0400 Subject: [PATCH 03/38] regenerate guide --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 5b7d265b3a..f12489e15a 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -11,7 +11,7 @@ long_title = "Migration Guide: 0.8 to 0.9" ### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) - +* If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. ### [Plugins own their settings. Rework PluginGroup trait.](https://github.com/bevyengine/bevy/pull/6336) @@ -337,4 +337,4 @@ All APIs accessing the raw data of individual resources (mutable _and_ read-only ### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) - +In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are not collapsed automatically. You should remove `#[bundle]` attributes. From 8b5270292c81ba92dabf73cc63361bca941658f9 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 02:35:07 -0400 Subject: [PATCH 04/38] regenerate guide --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index f12489e15a..c84f792080 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -121,7 +121,7 @@ transform.scale *= scale_factor; ### [Rename `Transform::mul_vec3` to `transform_point` and improve docs](https://github.com/bevyengine/bevy/pull/6132) - +`Transform::mul_vec3` has been renamed to `transform_point`. ### [Make `raw_window_handle` field in `Window` and `ExtractedWindow` an `Option`.](https://github.com/bevyengine/bevy/pull/6114) From f293a6ca13bceae73b759ea52e1f24773f02da6e Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 25 Oct 2022 02:44:34 -0400 Subject: [PATCH 05/38] manually update some titles --- content/learn/book/migration-guides/0.8-0.9/_index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index c84f792080..bb5506306a 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -131,7 +131,7 @@ transform.scale *= scale_factor; `UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. -### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) +### [Merge `TextureAtlas::from_grid_with_padding` into `TextureAtlas::from_grid` through option arguments](https://github.com/bevyengine/bevy/pull/6057) `TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. @@ -173,7 +173,7 @@ let entity = world.spawn().id(); let entity = world.spawn_empty(); ``` -### [Accept Bundles for insert and remove. Deprecate insert/remove_bundle](https://github.com/bevyengine/bevy/pull/6039) +### [Accept Bundles for insert and remove. Deprecate `insert`/`remove_bundle`](https://github.com/bevyengine/bevy/pull/6039) Replace `insert_bundle` with `insert`: @@ -253,7 +253,7 @@ app // AssetServerSettings must be inserted before adding the AssetPlugin or Def Ambiguity sets have been removed. -### [Remove ExactSizeIterator from QueryCombinationIter](https://github.com/bevyengine/bevy/pull/5895) +### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) * Switch to using other methods of getting the length. @@ -325,7 +325,7 @@ Use the associated constant `IDENTITY` instead. -### [Swap out num_cpus for std::thread::available_parallelism](https://github.com/bevyengine/bevy/pull/4970) +### [Swap out `num_cpus` for `std::thread::available_parallelism`](https://github.com/bevyengine/bevy/pull/4970) `bevy_tasks::logical_core_count` and `bevy_tasks::physical_core_count` have been removed. `logical_core_count` has been replaced with `bevy_tasks::available_parallelism`, which works identically. If `bevy_tasks::physical_core_count` is required, the `num_cpus` crate can be used directly, as these two were just aliases for `num_cpus` APIs. From e53272f1f611b893ba45ace5f0358f011111f394 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 02:51:22 -0400 Subject: [PATCH 06/38] more manual updates --- content/learn/book/migration-guides/0.8-0.9/_index.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index bb5506306a..61f2861c5e 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -305,7 +305,7 @@ The `bevy::sprite::Rect` type moved to the math utility crate as ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) - +`Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` ### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) @@ -323,7 +323,11 @@ Use the associated constant `IDENTITY` instead. ### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) - +`LogDiagnosticsPlugin` now records the smoothed value rather than the raw value. + +* For diagnostics recorded less often than every 0.1 seconds, this change to defaults will have no visible effect. +* For discrete diagnostics where this smoothing is not desirable, set a smoothing factor of 0 to disable smoothing. +* The average of the recent history is still shown when available. ### [Swap out `num_cpus` for `std::thread::available_parallelism`](https://github.com/bevyengine/bevy/pull/4970) From 8efeceb17807128d2517aea373dbe40f63a10619 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 02:52:04 -0400 Subject: [PATCH 07/38] hide a PR that isn't breaking --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 61f2861c5e..a2c3317779 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -282,7 +282,7 @@ Ambiguity sets have been removed. window.set_position(MonitorSelection::Current, position); ``` -### [Miscellaneous code-quality improvements.](https://github.com/bevyengine/bevy/pull/5860) + From 43ecb661fa9d8f628d3629ecd1b9720a89c7654d Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 12:22:04 -0400 Subject: [PATCH 08/38] remove not breaking change --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index a2c3317779..7283f2e0ad 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -282,10 +282,6 @@ Ambiguity sets have been removed. window.set_position(MonitorSelection::Current, position); ``` - - - - ### [Add `pop` method for `List` trait.](https://github.com/bevyengine/bevy/pull/5797) * Any custom type that implements the `List` trait will now need to implement the `pop` method. From 016e088ba122a640414157c3718937d701e1a908 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 13:16:09 -0400 Subject: [PATCH 09/38] update migration guide --- .../book/migration-guides/0.8-0.9/_index.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 7283f2e0ad..effbe68995 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -9,10 +9,43 @@ insert_anchor_links = "right" long_title = "Migration Guide: 0.8 to 0.9" +++ +### [bevy_scene: Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) + +The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. + +```rust +// OLD +[ + ( + entity: 0, + components: [ + // Components... + ] + ), +] + +// NEW +( + entities: [ + ( + entity: 0, + components: [ + // Components... + ] + ), + ] +) +``` + ### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) * If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. +### [feat: add GamepadInfo, expose gamepad names](https://github.com/bevyengine/bevy/pull/6342) + +* Pattern matches on `GamepadEventType::Connected` will need to be updated, as the form of the variant has changed. +* Code that requires `GamepadEvent`, `GamepadEventRaw` or `GamepadEventType` to be `Copy` will need to be updated. + ### [Plugins own their settings. Rework PluginGroup trait.](https://github.com/bevyengine/bevy/pull/6336) The `WindowDescriptor` settings have been moved from a resource to `WindowPlugin::window`: @@ -81,6 +114,10 @@ Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table:: The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struct is now `PipeSystem`. +### [Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7](https://github.com/bevyengine/bevy/pull/6218) + +* Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. + ### [Make the default background color of `NodeBundle` transparent](https://github.com/bevyengine/bevy/pull/6211) If you want a `NodeBundle` with a white background color, you must explicitly specify it: From 8038af0c135f3c7d45e18a76be78dd44c1c2a0c4 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 25 Oct 2022 15:14:58 -0400 Subject: [PATCH 10/38] update with older commits before 0.8.1 --- .../book/migration-guides/0.8-0.9/_index.md | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index effbe68995..86c1eec38b 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -336,6 +336,22 @@ If you aren’t sure which to use, most systems should continue to use “scaled The `bevy::sprite::Rect` type moved to the math utility crate as `bevy::math::Rect`. You should change your imports from `use bevy::sprite::Rect` to `use bevy::math::Rect`. +### [Remove unused DepthCalculation enum](https://github.com/bevyengine/bevy/pull/5684) + +Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_render::camera::DepthCalculation`. Remove `depth_calculation` fields from Projections. + +### [remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) + + + +### [Make internal struct `ShaderData` non-`pub`](https://github.com/bevyengine/bevy/pull/5609) + + + +### [changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) + + + ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) `Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` @@ -344,6 +360,54 @@ The `bevy::sprite::Rect` type moved to the math utility crate as * Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. +### [Add `FromWorld` bound to `T` in `Local`](https://github.com/bevyengine/bevy/pull/5481) + +* It might be possible for references to `Local`s without `T: FromWorld` to exist, but these should be exceedingly rare and probably dead code. In the event that one of these is encountered, the easiest solutions are to delete the code or wrap the inner `T` in an `Option` to allow it to be default constructed to `None`. + +### [bevy_reflect: Update enum derives](https://github.com/bevyengine/bevy/pull/5473) + +Bevy-defined enums have been updated to implement `Enum` and are not considered value types (`ReflectRef::Value`) anymore. This means that their serialized representations will need to be updated. For example, given the Bevy enum: + +```rust +pub enum ScalingMode { + None, + WindowSize, + Auto { min_width: f32, min_height: f32 }, + FixedVertical(f32), + FixedHorizontal(f32), +} +``` + +You will need to update the serialized versions accordingly. + +```js +// OLD FORMAT +{ + "type": "bevy_render::camera::projection::ScalingMode", + "value": FixedHorizontal(720), +}, + +// NEW FORMAT +{ + "type": "bevy_render::camera::projection::ScalingMode", + "enum": { + "variant": "FixedHorizontal", + "tuple": [ + { + "type": "f32", + "value": 720, + }, + ], + }, +}, +``` + +This may also have other smaller implications (such as `Debug` representation), but serialization is probably the most prominent. + +### [Remove `Size` and `UiRect` generics](https://github.com/bevyengine/bevy/pull/5404) + +* The generic `T` of `Size` and `UiRect` got removed and instead they both now always use `Val`. If you used a `Size` consider replacing it with a `Vec2` which is way more powerful. + ### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been deprecated. @@ -354,6 +418,10 @@ Use the associated constant `IDENTITY` instead. * `Gamepads::iter` now returns an iterator of `Gamepad`. rather than an iterator of `&Gamepad`. * `Gamepads::contains` now accepts a `Gamepad`, rather than a `&Gamepad`. +### [remove blanket `Serialize + Deserialize` requirement for `Reflect` on generic types](https://github.com/bevyengine/bevy/pull/5197) + + + ### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) `LogDiagnosticsPlugin` now records the smoothed value rather than the raw value. @@ -372,6 +440,30 @@ Resources have been moved to `Resources` under `Storages` in `World`. All code d All APIs accessing the raw data of individual resources (mutable _and_ read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. +### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) + +* The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. + +### [Rename `ElementState` to `ButtonState`](https://github.com/bevyengine/bevy/pull/4314) + +* The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. + +### [Move `Size` to `bevy_ui`](https://github.com/bevyengine/bevy/pull/4285) + +* The `Size` type got moved from `bevy::math` to `bevy::ui`. To migrate you just have to import `bevy::ui::Size` instead of `bevy::math::Math` or use the `bevy::prelude` instead. + +### [Remove `margins.rs`](https://github.com/bevyengine/bevy/pull/4284) + +* The `Margins` type got removed. To migrate you just have to change every occurrence of `Margins` to `UiRect`. + +### [Remove `face_toward.rs`](https://github.com/bevyengine/bevy/pull/4277) + +* The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`. + +### [Move `Rect` to `bevy_ui` and rename it to `UiRect`](https://github.com/bevyengine/bevy/pull/4276) + +* The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`. + ### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are not collapsed automatically. You should remove `#[bundle]` attributes. From 4be94ff5695336fa8cfbc3e5377b49b0c36ad44d Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 26 Oct 2022 12:44:48 -0400 Subject: [PATCH 11/38] regenerate migration guide --- .../book/migration-guides/0.8-0.9/_index.md | 177 +++++++++++++++++- 1 file changed, 176 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 86c1eec38b..9befc81454 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -9,6 +9,52 @@ insert_anchor_links = "right" long_title = "Migration Guide: 0.8 to 0.9" +++ +### [Use plugin setup for resource only used at setup time](https://github.com/bevyengine/bevy/pull/6360) + +The `LogSettings` settings have been moved from a resource to `LogPlugin` configuration: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(LogSettings { + level: Level::DEBUG, + filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), + }) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(LogPlugin { + level: Level::DEBUG, + filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), +})) +``` + +The `ImageSettings` settings have been moved from a resource to `ImagePlugin` configuration: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(ImageSettings::default_nearest()) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) +``` + +The `DefaultTaskPoolOptions` settings have been moved from a resource to `CorePlugin::task_pool_options`: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(DefaultTaskPoolOptions::with_num_threads(4)) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(CorePlugin { + task_pool_options: TaskPoolOptions::with_num_threads(4), +})) +``` + ### [bevy_scene: Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. @@ -147,6 +193,40 @@ let node = NodeBundle { +### [Add methods for silencing system-order ambiguity warnings](https://github.com/bevyengine/bevy/pull/6158) + +_Note for maintainers: This should replace the migration guide for #5916_ + +Ambiguity sets have been replaced with a simpler API. + +```rust +// These systems technically conflict, but we don't care which order they run in. +fn jump_on_click(mouse: Res>, mut transforms: Query<&mut Transform>) { ... } +fn jump_on_spacebar(keys: Res>, mut transforms: Query<&mut Transform>) { ... } + +// +// Before + +#[derive(AmbiguitySetLabel)] +struct JumpSystems; + +app + .add_system(jump_on_click.in_ambiguity_set(JumpSystems)) + .add_system(jump_on_spacebar.in_ambiguity_set(JumpSystems)); + +// +// After + +app + .add_system(jump_on_click.ambiguous_with(jump_on_spacebar)) + .add_system(jump_on_spacebar); + +``` + +### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) + +Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. + ### [Remove `Transform::apply_non_uniform_scale`](https://github.com/bevyengine/bevy/pull/6133) `Transform::apply_non_uniform_scale` has been removed. @@ -164,11 +244,55 @@ transform.scale *= scale_factor; `Window::raw_window_handle()` now returns `Option`. +### [Add getters and setters for `InputAxis` and `ButtonSettings`](https://github.com/bevyengine/bevy/pull/6088) + +`AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. +`AxisSettings` fields made private; now must be accessed through getters and setters. There’s a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. +`AxisSettings` setters no longer panic. +`ButtonSettings` fields made private; now must be accessed through getters and setters. +`ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. + ### [Rename `UiColor` to `BackgroundColor`](https://github.com/bevyengine/bevy/pull/6087) `UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. -### [Merge `TextureAtlas::from_grid_with_padding` into `TextureAtlas::from_grid` through option arguments](https://github.com/bevyengine/bevy/pull/6057) +### [Exclusive Systems Now Implement `System`. Flexible Exclusive System Params](https://github.com/bevyengine/bevy/pull/6083) + +Calling `.exclusive_system()` is no longer required (or supported) for converting exclusive system functions to exclusive systems: + +```rust +// Old (0.8) +app.add_system(some_exclusive_system.exclusive_system()); +// New (0.9) +app.add_system(some_exclusive_system); +``` + +Converting “normal” parallel systems to exclusive systems is done by calling the exclusive ordering apis: + +```rust +// Old (0.8) +app.add_system(some_system.exclusive_system().at_end()); +// New (0.9) +app.add_system(some_system.at_end()); +``` + +Query state in exclusive systems can now be cached via ExclusiveSystemParams, which should be preferred for clarity and performance reasons: + +```rust +// Old (0.8) +fn some_system(world: &mut World) { + let mut transforms = world.query::<&Transform>(); + for transform in transforms.iter(world) { + } +} +// New (0.9) +fn some_system(world: &mut World, transforms: &mut QueryState<&Transform>) { + for transform in transforms.iter(world) { + } +} +``` + +### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) `TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. @@ -260,6 +384,11 @@ commands.spawn_bundle(( )) ``` +### [Fix inconsistent children removal behavior](https://github.com/bevyengine/bevy/pull/6017) + +* Queries with `Changed` will no longer match entities that had all of their children removed using `remove_children`. +* `RemovedComponents` will now contain entities that had all of their children remove using `remove_children`. + ### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) Query filter (`F`) generics are now bound by `ReadOnlyWorldQuery`, rather than `WorldQuery`. If for some reason you were requesting `Query<&A, &mut B>`, please use `Query<&A, With>` instead. @@ -331,6 +460,39 @@ window.set_position(MonitorSelection::Current, position); If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. +### [bevy_reflect: Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) + +* This PR reduces the verbosity of the scene format. Scenes will need to be updated accordingly: + +```js +// Old format +{ + "type": "my_game::item::Item", + "struct": { + "id": { + "type": "alloc::string::String", + "value": "bevycraft:stone", + }, + "tags": { + "type": "alloc::vec::Vec", + "list": [ + { + "type": "alloc::string::String", + "value": "material" + }, + ], + }, +} + +// New format +{ + "my_game::item::Item": ( + id: "bevycraft:stone", + tags: ["material"] + ) +} +``` + ### [Move `sprite::Rect` into `bevy_math`](https://github.com/bevyengine/bevy/pull/5686) The `bevy::sprite::Rect` type moved to the math utility crate as @@ -340,6 +502,10 @@ The `bevy::sprite::Rect` type moved to the math utility crate as Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_render::camera::DepthCalculation`. Remove `depth_calculation` fields from Projections. +### [Remove an outdated workaround for `impl Trait`](https://github.com/bevyengine/bevy/pull/5659) + +The methods `Schedule::get_stage` and `get_stage_mut` now accept `impl StageLabel` instead of `&dyn StageLabel`. + ### [remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) @@ -348,6 +514,15 @@ Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_ +### [Make `Resource` trait opt-in, requiring `#[derive(Resource)]` V2](https://github.com/bevyengine/bevy/pull/5577) + +Add `#[derive(Resource)]` to all types you are using as a resource. + +If you are using a third party type as a resource, wrap it in a tuple struct to bypass orphan rules. Consider deriving `Deref` and `DerefMut` to improve ergonomics. + +`ClearColor` no longer implements `Component`. Using `ClearColor` as a component in 0.8 did nothing. +Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. + ### [changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) From 6b36607914cea32b075d862e03e41346aaba9343 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 26 Oct 2022 12:46:53 -0400 Subject: [PATCH 12/38] clean up --- content/learn/book/migration-guides/0.8-0.9/_index.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 9befc81454..9eba73cb22 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -195,8 +195,6 @@ let node = NodeBundle { ### [Add methods for silencing system-order ambiguity warnings](https://github.com/bevyengine/bevy/pull/6158) -_Note for maintainers: This should replace the migration guide for #5916_ - Ambiguity sets have been replaced with a simpler API. ```rust @@ -415,10 +413,6 @@ app // AssetServerSettings must be inserted before adding the AssetPlugin or Def }) ``` -### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) - -Ambiguity sets have been removed. - ### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) * Switch to using other methods of getting the length. From 0c3f62e5cb129af0245d45e1af04fa05a45a572e Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:04:59 -0400 Subject: [PATCH 13/38] regenerate migration guide --- .../book/migration-guides/0.8-0.9/_index.md | 180 +++++++++++++++++- 1 file changed, 179 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 9eba73cb22..6287f3a18c 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -87,6 +87,74 @@ The scene file format now uses a struct as the root object rather than a list of * If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. +### [bevy_scene: Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) + +The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. + +```rust +// OLD +[ + ( + entity: 0, + components: [ + { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + { + "my_crate::Foo": ( + text: "Hello World", + ), + }, + { + "my_crate::Bar": ( + baz: 123, + ), + }, + ], + ), +] + +// NEW +[ + ( + entity: 0, + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + "my_crate::Foo": ( + text: "Hello World", + ), + "my_crate::Bar": ( + baz: 123 + ), + }, + ), +] +``` + ### [feat: add GamepadInfo, expose gamepad names](https://github.com/bevyengine/bevy/pull/6342) * Pattern matches on `GamepadEventType::Connected` will need to be updated, as the form of the variant has changed. @@ -143,6 +211,10 @@ app.add_plugins_with(DefaultPlugins, |group| group.disable::()); app.add_plugins(DefaultPlugins.build().disable::()); ``` +### [Replace `WorldQueryGats` trait with actual gats](https://github.com/bevyengine/bevy/pull/6319) + +* Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait + ### [Add a method for accessing the width of a `Table`](https://github.com/bevyengine/bevy/pull/6249) Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table::capacity` should now be `Table::entity_capacity`. @@ -155,6 +227,11 @@ Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table:: * Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. * Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. +### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) + +* `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. +* As a reminder, private fields exposed via reflection are not subject to any stability guarantees. + ### [Rename system chaining to system piping](https://github.com/bevyengine/bevy/pull/6230) The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. @@ -242,6 +319,10 @@ transform.scale *= scale_factor; `Window::raw_window_handle()` now returns `Option`. +### [[Fixes #6059] ``Entity``'s “ID” should be named “index” instead](https://github.com/bevyengine/bevy/pull/6107) + +The `Entity::id()` method was renamed to `Entity::index()`. + ### [Add getters and setters for `InputAxis` and `ButtonSettings`](https://github.com/bevyengine/bevy/pull/6088) `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. @@ -413,7 +494,11 @@ app // AssetServerSettings must be inserted before adding the AssetPlugin or Def }) ``` -### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) +### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) + +Ambiguity sets have been removed. + +### [Remove ExactSizeIterator from QueryCombinationIter](https://github.com/bevyengine/bevy/pull/5895) * Switch to using other methods of getting the length. @@ -446,6 +531,49 @@ window.set_position(MonitorSelection::Current, position); * Any custom type that implements the `List` trait will now need to implement the `pop` method. +### [bevy_pbr: Fix incorrect and unnecessary normal-mapping code](https://github.com/bevyengine/bevy/pull/5766) + +`prepare_normal` from the `bevy_pbr::pbr_functions` shader import has been reworked. + +Before: + +```rust + pbr_input.world_normal = in.world_normal; + + pbr_input.N = prepare_normal( + pbr_input.material.flags, + in.world_normal, +#ifdef VERTEX_TANGENTS +#ifdef STANDARDMATERIAL_NORMAL_MAP + in.world_tangent, +#endif +#endif + in.uv, + in.is_front, + ); +``` + +After: + +```rust + pbr_input.world_normal = prepare_world_normal( + in.world_normal, + (material.flags & STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u, + in.is_front, + ); + + pbr_input.N = apply_normal_mapping( + pbr_input.material.flags, + pbr_input.world_normal, +#ifdef VERTEX_TANGENTS +#ifdef STANDARDMATERIAL_NORMAL_MAP + in.world_tangent, +#endif +#endif + in.uv, + ); +``` + ### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) * `time.time_since_startup()` -> `time.elapsed()` @@ -500,6 +628,31 @@ Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_ The methods `Schedule::get_stage` and `get_stage_mut` now accept `impl StageLabel` instead of `&dyn StageLabel`. +### [bevy_reflect: Relax bounds on `Option`](https://github.com/bevyengine/bevy/pull/5658) + +If using `Option` with Bevy’s reflection API, `T` now needs to implement `FromReflect` rather than just `Clone`. This can be achieved easily by simply deriving `FromReflect`: + +```rust + +// OLD +#[derive(Reflect, Clone)] +struct Foo; + +let reflected: Box = Box::new(Some(Foo)); + +// NEW +#[derive(Reflect, FromReflect)] +struct Foo; + +let reflected: Box = Box::new(Some(Foo)); +``` + +Note: You can still derive `Clone`, but it’s not required in order to compile. + +### [Add a change detection bypass and manual control over change ticks](https://github.com/bevyengine/bevy/pull/5635) + +Add the `Inner` associated type and new methods to any type that you’ve implemented `DetectChanges` for. + ### [remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) @@ -524,6 +677,9 @@ Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) `Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` +### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) + + ### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) @@ -582,6 +738,12 @@ This may also have other smaller implications (such as `Debug` representation), The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been deprecated. Use the associated constant `IDENTITY` instead. +### [Rename Handle::as_weak() to cast_weak()](https://github.com/bevyengine/bevy/pull/5321) + +* Rename `Handle::as_weak` uses to `Handle::cast_weak` + +The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior. + ### [`Gamepad` type is `Copy`; do not require / return references to it in `Gamepads` API](https://github.com/bevyengine/bevy/pull/5296) * `Gamepads::iter` now returns an iterator of `Gamepad`. rather than an iterator of `&Gamepad`. @@ -609,10 +771,26 @@ Resources have been moved to `Resources` under `Storages` in `World`. All code d All APIs accessing the raw data of individual resources (mutable _and_ read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. +### [Clean up Fetch code](https://github.com/bevyengine/bevy/pull/4800) + +TODO + ### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) * The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. +### [Nested spawns on scope](https://github.com/bevyengine/bevy/pull/4466) + +If you were using explicit lifetimes and Passing Scope you’ll need to specify two lifetimes now. + +```rust +fn scoped_function<'scope>(scope: &mut Scope<'scope, ()>) {} +// should become +fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} +``` + +`scope.spawn_local` changed to `scope.spawn_on_scope` this should cover cases where you needed to run tasks on the local thread, but does not cover spawning Nonsend Futures. Spawning of NonSend futures on scope is no longer supported. + ### [Rename `ElementState` to `ButtonState`](https://github.com/bevyengine/bevy/pull/4314) * The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. From d3c3fe233133fc2c1b2e27bcc4f8ade1926ffe91 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:05:24 -0400 Subject: [PATCH 14/38] fix --- content/learn/book/migration-guides/0.8-0.9/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 6287f3a18c..6474355842 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -498,7 +498,7 @@ app // AssetServerSettings must be inserted before adding the AssetPlugin or Def Ambiguity sets have been removed. -### [Remove ExactSizeIterator from QueryCombinationIter](https://github.com/bevyengine/bevy/pull/5895) +### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) * Switch to using other methods of getting the length. @@ -677,6 +677,7 @@ Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) `Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` + ### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) From 86c824d82579e2659f29488f5955ac00527f34c6 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:20:13 -0400 Subject: [PATCH 15/38] manual fixes --- .../book/migration-guides/0.8-0.9/_index.md | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 6474355842..94e849e9c1 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -60,7 +60,7 @@ app.add_plugins(DefaultPlugins.set(CorePlugin { The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. ```rust -// OLD +// Old (Bevy 0.8) [ ( entity: 0, @@ -70,7 +70,7 @@ The scene file format now uses a struct as the root object rather than a list of ), ] -// NEW +// New (Bevy 0.9) ( entities: [ ( @@ -92,7 +92,7 @@ The scene file format now uses a struct as the root object rather than a list of The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. ```rust -// OLD +// Old (Bevy 0.8) [ ( entity: 0, @@ -126,7 +126,7 @@ The scene format now uses a map to represent the collection of components. Scene ), ] -// NEW +// New (Bevy 0.9) [ ( entity: 0, @@ -484,14 +484,14 @@ All references to the old `size` name has been changed, to access `bevy::ui::Nod ### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) `AssetServer::watch_for_changes()` was removed. -Instead, use the `AssetServerSettings` resource. +Instead, set it directly on the `AssetPlugin`. ```rust -app // AssetServerSettings must be inserted before adding the AssetPlugin or DefaultPlugins. - .insert_resource(AssetServerSettings { - watch_for_changes: true, - ..default() - }) +app + .add_plugin(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() + })) ``` ### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) @@ -514,11 +514,14 @@ Ambiguity sets have been removed. ..default() }) // After -.insert_resource(WindowDescriptor { - monitor: MonitorSelection::Index(1), - position: WindowPosition::Centered, +.add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + monitor: MonitorSelection::Index(1), + position: WindowPosition::Centered, + ..default() + }, ..default() -}) +})) ``` `Window::set_position` now takes a `MonitorSelection` as argument. @@ -537,7 +540,7 @@ window.set_position(MonitorSelection::Current, position); Before: -```rust +```wgsl pbr_input.world_normal = in.world_normal; pbr_input.N = prepare_normal( @@ -555,7 +558,7 @@ Before: After: -```rust +```wgsl pbr_input.world_normal = prepare_world_normal( in.world_normal, (material.flags & STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u, @@ -604,6 +607,7 @@ If you aren’t sure which to use, most systems should continue to use “scaled }, ], }, + } } // New format @@ -672,7 +676,7 @@ Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. ### [changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) - +Diagnostics values are now in milliseconds. If you need secconds, simply divide it by 1000.0; ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) From edf63ac220452706b11ef44edfc64fd6d3d6f639 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:23:02 -0400 Subject: [PATCH 16/38] fix --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 94e849e9c1..eb0d23456e 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -451,13 +451,13 @@ commands.spawn() .insert(SomeComponent); // New (0.9) - Option 1 -commands.spawn().insert(( +commands.spawn_empty().insert(( SomeBundle::default(), SomeComponent, )) // New (0.9) - Option 2 -commands.spawn_bundle(( +commands.spawn(( SomeBundle::default(), SomeComponent, )) From e0c376ad8df031a869553f50457bcd2f4ab0c703 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:26:06 -0400 Subject: [PATCH 17/38] add warning --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index eb0d23456e..572055479d 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -9,6 +9,10 @@ insert_anchor_links = "right" long_title = "Migration Guide: 0.8 to 0.9" +++ +Before migrating make sure to run rustup update + +Bevy relies heavily on improvements in the Rust language and compiler. As a result, the Minimum Supported Rust Version (MSRV) is "the latest stable release" of Rust. + ### [Use plugin setup for resource only used at setup time](https://github.com/bevyengine/bevy/pull/6360) The `LogSettings` settings have been moved from a resource to `LogPlugin` configuration: From f47ff6d0e5e3b535ccd84d6dd45aa550a81f6373 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:28:16 -0400 Subject: [PATCH 18/38] remove bullet points --- .../book/migration-guides/0.8-0.9/_index.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 572055479d..60fb59c347 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -243,7 +243,7 @@ The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struc ### [Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7](https://github.com/bevyengine/bevy/pull/6218) -* Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. +Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. ### [Make the default background color of `NodeBundle` transparent](https://github.com/bevyengine/bevy/pull/6211) @@ -536,7 +536,7 @@ window.set_position(MonitorSelection::Current, position); ### [Add `pop` method for `List` trait.](https://github.com/bevyengine/bevy/pull/5797) -* Any custom type that implements the `List` trait will now need to implement the `pop` method. +Any custom type that implements the `List` trait will now need to implement the `pop` method. ### [bevy_pbr: Fix incorrect and unnecessary normal-mapping code](https://github.com/bevyengine/bevy/pull/5766) @@ -591,7 +591,7 @@ If you aren’t sure which to use, most systems should continue to use “scaled ### [bevy_reflect: Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) -* This PR reduces the verbosity of the scene format. Scenes will need to be updated accordingly: +This PR reduces the verbosity of the scene format. Scenes will need to be updated accordingly: ```js // Old format @@ -692,11 +692,11 @@ Diagnostics values are now in milliseconds. If you need secconds, simply divide ### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) -* Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. +Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. ### [Add `FromWorld` bound to `T` in `Local`](https://github.com/bevyengine/bevy/pull/5481) -* It might be possible for references to `Local`s without `T: FromWorld` to exist, but these should be exceedingly rare and probably dead code. In the event that one of these is encountered, the easiest solutions are to delete the code or wrap the inner `T` in an `Option` to allow it to be default constructed to `None`. +It might be possible for references to `Local`s without `T: FromWorld` to exist, but these should be exceedingly rare and probably dead code. In the event that one of these is encountered, the easiest solutions are to delete the code or wrap the inner `T` in an `Option` to allow it to be default constructed to `None`. ### [bevy_reflect: Update enum derives](https://github.com/bevyengine/bevy/pull/5473) @@ -740,7 +740,7 @@ This may also have other smaller implications (such as `Debug` representation), ### [Remove `Size` and `UiRect` generics](https://github.com/bevyengine/bevy/pull/5404) -* The generic `T` of `Size` and `UiRect` got removed and instead they both now always use `Val`. If you used a `Size` consider replacing it with a `Vec2` which is way more powerful. +The generic `T` of `Size` and `UiRect` got removed and instead they both now always use `Val`. If you used a `Size` consider replacing it with a `Vec2` which is way more powerful. ### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) @@ -786,7 +786,7 @@ TODO ### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) -* The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. +The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. ### [Nested spawns on scope](https://github.com/bevyengine/bevy/pull/4466) @@ -802,23 +802,23 @@ fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} ### [Rename `ElementState` to `ButtonState`](https://github.com/bevyengine/bevy/pull/4314) -* The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. +The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. ### [Move `Size` to `bevy_ui`](https://github.com/bevyengine/bevy/pull/4285) -* The `Size` type got moved from `bevy::math` to `bevy::ui`. To migrate you just have to import `bevy::ui::Size` instead of `bevy::math::Math` or use the `bevy::prelude` instead. +The `Size` type got moved from `bevy::math` to `bevy::ui`. To migrate you just have to import `bevy::ui::Size` instead of `bevy::math::Math` or use the `bevy::prelude` instead. ### [Remove `margins.rs`](https://github.com/bevyengine/bevy/pull/4284) -* The `Margins` type got removed. To migrate you just have to change every occurrence of `Margins` to `UiRect`. +The `Margins` type got removed. To migrate you just have to change every occurrence of `Margins` to `UiRect`. ### [Remove `face_toward.rs`](https://github.com/bevyengine/bevy/pull/4277) -* The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`. +The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`. ### [Move `Rect` to `bevy_ui` and rename it to `UiRect`](https://github.com/bevyengine/bevy/pull/4276) -* The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`. +The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`. ### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) From ff82f7e20652d34690f7a734c12896fd858de8d0 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:44:09 -0400 Subject: [PATCH 19/38] polish --- .../book/migration-guides/0.8-0.9/_index.md | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 60fb59c347..6177a13da5 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -159,7 +159,7 @@ The scene format now uses a map to represent the collection of components. Scene ] ``` -### [feat: add GamepadInfo, expose gamepad names](https://github.com/bevyengine/bevy/pull/6342) +### [Add GamepadInfo, expose gamepad names](https://github.com/bevyengine/bevy/pull/6342) * Pattern matches on `GamepadEventType::Connected` will need to be updated, as the form of the variant has changed. * Code that requires `GamepadEvent`, `GamepadEventRaw` or `GamepadEventType` to be `Copy` will need to be updated. @@ -266,13 +266,15 @@ let node = NodeBundle { } ``` -### [make `Handle::` field id private, and replace with a getter](https://github.com/bevyengine/bevy/pull/6176) +### [Make `Handle::` field id private, and replace with a getter](https://github.com/bevyengine/bevy/pull/6176) -* If you were accessing the value `handle.id`, you can now do so with `handle.id()` +If you were accessing the value `handle.id`, you can now do so with `handle.id()` ### [Add `TimeUpdateStrategy` resource for manual `Time` updating](https://github.com/bevyengine/bevy/pull/6159) - +Changes the value reported by `time.delta()` on startup. + +Before it would be `[0, 0, correct]` and this PR changes it to be `[0, "approximately the time between the time_system and present_frame", correct]`. ### [Add methods for silencing system-order ambiguity warnings](https://github.com/bevyengine/bevy/pull/6158) @@ -661,9 +663,10 @@ Note: You can still derive `Clone`, but it’s not required in order to compile. Add the `Inner` associated type and new methods to any type that you’ve implemented `DetectChanges` for. -### [remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) +### [Remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) - +* relax `T: ?Sized` bound in `Mut` +* replace all instances of `ReflectMut` with `Mut` ### [Make internal struct `ShaderData` non-`pub`](https://github.com/bevyengine/bevy/pull/5609) @@ -678,7 +681,7 @@ If you are using a third party type as a resource, wrap it in a tuple struct to `ClearColor` no longer implements `Component`. Using `ClearColor` as a component in 0.8 did nothing. Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. -### [changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) +### [Changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) Diagnostics values are now in milliseconds. If you need secconds, simply divide it by 1000.0; @@ -688,7 +691,9 @@ Diagnostics values are now in milliseconds. If you need secconds, simply divide ### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) - +* Rename `image_to_texture` to `Image::from_dynamic` +* Rename `texture_to_image` to `Image::try_into_dynamic` +* `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.) ### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) @@ -760,7 +765,13 @@ The method now properly sets the associated type uuid if the handle is a direct ### [remove blanket `Serialize + Deserialize` requirement for `Reflect` on generic types](https://github.com/bevyengine/bevy/pull/5197) - +`.register_type` for generic types like `Option`, `Vec`, `HashMap` will no longer insert `ReflectSerialize` and `ReflectDeserialize` type data. Instead you need to register it separately for concrete generic types like so: + +```rust + .register_type::>() + .register_type_data::, ReflectSerialize>() + .register_type_data::, ReflectDeserialize>() +``` ### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) @@ -782,7 +793,7 @@ All APIs accessing the raw data of individual resources (mutable _and_ read-only ### [Clean up Fetch code](https://github.com/bevyengine/bevy/pull/4800) -TODO +Changed: `Fetch::table_fetch` and `Fetch::archetype_fetch` have been merged into a single `Fetch::fetch` function. ### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) @@ -793,8 +804,10 @@ The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventR If you were using explicit lifetimes and Passing Scope you’ll need to specify two lifetimes now. ```rust +// 0.8 fn scoped_function<'scope>(scope: &mut Scope<'scope, ()>) {} -// should become + +// 0.9 fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} ``` From 5cdba228731e7580af469686a164f2dfaaccf2e5 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 3 Nov 2022 20:47:59 -0400 Subject: [PATCH 20/38] polish --- .../book/migration-guides/0.8-0.9/_index.md | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 6177a13da5..319ecbbc84 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -89,7 +89,7 @@ The scene file format now uses a struct as the root object rather than a list of ### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) -* If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. +If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. ### [bevy_scene: Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) @@ -217,7 +217,7 @@ app.add_plugins(DefaultPlugins.build().disable::()); ### [Replace `WorldQueryGats` trait with actual gats](https://github.com/bevyengine/bevy/pull/6319) -* Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait +Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait ### [Add a method for accessing the width of a `Table`](https://github.com/bevyengine/bevy/pull/6249) @@ -249,17 +249,13 @@ Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_g If you want a `NodeBundle` with a white background color, you must explicitly specify it: -Before: - ```rust +// Old (Bevy 0.8) let node = NodeBundle { ..default() } -``` -After: - -```rust +// New (Bevy 0.9) let node = NodeBundle { background_color: Color::WHITE.into(), ..default() @@ -285,9 +281,7 @@ Ambiguity sets have been replaced with a simpler API. fn jump_on_click(mouse: Res>, mut transforms: Query<&mut Transform>) { ... } fn jump_on_spacebar(keys: Res>, mut transforms: Query<&mut Transform>) { ... } -// -// Before - +// Old (Bevy 0.8) #[derive(AmbiguitySetLabel)] struct JumpSystems; @@ -295,9 +289,7 @@ app .add_system(jump_on_click.in_ambiguity_set(JumpSystems)) .add_system(jump_on_spacebar.in_ambiguity_set(JumpSystems)); -// -// After - +// New (Bevy 0.9) app .add_system(jump_on_click.ambiguous_with(jump_on_spacebar)) .add_system(jump_on_spacebar); @@ -325,7 +317,7 @@ transform.scale *= scale_factor; `Window::raw_window_handle()` now returns `Option`. -### [[Fixes #6059] ``Entity``'s “ID” should be named “index” instead](https://github.com/bevyengine/bevy/pull/6107) +### [``Entity``'s “ID” should be named “index” instead](https://github.com/bevyengine/bevy/pull/6107) The `Entity::id()` method was renamed to `Entity::index()`. @@ -506,7 +498,7 @@ Ambiguity sets have been removed. ### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) -* Switch to using other methods of getting the length. +Switch to using other methods of getting the length. ### [Support monitor selection for all window modes.](https://github.com/bevyengine/bevy/pull/5878) From 0a82ddc436d3c8f61578174d3981303446875f26 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 3 Nov 2022 22:29:48 -0400 Subject: [PATCH 21/38] Apply suggestions from code review Co-authored-by: Rob Parrett --- content/learn/book/migration-guides/0.8-0.9/_index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 319ecbbc84..7b1539f1d8 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -464,7 +464,7 @@ commands.spawn(( ### [Fix inconsistent children removal behavior](https://github.com/bevyengine/bevy/pull/6017) * Queries with `Changed` will no longer match entities that had all of their children removed using `remove_children`. -* `RemovedComponents` will now contain entities that had all of their children remove using `remove_children`. +* `RemovedComponents` will now contain entities that had all of their children removed using `remove_children`. ### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) @@ -675,7 +675,7 @@ Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. ### [Changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) -Diagnostics values are now in milliseconds. If you need secconds, simply divide it by 1000.0; +Diagnostics values are now in milliseconds. If you need seconds, simply divide it by 1000.0; ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) @@ -741,7 +741,7 @@ The generic `T` of `Size` and `UiRect` got removed and instead they both now alw ### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) -The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been deprecated. +The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been removed. Use the associated constant `IDENTITY` instead. ### [Rename Handle::as_weak() to cast_weak()](https://github.com/bevyengine/bevy/pull/5321) @@ -827,4 +827,4 @@ The `Rect` type got renamed to `UiRect`. To migrate you just have to change ever ### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) -In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are not collapsed automatically. You should remove `#[bundle]` attributes. +In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. From 1e0ad728d057b1951743282a861932d112d2d10c Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Thu, 3 Nov 2022 20:44:16 -0700 Subject: [PATCH 22/38] Order roughly by impact --- .../book/migration-guides/0.8-0.9/_index.md | 946 +++++++++--------- 1 file changed, 473 insertions(+), 473 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 7b1539f1d8..c57d12fe3c 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -13,6 +13,66 @@ Before migrating make sure to run rustup update Bevy relies heavily on improvements in the Rust language and compiler. As a result, the Minimum Supported Rust Version (MSRV) is "the latest stable release" of Rust. +### [Make `Resource` trait opt-in, requiring `#[derive(Resource)]` V2](https://github.com/bevyengine/bevy/pull/5577) + +Add `#[derive(Resource)]` to all types you are using as a resource. + +If you are using a third party type as a resource, wrap it in a tuple struct to bypass orphan rules. Consider deriving `Deref` and `DerefMut` to improve ergonomics. + +`ClearColor` no longer implements `Component`. Using `ClearColor` as a component in 0.8 did nothing. +Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. + +### [Plugins own their settings. Rework PluginGroup trait.](https://github.com/bevyengine/bevy/pull/6336) + +The `WindowDescriptor` settings have been moved from a resource to `WindowPlugin::window`: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(WindowDescriptor { + width: 400.0, + ..default() + }) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + width: 400.0, + ..default() + }, + ..default() +})) +``` + +The `AssetServerSettings` resource has been removed in favor of direct `AssetPlugin` configuration: + +```rust +// Old (Bevy 0.8) +app + .insert_resource(AssetServerSettings { + watch_for_changes: true, + ..default() + }) + .add_plugins(DefaultPlugins) + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() +})) +``` + +`add_plugins_with` has been replaced by `add_plugins` in combination with the builder pattern: + +```rust +// Old (Bevy 0.8) +app.add_plugins_with(DefaultPlugins, |group| group.disable::()); + +// New (Bevy 0.9) +app.add_plugins(DefaultPlugins.build().disable::()); +``` + ### [Use plugin setup for resource only used at setup time](https://github.com/bevyengine/bevy/pull/6360) The `LogSettings` settings have been moved from a resource to `LogPlugin` configuration: @@ -59,208 +119,310 @@ app.add_plugins(DefaultPlugins.set(CorePlugin { })) ``` -### [bevy_scene: Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) +### [Spawn now takes a Bundle](https://github.com/bevyengine/bevy/pull/6054) -The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. +```rust +// Old (0.8): +commands + .spawn() + .insert_bundle((A, B, C)); +// New (0.9) +commands.spawn((A, B, C)); + +// Old (0.8): +commands.spawn_bundle((A, B, C)); +// New (0.9) +commands.spawn((A, B, C)); + +// Old (0.8): +let entity = commands.spawn().id(); +// New (0.9) +let entity = commands.spawn_empty().id(); + +// Old (0.8) +let entity = world.spawn().id(); +// New (0.9) +let entity = world.spawn_empty(); +``` + +### [Accept Bundles for insert and remove. Deprecate `insert`/`remove_bundle`](https://github.com/bevyengine/bevy/pull/6039) + +Replace `insert_bundle` with `insert`: ```rust -// Old (Bevy 0.8) -[ - ( - entity: 0, - components: [ - // Components... - ] - ), -] +// Old (0.8) +commands.spawn().insert_bundle(SomeBundle::default()); +// New (0.9) +commands.spawn().insert(SomeBundle::default()); +``` -// New (Bevy 0.9) -( - entities: [ - ( - entity: 0, - components: [ - // Components... - ] - ), - ] -) +Replace `remove_bundle` with `remove`: + +```rust +// Old (0.8) +commands.entity(some_entity).remove_bundle::(); +// New (0.9) +commands.entity(some_entity).remove::(); ``` -### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) +Replace `remove_bundle_intersection` with `remove_intersection`: -If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. +```rust +// Old (0.8) +world.entity_mut(some_entity).remove_bundle_intersection::(); +// New (0.9) +world.entity_mut(some_entity).remove_intersection::(); +``` -### [bevy_scene: Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) +Consider consolidating as many operations as possible to improve ergonomics and cut down on archetype moves: -The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. +```rust +// Old (0.8) +commands.spawn() + .insert_bundle(SomeBundle::default()) + .insert(SomeComponent); + +// New (0.9) - Option 1 +commands.spawn_empty().insert(( + SomeBundle::default(), + SomeComponent, +)) + +// New (0.9) - Option 2 +commands.spawn(( + SomeBundle::default(), + SomeComponent, +)) +``` + +### [Replace the `bool` argument of `Timer` with `TimerMode`](https://github.com/bevyengine/bevy/pull/6247) + +* Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`. +* Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`. +* Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`. +* Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. +* Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. + +### [Change UI coordinate system to have origin at top left corner](https://github.com/bevyengine/bevy/pull/6000) + +All flex layout should be inverted (ColumnReverse => Column, FlexStart => FlexEnd, WrapReverse => Wrap) +System where dealing with cursor position should be changed to account for cursor position being based on the top left instead of bottom left + +### [Rename `UiColor` to `BackgroundColor`](https://github.com/bevyengine/bevy/pull/6087) + +`UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. + +### [Make the default background color of `NodeBundle` transparent](https://github.com/bevyengine/bevy/pull/6211) + +If you want a `NodeBundle` with a white background color, you must explicitly specify it: ```rust // Old (Bevy 0.8) -[ - ( - entity: 0, - components: [ - { - "bevy_transform::components::transform::Transform": ( - translation: ( - x: 0.0, - y: 0.0, - z: 0.0 - ), - rotation: (0.0, 0.0, 0.0, 1.0), - scale: ( - x: 1.0, - y: 1.0, - z: 1.0 - ), - ), - }, - { - "my_crate::Foo": ( - text: "Hello World", - ), - }, - { - "my_crate::Bar": ( - baz: 123, - ), - }, - ], - ), -] +let node = NodeBundle { + ..default() +} // New (Bevy 0.9) -[ - ( - entity: 0, - components: { - "bevy_transform::components::transform::Transform": ( - translation: ( - x: 0.0, - y: 0.0, - z: 0.0 - ), - rotation: (0.0, 0.0, 0.0, 1.0), - scale: ( - x: 1.0, - y: 1.0, - z: 1.0 - ), - ), - "my_crate::Foo": ( - text: "Hello World", - ), - "my_crate::Bar": ( - baz: 123 - ), - }, - ), -] +let node = NodeBundle { + background_color: Color::WHITE.into(), + ..default() +} ``` +### [Clarify `bevy::ui::Node` field and documentation](https://github.com/bevyengine/bevy/pull/5995) + +All references to the old `size` name has been changed, to access `bevy::ui::Node` `size` field use `calculated_size` + +### [Remove `Size` and `UiRect` generics](https://github.com/bevyengine/bevy/pull/5404) + +The generic `T` of `Size` and `UiRect` got removed and instead they both now always use `Val`. If you used a `Size` consider replacing it with a `Vec2` which is way more powerful. + +### [Remove `margins.rs`](https://github.com/bevyengine/bevy/pull/4284) + +The `Margins` type got removed. To migrate you just have to change every occurrence of `Margins` to `UiRect`. + +### [Move `Size` to `bevy_ui`](https://github.com/bevyengine/bevy/pull/4285) + +The `Size` type got moved from `bevy::math` to `bevy::ui`. To migrate you just have to import `bevy::ui::Size` instead of `bevy::math::Math` or use the `bevy::prelude` instead. + +### [Move `Rect` to `bevy_ui` and rename it to `UiRect`](https://github.com/bevyengine/bevy/pull/4276) + +The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`. + +### [Move `sprite::Rect` into `bevy_math`](https://github.com/bevyengine/bevy/pull/5686) + +The `bevy::sprite::Rect` type moved to the math utility crate as +`bevy::math::Rect`. You should change your imports from `use bevy::sprite::Rect` to `use bevy::math::Rect`. + +### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) + +In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. + +### [Exclusive Systems Now Implement `System`. Flexible Exclusive System Params](https://github.com/bevyengine/bevy/pull/6083) + +Calling `.exclusive_system()` is no longer required (or supported) for converting exclusive system functions to exclusive systems: + +```rust +// Old (0.8) +app.add_system(some_exclusive_system.exclusive_system()); +// New (0.9) +app.add_system(some_exclusive_system); +``` + +Converting “normal” parallel systems to exclusive systems is done by calling the exclusive ordering apis: + +```rust +// Old (0.8) +app.add_system(some_system.exclusive_system().at_end()); +// New (0.9) +app.add_system(some_system.at_end()); +``` + +Query state in exclusive systems can now be cached via ExclusiveSystemParams, which should be preferred for clarity and performance reasons: + +```rust +// Old (0.8) +fn some_system(world: &mut World) { + let mut transforms = world.query::<&Transform>(); + for transform in transforms.iter(world) { + } +} +// New (0.9) +fn some_system(world: &mut World, transforms: &mut QueryState<&Transform>) { + for transform in transforms.iter(world) { + } +} +``` + +### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) + +`TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. + +```rust +// 0.8 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); +// 0.9 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, None, None) + +// 0.8 +TextureAtlas::from_grid_with_padding(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Vec2::new(4.0, 4.0)); +// 0.9 +TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Some(Vec2::new(4.0, 4.0)), None) +``` + +### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) + +* `time.time_since_startup()` -> `time.elapsed()` +* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` +* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` + +If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. + +### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) + +If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. + +### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) + +The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. + +### [Add getters and setters for `InputAxis` and `ButtonSettings`](https://github.com/bevyengine/bevy/pull/6088) + +`AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. +`AxisSettings` fields made private; now must be accessed through getters and setters. There’s a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. +`AxisSettings` setters no longer panic. +`ButtonSettings` fields made private; now must be accessed through getters and setters. +`ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. + ### [Add GamepadInfo, expose gamepad names](https://github.com/bevyengine/bevy/pull/6342) * Pattern matches on `GamepadEventType::Connected` will need to be updated, as the form of the variant has changed. * Code that requires `GamepadEvent`, `GamepadEventRaw` or `GamepadEventType` to be `Copy` will need to be updated. -### [Plugins own their settings. Rework PluginGroup trait.](https://github.com/bevyengine/bevy/pull/6336) +### [`Gamepad` type is `Copy`; do not require / return references to it in `Gamepads` API](https://github.com/bevyengine/bevy/pull/5296) -The `WindowDescriptor` settings have been moved from a resource to `WindowPlugin::window`: +* `Gamepads::iter` now returns an iterator of `Gamepad`. rather than an iterator of `&Gamepad`. +* `Gamepads::contains` now accepts a `Gamepad`, rather than a `&Gamepad`. + +### [Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7](https://github.com/bevyengine/bevy/pull/6218) + +Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. + +### [Support monitor selection for all window modes.](https://github.com/bevyengine/bevy/pull/5878) + +`MonitorSelection` was moved out of `WindowPosition::Centered`, into `WindowDescriptor`. +`MonitorSelection::Number` was renamed to `MonitorSelection::Index`. ```rust -// Old (Bevy 0.8) -app - .insert_resource(WindowDescriptor { - width: 400.0, +// Before +.insert_resource(WindowDescriptor { + position: WindowPosition::Centered(MonitorSelection::Number(1)), ..default() - }) - .add_plugins(DefaultPlugins) - -// New (Bevy 0.9) -app.add_plugins(DefaultPlugins.set(WindowPlugin { - window: WindowDescriptor { - width: 400.0, +}) +// After +.add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + monitor: MonitorSelection::Index(1), + position: WindowPosition::Centered, + ..default() + }, ..default() - }, - ..default() })) ``` -The `AssetServerSettings` resource has been removed in favor of direct `AssetPlugin` configuration: +`Window::set_position` now takes a `MonitorSelection` as argument. ```rust -// Old (Bevy 0.8) -app - .insert_resource(AssetServerSettings { - watch_for_changes: true, - ..default() - }) - .add_plugins(DefaultPlugins) - -// New (Bevy 0.9) -app.add_plugins(DefaultPlugins.set(AssetPlugin { - watch_for_changes: true, - ..default() -})) +window.set_position(MonitorSelection::Current, position); ``` -`add_plugins_with` has been replaced by `add_plugins` in combination with the builder pattern: +### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) -```rust -// Old (Bevy 0.8) -app.add_plugins_with(DefaultPlugins, |group| group.disable::()); +`AssetServer::watch_for_changes()` was removed. +Instead, set it directly on the `AssetPlugin`. -// New (Bevy 0.9) -app.add_plugins(DefaultPlugins.build().disable::()); +```rust +app + .add_plugin(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() + })) ``` -### [Replace `WorldQueryGats` trait with actual gats](https://github.com/bevyengine/bevy/pull/6319) - -Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait +### [Rename system chaining to system piping](https://github.com/bevyengine/bevy/pull/6230) -### [Add a method for accessing the width of a `Table`](https://github.com/bevyengine/bevy/pull/6249) +The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. +The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struct is now `PipeSystem`. -Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table::capacity` should now be `Table::entity_capacity`. +### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) -### [Replace the `bool` argument of `Timer` with `TimerMode`](https://github.com/bevyengine/bevy/pull/6247) +The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been removed. +Use the associated constant `IDENTITY` instead. -* Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`. -* Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`. -* Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`. -* Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. -* Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. +### [Rename `Transform::mul_vec3` to `transform_point` and improve docs](https://github.com/bevyengine/bevy/pull/6132) -### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) +`Transform::mul_vec3` has been renamed to `transform_point`. -* `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. -* As a reminder, private fields exposed via reflection are not subject to any stability guarantees. +### [Remove `Transform::apply_non_uniform_scale`](https://github.com/bevyengine/bevy/pull/6133) -### [Rename system chaining to system piping](https://github.com/bevyengine/bevy/pull/6230) +`Transform::apply_non_uniform_scale` has been removed. +It can be replaced with the following snippet: -The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. -The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struct is now `PipeSystem`. +```rust +transform.scale *= scale_factor; +``` -### [Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7](https://github.com/bevyengine/bevy/pull/6218) +### [Remove `face_toward.rs`](https://github.com/bevyengine/bevy/pull/4277) -Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. +The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`. -### [Make the default background color of `NodeBundle` transparent](https://github.com/bevyengine/bevy/pull/6211) +### [Replace `WorldQueryGats` trait with actual gats](https://github.com/bevyengine/bevy/pull/6319) -If you want a `NodeBundle` with a white background color, you must explicitly specify it: +Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait -```rust -// Old (Bevy 0.8) -let node = NodeBundle { - ..default() -} +### [Add a method for accessing the width of a `Table`](https://github.com/bevyengine/bevy/pull/6249) -// New (Bevy 0.9) -let node = NodeBundle { - background_color: Color::WHITE.into(), - ..default() -} -``` +Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table::capacity` should now be `Table::entity_capacity`. ### [Make `Handle::` field id private, and replace with a getter](https://github.com/bevyengine/bevy/pull/6176) @@ -296,241 +458,114 @@ app ``` -### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) - -Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. - -### [Remove `Transform::apply_non_uniform_scale`](https://github.com/bevyengine/bevy/pull/6133) - -`Transform::apply_non_uniform_scale` has been removed. -It can be replaced with the following snippet: +### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) -```rust -transform.scale *= scale_factor; -``` +Ambiguity sets have been removed. -### [Rename `Transform::mul_vec3` to `transform_point` and improve docs](https://github.com/bevyengine/bevy/pull/6132) +### [Remove unused DepthCalculation enum](https://github.com/bevyengine/bevy/pull/5684) -`Transform::mul_vec3` has been renamed to `transform_point`. +Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_render::camera::DepthCalculation`. Remove `depth_calculation` fields from Projections. ### [Make `raw_window_handle` field in `Window` and `ExtractedWindow` an `Option`.](https://github.com/bevyengine/bevy/pull/6114) `Window::raw_window_handle()` now returns `Option`. -### [``Entity``'s “ID” should be named “index” instead](https://github.com/bevyengine/bevy/pull/6107) - -The `Entity::id()` method was renamed to `Entity::index()`. - -### [Add getters and setters for `InputAxis` and `ButtonSettings`](https://github.com/bevyengine/bevy/pull/6088) - -`AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. -`AxisSettings` fields made private; now must be accessed through getters and setters. There’s a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. -`AxisSettings` setters no longer panic. -`ButtonSettings` fields made private; now must be accessed through getters and setters. -`ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. - -### [Rename `UiColor` to `BackgroundColor`](https://github.com/bevyengine/bevy/pull/6087) - -`UiColor` has been renamed to `BackgroundColor`. This change affects `NodeBundle`, `ButtonBundle` and `ImageBundle`. In addition, the corresponding field on `ExtractedUiNode` has been renamed to `background_color` for consistency. - -### [Exclusive Systems Now Implement `System`. Flexible Exclusive System Params](https://github.com/bevyengine/bevy/pull/6083) - -Calling `.exclusive_system()` is no longer required (or supported) for converting exclusive system functions to exclusive systems: - -```rust -// Old (0.8) -app.add_system(some_exclusive_system.exclusive_system()); -// New (0.9) -app.add_system(some_exclusive_system); -``` +### [Fix inconsistent children removal behavior](https://github.com/bevyengine/bevy/pull/6017) -Converting “normal” parallel systems to exclusive systems is done by calling the exclusive ordering apis: +* Queries with `Changed` will no longer match entities that had all of their children removed using `remove_children`. +* `RemovedComponents` will now contain entities that had all of their children removed using `remove_children`. -```rust -// Old (0.8) -app.add_system(some_system.exclusive_system().at_end()); -// New (0.9) -app.add_system(some_system.at_end()); -``` +### [``Entity``'s “ID” should be named “index” instead](https://github.com/bevyengine/bevy/pull/6107) -Query state in exclusive systems can now be cached via ExclusiveSystemParams, which should be preferred for clarity and performance reasons: +The `Entity::id()` method was renamed to `Entity::index()`. -```rust -// Old (0.8) -fn some_system(world: &mut World) { - let mut transforms = world.query::<&Transform>(); - for transform in transforms.iter(world) { - } -} -// New (0.9) -fn some_system(world: &mut World, transforms: &mut QueryState<&Transform>) { - for transform in transforms.iter(world) { - } -} -``` +### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) -### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) +Switch to using other methods of getting the length. -`TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. +### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) -```rust -// 0.8 -TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); -// 0.9 -TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, None, None) +Query filter (`F`) generics are now bound by `ReadOnlyWorldQuery`, rather than `WorldQuery`. If for some reason you were requesting `Query<&A, &mut B>`, please use `Query<&A, With>` instead. -// 0.8 -TextureAtlas::from_grid_with_padding(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Vec2::new(4.0, 4.0)); -// 0.9 -TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Some(Vec2::new(4.0, 4.0)), None) -``` +### [Add `pop` method for `List` trait.](https://github.com/bevyengine/bevy/pull/5797) -### [Spawn now takes a Bundle](https://github.com/bevyengine/bevy/pull/6054) +Any custom type that implements the `List` trait will now need to implement the `pop` method. -```rust -// Old (0.8): -commands - .spawn() - .insert_bundle((A, B, C)); -// New (0.9) -commands.spawn((A, B, C)); +### [Remove an outdated workaround for `impl Trait`](https://github.com/bevyengine/bevy/pull/5659) -// Old (0.8): -commands.spawn_bundle((A, B, C)); -// New (0.9) -commands.spawn((A, B, C)); +The methods `Schedule::get_stage` and `get_stage_mut` now accept `impl StageLabel` instead of `&dyn StageLabel`. -// Old (0.8): -let entity = commands.spawn().id(); -// New (0.9) -let entity = commands.spawn_empty().id(); +### [Add a change detection bypass and manual control over change ticks](https://github.com/bevyengine/bevy/pull/5635) -// Old (0.8) -let entity = world.spawn().id(); -// New (0.9) -let entity = world.spawn_empty(); -``` +Add the `Inner` associated type and new methods to any type that you’ve implemented `DetectChanges` for. -### [Accept Bundles for insert and remove. Deprecate `insert`/`remove_bundle`](https://github.com/bevyengine/bevy/pull/6039) +### [Make internal struct `ShaderData` non-`pub`](https://github.com/bevyengine/bevy/pull/5609) -Replace `insert_bundle` with `insert`: + -```rust -// Old (0.8) -commands.spawn().insert_bundle(SomeBundle::default()); -// New (0.9) -commands.spawn().insert(SomeBundle::default()); -``` +### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) -Replace `remove_bundle` with `remove`: +`Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` -```rust -// Old (0.8) -commands.entity(some_entity).remove_bundle::(); -// New (0.9) -commands.entity(some_entity).remove::(); -``` +### [Rename Handle::as_weak() to cast_weak()](https://github.com/bevyengine/bevy/pull/5321) -Replace `remove_bundle_intersection` with `remove_intersection`: +* Rename `Handle::as_weak` uses to `Handle::cast_weak` -```rust -// Old (0.8) -world.entity_mut(some_entity).remove_bundle_intersection::(); -// New (0.9) -world.entity_mut(some_entity).remove_intersection::(); -``` +The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior. -Consider consolidating as many operations as possible to improve ergonomics and cut down on archetype moves: +### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) -```rust -// Old (0.8) -commands.spawn() - .insert_bundle(SomeBundle::default()) - .insert(SomeComponent); +Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. -// New (0.9) - Option 1 -commands.spawn_empty().insert(( - SomeBundle::default(), - SomeComponent, -)) +### [Add `FromWorld` bound to `T` in `Local`](https://github.com/bevyengine/bevy/pull/5481) -// New (0.9) - Option 2 -commands.spawn(( - SomeBundle::default(), - SomeComponent, -)) -``` +It might be possible for references to `Local`s without `T: FromWorld` to exist, but these should be exceedingly rare and probably dead code. In the event that one of these is encountered, the easiest solutions are to delete the code or wrap the inner `T` in an `Option` to allow it to be default constructed to `None`. -### [Fix inconsistent children removal behavior](https://github.com/bevyengine/bevy/pull/6017) +This may also have other smaller implications (such as `Debug` representation), but serialization is probably the most prominent. -* Queries with `Changed` will no longer match entities that had all of their children removed using `remove_children`. -* `RemovedComponents` will now contain entities that had all of their children removed using `remove_children`. +### [Swap out `num_cpus` for `std::thread::available_parallelism`](https://github.com/bevyengine/bevy/pull/4970) -### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) +`bevy_tasks::logical_core_count` and `bevy_tasks::physical_core_count` have been removed. `logical_core_count` has been replaced with `bevy_tasks::available_parallelism`, which works identically. If `bevy_tasks::physical_core_count` is required, the `num_cpus` crate can be used directly, as these two were just aliases for `num_cpus` APIs. -Query filter (`F`) generics are now bound by `ReadOnlyWorldQuery`, rather than `WorldQuery`. If for some reason you were requesting `Query<&A, &mut B>`, please use `Query<&A, With>` instead. +### [Changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) -### [Change UI coordinate system to have origin at top left corner](https://github.com/bevyengine/bevy/pull/6000) +Diagnostics values are now in milliseconds. If you need seconds, simply divide it by 1000.0; -All flex layout should be inverted (ColumnReverse => Column, FlexStart => FlexEnd, WrapReverse => Wrap) -System where dealing with cursor position should be changed to account for cursor position being based on the top left instead of bottom left +### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) -### [Clarify `bevy::ui::Node` field and documentation](https://github.com/bevyengine/bevy/pull/5995) +`LogDiagnosticsPlugin` now records the smoothed value rather than the raw value. -All references to the old `size` name has been changed, to access `bevy::ui::Node` `size` field use `calculated_size` +* For diagnostics recorded less often than every 0.1 seconds, this change to defaults will have no visible effect. +* For discrete diagnostics where this smoothing is not desirable, set a smoothing factor of 0 to disable smoothing. +* The average of the recent history is still shown when available. -### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) +### [Nested spawns on scope](https://github.com/bevyengine/bevy/pull/4466) -`AssetServer::watch_for_changes()` was removed. -Instead, set it directly on the `AssetPlugin`. +If you were using explicit lifetimes and Passing Scope you’ll need to specify two lifetimes now. ```rust -app - .add_plugin(DefaultPlugins.set(AssetPlugin { - watch_for_changes: true, - ..default() - })) -``` - -### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) - -Ambiguity sets have been removed. - -### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) +// 0.8 +fn scoped_function<'scope>(scope: &mut Scope<'scope, ()>) {} -Switch to using other methods of getting the length. +// 0.9 +fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} +``` -### [Support monitor selection for all window modes.](https://github.com/bevyengine/bevy/pull/5878) +`scope.spawn_local` changed to `scope.spawn_on_scope` this should cover cases where you needed to run tasks on the local thread, but does not cover spawning Nonsend Futures. Spawning of NonSend futures on scope is no longer supported. -`MonitorSelection` was moved out of `WindowPosition::Centered`, into `WindowDescriptor`. -`MonitorSelection::Number` was renamed to `MonitorSelection::Index`. +### [Extract Resources into their own dedicated storage](https://github.com/bevyengine/bevy/pull/4809) -```rust -// Before -.insert_resource(WindowDescriptor { - position: WindowPosition::Centered(MonitorSelection::Number(1)), - ..default() -}) -// After -.add_plugins(DefaultPlugins.set(WindowPlugin { - window: WindowDescriptor { - monitor: MonitorSelection::Index(1), - position: WindowPosition::Centered, - ..default() - }, - ..default() -})) -``` +Resources have been moved to `Resources` under `Storages` in `World`. All code dependent on `Archetype::unique_components(_mut)` should access it via `world.storages().resources()` instead. -`Window::set_position` now takes a `MonitorSelection` as argument. +All APIs accessing the raw data of individual resources (mutable _and_ read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. -```rust -window.set_position(MonitorSelection::Current, position); -``` +### [Clean up Fetch code](https://github.com/bevyengine/bevy/pull/4800) -### [Add `pop` method for `List` trait.](https://github.com/bevyengine/bevy/pull/5797) +Changed: `Fetch::table_fetch` and `Fetch::archetype_fetch` have been merged into a single `Fetch::fetch` function. -Any custom type that implements the `List` trait will now need to implement the `pop` method. +### [Rename `ElementState` to `ButtonState`](https://github.com/bevyengine/bevy/pull/4314) + +The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. ### [bevy_pbr: Fix incorrect and unnecessary normal-mapping code](https://github.com/bevyengine/bevy/pull/5766) @@ -575,13 +610,106 @@ After: ); ``` -### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) +### [bevy_scene: Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) -* `time.time_since_startup()` -> `time.elapsed()` -* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` -* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` +The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. -If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. +```rust +// Old (Bevy 0.8) +[ + ( + entity: 0, + components: [ + // Components... + ] + ), +] + +// New (Bevy 0.9) +( + entities: [ + ( + entity: 0, + components: [ + // Components... + ] + ), + ] +) +``` + +### [bevy_scene: Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) + +The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. + +```rust +// Old (Bevy 0.8) +[ + ( + entity: 0, + components: [ + { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + { + "my_crate::Foo": ( + text: "Hello World", + ), + }, + { + "my_crate::Bar": ( + baz: 123, + ), + }, + ], + ), +] + +// New (Bevy 0.9) +[ + ( + entity: 0, + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + "my_crate::Foo": ( + text: "Hello World", + ), + "my_crate::Bar": ( + baz: 123 + ), + }, + ), +] +``` + +### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) + +* `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. +* As a reminder, private fields exposed via reflection are not subject to any stability guarantees. ### [bevy_reflect: Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) @@ -617,19 +745,6 @@ This PR reduces the verbosity of the scene format. Scenes will need to be update } ``` -### [Move `sprite::Rect` into `bevy_math`](https://github.com/bevyengine/bevy/pull/5686) - -The `bevy::sprite::Rect` type moved to the math utility crate as -`bevy::math::Rect`. You should change your imports from `use bevy::sprite::Rect` to `use bevy::math::Rect`. - -### [Remove unused DepthCalculation enum](https://github.com/bevyengine/bevy/pull/5684) - -Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_render::camera::DepthCalculation`. Remove `depth_calculation` fields from Projections. - -### [Remove an outdated workaround for `impl Trait`](https://github.com/bevyengine/bevy/pull/5659) - -The methods `Schedule::get_stage` and `get_stage_mut` now accept `impl StageLabel` instead of `&dyn StageLabel`. - ### [bevy_reflect: Relax bounds on `Option`](https://github.com/bevyengine/bevy/pull/5658) If using `Option` with Bevy’s reflection API, `T` now needs to implement `FromReflect` rather than just `Clone`. This can be achieved easily by simply deriving `FromReflect`: @@ -651,50 +766,11 @@ let reflected: Box = Box::new(Some(Foo)); Note: You can still derive `Clone`, but it’s not required in order to compile. -### [Add a change detection bypass and manual control over change ticks](https://github.com/bevyengine/bevy/pull/5635) - -Add the `Inner` associated type and new methods to any type that you’ve implemented `DetectChanges` for. - ### [Remove `ReflectMut` in favor of `Mut`](https://github.com/bevyengine/bevy/pull/5630) * relax `T: ?Sized` bound in `Mut` * replace all instances of `ReflectMut` with `Mut` -### [Make internal struct `ShaderData` non-`pub`](https://github.com/bevyengine/bevy/pull/5609) - - - -### [Make `Resource` trait opt-in, requiring `#[derive(Resource)]` V2](https://github.com/bevyengine/bevy/pull/5577) - -Add `#[derive(Resource)]` to all types you are using as a resource. - -If you are using a third party type as a resource, wrap it in a tuple struct to bypass orphan rules. Consider deriving `Deref` and `DerefMut` to improve ergonomics. - -`ClearColor` no longer implements `Component`. Using `ClearColor` as a component in 0.8 did nothing. -Use the `ClearColorConfig` in the `Camera3d` and `Camera2d` components instead. - -### [Changed diagnostics from seconds to milliseconds](https://github.com/bevyengine/bevy/pull/5554) - -Diagnostics values are now in milliseconds. If you need seconds, simply divide it by 1000.0; - -### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) - -`Children::with()` is now renamed `Children::from_entities()` and is now `pub(crate)` - -### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) - -* Rename `image_to_texture` to `Image::from_dynamic` -* Rename `texture_to_image` to `Image::try_into_dynamic` -* `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.) - -### [Remove `Sync` bound from `Local`](https://github.com/bevyengine/bevy/pull/5483) - -Any code relying on `Local` having `T: Resource` may have to be changed, but this is unlikely. - -### [Add `FromWorld` bound to `T` in `Local`](https://github.com/bevyengine/bevy/pull/5481) - -It might be possible for references to `Local`s without `T: FromWorld` to exist, but these should be exceedingly rare and probably dead code. In the event that one of these is encountered, the easiest solutions are to delete the code or wrap the inner `T` in an `Option` to allow it to be default constructed to `None`. - ### [bevy_reflect: Update enum derives](https://github.com/bevyengine/bevy/pull/5473) Bevy-defined enums have been updated to implement `Enum` and are not considered value types (`ReflectRef::Value`) anymore. This means that their serialized representations will need to be updated. For example, given the Bevy enum: @@ -733,28 +809,6 @@ You will need to update the serialized versions accordingly. }, ``` -This may also have other smaller implications (such as `Debug` representation), but serialization is probably the most prominent. - -### [Remove `Size` and `UiRect` generics](https://github.com/bevyengine/bevy/pull/5404) - -The generic `T` of `Size` and `UiRect` got removed and instead they both now always use `Val`. If you used a `Size` consider replacing it with a `Vec2` which is way more powerful. - -### [Add associated constant `IDENTITY` to `Transform` and friends.](https://github.com/bevyengine/bevy/pull/5340) - -The method `identity()` on `Transform`, `GlobalTransform` and `TransformBundle` has been removed. -Use the associated constant `IDENTITY` instead. - -### [Rename Handle::as_weak() to cast_weak()](https://github.com/bevyengine/bevy/pull/5321) - -* Rename `Handle::as_weak` uses to `Handle::cast_weak` - -The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior. - -### [`Gamepad` type is `Copy`; do not require / return references to it in `Gamepads` API](https://github.com/bevyengine/bevy/pull/5296) - -* `Gamepads::iter` now returns an iterator of `Gamepad`. rather than an iterator of `&Gamepad`. -* `Gamepads::contains` now accepts a `Gamepad`, rather than a `&Gamepad`. - ### [remove blanket `Serialize + Deserialize` requirement for `Reflect` on generic types](https://github.com/bevyengine/bevy/pull/5197) `.register_type` for generic types like `Option`, `Vec`, `HashMap` will no longer insert `ReflectSerialize` and `ReflectDeserialize` type data. Instead you need to register it separately for concrete generic types like so: @@ -765,66 +819,12 @@ The method now properly sets the associated type uuid if the handle is a direct .register_type_data::, ReflectDeserialize>() ``` -### [Add Exponential Moving Average into diagnostics](https://github.com/bevyengine/bevy/pull/4992) - -`LogDiagnosticsPlugin` now records the smoothed value rather than the raw value. - -* For diagnostics recorded less often than every 0.1 seconds, this change to defaults will have no visible effect. -* For discrete diagnostics where this smoothing is not desirable, set a smoothing factor of 0 to disable smoothing. -* The average of the recent history is still shown when available. - -### [Swap out `num_cpus` for `std::thread::available_parallelism`](https://github.com/bevyengine/bevy/pull/4970) - -`bevy_tasks::logical_core_count` and `bevy_tasks::physical_core_count` have been removed. `logical_core_count` has been replaced with `bevy_tasks::available_parallelism`, which works identically. If `bevy_tasks::physical_core_count` is required, the `num_cpus` crate can be used directly, as these two were just aliases for `num_cpus` APIs. - -### [Extract Resources into their own dedicated storage](https://github.com/bevyengine/bevy/pull/4809) - -Resources have been moved to `Resources` under `Storages` in `World`. All code dependent on `Archetype::unique_components(_mut)` should access it via `world.storages().resources()` instead. - -All APIs accessing the raw data of individual resources (mutable _and_ read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. - -### [Clean up Fetch code](https://github.com/bevyengine/bevy/pull/4800) - -Changed: `Fetch::table_fetch` and `Fetch::archetype_fetch` have been merged into a single `Fetch::fetch` function. - -### [Change `gamepad.rs` tuples to normal structs](https://github.com/bevyengine/bevy/pull/4519) - -The `Gamepad`, `GamepadButton`, `GamepadAxis`, `GamepadEvent` and `GamepadEventRaw` types are now normal structs instead of tuple structs and have a `new()` function. To migrate change every instantiation to use the `new()` function instead and use the appropriate field names instead of `.0` and `.1`. - -### [Nested spawns on scope](https://github.com/bevyengine/bevy/pull/4466) - -If you were using explicit lifetimes and Passing Scope you’ll need to specify two lifetimes now. - -```rust -// 0.8 -fn scoped_function<'scope>(scope: &mut Scope<'scope, ()>) {} - -// 0.9 -fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} -``` - -`scope.spawn_local` changed to `scope.spawn_on_scope` this should cover cases where you needed to run tasks on the local thread, but does not cover spawning Nonsend Futures. Spawning of NonSend futures on scope is no longer supported. - -### [Rename `ElementState` to `ButtonState`](https://github.com/bevyengine/bevy/pull/4314) - -The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. - -### [Move `Size` to `bevy_ui`](https://github.com/bevyengine/bevy/pull/4285) - -The `Size` type got moved from `bevy::math` to `bevy::ui`. To migrate you just have to import `bevy::ui::Size` instead of `bevy::math::Math` or use the `bevy::prelude` instead. - -### [Remove `margins.rs`](https://github.com/bevyengine/bevy/pull/4284) - -The `Margins` type got removed. To migrate you just have to change every occurrence of `Margins` to `UiRect`. - -### [Remove `face_toward.rs`](https://github.com/bevyengine/bevy/pull/4277) - -The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`. - -### [Move `Rect` to `bevy_ui` and rename it to `UiRect`](https://github.com/bevyengine/bevy/pull/4276) +### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) -The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`. +Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. -### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) +### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) -In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. +* Rename `image_to_texture` to `Image::from_dynamic` +* Rename `texture_to_image` to `Image::try_into_dynamic` +* `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.) From 05bbab2c751f8e217de61630a9bedcb5507fb37e Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 4 Nov 2022 00:54:15 -0400 Subject: [PATCH 23/38] more reorganization --- .../book/migration-guides/0.8-0.9/_index.md | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index c57d12fe3c..42c15547ab 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -119,6 +119,19 @@ app.add_plugins(DefaultPlugins.set(CorePlugin { })) ``` +### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) + +`AssetServer::watch_for_changes()` was removed. +Instead, set it directly on the `AssetPlugin`. + +```rust +app + .add_plugin(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() + })) +``` + ### [Spawn now takes a Bundle](https://github.com/bevyengine/bevy/pull/6054) ```rust @@ -195,6 +208,10 @@ commands.spawn(( )) ``` +### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) + +In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. + ### [Replace the `bool` argument of `Timer` with `TimerMode`](https://github.com/bevyengine/bevy/pull/6247) * Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`. @@ -203,6 +220,14 @@ commands.spawn(( * Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. * Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. +### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) + +* `time.time_since_startup()` -> `time.elapsed()` +* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` +* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` + +If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. + ### [Change UI coordinate system to have origin at top left corner](https://github.com/bevyengine/bevy/pull/6000) All flex layout should be inverted (ColumnReverse => Column, FlexStart => FlexEnd, WrapReverse => Wrap) @@ -254,10 +279,6 @@ The `Rect` type got renamed to `UiRect`. To migrate you just have to change ever The `bevy::sprite::Rect` type moved to the math utility crate as `bevy::math::Rect`. You should change your imports from `use bevy::sprite::Rect` to `use bevy::math::Rect`. -### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) - -In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. - ### [Exclusive Systems Now Implement `System`. Flexible Exclusive System Params](https://github.com/bevyengine/bevy/pull/6083) Calling `.exclusive_system()` is no longer required (or supported) for converting exclusive system functions to exclusive systems: @@ -310,14 +331,6 @@ TextureAtlas::from_grid_with_padding(texture_handle, Vec2::new(24.0, 24.0), 7, 1 TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, Some(Vec2::new(4.0, 4.0)), None) ``` -### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) - -* `time.time_since_startup()` -> `time.elapsed()` -* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` -* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` - -If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. - ### [Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing](https://github.com/bevyengine/bevy/pull/6350) If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won’t have any effect if the requested animation is already playing. @@ -376,19 +389,6 @@ Adjust usage of `bevy_window::WindowDescriptor`’s `cursor_locked` to `cursor_g window.set_position(MonitorSelection::Current, position); ``` -### [Remove `AssetServer::watch_for_changes()`](https://github.com/bevyengine/bevy/pull/5968) - -`AssetServer::watch_for_changes()` was removed. -Instead, set it directly on the `AssetPlugin`. - -```rust -app - .add_plugin(DefaultPlugins.set(AssetPlugin { - watch_for_changes: true, - ..default() - })) -``` - ### [Rename system chaining to system piping](https://github.com/bevyengine/bevy/pull/6230) The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. @@ -567,7 +567,7 @@ Changed: `Fetch::table_fetch` and `Fetch::archetype_fetch` have been merged into The `ElementState` type received a rename and is now called `ButtonState`. To migrate you just have to change every occurrence of `ElementState` to `ButtonState`. -### [bevy_pbr: Fix incorrect and unnecessary normal-mapping code](https://github.com/bevyengine/bevy/pull/5766) +### [Fix incorrect and unnecessary normal-mapping code](https://github.com/bevyengine/bevy/pull/5766) `prepare_normal` from the `bevy_pbr::pbr_functions` shader import has been reworked. @@ -610,7 +610,7 @@ After: ); ``` -### [bevy_scene: Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) +### [Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. @@ -638,7 +638,7 @@ The scene file format now uses a struct as the root object rather than a list of ) ``` -### [bevy_scene: Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) +### [Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. @@ -711,7 +711,7 @@ The scene format now uses a map to represent the collection of components. Scene * `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. * As a reminder, private fields exposed via reflection are not subject to any stability guarantees. -### [bevy_reflect: Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) +### [Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) This PR reduces the verbosity of the scene format. Scenes will need to be updated accordingly: @@ -745,7 +745,7 @@ This PR reduces the verbosity of the scene format. Scenes will need to be update } ``` -### [bevy_reflect: Relax bounds on `Option`](https://github.com/bevyengine/bevy/pull/5658) +### [Relax bounds on `Option`](https://github.com/bevyengine/bevy/pull/5658) If using `Option` with Bevy’s reflection API, `T` now needs to implement `FromReflect` rather than just `Clone`. This can be achieved easily by simply deriving `FromReflect`: @@ -771,7 +771,7 @@ Note: You can still derive `Clone`, but it’s not required in order to compile. * relax `T: ?Sized` bound in `Mut` * replace all instances of `ReflectMut` with `Mut` -### [bevy_reflect: Update enum derives](https://github.com/bevyengine/bevy/pull/5473) +### [Update enum derives](https://github.com/bevyengine/bevy/pull/5473) Bevy-defined enums have been updated to implement `Enum` and are not considered value types (`ReflectRef::Value`) anymore. This means that their serialized representations will need to be updated. For example, given the Bevy enum: @@ -814,9 +814,9 @@ You will need to update the serialized versions accordingly. `.register_type` for generic types like `Option`, `Vec`, `HashMap` will no longer insert `ReflectSerialize` and `ReflectDeserialize` type data. Instead you need to register it separately for concrete generic types like so: ```rust - .register_type::>() - .register_type_data::, ReflectSerialize>() - .register_type_data::, ReflectDeserialize>() + .register_type::>() + .register_type_data::, ReflectSerialize>() + .register_type_data::, ReflectDeserialize>() ``` ### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) From 22d4b6d07ccf1864f484cbabe3df42b079529516 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 Nov 2022 01:15:29 -0400 Subject: [PATCH 24/38] Apply suggestions from code review Co-authored-by: Rob Parrett --- .../learn/book/migration-guides/0.8-0.9/_index.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 42c15547ab..243cf9cf29 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -166,7 +166,7 @@ Replace `insert_bundle` with `insert`: // Old (0.8) commands.spawn().insert_bundle(SomeBundle::default()); // New (0.9) -commands.spawn().insert(SomeBundle::default()); +commands.spawn_empty().insert(SomeBundle::default()); ``` Replace `remove_bundle` with `remove`: @@ -458,10 +458,6 @@ app ``` -### [Remove ambiguity sets](https://github.com/bevyengine/bevy/pull/5916) - -Ambiguity sets have been removed. - ### [Remove unused DepthCalculation enum](https://github.com/bevyengine/bevy/pull/5684) Remove references to `bevy_render::camera::DepthCalculation`, such as `use bevy_render::camera::DepthCalculation`. Remove `depth_calculation` fields from Projections. @@ -822,9 +818,3 @@ You will need to update the serialized versions accordingly. ### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. - -### [Expose `Image` conversion functions (fixes #5452)](https://github.com/bevyengine/bevy/pull/5527) - -* Rename `image_to_texture` to `Image::from_dynamic` -* Rename `texture_to_image` to `Image::try_into_dynamic` -* `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.) From 03cf6c82abfef104c183fc98b6bae8a06f3e861f Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 4 Nov 2022 14:25:07 -0400 Subject: [PATCH 25/38] update --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 243cf9cf29..01782add48 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -497,7 +497,7 @@ Add the `Inner` associated type and new methods to any type that you’ve implem ### [Make internal struct `ShaderData` non-`pub`](https://github.com/bevyengine/bevy/pull/5609) - +Removed `ShaderData` from the public API, which was only ever used internally. No public function was using it so there should be no need for any migration action. ### [Make `Children` constructor `pub(crate)`.](https://github.com/bevyengine/bevy/pull/5532) From 94c435ae96862bcbd03c74d2614c007c01641478 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Fri, 4 Nov 2022 14:30:29 -0400 Subject: [PATCH 26/38] add 6442 --- content/learn/book/migration-guides/0.8-0.9/_index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 01782add48..833fbdf0bf 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -818,3 +818,8 @@ You will need to update the serialized versions accordingly. ### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. + +### [Allow passing glam vector types as vertex attributes](https://github.com/bevyengine/bevy/pull/6442) + +Implementations of `From>` and `From>` for `VertexAttributeValues` have been removed. +I you're passing either `Vec<[u16; 4]>` or `Vec<[u8; 4]>` into `Mesh::insert_attribute` it will now require wrapping it with right the `VertexAttributeValues` enum variant. From 5798dfefab59c352024d57cc537aae48ab45075d Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 Nov 2022 17:10:30 -0400 Subject: [PATCH 27/38] Apply suggestions from code review Co-authored-by: Rob Parrett --- .../learn/book/migration-guides/0.8-0.9/_index.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 833fbdf0bf..66bf8ff97d 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -178,7 +178,6 @@ commands.entity(some_entity).remove_bundle::(); commands.entity(some_entity).remove::(); ``` -Replace `remove_bundle_intersection` with `remove_intersection`: ```rust // Old (0.8) @@ -210,7 +209,16 @@ commands.spawn(( ### [Implement `Bundle` for `Component`. Use `Bundle` tuples for insertion](https://github.com/bevyengine/bevy/pull/2975) -In `derive(Bundle)`, the `bundle` attribute has been removed. Nested bundles are now collapsed automatically. You should remove `#[bundle]` attributes. +The `#[bundle]` attribute is no longer required when deriving `Bundle` for nested bundles. + +```rust +#[derive(Bundle)] +struct PlayerBundle { + #[bundle] // Remove this line + sprite_bundle: SpriteBundle, + collider: Collider, +} +``` ### [Replace the `bool` argument of `Timer` with `TimerMode`](https://github.com/bevyengine/bevy/pull/6247) From 6316c0cc0ba38a701a50c9442ea5c5d1edd66dfd Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 Nov 2022 17:55:17 -0400 Subject: [PATCH 28/38] Update content/learn/book/migration-guides/0.8-0.9/_index.md Co-authored-by: Rob Parrett --- .../book/migration-guides/0.8-0.9/_index.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 66bf8ff97d..4ebcd2649a 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -230,11 +230,21 @@ struct PlayerBundle { ### [Add global time scaling](https://github.com/bevyengine/bevy/pull/5752) -* `time.time_since_startup()` -> `time.elapsed()` -* `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` -* `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` +Some `Time` methods were renamed for consistency. -If you aren’t sure which to use, most systems should continue to use “scaled” time (e.g. `time.delta_seconds()`). The realtime “unscaled” time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. +The values returned by most methods are now scaled by a value optionally set with `set_relative_speed`. Most systems should continue to use these scaled values. If you need unscaled time, use the new methods prefixed with `raw_`. + +```rust +// Old (Bevy 0.8) +let dur: Duration = time.time_since_startup(); +let secs: f32 = time.time_since_startup().as_secs_f32(); +let secs: f64 = time.seconds_since_startup(); + +// New (Bevy 0.9) +let dur: Duration = time.elapsed(); +let secs: f32 = time.elapsed_seconds(); +let secs: f64 = time.elapsed_seconds_f64(); +``` ### [Change UI coordinate system to have origin at top left corner](https://github.com/bevyengine/bevy/pull/6000) From e3e41ec1a5e2685bed33b567156e306e870f0410 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 Nov 2022 19:58:09 -0400 Subject: [PATCH 29/38] Update content/learn/book/migration-guides/0.8-0.9/_index.md Co-authored-by: Rob Parrett --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 4ebcd2649a..8adbc92bbd 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -495,7 +495,7 @@ The `Entity::id()` method was renamed to `Entity::index()`. ### [Remove `ExactSizeIterator` from `QueryCombinationIter`](https://github.com/bevyengine/bevy/pull/5895) -Switch to using other methods of getting the length. +`len` is no longer implemented for `QueryCombinationIter`. You can get the same value with `size_hint().0`, but be aware that values exceeding `usize::MAX` will be returned as `usize::MAX`. ### [`Query` filter types must be `ReadOnlyWorldQuery`](https://github.com/bevyengine/bevy/pull/6008) From 61d21eb68629ef0f03253f8b4829471812f29d97 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 Nov 2022 22:49:32 -0400 Subject: [PATCH 30/38] Update content/learn/book/migration-guides/0.8-0.9/_index.md Co-authored-by: Rob Parrett --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 8adbc92bbd..d3c94feb5d 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -835,7 +835,9 @@ You will need to update the serialized versions accordingly. ### [Utility methods for Val](https://github.com/bevyengine/bevy/pull/6134) -Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. +It is no longer possible to use the `+`, `+=`, `-`, or `-=` operators with `Val` or `Size`. + +Use the new `try_add` and `try_sub` methods instead and perform operations on `Size`'s `height` and `width` fields separately. ### [Allow passing glam vector types as vertex attributes](https://github.com/bevyengine/bevy/pull/6442) From 7b6d378a431c04f8d77981ff6b4b9ee1f7653e3a Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 7 Nov 2022 15:53:30 -0500 Subject: [PATCH 31/38] Update content/learn/book/migration-guides/0.8-0.9/_index.md --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index d3c94feb5d..f91812f9e3 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -177,7 +177,7 @@ commands.entity(some_entity).remove_bundle::(); // New (0.9) commands.entity(some_entity).remove::(); ``` - +Replace `remove_bundle_intersection` with `remove_intersection`: ```rust // Old (0.8) From 98c9b05a021109abfdc11a061574337c2000b54d Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 8 Nov 2022 09:20:56 -0700 Subject: [PATCH 32/38] Combine scene serialization sections --- .../book/migration-guides/0.8-0.9/_index.md | 133 +----------------- 1 file changed, 6 insertions(+), 127 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index f91812f9e3..be1fcc0144 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -177,6 +177,7 @@ commands.entity(some_entity).remove_bundle::(); // New (0.9) commands.entity(some_entity).remove::(); ``` + Replace `remove_bundle_intersection` with `remove_intersection`: ```rust @@ -624,141 +625,19 @@ After: ); ``` -### [Replace root list with struct](https://github.com/bevyengine/bevy/pull/6354) - -The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. - -```rust -// Old (Bevy 0.8) -[ - ( - entity: 0, - components: [ - // Components... - ] - ), -] - -// New (Bevy 0.9) -( - entities: [ - ( - entity: 0, - components: [ - // Components... - ] - ), - ] -) -``` - -### [Use map for scene `components`](https://github.com/bevyengine/bevy/pull/6345) +### Scene serialization format improvements from [#6354](https://github.com/bevyengine/bevy/pull/6354), [#6345](https://github.com/bevyengine/bevy/pull/6345), and [#5723](https://github.com/bevyengine/bevy/pull/5723) -The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. +* The root of the scene is now a struct rather than a list +* Components are now a map keyed by type name rather than a list +* Type information is now omitted when possible, making scenes much more compact -```rust -// Old (Bevy 0.8) -[ - ( - entity: 0, - components: [ - { - "bevy_transform::components::transform::Transform": ( - translation: ( - x: 0.0, - y: 0.0, - z: 0.0 - ), - rotation: (0.0, 0.0, 0.0, 1.0), - scale: ( - x: 1.0, - y: 1.0, - z: 1.0 - ), - ), - }, - { - "my_crate::Foo": ( - text: "Hello World", - ), - }, - { - "my_crate::Bar": ( - baz: 123, - ), - }, - ], - ), -] - -// New (Bevy 0.9) -[ - ( - entity: 0, - components: { - "bevy_transform::components::transform::Transform": ( - translation: ( - x: 0.0, - y: 0.0, - z: 0.0 - ), - rotation: (0.0, 0.0, 0.0, 1.0), - scale: ( - x: 1.0, - y: 1.0, - z: 1.0 - ), - ), - "my_crate::Foo": ( - text: "Hello World", - ), - "my_crate::Bar": ( - baz: 123 - ), - }, - ), -] -``` +See [this diff](https://github.com/bevyengine/bevy/compare/v0.8.0...main#diff-12b7f105bbb2a716e818a2a7eb2c79d40bef29ae8cba45b536c79cfa16b83558) for an illustration. ### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) * `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. * As a reminder, private fields exposed via reflection are not subject to any stability guarantees. -### [Improve serialization format even more](https://github.com/bevyengine/bevy/pull/5723) - -This PR reduces the verbosity of the scene format. Scenes will need to be updated accordingly: - -```js -// Old format -{ - "type": "my_game::item::Item", - "struct": { - "id": { - "type": "alloc::string::String", - "value": "bevycraft:stone", - }, - "tags": { - "type": "alloc::vec::Vec", - "list": [ - { - "type": "alloc::string::String", - "value": "material" - }, - ], - }, - } -} - -// New format -{ - "my_game::item::Item": ( - id: "bevycraft:stone", - tags: ["material"] - ) -} -``` - ### [Relax bounds on `Option`](https://github.com/bevyengine/bevy/pull/5658) If using `Option` with Bevy’s reflection API, `T` now needs to implement `FromReflect` rather than just `Clone`. This can be achieved easily by simply deriving `FromReflect`: From 9d09d0b7072e79e552c4778ba592cb13823dd323 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 8 Nov 2022 09:41:54 -0700 Subject: [PATCH 33/38] Embed diff --- .../book/migration-guides/0.8-0.9/_index.md | 101 +++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index be1fcc0144..35bae3dee8 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -631,7 +631,106 @@ After: * Components are now a map keyed by type name rather than a list * Type information is now omitted when possible, making scenes much more compact -See [this diff](https://github.com/bevyengine/bevy/compare/v0.8.0...main#diff-12b7f105bbb2a716e818a2a7eb2c79d40bef29ae8cba45b536c79cfa16b83558) for an illustration. +```diff +-[ +- ( +- entity: 0, +- components: [ +- { +- "type": "bevy_transform::components::transform::Transform", +- "struct": { +- "translation": { +- "type": "glam::vec3::Vec3", +- "value": (0.0, 0.0, 0.0), +- }, +- "rotation": { +- "type": "glam::quat::Quat", +- "value": (0.0, 0.0, 0.0, 1.0), +- }, +- "scale": { +- "type": "glam::vec3::Vec3", +- "value": (1.0, 1.0, 1.0), +- }, +- }, ++( ++ entities: { ++ 0: ( ++ components: { ++ "bevy_transform::components::transform::Transform": ( ++ translation: ( ++ x: 0.0, ++ y: 0.0, ++ z: 0.0 ++ ), ++ rotation: (0.0, 0.0, 0.0, 1.0), ++ scale: ( ++ x: 1.0, ++ y: 1.0, ++ z: 1.0 ++ ), ++ ), ++ "scene::ComponentB": ( ++ value: "hello", ++ ), ++ "scene::ComponentA": ( ++ x: 1.0, ++ y: 2.0, ++ ), + }, +- { +- "type": "scene::ComponentB", +- "struct": { +- "value": { +- "type": "alloc::string::String", +- "value": "hello", +- }, +- }, ++ ), ++ 1: ( ++ components: { ++ "scene::ComponentA": ( ++ x: 3.0, ++ y: 4.0, ++ ), + }, +- { +- "type": "scene::ComponentA", +- "struct": { +- "x": { +- "type": "f32", +- "value": 1.0, +- }, +- "y": { +- "type": "f32", +- "value": 2.0, +- }, +- }, +- }, +- ], +- ), +- ( +- entity: 1, +- components: [ +- { +- "type": "scene::ComponentA", +- "struct": { +- "x": { +- "type": "f32", +- "value": 3.0, +- }, +- "y": { +- "type": "f32", +- "value": 4.0, +- }, +- }, +- }, +- ], +- ), +-] ++ ), ++ } ++) +``` ### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) From f8362a4f6fa97c859acb9a75c29c286044a5904b Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 8 Nov 2022 10:00:08 -0700 Subject: [PATCH 34/38] Undiff the diff --- .../book/migration-guides/0.8-0.9/_index.md | 203 +++++++++--------- 1 file changed, 104 insertions(+), 99 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 35bae3dee8..83a4593229 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -631,105 +631,110 @@ After: * Components are now a map keyed by type name rather than a list * Type information is now omitted when possible, making scenes much more compact -```diff --[ -- ( -- entity: 0, -- components: [ -- { -- "type": "bevy_transform::components::transform::Transform", -- "struct": { -- "translation": { -- "type": "glam::vec3::Vec3", -- "value": (0.0, 0.0, 0.0), -- }, -- "rotation": { -- "type": "glam::quat::Quat", -- "value": (0.0, 0.0, 0.0, 1.0), -- }, -- "scale": { -- "type": "glam::vec3::Vec3", -- "value": (1.0, 1.0, 1.0), -- }, -- }, -+( -+ entities: { -+ 0: ( -+ components: { -+ "bevy_transform::components::transform::Transform": ( -+ translation: ( -+ x: 0.0, -+ y: 0.0, -+ z: 0.0 -+ ), -+ rotation: (0.0, 0.0, 0.0, 1.0), -+ scale: ( -+ x: 1.0, -+ y: 1.0, -+ z: 1.0 -+ ), -+ ), -+ "scene::ComponentB": ( -+ value: "hello", -+ ), -+ "scene::ComponentA": ( -+ x: 1.0, -+ y: 2.0, -+ ), - }, -- { -- "type": "scene::ComponentB", -- "struct": { -- "value": { -- "type": "alloc::string::String", -- "value": "hello", -- }, -- }, -+ ), -+ 1: ( -+ components: { -+ "scene::ComponentA": ( -+ x: 3.0, -+ y: 4.0, -+ ), - }, -- { -- "type": "scene::ComponentA", -- "struct": { -- "x": { -- "type": "f32", -- "value": 1.0, -- }, -- "y": { -- "type": "f32", -- "value": 2.0, -- }, -- }, -- }, -- ], -- ), -- ( -- entity: 1, -- components: [ -- { -- "type": "scene::ComponentA", -- "struct": { -- "x": { -- "type": "f32", -- "value": 3.0, -- }, -- "y": { -- "type": "f32", -- "value": 4.0, -- }, -- }, -- }, -- ], -- ), --] -+ ), -+ } -+) +```javascript +// Old (Bevy 0.8) +[ + ( + entity: 0, + components: [ + { + "type": "bevy_transform::components::transform::Transform", + "struct": { + "translation": { + "type": "glam::vec3::Vec3", + "value": (0.0, 0.0, 0.0), + }, + "rotation": { + "type": "glam::quat::Quat", + "value": (0.0, 0.0, 0.0, 1.0), + }, + "scale": { + "type": "glam::vec3::Vec3", + "value": (1.0, 1.0, 1.0), + }, + }, + }, + { + "type": "scene::ComponentB", + "struct": { + "value": { + "type": "alloc::string::String", + "value": "hello", + }, + }, + }, + { + "type": "scene::ComponentA", + "struct": { + "x": { + "type": "f32", + "value": 1.0, + }, + "y": { + "type": "f32", + "value": 2.0, + }, + }, + }, + ], + ), + ( + entity: 1, + components: [ + { + "type": "scene::ComponentA", + "struct": { + "x": { + "type": "f32", + "value": 3.0, + }, + "y": { + "type": "f32", + "value": 4.0, + }, + }, + }, + ], + ), +] + +// New (Bevy 0.9) +( + entities: { + 0: ( + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + "scene::ComponentB": ( + value: "hello", + ), + "scene::ComponentA": ( + x: 1.0, + y: 2.0, + ), + }, + ), + 1: ( + components: { + "scene::ComponentA": ( + x: 3.0, + y: 4.0, + ), + }, + ), + } +) ``` ### [Derive `Reflect` + `FromReflect` for input types](https://github.com/bevyengine/bevy/pull/6232) From 5bf793c8a0c45d72fc82287d24584c864048527c Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 8 Nov 2022 11:16:20 -0700 Subject: [PATCH 35/38] Add migration advice --- content/learn/book/migration-guides/0.8-0.9/_index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 83a4593229..1dd17fa478 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -631,6 +631,10 @@ After: * Components are now a map keyed by type name rather than a list * Type information is now omitted when possible, making scenes much more compact +Scenes serialized with Bevy 0.8 will need to be recreated, but it is possible to hand-edit scenes to match the new format. + +Here's an example scene in the old and new format: + ```javascript // Old (Bevy 0.8) [ From 0c89f6369083739a8f97888a9276083467a6c0bc Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 8 Nov 2022 13:03:13 -0700 Subject: [PATCH 36/38] Move serialization format thing closer to the other one --- .../book/migration-guides/0.8-0.9/_index.md | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 1dd17fa478..3ac5e7e4cd 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -772,44 +772,6 @@ Note: You can still derive `Clone`, but it’s not required in order to compile. * relax `T: ?Sized` bound in `Mut` * replace all instances of `ReflectMut` with `Mut` -### [Update enum derives](https://github.com/bevyengine/bevy/pull/5473) - -Bevy-defined enums have been updated to implement `Enum` and are not considered value types (`ReflectRef::Value`) anymore. This means that their serialized representations will need to be updated. For example, given the Bevy enum: - -```rust -pub enum ScalingMode { - None, - WindowSize, - Auto { min_width: f32, min_height: f32 }, - FixedVertical(f32), - FixedHorizontal(f32), -} -``` - -You will need to update the serialized versions accordingly. - -```js -// OLD FORMAT -{ - "type": "bevy_render::camera::projection::ScalingMode", - "value": FixedHorizontal(720), -}, - -// NEW FORMAT -{ - "type": "bevy_render::camera::projection::ScalingMode", - "enum": { - "variant": "FixedHorizontal", - "tuple": [ - { - "type": "f32", - "value": 720, - }, - ], - }, -}, -``` - ### [remove blanket `Serialize + Deserialize` requirement for `Reflect` on generic types](https://github.com/bevyengine/bevy/pull/5197) `.register_type` for generic types like `Option`, `Vec`, `HashMap` will no longer insert `ReflectSerialize` and `ReflectDeserialize` type data. Instead you need to register it separately for concrete generic types like so: From e4354e15a9f86541876a8c0d7b4e5527b63d1191 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 9 Nov 2022 10:34:44 -0500 Subject: [PATCH 37/38] Apply suggestions from code review Co-authored-by: Rob Parrett --- .../book/migration-guides/0.8-0.9/_index.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 3ac5e7e4cd..174169abff 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -73,6 +73,26 @@ app.add_plugins_with(DefaultPlugins, |group| group.disable::()); app.add_plugins(DefaultPlugins.build().disable::()); ``` +`PluginGroupBoulder` and the `PluginGroup` trait have also been reworked. + +```rust +// Old (Bevy 0.8) +impl PluginGroup for HelloWorldPlugins { + fn build(&mut self, group: &mut PluginGroupBuilder) { + group.add(PrintHelloPlugin).add(PrintWorldPlugin); + } +} + +// New (Bevy 0.9) +impl PluginGroup for HelloWorldPlugins { + fn build(self) -> PluginGroupBuilder { + PluginGroupBuilder::start::() + .add(PrintHelloPlugin) + .add(PrintWorldPlugin) + } +} + +``` ### [Use plugin setup for resource only used at setup time](https://github.com/bevyengine/bevy/pull/6360) The `LogSettings` settings have been moved from a resource to `LogPlugin` configuration: @@ -334,6 +354,10 @@ fn some_system(world: &mut World, transforms: &mut QueryState<&Transform>) { } ``` +The `IntoExclusiveSystem` trait was removed. Use `IntoSystem` instead. + +The `ExclusiveSystemDescriptorCoercion` trait was removed. You can delete any imports of it. + ### [Merge TextureAtlas::from_grid_with_padding into TextureAtlas::from_grid through option arguments](https://github.com/bevyengine/bevy/pull/6057) `TextureAtlas::from_grid_with_padding` was merged into `from_grid` which takes two additional parameters for padding and an offset. From 6ece234c23167647f31fc0c7ef454ec9d504dd71 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 11 Nov 2022 13:10:55 -0500 Subject: [PATCH 38/38] Update content/learn/book/migration-guides/0.8-0.9/_index.md Co-authored-by: ickk --- content/learn/book/migration-guides/0.8-0.9/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.8-0.9/_index.md b/content/learn/book/migration-guides/0.8-0.9/_index.md index 174169abff..21c6535a2f 100644 --- a/content/learn/book/migration-guides/0.8-0.9/_index.md +++ b/content/learn/book/migration-guides/0.8-0.9/_index.md @@ -175,7 +175,7 @@ let entity = commands.spawn_empty().id(); // Old (0.8) let entity = world.spawn().id(); // New (0.9) -let entity = world.spawn_empty(); +let entity = world.spawn_empty().id(); ``` ### [Accept Bundles for insert and remove. Deprecate `insert`/`remove_bundle`](https://github.com/bevyengine/bevy/pull/6039)