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

add support for render layers on tilemaps #244

Merged
merged 1 commit into from
Sep 4, 2022
Merged
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
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