Skip to content

Commit 5f9ca02

Browse files
committed
Material, mesh, skin extraction optimization
1 parent a9b0b4e commit 5f9ca02

File tree

4 files changed

+5
-19
lines changed

4 files changed

+5
-19
lines changed

crates/bevy_pbr/src/material.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,11 @@ fn early_sweep_material_instances<M>(
784784
/// preparation for a new frame.
785785
fn late_sweep_material_instances(
786786
mut material_instances: ResMut<RenderMaterialInstances>,
787-
mut removed_visibilities_query: Extract<RemovedComponents<ViewVisibility>>,
787+
mut removed_meshes_query: Extract<RemovedComponents<Mesh3d>>,
788788
) {
789789
let last_change_tick = material_instances.current_change_tick;
790790

791-
for entity in removed_visibilities_query.read() {
791+
for entity in removed_meshes_query.read() {
792792
if let Entry::Occupied(occupied_entry) = material_instances.instances.entry(entity.into()) {
793793
// Only sweep the entry if it wasn't updated this frame. It's
794794
// possible that a `ViewVisibility` component was removed and

crates/bevy_pbr/src/render/mesh.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,8 +1451,6 @@ pub fn extract_meshes_for_gpu_building(
14511451
>,
14521452
>,
14531453
all_meshes_query: Extract<Query<GpuMeshExtractionQuery>>,
1454-
mut removed_visibilities_query: Extract<RemovedComponents<ViewVisibility>>,
1455-
mut removed_global_transforms_query: Extract<RemovedComponents<GlobalTransform>>,
14561454
mut removed_meshes_query: Extract<RemovedComponents<Mesh3d>>,
14571455
gpu_culling_query: Extract<Query<(), (With<Camera>, Without<NoIndirectDrawing>)>>,
14581456
meshes_to_reextract_next_frame: ResMut<MeshesToReextractNextFrame>,
@@ -1508,11 +1506,7 @@ pub fn extract_meshes_for_gpu_building(
15081506
}
15091507

15101508
// Also record info about each mesh that became invisible.
1511-
for entity in removed_visibilities_query
1512-
.read()
1513-
.chain(removed_global_transforms_query.read())
1514-
.chain(removed_meshes_query.read())
1515-
{
1509+
for entity in removed_meshes_query.read() {
15161510
// Only queue a mesh for removal if we didn't pick it up above.
15171511
// It's possible that a necessary component was removed and re-added in
15181512
// the same frame.

crates/bevy_pbr/src/render/skin.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ pub fn extract_skins(
309309
skinned_mesh_inverse_bindposes: Extract<Res<Assets<SkinnedMeshInverseBindposes>>>,
310310
changed_transforms: Extract<Query<(Entity, &GlobalTransform), Changed<GlobalTransform>>>,
311311
joints: Extract<Query<&GlobalTransform>>,
312-
mut removed_visibilities_query: Extract<RemovedComponents<ViewVisibility>>,
313312
mut removed_skinned_meshes_query: Extract<RemovedComponents<SkinnedMesh>>,
314313
) {
315314
let skin_uniforms = skin_uniforms.into_inner();
@@ -335,10 +334,7 @@ pub fn extract_skins(
335334
);
336335

337336
// Delete skins that became invisible.
338-
for skinned_mesh_entity in removed_visibilities_query
339-
.read()
340-
.chain(removed_skinned_meshes_query.read())
341-
{
337+
for skinned_mesh_entity in removed_skinned_meshes_query.read() {
342338
// Only remove a skin if we didn't pick it up in `add_or_delete_skins`.
343339
// It's possible that a necessary component was removed and re-added in
344340
// the same frame.

crates/bevy_sprite/src/mesh2d/material.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ pub fn extract_mesh_materials_2d<M: Material2d>(
331331
Or<(Changed<ViewVisibility>, Changed<MeshMaterial2d<M>>)>,
332332
>,
333333
>,
334-
mut removed_visibilities_query: Extract<RemovedComponents<ViewVisibility>>,
335334
mut removed_materials_query: Extract<RemovedComponents<MeshMaterial2d<M>>>,
336335
) {
337336
for (entity, view_visibility, material) in &changed_meshes_query {
@@ -342,10 +341,7 @@ pub fn extract_mesh_materials_2d<M: Material2d>(
342341
}
343342
}
344343

345-
for entity in removed_visibilities_query
346-
.read()
347-
.chain(removed_materials_query.read())
348-
{
344+
for entity in removed_materials_query.read() {
349345
// Only queue a mesh for removal if we didn't pick it up above.
350346
// It's possible that a necessary component was removed and re-added in
351347
// the same frame.

0 commit comments

Comments
 (0)