Skip to content

Commit dfb809c

Browse files
authored
Implement Reflect for CameraOutputMode (#21344)
# Objective `CameraOutputMode` doesn't Implement `Reflect` and is ignored in `Camera`. ## Solution Like #15355, this Implements opaque `Reflect` for `wgpu::BlendState` thus we can add `#derive(Reflect)` for `CameraOutputMode`. As the commnent says, it can also implement `Reflect` througth `reflect_remote` (#6042), but I'm not sure if we should do this for wgpu types. ## Testing ci
1 parent cc4398e commit dfb809c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/bevy_camera/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ bevy_asset = { path = "../bevy_asset", version = "0.18.0-dev" }
1515
bevy_image = { path = "../bevy_image", version = "0.18.0-dev" }
1616
bevy_mesh = { path = "../bevy_mesh", version = "0.18.0-dev" }
1717
bevy_math = { path = "../bevy_math", version = "0.18.0-dev" }
18-
bevy_reflect = { path = "../bevy_reflect", version = "0.18.0-dev" }
18+
bevy_reflect = { path = "../bevy_reflect", version = "0.18.0-dev", features = [
19+
"wgpu-types",
20+
] }
1921
bevy_ecs = { path = "../bevy_ecs", version = "0.18.0-dev" }
2022
bevy_transform = { path = "../bevy_transform", version = "0.18.0-dev" }
2123
bevy_derive = { path = "../bevy_derive", version = "0.18.0-dev" }

crates/bevy_camera/src/camera.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,7 @@ pub struct Camera {
362362
pub computed: ComputedCameraValues,
363363
/// The "target" that this camera will render to.
364364
pub target: RenderTarget,
365-
// todo: reflect this when #6042 lands
366365
/// The [`CameraOutputMode`] for this camera.
367-
#[reflect(ignore, clone)]
368366
pub output_mode: CameraOutputMode,
369367
/// If this is enabled, a previous camera exists that shares this camera's render target, and this camera has MSAA enabled, then the previous camera's
370368
/// outputs will be written to the intermediate multi-sampled render target textures for this camera. This enables cameras with MSAA enabled to
@@ -777,7 +775,7 @@ impl Camera {
777775
}
778776

779777
/// Control how this [`Camera`] outputs once rendering is completed.
780-
#[derive(Debug, Clone, Copy)]
778+
#[derive(Debug, Clone, Copy, Reflect)]
781779
pub enum CameraOutputMode {
782780
/// Writes the camera output to configured render target.
783781
Write {

crates/bevy_reflect/src/impls/wgpu_types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ impl_reflect_opaque!(::wgpu_types::TextureFormat(
88
Deserialize,
99
Serialize,
1010
));
11+
impl_reflect_opaque!(::wgpu_types::BlendState(
12+
Clone,
13+
Debug,
14+
Hash,
15+
PartialEq,
16+
Deserialize,
17+
Serialize,
18+
));

0 commit comments

Comments
 (0)