Skip to content

Commit

Permalink
Add some missed migration guides for 0.15 (#1846)
Browse files Browse the repository at this point in the history
Co-authored-by: BD103 <[email protected]>
  • Loading branch information
alice-i-cecile and BD103 authored Nov 25, 2024
1 parent 7ff7814 commit 6fc4724
Show file tree
Hide file tree
Showing 24 changed files with 607 additions and 324 deletions.
2 changes: 1 addition & 1 deletion generate-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To create issues for the `release-notes` subcommand, you need to pass the `--cre
Before running the command, you'll need to generate a GitHub API token at <https://github.com/settings/tokens>. It's easier to use classic tokens.
The token must have `repo` permissions to be able to open issues (and PRs) on your behalf.

Then add it to a file called `.env` like so:
Then add it to a file called `.env` (stored in the root `bevy-website` folder) like so:

```env
GITHUB_TOKEN=token_string_copied_from_github
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The user will just need to replace functions named `is_playing_animation` with `animation_is_playing`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(Since I added `P = ()`, I don’t think this is actually a breaking change anymore, but I’ll leave this in)

`bevy_reflect`’s `ReflectDeserializer` and `TypedReflectDeserializer` now take a `ReflectDeserializerProcessor` as the type parameter `P`, which allows you to customize deserialization for specific types when they are found. However, the rest of the API surface (`new`) remains the same.
<details>
<summary>Original implementation</summary>

Add `ReflectDeserializerProcessor`:

```rs
struct ReflectDeserializerProcessor {
pub can_deserialize: Box<dyn FnMut(&TypeRegistration) -> bool + 'p>,
pub deserialize: Box<
dyn FnMut(
&TypeRegistration,
&mut dyn erased_serde::Deserializer,
) -> Result<Box<dyn PartialReflect>, erased_serde::Error>
+ 'p,
}
```

Along with `ReflectDeserializer::new_with_processor` and `TypedReflectDeserializer::new_with_processor`. This does not touch the public API of the existing `new` fns.

This is stored as an `Option<&mut ReflectDeserializerProcessor>` on the deserializer and any of the private `-Visitor` structs, and when we attempt to deserialize a value, we first pass it through this processor.

Also added a very comprehensive doc test to `ReflectDeserializerProcessor`, which is actually a scaled down version of the code for the `bevy_animation_graph` loader. This should give users a good motivating example for when and why to use this feature.

__Why `Box<dyn ..>`?__

When I originally implemented this, I added a type parameter to `ReflectDeserializer` to determine the processor used, with `()` beingno processor. However when using this, I kept running into rustc errors where it failed to validate certain type bounds and led to overflows. I then switched to a dynamic dispatch approach.

The dynamic dispatch should not be that expensive, nor should it be a performance regression, since its only used if there is `Some` processor. (Note: I have not benchmarked this, I am just speculating.) Also, it means that we dont infect the rest of the code with an extra type parameter, which is nicer to maintain.

__Why the `'p` on `ReflectDeserializerProcessor<'p>`?__

Without a lifetime here, the `Box`es would automatically become `Box<dyn FnMut(..) + 'static>`. This makes them practically useless, since any local data you would want to pass in must then be `'static`. In the motivating example, you couldnt pass in that `&mut LoadContext` to the function.

This means that the `'p` infects the rest of the Visitor types, but this is acceptable IMO. This PR also elides the lifetimes in the `impl<'de> Visitor<'de> for -Visitor` blocks where possible.

__Future possibilities__

I think its technically possible to turn the processor into a trait, and make the deserializers generic over that trait. This would also open the door to an API like:

```rs
type Seed;

fn seed_deserialize(&mut self, r: &TypeRegistration) -> Option<Self::Seed>;

fn deserialize(&mut self, r: &TypeRegistration, d: &mut dyn erased_serde::Deserializer, s: Self::Seed) -> ...;
```

A similar processor system should also be added to the serialization side, but that’s for another PR. Ideally, both PRs will be in the same release, since one isn’t very useful without the other.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Various observer methods have been renamed for clarity.

- `App::observe` -> `App::add_observer`
- `World::observe` -> `World::add_observer`
- `Commands::observe` -> `Commands::add_observer`
- `EntityWorldMut::observe_entity` -> `EntityWorldMut::observe`
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The following methods or fields have been renamed from `*dependants*` to `*dependents*`.

- `ProcessorAssetInfo::dependants`
- `ProcessorAssetInfos::add_dependant`
- `ProcessorAssetInfos::non_existent_dependants`
- `AssetInfo::dependants_waiting_on_load`
- `AssetInfo::dependants_waiting_on_recursive_dep_load`
- `AssetInfos::loader_dependants`
- `AssetInfos::remove_dependants_and_labels`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- TODO -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Before:

```rust
commands.spawn((
UiImage::new(image),
TextureAtlas { index, layout },
));
```

After:

```rust
commands.spawn(UiImage::from_atlas_image(image, TextureAtlas { index, layout }));
```

Before:

```rust
commands.spawn(UiImage {
texture: some_image,
..default()
})
```

After:

```rust
commands.spawn(UiImage {
image: some_image,
..default()
})
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
If you previously explicitly initialized OrderIndependentTransparencySettings with your own `layer_count`, you will now have to add either a `..default()` statement or an explicit `alpha_threshold` value:

```rust
fn setup(mut commands: Commands) {
commands.spawn((
Camera3d::default(),
OrderIndependentTransparencySettings {
layer_count: 16,
..default()
},
));
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`UiSurface::get_layout` now also returns the final sizes before rounding. Call `.0` on the `Ok` result to get the previously returned `taffy::Layout` value.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If you don’t need the returned value from `remove`, discard it.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `bevy_image` instead of `bevy_render::texture` items.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `Gamepad` fields are now public.
- Instead of using `Gamepad` delegates like `Gamepad::just_pressed`, call these methods directly on the fields.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- `GamepadInfo` no longer exists:
- Name now accessible via `Name` component.
- Other information available on `Gamepad` component directly.
- `GamepadConnection::Connected` now stores all info fields directly.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```diff
# main.rs
-- use bevy_a11y::{
-- accesskit::{Node, Rect, Role},
-- AccessibilityNode,
-- };
++ use bevy_a11y::AccessibilityNode;
++ use accesskit::{Node, Rect, Role};

# Cargo.toml
++ accesskit = "0.17"
```

- Users will need to add `accesskit = "0.17"` to the dependencies section of their `Cargo.toml` file and update their `accesskit` use statements to come directly from the external crate instead of `bevy_a11y`.
- Make sure to keep the versions of `accesskit` aligned with the versions Bevy uses.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Instead of using `ComponentTicks::last_changed_tick` and `ComponentTicks::added_tick` methods, access fields directly.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Before:

```rust
commands.spawn(UiImage::new(image));
```

After:

```rust
commands.spawn(ImageNode::new(image));
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- add `zero_initialize_workgroup_memory: false,` to `ComputePipelineDescriptor` or `RenderPipelineDescriptor` structs to preserve 0.14 functionality, add `zero_initialize_workgroup_memory: true,` to restore bevy 0.13 functionality.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`Rot2::angle_between` has been deprecated, use `Rot2::angle_to` instead, the semantics of `Rot2::angle_between` will change in the future.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`ComputedNode`’s fields and methods now use physical coordinates.
`ComputedNode` has a new field `inverse_scale_factor`. Multiplying the physical coordinates by the `inverse_scale_factor` will give the logical values.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed a bug with StorageBuffer and DynamicStorageBuffer binding data from the previous frame(s) due to caching GPU buffers between frames.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The `VisibilityRange` component now has an extra field, `use_aabb`. Generally, you can safely set it to false.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `UiPlugin` now contains an extra `add_picking` field if `bevy_ui_picking_backend` is enabled.
- `SpritePlugin` is no longer a unit struct, and has one field if `bevy_sprite_picking_backend` is enabled (otherwise no fields).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`RenderCreation::Manual` variant fields are now wrapped in a struct called `RenderResources`
Loading

0 comments on commit 6fc4724

Please sign in to comment.