diff --git a/release-content/migration-guides/ambient_light_split.md b/release-content/migration-guides/ambient_light_split.md index ae974e835ea64..d0cde6b1673c5 100644 --- a/release-content/migration-guides/ambient_light_split.md +++ b/release-content/migration-guides/ambient_light_split.md @@ -9,19 +9,15 @@ The resource `GlobalAmbientLight` is the default ambient light for the entire wo Meanwhile, `AmbientLight` is a component that can be added to a `Camera` in order to override the default `GlobalAmbientLight`. When appropriate, rename `AmbientLight` to `GlobalAmbientLight`. -Before: - ```rust +// 0.17 app.insert_resource(AmbientLight { color: Color::WHITE, brightness: 2000., ..default() }); -``` -After: - -```rust +// 0.18 app.insert_resource(GlobalAmbientLight { color: Color::WHITE, brightness: 2000., diff --git a/release-content/migration-guides/animation-target-refactor.md b/release-content/migration-guides/animation-target-refactor.md index 1e1fc631ae3fd..00ebcbaa9e0ca 100644 --- a/release-content/migration-guides/animation-target-refactor.md +++ b/release-content/migration-guides/animation-target-refactor.md @@ -10,14 +10,10 @@ The `AnimationTarget` component has been split into two separate components. This change was made to add flexibility. It's now possible to calculate the `AnimationTargetId` first, but defer the choice of player until later. -Before: - ```rust +// 0.17 entity.insert(AnimationTarget { id: AnimationTargetId(id), player: player_entity }); -``` -After: - -```rust +// 0.18 entity.insert((AnimationTargetId(id), AnimatedBy(player_entity))); ``` diff --git a/release-content/migration-guides/archetype_query_data.md b/release-content/migration-guides/archetype_query_data.md index 34967124901bb..18edea24be5c9 100644 --- a/release-content/migration-guides/archetype_query_data.md +++ b/release-content/migration-guides/archetype_query_data.md @@ -15,6 +15,7 @@ Code that requires queries to `impl ExactSizeIterator` may need to replace `Quer fn requires_exact_size(q: Query) -> usize { q.into_iter().len() } + // 0.18 fn requires_exact_size(q: Query) -> usize { q.into_iter().len() diff --git a/release-content/migration-guides/asset_watcher_async_sender.md b/release-content/migration-guides/asset_watcher_async_sender.md index 60b1383e5c23f..8d8e54088c5a0 100644 --- a/release-content/migration-guides/asset_watcher_async_sender.md +++ b/release-content/migration-guides/asset_watcher_async_sender.md @@ -1,6 +1,6 @@ --- title: AssetSources now give an `async_channel::Sender` instead of a `crossbeam_channel::Sender` -pull_requests: [] +pull_requests: [21626] --- Previously, when creating an asset source, `AssetSourceBuilder::with_watcher` would provide users diff --git a/release-content/migration-guides/bevy_input_features.md b/release-content/migration-guides/bevy_input_features.md index dbab8f69455e9..35c5f2fe707d7 100644 --- a/release-content/migration-guides/bevy_input_features.md +++ b/release-content/migration-guides/bevy_input_features.md @@ -11,12 +11,13 @@ If you use `bevy_window` or `bevy_gilrs`, they will automatically enable the necessary features on `bevy_input`. If you don't depend on them (for example, if you are developing for a platform that isn't supported by these crates), you need to enable the required -input sources on `bevy_input` manually: +input sources on the `bevy_input` / `bevy` crate manually: ```toml -# Before: +# 0.17 bevy = { version = "0.17", default-features = false } -# After (enable sources that you actually use): + +# 0.18 (enable sources that you actually use): bevy = { version = "0.18", default-features = false, features = [ "mouse", "keyboard", diff --git a/release-content/migration-guides/bindgroup-labels-mandatory.md b/release-content/migration-guides/bindgroup-labels-mandatory.md index efe9667b14db7..1021f285992a0 100644 --- a/release-content/migration-guides/bindgroup-labels-mandatory.md +++ b/release-content/migration-guides/bindgroup-labels-mandatory.md @@ -8,7 +8,12 @@ In previous versions of Bevy, the `label` of a `BindGroupLayout` was optional. T If you were previously omitting the `label` implementation from a `impl AsBindGroup`, you now must implement it: ```rust -fn label() -> &'static str { - "my label" +impl AsBindGroup for CoolMaterial { + // ... + + fn label() -> &'static str { + // It is customary to make the label the name of the type. + "CoolMaterial" + } } ``` diff --git a/release-content/migration-guides/bundle_component_ids.md b/release-content/migration-guides/bundle_component_ids.md index 55c70331c45cd..e889a61c0b852 100644 --- a/release-content/migration-guides/bundle_component_ids.md +++ b/release-content/migration-guides/bundle_component_ids.md @@ -6,9 +6,10 @@ pull_requests: [14791, 15458, 15269] `Bundle::component_ids` and `Bundle::get_component_ids` were changed to return an iterator over `ComponentId` and `Option` respectively. In some cases this can avoid allocating. +For implementors: + ```rust -// For implementors -// Before +// 0.17 unsafe impl Bundle for C { fn component_ids(components: &mut ComponentsRegistrator, ids: &mut impl FnMut(ComponentId)) { ids(components.register_component::()); @@ -19,7 +20,7 @@ unsafe impl Bundle for C { } } -// After +// 0.18 unsafe impl Bundle for C { fn component_ids<( components: &mut ComponentsRegistrator, @@ -34,14 +35,15 @@ unsafe impl Bundle for C { } ``` +For consumers: + ```rust -// For Consumers -// Before +// 0.17 let mut components = vec![]; MyBundle::component_ids(&mut world.components_registrator(), &mut |id| { components.push(id); }); -// After +// 0.18 let components: Vec<_> = B::component_ids(&mut world.components_registrator()).collect(); ``` diff --git a/release-content/migration-guides/changed_asset_server_init.md b/release-content/migration-guides/changed_asset_server_init.md index ae0735c6c4d15..d09bd53a32f08 100644 --- a/release-content/migration-guides/changed_asset_server_init.md +++ b/release-content/migration-guides/changed_asset_server_init.md @@ -3,10 +3,11 @@ title: Changes to `AssetServer` and `AssetProcessor` creation. pull_requests: [21763] --- -Previously `AssetServer`s `new` methods would take `AssetSources`. Now, these methods take -`Arc`. So if you previously had: +Previously `AssetServer`s `new` and `new_with_method_check` methods would take `AssetSources`. Now, these methods take +`Arc`. ```rust +// 0.17 AssetServer::new( sources, mode, @@ -14,46 +15,24 @@ AssetServer::new( unapproved_path_mode, ) -// OR: -AssetServer::new_with_meta_check( - sources, - mode, - meta_check, - watching_for_changes, - unapproved_path_mode, -) -``` - -Now you need to do: - -```rust +// 0.18 AssetServer::new( + // Wrap the sources in an `Arc`. Arc::new(sources), mode, watching_for_changes, unapproved_path_mode, ) - -// OR: -AssetServer::new_with_meta_check( - Arc::new(sources), - mode, - meta_check, - watching_for_changes, - unapproved_path_mode, -) ``` `AssetProcessor::new` has also changed. It now returns to you the `Arc` which can (and -should) be shared with the `AssetServer`. So if you previously had: +should) be shared with the `AssetServer`. ```rust +// 0.17 let processor = AssetProcessor::new(sources); -``` -Now you need: - -```rust +// 0.18 let (processor, sources_arc) = AssetProcessor::new( sources, // A bool whether the returned sources should listen for changes as asset processing completes. diff --git a/release-content/migration-guides/combinator_system.md b/release-content/migration-guides/combinator_system.md index 7af01c344e41c..e62e7b33f9e76 100644 --- a/release-content/migration-guides/combinator_system.md +++ b/release-content/migration-guides/combinator_system.md @@ -3,12 +3,41 @@ title: System Combinators pull_requests: [20671] --- -The `CombinatorSystem`s can be used to combine multiple `SystemCondition`s with logical operators. Previously, the conditions would short circuit if the system failed to run, for example because it's query could not be filled by the world. +`CombinatorSystem`s can be used to combine multiple `SystemCondition`s with logical operators (such as `and`, `or`, and `xor`). Previously, these combinators would propagate any errors made when running the combined systems: -Now, the `CombinatorSystem`s will work as expected, following the semantics of rust's logical operators. -Namely, if a `SystemCondition` fails, it will be considered to have returned `false` and in combinators that don't short circuit the other condition will now be run. +```rust +// 0.17 +#[derive(Component)] +struct Foo; + +// This run condition will fail validation because there is not an entity with `Foo` in the world. +fn fails_validation(_: Single<&Foo>) -> bool { + // ... +} + +fn always_true() -> bool { + true +} + +let mut world = World::new(); -Specifically, the combinators act as follows: +// Because `fails_validation` is invalid, trying to run this combinator system will return an +// error. +assert!(world.run_system_once(fails_validation.or(always_true)).is_err()); +``` + +This behavior has been changed in Bevy 0.18. Now if one of the combined systems fails, it will be considered to have returned `false`. The error will not be propagated, and the combinator logic will continue: + +```rust +// 0.18 +let mut world = World::new(); + +// `fails_validation` is invalid, but it is converted to `false`. Because `always_true` succeeds, +// the combinator returns `true`. +assert_eq!(matches!(world.run_system_once(fails_validation.or(always_true)), Ok(true))); +``` + +This affects the following combinators: | Combinator | Rust Equivalent | |:----------:|:---------------:| @@ -18,21 +47,3 @@ Specifically, the combinators act as follows: | `nand` | `!(a && b)` | | `nor` | `!(a \|\| b)` | | `xnor` | `!(a ^ b)` | - -```rust -fn vacant(_: crate::system::Single<&Vacant>) -> bool { - true -} - -fn is_true() -> bool { - true -} - -assert!(world.query::<&Vacant>().iter(&world).next().is_none()); - -// previously: -assert!(world.run_system_once(is_true.or(vacant)).is_err()); - -// now: -assert!(matches!(world.run_system_once(is_true.or(vacant)), Ok(true))); -``` diff --git a/release-content/migration-guides/custom_asset_source_infallible.md b/release-content/migration-guides/custom_asset_source_infallible.md index 4a921982525ff..f283dfbc3e79b 100644 --- a/release-content/migration-guides/custom_asset_source_infallible.md +++ b/release-content/migration-guides/custom_asset_source_infallible.md @@ -7,22 +7,17 @@ Previously, it was possible to create asset sources with no reader, resulting in silently being skipped. This is no longer possible, since `AssetSourceBuilder` must now be given a reader to start. We also slightly changed how sources are expected to be built. -In previous versions, creating a custom source would look like: - ```rust +// 0.17 AssetSource::build() - .with_reader(move || todo!("the reader!")) - .with_writer(move || todo!()) - .with_processed_reader(move || todo!()) - .with_processed_writer(move || todo!()) -``` + .with_reader(move || /* reader logic */) + .with_writer(move || /* ... */) + .with_processed_reader(move || /* ... */) + .with_processed_writer(move || /* ... */); -In Bevy 0.18, this now looks like: - -```rust -// You may need to import AssetSourceBuilder. -AssetSourceBuilder::new(move || todo!("the reader!")) - .with_writer(move || todo!()) - .with_processed_reader(move || todo!()) - .with_processed_writer(move || todo!()) +// 0.18 +AssetSourceBuilder::new(move || /* reader logic */) + .with_writer(move || /* ... */) + .with_processed_reader(move || /* ... */) + .with_processed_writer(move || /* ... */; ``` diff --git a/release-content/migration-guides/derive_compile_error_for_non_static_resource.md b/release-content/migration-guides/derive_compile_error_for_non_static_resource.md index 45e4b57419623..24a2a79fecbda 100644 --- a/release-content/migration-guides/derive_compile_error_for_non_static_resource.md +++ b/release-content/migration-guides/derive_compile_error_for_non_static_resource.md @@ -6,8 +6,7 @@ pull_requests: [21385] Any type with `#[derive(Resource)]` that uses non-static lifetime will no longer compile. ```rust -// Will no longer compile in 0.18, -// 'a should be 'static +// Will no longer compile in 0.18, `'a` should be `'static`. #[derive(Resource)] struct Foo<'a> { bar: &'a str diff --git a/release-content/migration-guides/enable_prepass.md b/release-content/migration-guides/enable_prepass.md index 32ea69d646bed..640cdf792eed9 100644 --- a/release-content/migration-guides/enable_prepass.md +++ b/release-content/migration-guides/enable_prepass.md @@ -9,13 +9,13 @@ been replaced by the `Material` methods `enable_prepass` and `enable_shadows`. Analogous methods have also been added to `MaterialExtension` ```rust -/// before +// 0.17 MaterialPlugin:: { prepass_enabled: false, shadows_enabled: false, } -/// after +// 0.18 impl Material for MyMaterial { /// ... diff --git a/release-content/migration-guides/generalized_atmosphere.md b/release-content/migration-guides/generalized_atmosphere.md index 14bcd8a621997..f93645b9c9a72 100644 --- a/release-content/migration-guides/generalized_atmosphere.md +++ b/release-content/migration-guides/generalized_atmosphere.md @@ -7,21 +7,31 @@ pull_requests: [20838] Most of the fields on `Atmosphere` have been removed in favor of a handle to the new `ScatteringMedium` asset. -```diff +```rust +// 0.17 +pub struct Atmosphere { + pub bottom_radius: f32, + pub top_radius: f32, + pub ground_albedo: Vec3, + // All of these fields have been removed. + pub rayleigh_density_exp_scale: f32, + pub rayleigh_scattering: Vec3, + pub mie_density_exp_scale: f32, + pub mie_scattering: f32, + pub mie_absorption: f32, + pub mie_asymmetry: f32, + pub ozone_layer_altitude: f32, + pub ozone_layer_width: f32, + pub ozone_absorption: Vec3, +} + +// 0.18 pub struct Atmosphere { pub bottom_radius: f32, pub top_radius: f32, pub ground_albedo: Vec3, -+ pub medium: Handle, -- pub rayleigh_density_exp_scale: f32, -- pub rayleigh_scattering: Vec3, -- pub mie_density_exp_scale: f32, -- pub mie_scattering: f32, -- pub mie_absorption: f32, -- pub mie_asymmetry: f32, -- pub ozone_layer_altitude: f32, -- pub ozone_layer_width: f32, -- pub ozone_absorption: Vec3, + // This replaces all of the old fields. + pub medium: Handle, } ``` diff --git a/release-content/migration-guides/gltf-coordinate-conversion.md b/release-content/migration-guides/gltf-coordinate-conversion.md index fda7db176f789..df688a6bac990 100644 --- a/release-content/migration-guides/gltf-coordinate-conversion.md +++ b/release-content/migration-guides/gltf-coordinate-conversion.md @@ -25,16 +25,20 @@ In 0.18 there are two changes. Firstly, the `use_model_forward_direction` option has been renamed to `convert_coordinates`, and is now a struct with two separate options. -```diff - struct GltfPlugin { - ... -- use_model_forward_direction: bool, -+ convert_coordinates: GltfConvertCoordinates, - } -``` - ```rust -struct GltfConvertCoordinates { +// 0.17 +pub struct GltfPlugin { + use_model_forward_direction: bool, + // ... +} + +// 0.18 +pub struct GltfPlugin { + convert_coordinates: GltfConvertCoordinates, + // ... +} + +pub struct GltfConvertCoordinates { rotate_scene_entity: bool, rotate_meshes: bool, } diff --git a/release-content/migration-guides/image_render_target_scale_factor_is_now_f32.md b/release-content/migration-guides/image_render_target_scale_factor_is_now_f32.md index afe4c4d1f56fb..5d9fbb8fcdfd1 100644 --- a/release-content/migration-guides/image_render_target_scale_factor_is_now_f32.md +++ b/release-content/migration-guides/image_render_target_scale_factor_is_now_f32.md @@ -1,6 +1,6 @@ --- title: "`ImageRenderTarget`s `scale_factor` field is now an `f32`" -pull_requests: [ 21054 ] +pull_requests: [21054] --- The `scale_factor` field on `ImageRenderTarget` is now an `f32` and no longer requires wrapping in `FloatOrd`. diff --git a/release-content/migration-guides/internal_disabling_component_removed.md b/release-content/migration-guides/internal_disabling_component_removed.md index 4694885554cfc..fd9a0f9705fd7 100644 --- a/release-content/migration-guides/internal_disabling_component_removed.md +++ b/release-content/migration-guides/internal_disabling_component_removed.md @@ -1,6 +1,6 @@ --- title: "`Internal` has been removed" -pull_requests: [ 21623 ] +pull_requests: [21623] --- The `Internal` component, previously added as a required component to both one-shot systems and observer entities has been removed. diff --git a/release-content/migration-guides/lineheight_is_now_a_separate_component.md b/release-content/migration-guides/lineheight_is_now_a_separate_component.md index 8a8ed6d5f2fa8..8cd1424b1213d 100644 --- a/release-content/migration-guides/lineheight_is_now_a_separate_component.md +++ b/release-content/migration-guides/lineheight_is_now_a_separate_component.md @@ -1,6 +1,6 @@ --- title: "`LineHeight` is now a separate component" -pull_requests: [] +pull_requests: [21180] --- The `line_height` field has been removed from `TextFont`. `LineHeight` is now a component required by `Text`, `Text2d`, and `TextSpan`. diff --git a/release-content/migration-guides/process_trait_changes.md b/release-content/migration-guides/process_trait_changes.md index 0b043a60e0845..c304fe1f13391 100644 --- a/release-content/migration-guides/process_trait_changes.md +++ b/release-content/migration-guides/process_trait_changes.md @@ -4,21 +4,16 @@ pull_requests: [21925] --- `ProcessContext` no longer includes `asset_bytes`. This has been replaced by `asset_reader`. To -maintain current behavior in a `Process` implementation, you can read all the bytes into memory. -If previously, you did: +maintain current behavior in a `Process` implementation, you can read all the bytes into a memory `Vec`. ```rust -// Inside `impl Process for Type` +// 0.17 let bytes = context.asset_bytes(); -// Use bytes here! -``` - -Then now, it should be: -```rust -// Inside `impl Process for Type` +// 0.18 let reader = context.asset_reader(); let mut bytes = vec![]; + reader .read_to_end(&mut bytes) .await @@ -26,5 +21,4 @@ reader path: context.path().clone_owned(), err: err.into(), })?; -// Use bytes here! ``` diff --git a/release-content/migration-guides/reader_required_features.md b/release-content/migration-guides/reader_required_features.md index c9fda72f2986c..11d8919339046 100644 --- a/release-content/migration-guides/reader_required_features.md +++ b/release-content/migration-guides/reader_required_features.md @@ -1,12 +1,12 @@ --- title: The `AssetReader` trait now takes a `ReaderRequiredFeatures` argument. -pull_requests: [] +pull_requests: [22104] --- -The `AssetReader::read` method now takes an additional `ReaderRequiredFeatures` argument. If -previously you had: +The `AssetReader::read` method now takes an additional `ReaderRequiredFeatures` argument. ```rust +// 0.17 struct MyAssetReader; impl AssetReader for MyAssetReader { @@ -14,27 +14,23 @@ impl AssetReader for MyAssetReader { &'a self, path: &'a Path, ) -> Result { - todo!() + // ... } - // more stuff... + // ... } -``` - -Change this to: -```rust +// 0.18 struct MyAssetReader; impl AssetReader for MyAssetReader { async fn read<'a>( &'a self, path: &'a Path, + // This is new! _required_features: ReaderRequiredFeatures, ) -> Result { - todo!() + // ... } - - // more stuff... } ``` diff --git a/release-content/migration-guides/readers_impl_async_seek.md b/release-content/migration-guides/readers_impl_async_seek.md index d2957efc6a220..ed37319fa245a 100644 --- a/release-content/migration-guides/readers_impl_async_seek.md +++ b/release-content/migration-guides/readers_impl_async_seek.md @@ -1,6 +1,6 @@ --- title: Implementations of `Reader` now must implement `AsyncSeek`, and `AsyncSeekForward` is deleted. -pull_requests: [] +pull_requests: [22104] --- The `Reader` trait no longer requires implementing `AsyncSeekForward` and instead requires @@ -22,7 +22,7 @@ impl AsyncSeek for MyReader { ), }; - // Do whatever your previous `AsyncSeekForward` implementation did... + // ... } } ``` @@ -42,8 +42,7 @@ impl AssetReader for MyAssetReader { SeekKind::AnySeek => return Err(UnsupportedReaderFeature::AnySeek), } - // Do whatever your previous `AssetReader` implementation did, like... - Ok(MyReader) + // ... } } ``` diff --git a/release-content/migration-guides/reflect_parentheses.md b/release-content/migration-guides/reflect_parentheses.md index 7f71f740e89db..b94532033e5f3 100644 --- a/release-content/migration-guides/reflect_parentheses.md +++ b/release-content/migration-guides/reflect_parentheses.md @@ -8,19 +8,21 @@ supported parentheses, braces, or brackets, to standardize the syntax going forward, it now supports only parentheses. ```rust -/// before +/// 0.17 #[derive(Clone, Reflect)] #[reflect[Clone]] -/// after +/// 0.18 #[derive(Clone, Reflect)] #[reflect(Clone)] +``` -/// before +```rust +/// 0.17 #[derive(Clone, Reflect)] #[reflect{Clone}] -/// after +/// 0.18 #[derive(Clone, Reflect)] #[reflect(Clone)] ``` diff --git a/release-content/migration-guides/render_target_component.md b/release-content/migration-guides/render_target_component.md index 9896cebbb5e4c..ca8fbdd392be1 100644 --- a/release-content/migration-guides/render_target_component.md +++ b/release-content/migration-guides/render_target_component.md @@ -8,7 +8,7 @@ pull_requests: [20917] When spawning a camera, specify `RenderTarget` as a component instead of setting `camera.target`: ```rust -// before +// 0.17 commands.spawn(( Camera3d::default(), Camera { @@ -17,7 +17,7 @@ commands.spawn(( }, )); -// after +// 0.18 commands.spawn(( Camera3d::default(), RenderTarget::Image(image_handle.into()), diff --git a/release-content/migration-guides/set_index_buffer.md b/release-content/migration-guides/set_index_buffer.md index f7c76026124b0..112df0a18a53b 100644 --- a/release-content/migration-guides/set_index_buffer.md +++ b/release-content/migration-guides/set_index_buffer.md @@ -6,8 +6,9 @@ pull_requests: [20468] `TrackedRenderPass::set_index_buffer` no longer takes a separate buffer offset argument, which wasn't actually forwarded to wgpu. You have already needed to pass a `BufferSlice` that is sliced to the desired offset/size. ```rust -// Before: +// 0.17 pass.set_index_buffer(indices.slice(1..), 1, IndexFormat::Uint32); -// After: + +// 0.18 pass.set_index_buffer(indices.slice(1..), IndexFormat::Uint32); ``` diff --git a/release-content/migration-guides/text_layout_info_section_rects_is_replaced_by_run_geometry.md b/release-content/migration-guides/text_layout_info_section_rects_is_replaced_by_run_geometry.md index bbbdfc76cb43c..776100fc36b5b 100644 --- a/release-content/migration-guides/text_layout_info_section_rects_is_replaced_by_run_geometry.md +++ b/release-content/migration-guides/text_layout_info_section_rects_is_replaced_by_run_geometry.md @@ -1,6 +1,6 @@ --- title: "`TextLayoutInfo`'s `section_rects` field has been replaced with `run_geometry`" -pull_requests: [] +pull_requests: [21656] --- `TextLayoutInfo`'s `section_rects` field has been removed. diff --git a/release-content/migration-guides/type_path_for_asset_traits.md b/release-content/migration-guides/type_path_for_asset_traits.md index eda0fd901735f..7514ae1e02529 100644 --- a/release-content/migration-guides/type_path_for_asset_traits.md +++ b/release-content/migration-guides/type_path_for_asset_traits.md @@ -7,6 +7,7 @@ The `AssetLoader`, `AssetTransformer`, `AssetSaver`, and `Process` traits now in of `TypePath`. This means if you previously had a loader like: ```rust +// 0.17 struct MyFunkyLoader { add_funk: u32, } @@ -15,6 +16,7 @@ struct MyFunkyLoader { You will need to add the following derive: ```rust +// 0.18 #[derive(TypePath)] struct MyFunkyLoader { add_funk: u32,