Skip to content

Commit

Permalink
Merge pull request #244 from Piefayth/renderlayers-support
Browse files Browse the repository at this point in the history
add support for render layers on tilemaps
  • Loading branch information
StarArawn committed Sep 4, 2022
2 parents 6fa441f + 2fc7d84 commit 291ae98
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/render/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy::{
PipelineCache, SpecializedRenderPipelines,
},
renderer::RenderDevice,
view::{ExtractedView, ViewUniforms},
view::{ExtractedView, ViewUniforms, VisibleEntities},
},
utils::FloatOrd,
utils::HashMap,
Expand Down Expand Up @@ -103,15 +103,15 @@ pub fn queue_meshes(
msaa: Res<Msaa>,
mut image_bind_groups: ResMut<ImageBindGroups>,
standard_tilemap_meshes: Query<(Entity, &ChunkId, &Transform, &TilemapId)>,
mut views: Query<(Entity, &ExtractedView, &mut RenderPhase<Transparent2d>)>,
mut views: Query<(Entity, &ExtractedView, &VisibleEntities, &mut RenderPhase<Transparent2d>)>,
#[cfg(not(feature = "atlas"))] mut texture_array_cache: ResMut<TextureArrayCache>,
#[cfg(not(feature = "atlas"))] render_queue: Res<RenderQueue>,
) {
#[cfg(not(feature = "atlas"))]
texture_array_cache.queue(&render_device, &render_queue, &gpu_images);

if let Some(view_binding) = view_uniforms.uniforms.binding() {
for (entity, _view, mut transparent_phase) in views.iter_mut() {
for (entity, _view, visible_entities, mut transparent_phase) in views.iter_mut() {
let view_bind_group = render_device.create_bind_group(&BindGroupDescriptor {
entries: &[BindGroupEntry {
binding: 0,
Expand All @@ -131,6 +131,10 @@ pub fn queue_meshes(
.unwrap();

for (entity, chunk_id, transform, tilemap_id) in standard_tilemap_meshes.iter() {
if !visible_entities.entities.contains(&tilemap_id.0) {
continue
}

if let Some(chunk) = chunk_storage.get(&UVec4::new(
chunk_id.0.x,
chunk_id.0.y,
Expand Down

0 comments on commit 291ae98

Please sign in to comment.