Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain Rendering World #14449

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
95b7f0b
init
re0312 Jul 6, 2024
17f2bb0
sync
re0312 Jul 7, 2024
35fe01e
cleanup
re0312 Jul 22, 2024
f9bae87
clean
re0312 Jul 22, 2024
34853b2
fix
re0312 Jul 22, 2024
000cef4
Fly
re0312 Jul 22, 2024
2255b21
Merge branch 'main' into retain_world
re0312 Jul 22, 2024
f90c360
fly entity
re0312 Jul 22, 2024
756b082
sync world
re0312 Jul 22, 2024
5b5ef76
ui
re0312 Jul 22, 2024
e15e3a3
lighting
re0312 Jul 22, 2024
e4e0bc0
fix example
re0312 Jul 22, 2024
33cae8d
ui
re0312 Jul 22, 2024
4a58b0e
fix ui
re0312 Jul 22, 2024
3fc2207
fix gizmos
re0312 Jul 22, 2024
f9c8d5a
fix light
re0312 Jul 22, 2024
44d36a4
cleanup
re0312 Jul 22, 2024
9a7d641
Merge branch 'main' into retain_world
re0312 Jul 22, 2024
7989d21
fix cli
re0312 Jul 22, 2024
9485455
fix ui
re0312 Jul 23, 2024
bb3289b
clean
re0312 Jul 23, 2024
39e4f2e
fix cli
re0312 Jul 23, 2024
4b6506e
fix ui_material
re0312 Jul 23, 2024
03a6e09
fix sprite
re0312 Jul 23, 2024
b8b8225
whilelist
re0312 Jul 23, 2024
24212f5
Revert "whilelist"
re0312 Jul 23, 2024
2de636a
address review
re0312 Jul 24, 2024
1fbb76c
Update crates/bevy_render/src/world_sync.rs
re0312 Jul 24, 2024
c25d560
Update crates/bevy_render/src/world_sync.rs
re0312 Jul 24, 2024
457e83f
Update crates/bevy_render/src/world_sync.rs
re0312 Jul 24, 2024
16c1093
Merge branch 'main' into retain_world
re0312 Jul 25, 2024
cba1183
address review
re0312 Jul 25, 2024
2821849
fmt
re0312 Jul 25, 2024
a86dd39
address review
re0312 Jul 25, 2024
8422a48
comment
re0312 Jul 25, 2024
dc5f10f
remove mapping
re0312 Jul 26, 2024
2a6df8d
retain sprite
re0312 Jul 27, 2024
ce2ea36
cache state
re0312 Aug 1, 2024
c1a4fb9
fix cli
re0312 Aug 1, 2024
672778d
fix
re0312 Aug 1, 2024
0eed037
fix point light
re0312 Aug 1, 2024
5a83da4
fix regression
re0312 Aug 9, 2024
ed296f1
fix cli
re0312 Aug 9, 2024
bb8774d
Merge branch 'main' into retain_world
re0312 Aug 9, 2024
94be0cd
fix conflict
re0312 Aug 9, 2024
560ce59
Merge branch 'main' into retain_world
re0312 Aug 9, 2024
ab22138
Merge branch 'main' into retain_world
re0312 Aug 11, 2024
fd36379
Apply suggestions from code review
re0312 Aug 12, 2024
4bdfd60
Merge branch 'main' into retain_world
re0312 Aug 12, 2024
6214e6d
Merge branch 'retain_world' of https://github.com/re0312/bevy into re…
re0312 Aug 12, 2024
67e7a07
fix cli
re0312 Aug 12, 2024
1507437
Merge branch 'main' into retain_world
re0312 Aug 25, 2024
e5254be
fix
re0312 Aug 25, 2024
d9ecccd
Merge branch 'main' into retain_world
re0312 Aug 27, 2024
faf5ef2
fix
re0312 Aug 27, 2024
f127719
to render world
re0312 Aug 27, 2024
c7ba466
SyncRenderWorld
re0312 Aug 27, 2024
23a8bba
extract_component
re0312 Aug 27, 2024
37944a8
document and test
re0312 Aug 28, 2024
1e8601f
fix
re0312 Aug 28, 2024
7167cc0
typo
re0312 Aug 28, 2024
bfad1de
cleanup
re0312 Aug 28, 2024
8d2c81a
rename
re0312 Aug 28, 2024
d857e6e
Apply suggestions from code review
re0312 Aug 31, 2024
9c1a523
Cleared up some documentation
Trashtalk217 Sep 3, 2024
753d286
Merge pull request #1 from Trashtalk217/retain_world
re0312 Sep 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/bevy_core_pipeline/src/auto_exposure/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bevy_ecs::prelude::*;
use bevy_render::{
render_resource::{StorageBuffer, UniformBuffer},
renderer::{RenderDevice, RenderQueue},
world_sync::RenderEntity,
Extract,
};
use bevy_utils::{Entry, HashMap};
Expand All @@ -27,13 +28,13 @@ pub(super) struct ExtractedStateBuffers {

pub(super) fn extract_buffers(
mut commands: Commands,
changed: Extract<Query<(Entity, &AutoExposureSettings), Changed<AutoExposureSettings>>>,
changed: Extract<Query<(&RenderEntity, &AutoExposureSettings), Changed<AutoExposureSettings>>>,
mut removed: Extract<RemovedComponents<AutoExposureSettings>>,
) {
commands.insert_resource(ExtractedStateBuffers {
changed: changed
.iter()
.map(|(entity, settings)| (entity, settings.clone()))
.map(|(entity, settings)| (entity.id(), settings.clone()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a lot of noise in this PR due to the need to insert these RenderEntity::id calls. This might be a controversial suggestion, but we can implement WorldQuery for RenderEntity so it still behaves like a Component, but also returns the inner Entity when queried directly.

unsafe impl WorldQuery for RenderEntity { ... }
/// SAFETY:
/// This implementation delegates to the existing implementation for &RenderEntity
unsafe impl WorldQuery for RenderEntity {
  type Item<'w> = Entity;
  type Fetch<'w> = ReadFetch<'w, RenderEntity>;
  type State = ComponentId;

  fn shrink<'wlong: 'wshort, 'wshort>(item: Entity) -> Entity {
      item
  }

  fn shrink_fetch<'wlong: 'wshort, 'wshort>(fetch: Self::Fetch<'wlong>) -> Self::Fetch<'wshort> {
      <&Self as WorldQuery>::shrink_fetch(fetch)
  }

  #[inline]
  unsafe fn init_fetch<'w>(
      world: UnsafeWorldCell<'w>,
      component_id: &ComponentId,
      last_run: Tick,
      this_run: Tick,
  ) -> ReadFetch<'w, RenderEntity> {
      // SAFETY: This implementation delegates to the existing implementation for &RenderEntity
      unsafe {
          <&Self as WorldQuery>::init_fetch(world, component_id, last_run, this_run)
      }
  }

  const IS_DENSE: bool = <&Self as WorldQuery>::IS_DENSE;

  #[inline]
  unsafe fn set_archetype<'w>(
      fetch: &mut ReadFetch<'w, RenderEntity>,
      component_id: &ComponentId,
      archetype: &'w Archetype,
      table: &'w Table,
  ) {
      // SAFETY: This implementation delegates to the existing implementation for &RenderEntity
      unsafe {
          <&Self as WorldQuery>::set_archetype(fetch, component_id, archetype, table)
      }
  }

  #[inline]
  unsafe fn set_table<'w>(
      fetch: &mut ReadFetch<'w, RenderEntity>,
      component_id: &ComponentId,
      table: &'w Table,
  ) {
      // SAFETY: This implementation delegates to the existing implementation for &RenderEntity
      unsafe {
          <&Self as WorldQuery>::set_table(fetch, component_id, table)
      }
  }

  #[inline(always)]
  unsafe fn fetch<'w>(
      fetch: &mut Self::Fetch<'w>,
      entity: Entity,
      table_row: TableRow,
  ) -> Self::Item<'w> {
      // SAFETY: This implementation delegates to the existing implementation for &RenderEntity
      unsafe {
          <&Self as WorldQuery>::fetch(fetch, entity, table_row).id()
      }
  }

  fn update_component_access(
      component_id: &ComponentId,
      access: &mut FilteredAccess<ComponentId>,
  ) {
      <&Self as WorldQuery>::update_component_access(component_id, access)
  }

  fn init_state(world: &mut World) -> ComponentId {
      <&Self as WorldQuery>::init_state(world)
  }

  fn get_state(components: &Components) -> Option<Self::State> {
      <&Self as WorldQuery>::get_state(components)
  }

  fn matches_component_set(
      state: &ComponentId,
      set_contains_id: &impl Fn(ComponentId) -> bool,
  ) -> bool {
      <&Self as WorldQuery>::matches_component_set(state, set_contains_id)
  }
}

/// SAFETY: `Self` is the same as `Self::ReadOnly`
unsafe impl QueryData for RenderEntity {
  type ReadOnly = Self;
}

/// SAFETY: access is read only
unsafe impl ReadOnlyQueryData for RenderEntity {}

This would then allow for render systems to query for RenderEntity and directly receive the inner Entity, reducing the noise in this PR. Crucially, this doesn't conflict with the existing derive(Component), so you can still query for &RenderEntity, the mutable version, use it in filters, etc.

.collect(),
removed: removed.read().collect(),
});
Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_core_pipeline/src/core_2d/camera_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::tonemapping::{DebandDither, Tonemapping};
use bevy_ecs::prelude::*;
use bevy_reflect::Reflect;
use bevy_render::prelude::Msaa;
use bevy_render::world_sync::SyncRenderWorld;
use bevy_render::{
camera::{
Camera, CameraMainTextureUsages, CameraProjection, CameraRenderGraph,
Expand Down Expand Up @@ -37,6 +38,8 @@ pub struct Camera2dBundle {
pub deband_dither: DebandDither,
pub main_texture_usages: CameraMainTextureUsages,
pub msaa: Msaa,
/// Marker component that indicates that its entity needs to be Synchronized to the render world
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For here and all other comments, please do not capitalize "Synchronized" in the middle of the sentence.

pub sync: SyncRenderWorld,
}

impl Default for Camera2dBundle {
Expand All @@ -61,6 +64,7 @@ impl Default for Camera2dBundle {
deband_dither: DebandDither::Disabled,
main_texture_usages: Default::default(),
msaa: Default::default(),
sync: Default::default(),
}
}
}
Expand Down Expand Up @@ -94,6 +98,7 @@ impl Camera2dBundle {
deband_dither: DebandDither::Disabled,
main_texture_usages: Default::default(),
msaa: Default::default(),
sync: Default::default(),
}
}
}
7 changes: 3 additions & 4 deletions crates/bevy_core_pipeline/src/core_2d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use bevy_render::{
renderer::RenderDevice,
texture::TextureCache,
view::{Msaa, ViewDepthTexture},
world_sync::RenderEntity,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};

Expand Down Expand Up @@ -357,11 +358,10 @@ impl CachedRenderPipelinePhaseItem for Transparent2d {
}

pub fn extract_core_2d_camera_phases(
mut commands: Commands,
mut transparent_2d_phases: ResMut<ViewSortedRenderPhases<Transparent2d>>,
mut opaque_2d_phases: ResMut<ViewBinnedRenderPhases<Opaque2d>>,
mut alpha_mask_2d_phases: ResMut<ViewBinnedRenderPhases<AlphaMask2d>>,
cameras_2d: Extract<Query<(Entity, &Camera), With<Camera2d>>>,
cameras_2d: Extract<Query<(&RenderEntity, &Camera), With<Camera2d>>>,
mut live_entities: Local<EntityHashSet>,
) {
live_entities.clear();
Expand All @@ -370,8 +370,7 @@ pub fn extract_core_2d_camera_phases(
if !camera.is_active {
continue;
}

commands.get_or_spawn(entity);
let entity = entity.id();
transparent_2d_phases.insert_or_clear(entity);
opaque_2d_phases.insert_or_clear(entity);
alpha_mask_2d_phases.insert_or_clear(entity);
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_core_pipeline/src/core_3d/camera_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::{
};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::view::Msaa;
use bevy_render::{
camera::{Camera, CameraMainTextureUsages, CameraRenderGraph, Exposure, Projection},
extract_component::ExtractComponent,
primitives::Frustum,
render_resource::{LoadOp, TextureUsages},
view::{ColorGrading, VisibleEntities},
};
use bevy_render::{view::Msaa, world_sync::SyncRenderWorld};
use bevy_transform::prelude::{GlobalTransform, Transform};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -154,6 +154,8 @@ pub struct Camera3dBundle {
pub exposure: Exposure,
pub main_texture_usages: CameraMainTextureUsages,
pub msaa: Msaa,
/// Marker component that indicates that its entity needs to be Synchronized to the render world
pub sync: SyncRenderWorld,
}

// NOTE: ideally Perspective and Orthographic defaults can share the same impl, but sadly it breaks rust's type inference
Expand All @@ -174,6 +176,7 @@ impl Default for Camera3dBundle {
main_texture_usages: Default::default(),
deband_dither: DebandDither::Enabled,
msaa: Default::default(),
sync: Default::default(),
}
}
}
23 changes: 14 additions & 9 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ use bevy_render::{
renderer::RenderDevice,
texture::{BevyDefault, ColorAttachment, Image, TextureCache},
view::{ExtractedView, ViewDepthTexture, ViewTarget},
world_sync::RenderEntity,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};
use bevy_utils::{tracing::warn, HashMap};
Expand Down Expand Up @@ -504,23 +505,21 @@ impl CachedRenderPipelinePhaseItem for Transparent3d {
}

pub fn extract_core_3d_camera_phases(
mut commands: Commands,
mut opaque_3d_phases: ResMut<ViewBinnedRenderPhases<Opaque3d>>,
mut alpha_mask_3d_phases: ResMut<ViewBinnedRenderPhases<AlphaMask3d>>,
mut transmissive_3d_phases: ResMut<ViewSortedRenderPhases<Transmissive3d>>,
mut transparent_3d_phases: ResMut<ViewSortedRenderPhases<Transparent3d>>,
cameras_3d: Extract<Query<(Entity, &Camera), With<Camera3d>>>,
cameras_3d: Extract<Query<(&RenderEntity, &Camera), With<Camera3d>>>,
mut live_entities: Local<EntityHashSet>,
) {
live_entities.clear();

for (entity, camera) in &cameras_3d {
for (render_entity, camera) in &cameras_3d {
if !camera.is_active {
continue;
}

commands.get_or_spawn(entity);

let entity = render_entity.id();
opaque_3d_phases.insert_or_clear(entity);
alpha_mask_3d_phases.insert_or_clear(entity);
transmissive_3d_phases.insert_or_clear(entity);
Expand All @@ -545,7 +544,7 @@ pub fn extract_camera_prepass_phase(
cameras_3d: Extract<
Query<
(
Entity,
&RenderEntity,
&Camera,
Has<DepthPrepass>,
Has<NormalPrepass>,
Expand All @@ -559,13 +558,20 @@ pub fn extract_camera_prepass_phase(
) {
live_entities.clear();

for (entity, camera, depth_prepass, normal_prepass, motion_vector_prepass, deferred_prepass) in
cameras_3d.iter()
for (
render_entity,
camera,
depth_prepass,
normal_prepass,
motion_vector_prepass,
deferred_prepass,
) in cameras_3d.iter()
{
if !camera.is_active {
continue;
}

let entity = render_entity.id();
if depth_prepass || normal_prepass || motion_vector_prepass {
opaque_3d_prepass_phases.insert_or_clear(entity);
alpha_mask_3d_prepass_phases.insert_or_clear(entity);
Expand All @@ -581,7 +587,6 @@ pub fn extract_camera_prepass_phase(
opaque_3d_deferred_phases.remove(&entity);
alpha_mask_3d_deferred_phases.remove(&entity);
}

live_entities.insert(entity);

commands
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_core_pipeline/src/dof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use bevy_render::{
prepare_view_targets, ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform,
ViewUniformOffset, ViewUniforms,
},
world_sync::RenderEntity,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};
use bevy_utils::{info_once, prelude::default, warn_once};
Expand Down Expand Up @@ -798,7 +799,7 @@ impl SpecializedRenderPipeline for DepthOfFieldPipeline {
/// Extracts all [`DepthOfFieldSettings`] components into the render world.
fn extract_depth_of_field_settings(
mut commands: Commands,
mut query: Extract<Query<(Entity, &DepthOfFieldSettings, &Projection)>>,
mut query: Extract<Query<(&RenderEntity, &DepthOfFieldSettings, &Projection)>>,
) {
if !DEPTH_TEXTURE_SAMPLING_SUPPORTED {
info_once!(
Expand All @@ -808,6 +809,7 @@ fn extract_depth_of_field_settings(
}

for (entity, dof_settings, projection) in query.iter_mut() {
let entity = entity.id();
// Depth of field is nonsensical without a perspective projection.
let Projection::Perspective(ref perspective_projection) = *projection else {
continue;
Expand Down
20 changes: 13 additions & 7 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use bevy_render::{
renderer::{RenderContext, RenderDevice},
texture::{BevyDefault, CachedTexture, TextureCache},
view::{ExtractedView, Msaa, ViewTarget},
world_sync::RenderEntity,
ExtractSchedule, MainWorld, Render, RenderApp, RenderSet,
};
use bevy_utils::tracing::warn;
Expand Down Expand Up @@ -346,17 +347,22 @@ impl SpecializedRenderPipeline for TaaPipeline {
}

fn extract_taa_settings(mut commands: Commands, mut main_world: ResMut<MainWorld>) {
let mut cameras_3d = main_world
.query_filtered::<(Entity, &Camera, &Projection, &mut TemporalAntiAliasSettings), (
With<Camera3d>,
With<TemporalJitter>,
With<DepthPrepass>,
With<MotionVectorPrepass>,
)>();
let mut cameras_3d = main_world.query_filtered::<(
&RenderEntity,
&Camera,
&Projection,
&mut TemporalAntiAliasSettings,
), (
With<Camera3d>,
With<TemporalJitter>,
With<DepthPrepass>,
With<MotionVectorPrepass>,
)>();

for (entity, camera, camera_projection, mut taa_settings) in
cameras_3d.iter_mut(&mut main_world)
{
let entity = entity.id();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit: entity is only used once here, I'd rather not create a new variable, and just use entity.id() directly in commands.get_or_spawn()

let has_perspective_projection = matches!(camera_projection, Projection::Perspective(_));
if camera.is_active && has_perspective_projection {
commands.get_or_spawn(entity).insert(taa_settings.clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets see if I understand this correctly: this could be just get_mut() here instead of get_or_spawn(), as the entity should already exist as camera bundles have SyncRenderWorld, correct?

(That said I do think we should leave it as get_or_spawn() in case users aren't using the bundle, this comment is just to see if I understand this PR correctly or not)

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ use bevy_render::{
ShaderType, VertexFormat,
},
renderer::RenderDevice,
world_sync::TemporaryRenderEntity,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};

Expand Down Expand Up @@ -452,6 +453,7 @@ fn extract_gizmo_data(
(*handle).clone_weak(),
#[cfg(any(feature = "bevy_pbr", feature = "bevy_sprite"))]
config::GizmoMeshConfig::from(config),
TemporaryRenderEntity,
));
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_pbr/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bevy_derive::{Deref, DerefMut};
use bevy_ecs::entity::{Entity, EntityHashMap};
use bevy_ecs::{bundle::Bundle, component::Component, reflect::ReflectComponent};
use bevy_reflect::Reflect;
use bevy_render::world_sync::SyncRenderWorld;
use bevy_render::{
mesh::Mesh,
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
Expand Down Expand Up @@ -103,6 +104,8 @@ pub struct PointLightBundle {
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
pub view_visibility: ViewVisibility,
/// Marker component that indicates that its entity needs to be Synchronized to the render world
pub sync: SyncRenderWorld,
}

/// A component bundle for spot light entities
Expand All @@ -119,6 +122,8 @@ pub struct SpotLightBundle {
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
pub view_visibility: ViewVisibility,
/// Marker component that indicates that its entity needs to be Synchronized to the render world
pub sync: SyncRenderWorld,
}

/// A component bundle for [`DirectionalLight`] entities.
Expand All @@ -137,4 +142,6 @@ pub struct DirectionalLightBundle {
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
pub view_visibility: ViewVisibility,
/// Marker component that indicates that its entity needs to be Synchronized to the render world
pub sync: SyncRenderWorld,
}
14 changes: 9 additions & 5 deletions crates/bevy_pbr/src/cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use bevy_render::{
UniformBuffer,
},
renderer::{RenderDevice, RenderQueue},
world_sync::RenderEntity,
Extract,
};
use bevy_utils::{hashbrown::HashSet, tracing::warn};
Expand Down Expand Up @@ -512,7 +513,8 @@ pub(crate) fn clusterable_object_order(
/// Extracts clusters from the main world from the render world.
pub fn extract_clusters(
mut commands: Commands,
views: Extract<Query<(Entity, &Clusters, &Camera)>>,
views: Extract<Query<(&RenderEntity, &Clusters, &Camera)>>,
mapper: Extract<Query<&RenderEntity>>,
re0312 marked this conversation as resolved.
Show resolved Hide resolved
) {
for (entity, clusters, camera) in &views {
if !camera.is_active {
Expand All @@ -531,13 +533,15 @@ pub fn extract_clusters(
cluster_objects.spot_light_count as u32,
));
for clusterable_entity in &cluster_objects.entities {
data.push(ExtractedClusterableObjectElement::ClusterableObjectEntity(
*clusterable_entity,
));
if let Ok(entity) = mapper.get(*clusterable_entity) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we modify the clusterizer system to store RenderEntity on Clusters directly, instead of using another query here?

data.push(ExtractedClusterableObjectElement::ClusterableObjectEntity(
entity.id(),
));
}
}
}

commands.get_or_spawn(entity).insert((
commands.get_or_spawn(entity.id()).insert((
ExtractedClusterableObjects { data },
ExtractedClusterConfig {
near: clusters.near,
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ impl Plugin for PbrPlugin {
)
.init_resource::<LightMeta>();

render_app.world_mut().observe(add_light_view_entities);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these two lines doing here ?

render_app.world_mut().observe(remove_light_view_entities);

let shadow_pass_node = ShadowPassNode::new(render_app.world_mut());
let mut graph = render_app.world_mut().resource_mut::<RenderGraph>();
let draw_3d_graph = graph.get_sub_graph_mut(Core3d).unwrap();
Expand Down
Loading