Skip to content

Commit fe777d5

Browse files
authored
Implement and register Reflect (value) for CameraRenderGraph and CameraMainTextureUsages (#11878)
# Objective The new render graph labels do not (and cannot) implement normal Reflect, which breaks spawning scenes with cameras (including GLTF scenes). Likewise, the new `CameraMainTextureUsages` also does not (and cannot) implement normal Reflect because it uses `wgpu::TextureUsages` under the hood. Fixes #11852 ## Solution This implements minimal "reflect value" for `CameraRenderGraph` and `CameraMainTextureUsages` and registers the types, which satisfies our spawn logic. Note that this _does not_ fix scene serialization for these types, which will require more significant changes. We will especially need to think about how (and if) "interned labels" will fit into the scene system. For the purposes of 0.13, I think this is the best we can do. Given that this serialization issue is prevalent throughout Bevy atm, I'm ok with adding a couple more to the pile. When we roll out the new scene system, we will be forced to solve these on a case-by-case basis. --- ## Changelog - Implement Reflect (value) for `CameraMainTextureUsages` and `CameraRenderGraph`, and register those types.
1 parent f83de49 commit fe777d5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/bevy_render/src/camera/camera.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ impl Default for CameraOutputMode {
498498
}
499499

500500
/// Configures the [`RenderGraph`](crate::render_graph::RenderGraph) name assigned to be run for a given [`Camera`] entity.
501-
#[derive(Component, Deref, DerefMut)]
501+
#[derive(Component, Deref, DerefMut, Reflect, Clone)]
502+
#[reflect_value(Component)]
502503
pub struct CameraRenderGraph(InternedRenderSubGraph);
503504

504505
impl CameraRenderGraph {
@@ -773,7 +774,8 @@ pub fn camera_system<T: CameraProjection + Component>(
773774
}
774775

775776
/// This component lets you control the [`TextureUsages`] field of the main texture generated for the camera
776-
#[derive(Component, ExtractComponent, Clone, Copy)]
777+
#[derive(Component, ExtractComponent, Clone, Copy, Reflect)]
778+
#[reflect_value(Component)]
777779
pub struct CameraMainTextureUsages(pub TextureUsages);
778780
impl Default for CameraMainTextureUsages {
779781
fn default() -> Self {

crates/bevy_render/src/camera/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ impl Plugin for CameraPlugin {
3030
.register_type::<RenderTarget>()
3131
.register_type::<ClearColor>()
3232
.register_type::<ClearColorConfig>()
33+
.register_type::<CameraRenderGraph>()
34+
.register_type::<CameraMainTextureUsages>()
3335
.init_resource::<ManualTextureViews>()
3436
.init_resource::<ClearColor>()
3537
.add_plugins((

0 commit comments

Comments
 (0)