Skip to content

Commit

Permalink
Use ViewSortedRenderPhases<Transparent3d> instead of RenderPhase<Tran…
Browse files Browse the repository at this point in the history
…sparent3d>

Addresses changes from Bevy [12453](bevyengine/bevy#12453),
Bevy [13277](bevyengine/bevy#13277).

Inspired by similar fixes by bevy_ecs_tilemap
(StarArawn/bevy_ecs_tilemap@d234b18).
  • Loading branch information
zhaop committed Jun 24, 2024
1 parent 9c053ad commit b0998e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/transform-gizmo-bevy/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use bevy_render::render_asset::{
RenderAssets,
};
use bevy_render::render_phase::{
AddRenderCommand, DrawFunctions, PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, RenderPhase, SetItemPipeline, TrackedRenderPass
AddRenderCommand, DrawFunctions, PhaseItem, PhaseItemExtraIndex, RenderCommand,
RenderCommandResult, SetItemPipeline, TrackedRenderPass, ViewSortedRenderPhases,
};
use bevy_render::render_resource::{
BlendState, Buffer, BufferInitDescriptor, BufferUsages, ColorTargetState, ColorWrites,
Expand Down Expand Up @@ -289,8 +290,8 @@ fn queue_transform_gizmos(
transform_gizmos: Query<(Entity, &Handle<GizmoDrawData>)>,
transform_gizmo_assets: Res<RenderAssets<GizmoBuffers>>,
mut views: Query<(
Entity,
&ExtractedView,
&mut RenderPhase<Transparent3d>,
Option<&RenderLayers>,
(
Has<NormalPrepass>,
Expand All @@ -299,16 +300,21 @@ fn queue_transform_gizmos(
Has<DeferredPrepass>,
),
)>,
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent3d>>,
) {
let draw_function = draw_functions.read().get_id::<DrawGizmo>().unwrap();

for (
view_entity,
view,
mut transparent_phase,
_render_layers,
(normal_prepass, depth_prepass, motion_vector_prepass, deferred_prepass),
) in &mut views
{
let Some(transparent_phase) = transparent_render_phases.get_mut(&view_entity) else {
continue;
};

let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.samples())
| MeshPipelineKey::from_hdr(view.hdr);

Expand Down

0 comments on commit b0998e4

Please sign in to comment.