Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,12 @@ impl RenderGpuCulledEntities {
///
/// The `render_layers` argument specifies the set of render layers that the
/// entity belongs to.
///
/// Note that this method is only called for entities that the extraction
/// systems picked up this frame, so the extraction change detection must be
/// configured to catch render layer changes (see
/// `extract_meshes_for_gpu_building`) in order for layer changes on
/// GPU-culled meshes to propagate.
pub fn update(
&mut self,
new_entity: MainEntity,
Expand All @@ -1763,7 +1769,7 @@ impl RenderGpuCulledEntities {
match self.entities.entry(new_entity) {
Entry::Occupied(mut occupied_entry) => {
if no_cpu_culling {
if occupied_entry.get().ne(&render_layers) {
if *occupied_entry.get() != render_layers {
self.changed_layers.push(new_entity);
}

Expand Down Expand Up @@ -1961,6 +1967,7 @@ pub fn extract_meshes_for_gpu_building(
)>,
Changed<VisibilityRange>,
Changed<SkinnedMesh>,
Changed<RenderLayers>,
Comment thread
CodingDaniel1 marked this conversation as resolved.
)>,
>,
>,
Expand All @@ -1977,6 +1984,7 @@ pub fn extract_meshes_for_gpu_building(
mut removed_no_cpu_culling_query,
mut removed_visibility_range_query,
mut removed_skinned_mesh_query,
mut removed_render_layers_query,
): (
Extract<RemovedComponents<PreviousGlobalTransform>>,
Extract<RemovedComponents<Lightmap>>,
Expand All @@ -1990,6 +1998,7 @@ pub fn extract_meshes_for_gpu_building(
Extract<RemovedComponents<NoCpuCulling>>,
Extract<RemovedComponents<VisibilityRange>>,
Extract<RemovedComponents<SkinnedMesh>>,
Extract<RemovedComponents<RenderLayers>>,
),
all_meshes_query: Extract<Query<GpuMeshExtractionQuery>>,
mut removed_meshes_query: Extract<RemovedComponents<Mesh3d>>,
Expand Down Expand Up @@ -2029,7 +2038,8 @@ pub fn extract_meshes_for_gpu_building(
.chain(removed_no_automatic_batching_query.read())
.chain(removed_no_cpu_culling_query.read())
.chain(removed_visibility_range_query.read())
.chain(removed_skinned_mesh_query.read()),
.chain(removed_skinned_mesh_query.read())
.chain(removed_render_layers_query.read()),
);

// We have to skip the meshes in the potential reextraction set if we
Expand Down
13 changes: 2 additions & 11 deletions crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,6 @@ impl RenderVisibleEntitiesClass {
}
}

/// Adds a new entity to the [`Self::added_entities`] list.
///
/// After calling this method one or more times, you must call
/// [`Self::sort_added_entities`] to ensure the [`Self::added_entities`]
/// list is sorted.
pub fn add_entity(&mut self, pair: (Entity, MainEntity)) {
self.added_entities.push(pair);
}

/// Returns the list of newly-added entities.
pub fn added_entities(&self) -> &[(Entity, MainEntity)] {
&self.added_entities
Expand Down Expand Up @@ -297,8 +288,8 @@ impl RenderVisibleEntitiesClass {

/// Sorts the [`Self::added_entities`] list.
///
/// You must call this after adding entities to the list via
/// [`Self::add_entity`].
/// You must call this after pushing entities onto the list, as the

@beicause beicause Sep 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed add_entity() as well: its only callers on main were exactly the lines rewritten in collect_gpu_culled_meshes_for_subview, so it would be dead code after this PR. (During the bevyengine#25670 review its removal was suggested to be deferred to a follow-up PR — happy to drop this hunk if maintainers prefer that. AI-authored; untested.)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is good, i was worried people are using this public api, dont know if this requires a migration guide?

/// `DirtySpecializations` iterator will binary search it.
pub fn sort_added_entities(&mut self) {
self.added_entities
.sort_unstable_by_key(|(_, main_entity)| *main_entity);
Expand Down