Skip to content

Commit

Permalink
Allow minimising in 2d (bevyengine#4527)
Browse files Browse the repository at this point in the history
# Objective

- We can't minimise if there's a 2d camera because ??? there legally must be a 2d target.
- Fixes bevyengine#4526
- Fixes bevyengine#4856

## Solution

- Make it not crash in those cases, just do nothing
- Seems to work ¯\\_(ツ)_/¯
- See also the companion commit in bevyengine#3597 - 503c247

Co-authored-by: Asteria <asteria131@outlook.com>
  • Loading branch information
2 people authored and james7132 committed Jun 7, 2022
1 parent 3a464db commit 9cd55df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions crates/bevy_core_pipeline/src/main_pass_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ impl Node for MainPass2dNode {
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
let (transparent_phase, target) = self
.query
.get_manual(world, view_entity)
.expect("view entity should exist");
// If there is no view entity, do not try to process the render phase for the view
let (transparent_phase, target) = match self.query.get_manual(world, view_entity) {
Ok(it) => it,
_ => return Ok(()),
};

if transparent_phase.items.is_empty() {
return Ok(());
Expand Down
11 changes: 6 additions & 5 deletions crates/bevy_ui/src/render/render_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ impl Node for UiPassNode {
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
let (transparent_phase, target) = self
.query
.get_manual(world, view_entity)
.expect("view entity should exist");

// If there is no view entity, do not try to process the render phase for the view
let (transparent_phase, target) = match self.query.get_manual(world, view_entity) {
Ok(it) => it,
_ => return Ok(()),
};

if transparent_phase.items.is_empty() {
return Ok(());
}

let pass_descriptor = RenderPassDescriptor {
label: Some("ui_pass"),
color_attachments: &[RenderPassColorAttachment {
Expand Down

0 comments on commit 9cd55df

Please sign in to comment.