Skip to content

Commit

Permalink
fix: Skip some rendering logics when the viewport width or height is …
Browse files Browse the repository at this point in the history
…zero
  • Loading branch information
ShoyuVanilla committed Oct 5, 2024
1 parent 25bfa80 commit 444d15f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_core_pipeline/src/bloom/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ impl ExtractComponent for Bloom {
camera.is_active,
camera.hdr,
) {
(Some(URect { min: origin, .. }), Some(size), Some(target_size), true, true) => {
(Some(URect { min: origin, .. }), Some(size), Some(target_size), true, true)
if size.x != 0 && size.y != 0 =>
{
let threshold = bloom.prefilter.threshold;
let threshold_softness = bloom.prefilter.threshold_softness;
let knee = threshold * threshold_softness.clamp(0.0, 1.0);
Expand Down
9 changes: 6 additions & 3 deletions crates/bevy_pbr/src/cluster/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,12 @@ pub(crate) fn assign_objects_to_clusters(
continue;
}

let Some(screen_size) = camera.physical_viewport_size() else {
clusters.clear();
continue;
let screen_size = match camera.physical_viewport_size() {
Some(screen_size) if screen_size.x != 0 && screen_size.y != 0 => screen_size,
_ => {
clusters.clear();
continue;
}
};

let mut requested_cluster_dimensions = config.dimensions_for_screen_size(screen_size);
Expand Down
12 changes: 8 additions & 4 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,14 @@ pub fn camera_system<T: CameraProjection + Component>(
}
camera.computed.target_info = new_computed_target_info;
if let Some(size) = camera.logical_viewport_size() {
camera_projection.update(size.x, size.y);
camera.computed.clip_from_view = match &camera.sub_camera_view {
Some(sub_view) => camera_projection.get_clip_from_view_for_sub(sub_view),
None => camera_projection.get_clip_from_view(),
if size.x != 0.0 && size.y != 0.0 {
camera_projection.update(size.x, size.y);
camera.computed.clip_from_view = match &camera.sub_camera_view {
Some(sub_view) => {
camera_projection.get_clip_from_view_for_sub(sub_view)
}
None => camera_projection.get_clip_from_view(),
}
}
}
}
Expand Down

0 comments on commit 444d15f

Please sign in to comment.