Skip to content

Commit 42ffaea

Browse files
authored
Change the default for RenderTargetInfo::scale_factor to 1. (#21082)
# Objective The default for `RenderTargetInfo`'s `scale_factor` field is `0.` but it's much more natural to assume that it would be `1.`. A scale factor of `0.` is degenerate, and could potentially cause a panic. ## Solution Set it to `1.` by default.
1 parent fba385e commit 42ffaea

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/bevy_camera/src/camera.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Default for SubCameraView {
162162
}
163163

164164
/// Information about the current [`RenderTarget`].
165-
#[derive(Default, Debug, Clone)]
165+
#[derive(Debug, Clone)]
166166
pub struct RenderTargetInfo {
167167
/// The physical size of this render target (in physical pixels, ignoring scale factor).
168168
pub physical_size: UVec2,
@@ -173,6 +173,15 @@ pub struct RenderTargetInfo {
173173
pub scale_factor: f32,
174174
}
175175

176+
impl Default for RenderTargetInfo {
177+
fn default() -> Self {
178+
Self {
179+
physical_size: Default::default(),
180+
scale_factor: 1.,
181+
}
182+
}
183+
}
184+
176185
/// Holds internally computed [`Camera`] values.
177186
#[derive(Default, Debug, Clone)]
178187
pub struct ComputedCameraValues {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "RenderTargetInfo's default `scale_factor` has been changed to `1.`"
3+
pull_requests: [21802]
4+
---
5+
6+
The default for `RenderTargetInfo`'s `scale_factor` field is now `1.`.

0 commit comments

Comments
 (0)