Skip to content

Commit

Permalink
whilelist
Browse files Browse the repository at this point in the history
  • Loading branch information
re0312 committed Jul 23, 2024
1 parent 03a6e09 commit b8b8225
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 43 deletions.
2 changes: 0 additions & 2 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ use bevy_render::{
ShaderType, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode,
},
renderer::RenderDevice,
world_sync::RenderFlyEntity,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};
use bevy_time::Fixed;
Expand Down Expand Up @@ -433,7 +432,6 @@ fn extract_gizmo_data(
},
(*handle).clone_weak(),
GizmoMeshConfig::from(config),
RenderFlyEntity,
));
}
}
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy_ecs::entity::EntityHashSet;
use bevy_ecs::prelude::*;
use bevy_ecs::{entity::EntityHashMap, system::lifetimeless::Read};
use bevy_math::{Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles};
use bevy_render::world_sync::{MainToRenderEntityMap, RenderEntity, RenderFlyEntity};
use bevy_render::world_sync::{MainToRenderEntityMap, RenderEntity};
use bevy_render::{
diagnostic::RecordDiagnostics,
mesh::RenderMesh,
Expand Down Expand Up @@ -966,7 +966,6 @@ pub fn prepare_lights(
light_entity,
face_index,
},
RenderFlyEntity,
))
.id();
view_lights.push(view_light_entity);
Expand Down Expand Up @@ -1025,7 +1024,6 @@ pub fn prepare_lights(
},
*spot_light_frustum.unwrap(),
LightEntity::Spot { light_entity },
RenderFlyEntity,
))
.id();

Expand Down Expand Up @@ -1127,7 +1125,6 @@ pub fn prepare_lights(
light_entity,
cascade_index,
},
RenderFlyEntity
))
.id();
view_lights.push(view_light_entity);
Expand Down
7 changes: 2 additions & 5 deletions crates/bevy_render/src/world_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_ecs::{
component::Component,
entity::{Entity, EntityHashMap},
observer::Trigger,
query::With,
query::Without,
reflect::ReflectComponent,
system::{Query, ResMut, Resource},
world::{Mut, OnAdd, OnRemove, World},
Expand Down Expand Up @@ -37,9 +37,6 @@ impl MainEntity {
self.0
}
}
// marker component that its entity needs to be despawned per frame.
#[derive(Component, Clone, Debug, Default, Reflect)]
pub struct RenderFlyEntity;

pub(crate) enum EntityRecord {
Added(Entity),
Expand Down Expand Up @@ -91,7 +88,7 @@ pub(crate) fn entity_sync_system(main_world: &mut World, render_world: &mut Worl
}

pub(crate) fn despawn_fly_entity(world: &mut World) {
let mut query = world.query_filtered::<Entity, With<RenderFlyEntity>>();
let mut query = world.query_filtered::<Entity, Without<MainEntity>>();

// ensure next frame allocation keeps order
let mut entities: Vec<_> = query.iter(world).collect();
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use bevy_render::{
ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms,
ViewVisibility, VisibleEntities,
},
world_sync::RenderFlyEntity,
Extract,
};
use bevy_transform::components::GlobalTransform;
Expand Down Expand Up @@ -373,7 +372,7 @@ pub fn extract_sprites(
extracted_sprites.sprites.extend(
slices
.extract_sprites(transform, entity, sprite, handle)
.map(|e| (commands.spawn(RenderFlyEntity).id(), e)),
.map(|e| (commands.spawn_empty().id(), e)),
);
} else {
let atlas_rect =
Expand All @@ -392,7 +391,7 @@ pub fn extract_sprites(

// PERF: we don't check in this function that the `Image` asset is ready, since it should be in most cases and hashing the handle is expensive
extracted_sprites.sprites.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedSprite {
color: sprite.color.into(),
transform: *transform,
Expand Down
51 changes: 24 additions & 27 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d};
use bevy_hierarchy::Parent;
use bevy_render::render_phase::ViewSortedRenderPhases;
use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE;
use bevy_render::world_sync::{RenderEntity, RenderFlyEntity};
use bevy_render::world_sync::RenderEntity;
use bevy_render::{
render_phase::{PhaseItem, PhaseItemExtraIndex},
texture::GpuImage,
Expand Down Expand Up @@ -274,7 +274,7 @@ pub fn extract_uinode_background_colors(
};

extracted_uinodes.uinodes.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedUiNode {
stack_index: uinode.stack_index,
transform: transform.compute_matrix(),
Expand Down Expand Up @@ -367,7 +367,7 @@ pub fn extract_uinode_images(
extracted_uinodes.uinodes.extend(
slices
.extract_ui_nodes(transform, uinode, image, clip, camera_entity)
.map(|e| (commands.spawn(RenderFlyEntity).id(), e)),
.map(|e| (commands.spawn_empty().id(), e)),
);
continue;
}
Expand Down Expand Up @@ -424,7 +424,7 @@ pub fn extract_uinode_images(
};

extracted_uinodes.uinodes.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedUiNode {
stack_index: uinode.stack_index,
transform: transform.compute_matrix(),
Expand Down Expand Up @@ -604,7 +604,7 @@ pub fn extract_uinode_borders(
let transform = global_transform.compute_matrix();

extracted_uinodes.uinodes.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedUiNode {
stack_index: node.stack_index,
// This translates the uinode's transform to the center of the current border rectangle
Expand Down Expand Up @@ -700,7 +700,7 @@ pub fn extract_uinode_outlines(
for edge in outline_edges {
if edge.min.x < edge.max.x && edge.min.y < edge.max.y {
extracted_uinodes.uinodes.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedUiNode {
stack_index: node.stack_index,
// This translates the uinode's transform to the center of the current border rectangle
Expand Down Expand Up @@ -781,26 +781,23 @@ pub fn extract_default_ui_camera_view(
UI_CAMERA_FAR,
);
let default_camera_view = commands
.spawn((
ExtractedView {
clip_from_view: projection_matrix,
world_from_view: GlobalTransform::from_xyz(
0.0,
0.0,
UI_CAMERA_FAR + UI_CAMERA_TRANSFORM_OFFSET,
),
clip_from_world: None,
hdr: camera.hdr,
viewport: UVec4::new(
physical_origin.x,
physical_origin.y,
physical_size.x,
physical_size.y,
),
color_grading: Default::default(),
},
RenderFlyEntity,
))
.spawn((ExtractedView {
clip_from_view: projection_matrix,
world_from_view: GlobalTransform::from_xyz(
0.0,
0.0,
UI_CAMERA_FAR + UI_CAMERA_TRANSFORM_OFFSET,
),
clip_from_world: None,
hdr: camera.hdr,
viewport: UVec4::new(
physical_origin.x,
physical_origin.y,
physical_size.x,
physical_size.y,
),
color_grading: Default::default(),
},))
.id();
commands
.get_or_spawn(entity)
Expand Down Expand Up @@ -894,7 +891,7 @@ pub fn extract_uinode_text(
let mut rect = atlas.textures[atlas_info.location.glyph_index].as_rect();
rect.min *= inverse_scale_factor;
rect.max *= inverse_scale_factor;
let id = commands.spawn(RenderFlyEntity).id();
let id = commands.spawn_empty().id();
extracted_uinodes.uinodes.insert(
id,
ExtractedUiNode {
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ui/src/render/ui_material_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use bevy_render::{
renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, FallbackImage, GpuImage},
view::*,
world_sync::RenderFlyEntity,
Extract, ExtractSchedule, Render, RenderSet,
};
use bevy_transform::prelude::GlobalTransform;
Expand Down Expand Up @@ -429,7 +428,7 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
) / uinode.size().y;

extracted_uinodes.uinodes.insert(
commands.spawn(RenderFlyEntity).id(),
commands.spawn_empty().id(),
ExtractedUiMaterialNode {
stack_index: uinode.stack_index,
transform: transform.compute_matrix(),
Expand Down

0 comments on commit b8b8225

Please sign in to comment.