Skip to content

Commit 10f779e

Browse files
committed
ExtractComponent Derive, OpenGL Backend Default, LCH Color, Hex Perf, CorePlugin split, EntityCommand (#571)
1 parent f9b490c commit 10f779e

File tree

1 file changed

+114
-0
lines changed
  • content/news/2023-03-04-bevy-0.10

1 file changed

+114
-0
lines changed

content/news/2023-03-04-bevy-0.10/index.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,12 +890,57 @@ struct CoolMaterial {
890890

891891
[`AsBindGroup`]: https://docs.rs/bevy/0.10.0/bevy/render/render_resource/trait.AsBindGroup.html
892892

893+
## `ExtractComponent` Derive
894+
895+
<div class="release-feature-authors">authors: @torsteingrindvik</div>
896+
897+
To pass component data from the "main app" to the "render app" for [pipelined rendering](#enable-parallel-pipelined-rendering), we run an "extract step". The [`ExtractComponent`] trait is used to copy data over. In previous versions of Bevy you had to implement it manually, but now you can derive it!
898+
899+
```rust
900+
#[derive(Component, Clone, ExtractComponent)]
901+
pub struct Car {
902+
pub wheels: usize,
903+
}
904+
```
905+
906+
This expands to this:
907+
908+
```rust
909+
impl ExtractComponent for Car
910+
{
911+
type Query = &'static Self;
912+
type Filter = ();
913+
type Out = Self;
914+
fn extract_component(item: QueryItem<'_, Self::Query>) -> Option<Self::Out> {
915+
Some(item.clone())
916+
}
917+
}
918+
```
919+
920+
It also supports filters!
921+
922+
```rust
923+
#[derive(Component, Clone, ExtractComponent)]
924+
#[extract_component_filter(With<Fuel>)]
925+
pub struct Car {
926+
pub wheels: usize,
927+
}
928+
```
929+
930+
[`ExtractComponent`]: https://docs.rs/bevy/0.10.0/bevy/render/extract_component/trait.ExtractComponent.html
931+
893932
## Upgraded wgpu to 0.15
894933

895934
<div class="release-feature-authors">authors: @Elabajaba</div>
896935

897936
**Bevy 0.10** now uses the latest and greatest [`wgpu`](https://github.com/gfx-rs/wgpu) (our low level graphics layer). In addition to [a number of nice API improvements and bug fixes](https://github.com/gfx-rs/wgpu/releases/tag/v0.15.0), `wgpu` now uses the DXC shader compiler for DX12, which is faster, less buggy, and allows for new features.
898937

938+
## Enabled OpenGL Backend By Default
939+
940+
<div class="release-feature-authors">authors: @wangling12</div>
941+
942+
Bevy has supported `wgpu`'s OpenGL backend for a while now, but it was opt-in. This caused Bevy to fail to start up on some machines that don't support modern apis like Vulkan. In **Bevy 0.10** the OpenGL backend is enabled by default, which means machines will automatically fall back to OpenGL if no other API is available.
943+
899944
## Exposed Non-Uniform Indexing Support (Bindless)
900945

901946
<div class="release-feature-authors">authors: @cryscan</div>
@@ -1056,6 +1101,75 @@ assert!(concrete_value.is::<MyStruct>());
10561101
[`EntityMut`]: https://docs.rs/bevy/0.10.0/bevy/ecs/world/struct.EntityMut.html
10571102
[`World`]: https://docs.rs/bevy/0.10.0/bevy/ecs/world/struct.World.html
10581103

1104+
## LCH Color Space
1105+
1106+
<div class="release-feature-authors">authors: @ldubos</div>
1107+
1108+
Bevy's [`Color`] type now supports the LCH color space (Lightness, Chroma, Hue). LCH has a lot of arguments for it, including that it provides access to about 50% more colors over sRGB. Check out [this article](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) for more information.
1109+
1110+
```rust
1111+
Color::Lcha {
1112+
lightness: 1.0,
1113+
chroma: 0.5,
1114+
hue: 200.0,
1115+
alpha: 1.0,
1116+
}
1117+
```
1118+
1119+
[`Color`]: https://docs.rs/bevy/0.10.0/bevy/render/color/enum.Color.html
1120+
1121+
## Optimized `Color::hex` Performance
1122+
1123+
<div class="release-feature-authors">authors: @wyhaya</div>
1124+
1125+
[`Color::hex`](https://docs.rs/bevy/0.10.0/bevy/render/color/enum.Color.html#method.hex) is now a `const` function, which brought the runtime of `hex` from ~14ns to ~4ns!
1126+
1127+
## Split Up `CorePlugin`
1128+
1129+
<div class="release-feature-authors">authors: @targrub</div>
1130+
1131+
`CorePlugin` has historically been a bit of a "kitchen sink plugin". "Core" things that didn't fit anywhere else ended up there. This isn't a great organizational strategy, so we broke it up into individual pieces: [`TaskPoolPlugin`], [`TypeRegistrationPlugin`], and [`FrameCountPlugin`].
1132+
1133+
[`TaskPoolPlugin`]: https://docs.rs/bevy/0.10.0/bevy/core/struct.TaskPoolPlugin.html
1134+
[`TypeRegistrationPlugin`]: https://docs.rs/bevy/0.10.0/bevy/core/struct.TypeRegistrationPlugin.html
1135+
[`FrameCountPlugin`]: https://docs.rs/bevy/0.10.0/bevy/core/struct.FrameCountPlugin.html
1136+
1137+
## `EntityCommand`s
1138+
1139+
<div class="release-feature-authors">authors: @targrub</div>
1140+
1141+
[`Commands`] are "deferred ECS" operations. They enable developers to define custom ECS operations that are applied after a parallel system has finished running. Many [`Commands`] ran on individual entities, but this pattern was a bit cumbersome:
1142+
1143+
```rust
1144+
struct MyCustomCommand(Entity);
1145+
1146+
impl Command for MyCustomCommand {
1147+
fn write(self, world: &mut World) {
1148+
// do something with the entity at self.0
1149+
}
1150+
}
1151+
1152+
let id = commands.spawn(SpriteBundle::default()).id();
1153+
commmands.add(MyCustomCommand(id));
1154+
```
1155+
1156+
To solve this, in **Bevy 0.10** we added the [`EntityCommand`] trait. This allows the command to be ergonomically applied to spawned entities:
1157+
1158+
```rust
1159+
struct MyCustomCommand;
1160+
1161+
impl EntityCommand for MyCustomCommand {
1162+
fn write(self, id: Entity, world: &mut World) {
1163+
// do something with the given entity id
1164+
}
1165+
}
1166+
1167+
commands.spawn(SpriteBundle::default()).add(MyCustomCommand);
1168+
```
1169+
1170+
[`EntityCommand`]: https://docs.rs/bevy/0.10.0/bevy/ecs/system/trait.EntityCommand.html
1171+
[`Commands`]: https://docs.rs/bevy/0.10.0/bevy/ecs/system/struct.Commands.html
1172+
10591173
## What's Next?
10601174

10611175
* **[One-shot systems](https://github.com/bevyengine/bevy/issues/2192):** Run arbitrary systems in a push-based fashion via commands, and store them as callback components for ultra-flexible behavior customization.

0 commit comments

Comments
 (0)