Skip to content

Commit

Permalink
RenderPhase<Transparent2d> -> ViewSortedRenderPhases<Transparent2d>
Browse files Browse the repository at this point in the history
[12453](https://github.com/StarArawn/bevy_ecs_tilemap/pull/bevyengine/bevy#12453): Render phases are now binned or sorted.

Following the changes in the `mesh2d_manual` [example](https://github.com/bevyengine/bevy/blob/ecdd1624f302c5f71aaed95b0984cbbecf8880b7/examples/2d/mesh2d_manual.rs#L357-L358): use the `ViewSortedRenderPhases` resource.
  • Loading branch information
ChristopherBiscardi committed Jun 7, 2024
1 parent 29f5818 commit d234b18
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/render/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use bevy::{
extract_component::ExtractComponentPlugin,
globals::GlobalsBuffer,
render_asset::RenderAssets,
render_phase::{AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, RenderPhase},
render_phase::{
AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, ViewSortedRenderPhases,
},
render_resource::{
AsBindGroup, AsBindGroupError, BindGroup, BindGroupEntry, BindGroupLayout,
BindingResource, OwnedBindingResource, PipelineCache, RenderPipelineDescriptor,
Expand Down Expand Up @@ -386,16 +388,13 @@ pub fn queue_material_tilemap_meshes<M: MaterialTilemap>(
Query<(Entity, &ChunkId, &Transform, &TilemapId)>,
Query<&Handle<M>>,
),
mut views: Query<(
&ExtractedView,
&VisibleEntities,
&mut RenderPhase<Transparent2d>,
)>,
mut views: Query<(Entity, &ExtractedView, &VisibleEntities)>,
render_materials: Res<RenderMaterialsTilemap<M>>,
#[cfg(not(feature = "atlas"))] (mut texture_array_cache, render_queue): (
ResMut<TextureArrayCache>,
Res<RenderQueue>,
),
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent2d>>,
) where
M::Data: PartialEq + Eq + Hash + Clone,
{
Expand All @@ -410,7 +409,11 @@ pub fn queue_material_tilemap_meshes<M: MaterialTilemap>(
return;
}

for (view, visible_entities, mut transparent_phase) in views.iter_mut() {
for (view_entity, view, visible_entities) in views.iter_mut() {
let Some(transparent_phase) = transparent_render_phases.get_mut(&view_entity) else {
continue;
};

let draw_tilemap = transparent_2d_draw_functions
.read()
.get_id::<DrawTilemapMaterial<M>>()
Expand Down

0 comments on commit d234b18

Please sign in to comment.