From 720d6dab82a7acd1fdfd6ae78326f2207f6da06f Mon Sep 17 00:00:00 2001 From: Tygyh <32486062+tygyh@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:56:40 +0100 Subject: [PATCH] Change `Window` scale factor to f32 (adopted) (#10897) # Objective - Finish the work done in #8942 . ## Solution - Rebase the changes made in #8942 and fix the issues stopping it from being merged earlier --------- Co-authored-by: Thomas <1234328+thmsgntz@users.noreply.github.com> --- crates/bevy_render/src/camera/camera.rs | 4 +-- crates/bevy_text/src/pipeline.rs | 4 +-- crates/bevy_text/src/text2d.rs | 6 ++-- crates/bevy_ui/src/focus.rs | 2 +- crates/bevy_ui/src/layout/convert.rs | 6 ++-- crates/bevy_ui/src/layout/mod.rs | 10 +++---- crates/bevy_ui/src/lib.rs | 2 +- crates/bevy_ui/src/render/mod.rs | 8 ++--- .../src/render/ui_material_pipeline.rs | 2 +- crates/bevy_ui/src/ui_node.rs | 18 +++++------ crates/bevy_ui/src/widget/image.rs | 8 ++--- crates/bevy_ui/src/widget/text.rs | 14 ++++----- crates/bevy_window/src/window.rs | 30 +++++++++---------- crates/bevy_winit/src/lib.rs | 14 +++++---- crates/bevy_winit/src/system.rs | 2 +- crates/bevy_winit/src/winit_windows.rs | 2 +- examples/ui/text_wrap_debug.rs | 4 +-- examples/ui/ui_scaling.rs | 14 ++++----- 18 files changed, 76 insertions(+), 74 deletions(-) diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 11c472b28c..ecffba2d82 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -68,7 +68,7 @@ pub struct RenderTargetInfo { /// The physical size of this render target (ignores scale factor). pub physical_size: UVec2, /// The scale factor of this render target. - pub scale_factor: f64, + pub scale_factor: f32, } /// Holds internally computed [`Camera`] values. @@ -140,7 +140,7 @@ impl Camera { #[inline] pub fn to_logical(&self, physical_size: UVec2) -> Option { let scale = self.computed.target_info.as_ref()?.scale_factor; - Some((physical_size.as_dvec2() / scale).as_vec2()) + Some(physical_size.as_vec2() / scale) } /// The rendered physical bounds [`URect`] of the camera. If the `viewport` field is diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 8b98fe6497..90fb69c737 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -46,7 +46,7 @@ impl TextPipeline { &mut self, fonts: &Assets, sections: &[TextSection], - scale_factor: f64, + scale_factor: f32, text_alignment: JustifyText, linebreak_behavior: BreakLineOn, bounds: Vec2, @@ -129,7 +129,7 @@ impl TextMeasureInfo { pub fn from_text( text: &Text, fonts: &Assets, - scale_factor: f64, + scale_factor: f32, ) -> Result { let sections = &text.sections; for section in sections { diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 0dcf7b818c..5c380aae0e 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -99,7 +99,7 @@ pub fn extract_text2d_sprite( // TODO: Support window-independent scaling: https://github.com/bevyengine/bevy/issues/5621 let scale_factor = windows .get_single() - .map(|window| window.resolution.scale_factor() as f32) + .map(|window| window.resolution.scale_factor()) .unwrap_or(1.0); let scaling = GlobalTransform::from_scale(Vec2::splat(scale_factor.recip()).extend(1.)); @@ -225,6 +225,6 @@ pub fn update_text2d_layout( } /// Scales `value` by `factor`. -pub fn scale_value(value: f32, factor: f64) -> f32 { - (value as f64 * factor) as f32 +pub fn scale_value(value: f32, factor: f32) -> f32 { + value * factor } diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 35e879db40..204b91d267 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -181,7 +181,7 @@ pub fn ui_focus_system( .or_else(|| touches_input.first_pressed_position()) // The cursor position returned by `Window` only takes into account the window scale factor and not `UiScale`. // To convert the cursor position to logical UI viewport coordinates we have to divide it by `UiScale`. - .map(|cursor_position| cursor_position / ui_scale.0 as f32); + .map(|cursor_position| cursor_position / ui_scale.0); // prepare an iterator that contains all the nodes that have the cursor in their rect, // from the top node to the bottom one. this will also reset the interaction to `None` diff --git a/crates/bevy_ui/src/layout/convert.rs b/crates/bevy_ui/src/layout/convert.rs index 71f2d5ec22..b567a0cb2e 100644 --- a/crates/bevy_ui/src/layout/convert.rs +++ b/crates/bevy_ui/src/layout/convert.rs @@ -17,9 +17,9 @@ impl Val { match self { Val::Auto => taffy::style::LengthPercentageAuto::Auto, Val::Percent(value) => taffy::style::LengthPercentageAuto::Percent(value / 100.), - Val::Px(value) => taffy::style::LengthPercentageAuto::Points( - (context.scale_factor * value as f64) as f32, - ), + Val::Px(value) => { + taffy::style::LengthPercentageAuto::Points(context.scale_factor * value) + } Val::VMin(value) => { taffy::style::LengthPercentageAuto::Points(context.min_size * value / 100.) } diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index af9d7fcb77..16c3aa1f5b 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -22,7 +22,7 @@ use taffy::Taffy; use thiserror::Error; pub struct LayoutContext { - pub scale_factor: f64, + pub scale_factor: f32, pub physical_size: Vec2, pub min_size: f32, pub max_size: f32, @@ -30,7 +30,7 @@ pub struct LayoutContext { impl LayoutContext { /// create new a [`LayoutContext`] from the window's physical size and scale factor - fn new(scale_factor: f64, physical_size: Vec2) -> Self { + fn new(scale_factor: f32, physical_size: Vec2) -> Self { Self { scale_factor, physical_size, @@ -382,7 +382,7 @@ pub fn ui_layout_system( &ui_surface, &mut node_transform_query, &just_children_query, - inverse_target_scale_factor as f32, + inverse_target_scale_factor, Vec2::ZERO, Vec2::ZERO, ); @@ -399,7 +399,7 @@ pub fn resolve_outlines_system( .get_single() .map(|window| Vec2::new(window.resolution.width(), window.resolution.height())) .unwrap_or(Vec2::ZERO) - / ui_scale.0 as f32; + / ui_scale.0; for (outline, mut node) in outlines_query.iter_mut() { let node = node.bypass_change_detection(); @@ -806,7 +806,7 @@ mod tests { .copied() .collect::>(); - for r in [2, 3, 5, 7, 11, 13, 17, 19, 21, 23, 29, 31].map(|n| (n as f64).recip()) { + for r in [2, 3, 5, 7, 11, 13, 17, 19, 21, 23, 29, 31].map(|n| (n as f32).recip()) { let mut s = r; while s <= 5. { world.resource_mut::().0 = s; diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 756145d894..ee9b34ff32 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -76,7 +76,7 @@ pub enum UiSystem { /// A multiplier to fixed-sized ui values. /// **Note:** This will only affect fixed ui values like [`Val::Px`] #[derive(Debug, Reflect, Resource, Deref, DerefMut)] -pub struct UiScale(pub f64); +pub struct UiScale(pub f32); impl Default for UiScale { fn default() -> Self { diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 9cfeed27f0..3e5caad0e4 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -296,7 +296,7 @@ pub fn extract_uinode_borders( .unwrap_or(Vec2::ZERO) // The logical window resolution returned by `Window` only takes into account the window scale factor and not `UiScale`, // so we have to divide by `UiScale` to get the size of the UI viewport. - / ui_scale.0 as f32; + / ui_scale.0; for (node, global_transform, style, border_color, parent, view_visibility, clip) in uinode_query.iter() @@ -540,7 +540,7 @@ pub fn extract_default_ui_camera_view( ui_scale: Extract>, query: Extract), With>>, ) { - let scale = (ui_scale.0 as f32).recip(); + let scale = (ui_scale.0).recip(); for (entity, camera, camera_ui) in &query { // ignore cameras with disabled ui if matches!(camera_ui, Some(&UiCameraConfig { show_ui: false, .. })) { @@ -619,11 +619,11 @@ pub fn extract_text_uinodes( ) { // TODO: Support window-independent UI scale: https://github.com/bevyengine/bevy/issues/5621 - let scale_factor = (windows + let scale_factor = windows .get_single() .map(|window| window.scale_factor()) .unwrap_or(1.) - * ui_scale.0) as f32; + * ui_scale.0; let inverse_scale_factor = scale_factor.recip(); diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 90cd3ef7fd..348d112099 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -374,7 +374,7 @@ pub fn extract_ui_material_nodes( .unwrap_or(Vec2::ZERO) // The logical window resolution returned by `Window` only takes into account the window scale factor and not `UiScale`, // so we have to divide by `UiScale` to get the size of the UI viewport. - / ui_scale.0 as f32; + / ui_scale.0; for (stack_index, entity) in ui_stack.uinodes.iter().enumerate() { if let Ok((entity, uinode, style, transform, handle, view_visibility, clip)) = uinode_query.get(*entity) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 2425d7fdb0..6e59bba655 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -57,10 +57,10 @@ impl Node { /// Returns the size of the node in physical pixels based on the given scale factor and `UiScale`. #[inline] - pub fn physical_size(&self, scale_factor: f64, ui_scale: f64) -> Vec2 { + pub fn physical_size(&self, scale_factor: f32, ui_scale: f32) -> Vec2 { Vec2::new( - (self.calculated_size.x as f64 * scale_factor * ui_scale) as f32, - (self.calculated_size.y as f64 * scale_factor * ui_scale) as f32, + self.calculated_size.x * scale_factor * ui_scale, + self.calculated_size.y * scale_factor * ui_scale, ) } @@ -75,18 +75,18 @@ impl Node { pub fn physical_rect( &self, transform: &GlobalTransform, - scale_factor: f64, - ui_scale: f64, + scale_factor: f32, + ui_scale: f32, ) -> Rect { let rect = self.logical_rect(transform); Rect { min: Vec2::new( - (rect.min.x as f64 * scale_factor * ui_scale) as f32, - (rect.min.y as f64 * scale_factor * ui_scale) as f32, + rect.min.x * scale_factor * ui_scale, + rect.min.y * scale_factor * ui_scale, ), max: Vec2::new( - (rect.max.x as f64 * scale_factor * ui_scale) as f32, - (rect.max.y as f64 * scale_factor * ui_scale) as f32, + rect.max.x * scale_factor * ui_scale, + rect.max.y * scale_factor * ui_scale, ), } } diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index c676209605..ff36522211 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -78,7 +78,7 @@ type UpdateImageFilter = With; /// Updates content size of the node based on the image provided pub fn update_image_content_size_system( - mut previous_combined_scale_factor: Local, + mut previous_combined_scale_factor: Local, windows: Query<&Window, With>, ui_scale: Res, textures: Res>, @@ -101,7 +101,7 @@ pub fn update_image_content_size_system( image_size.size = size; content_size.set(ImageMeasure { // multiply the image size by the scale factor to get the physical size - size: size * combined_scale_factor as f32, + size: size * combined_scale_factor, }); } } @@ -112,7 +112,7 @@ pub fn update_image_content_size_system( /// Updates content size of the node based on the texture atlas sprite pub fn update_atlas_content_size_system( - mut previous_combined_scale_factor: Local, + mut previous_combined_scale_factor: Local, windows: Query<&Window, With>, ui_scale: Res, atlases: Res>, @@ -143,7 +143,7 @@ pub fn update_atlas_content_size_system( image_size.size = size; content_size.set(ImageMeasure { // multiply the image size by the scale factor to get the physical size - size: size * combined_scale_factor as f32, + size: size * combined_scale_factor, }); } } diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 4e25ff9f11..dd88584dcf 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -80,7 +80,7 @@ impl Measure for TextMeasure { #[inline] fn create_text_measure( fonts: &Assets, - scale_factor: f64, + scale_factor: f32, text: Ref, mut content_size: Mut, mut text_flags: Mut, @@ -117,7 +117,7 @@ fn create_text_measure( /// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection) /// method should be called when only changing the `Text`'s colors. pub fn measure_text_system( - mut last_scale_factor: Local, + mut last_scale_factor: Local, fonts: Res>, windows: Query<&Window, With>, ui_scale: Res, @@ -158,8 +158,8 @@ fn queue_text( texture_atlases: &mut Assets, textures: &mut Assets, text_settings: &TextSettings, - scale_factor: f64, - inverse_scale_factor: f64, + scale_factor: f32, + inverse_scale_factor: f32, text: &Text, node: Ref, mut text_flags: Mut, @@ -173,8 +173,8 @@ fn queue_text( } else { // `scale_factor` is already multiplied by `UiScale` Vec2::new( - (node.unrounded_size.x as f64 * scale_factor) as f32, - (node.unrounded_size.y as f64 * scale_factor) as f32, + node.unrounded_size.x * scale_factor, + node.unrounded_size.y * scale_factor, ) }; @@ -220,7 +220,7 @@ fn queue_text( #[allow(clippy::too_many_arguments)] pub fn text_system( mut textures: ResMut>, - mut last_scale_factor: Local, + mut last_scale_factor: Local, fonts: Res>, windows: Query<&Window, With>, text_settings: Res, diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index ecf99b9b74..87cdfb050e 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -326,7 +326,7 @@ impl Window { /// /// Ratio of physical size to logical size, see [`WindowResolution`]. #[inline] - pub fn scale_factor(&self) -> f64 { + pub fn scale_factor(&self) -> f32 { self.resolution.scale_factor() } @@ -338,7 +338,7 @@ impl Window { #[inline] pub fn cursor_position(&self) -> Option { self.physical_cursor_position() - .map(|position| (position.as_dvec2() / self.scale_factor()).as_vec2()) + .map(|position| (position.as_dvec2() / self.scale_factor() as f64).as_vec2()) } /// The cursor position in this window in physical pixels. @@ -369,7 +369,7 @@ impl Window { /// See [`WindowResolution`] for an explanation about logical/physical sizes. pub fn set_cursor_position(&mut self, position: Option) { self.internal.physical_cursor_position = - position.map(|p| p.as_dvec2() * self.scale_factor()); + position.map(|p| p.as_dvec2() * self.scale_factor() as f64); } /// Set the cursor position in this window in physical pixels. @@ -611,11 +611,11 @@ pub struct WindowResolution { /// Code-provided ratio of physical size to logical size. /// /// Should be used instead of `scale_factor` when set. - scale_factor_override: Option, + scale_factor_override: Option, /// OS-provided ratio of physical size to logical size. /// /// Set automatically depending on the pixel density of the screen. - scale_factor: f64, + scale_factor: f32, } impl Default for WindowResolution { @@ -640,7 +640,7 @@ impl WindowResolution { } /// Builder method for adding a scale factor override to the resolution. - pub fn with_scale_factor_override(mut self, scale_factor_override: f64) -> Self { + pub fn with_scale_factor_override(mut self, scale_factor_override: f32) -> Self { self.scale_factor_override = Some(scale_factor_override); self } @@ -648,13 +648,13 @@ impl WindowResolution { /// The window's client area width in logical pixels. #[inline] pub fn width(&self) -> f32 { - (self.physical_width() as f64 / self.scale_factor()) as f32 + self.physical_width() as f32 / self.scale_factor() } /// The window's client area height in logical pixels. #[inline] pub fn height(&self) -> f32 { - (self.physical_height() as f64 / self.scale_factor()) as f32 + self.physical_height() as f32 / self.scale_factor() } /// The window's client area width in physical pixels. @@ -672,7 +672,7 @@ impl WindowResolution { /// The ratio of physical pixels to logical pixels. /// /// `physical_pixels = logical_pixels * scale_factor` - pub fn scale_factor(&self) -> f64 { + pub fn scale_factor(&self) -> f32 { self.scale_factor_override .unwrap_or_else(|| self.base_scale_factor()) } @@ -681,7 +681,7 @@ impl WindowResolution { /// /// This value is unaffected by [`WindowResolution::scale_factor_override`]. #[inline] - pub fn base_scale_factor(&self) -> f64 { + pub fn base_scale_factor(&self) -> f32 { self.scale_factor } @@ -689,7 +689,7 @@ impl WindowResolution { /// /// This value may be different from the scale factor reported by the window backend. #[inline] - pub fn scale_factor_override(&self) -> Option { + pub fn scale_factor_override(&self) -> Option { self.scale_factor_override } @@ -697,8 +697,8 @@ impl WindowResolution { #[inline] pub fn set(&mut self, width: f32, height: f32) { self.set_physical_resolution( - (width as f64 * self.scale_factor()) as u32, - (height as f64 * self.scale_factor()) as u32, + (width * self.scale_factor()) as u32, + (height * self.scale_factor()) as u32, ); } @@ -714,7 +714,7 @@ impl WindowResolution { /// Set the window's scale factor, this may get overridden by the backend. #[inline] - pub fn set_scale_factor(&mut self, scale_factor: f64) { + pub fn set_scale_factor(&mut self, scale_factor: f32) { let (width, height) = (self.width(), self.height()); self.scale_factor = scale_factor; self.set(width, height); @@ -725,7 +725,7 @@ impl WindowResolution { /// This can change the logical and physical sizes if the resulting physical /// size is not within the limits. #[inline] - pub fn set_scale_factor_override(&mut self, scale_factor_override: Option) { + pub fn set_scale_factor_override(&mut self, scale_factor_override: Option) { let (width, height) = (self.width(), self.height()); self.scale_factor_override = scale_factor_override; self.set(width, height); diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 0cf0ddf3b1..4a9696d751 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -545,7 +545,7 @@ pub fn winit_runner(mut app: App) { window.set_physical_cursor_position(Some(physical_position)); event_writers.cursor_moved.send(CursorMoved { window: window_entity, - position: (physical_position / window.resolution.scale_factor()) + position: (physical_position / window.resolution.scale_factor() as f64) .as_vec2(), }); } @@ -596,7 +596,9 @@ pub fn winit_runner(mut app: App) { } }, WindowEvent::Touch(touch) => { - let location = touch.location.to_logical(window.resolution.scale_factor()); + let location = touch + .location + .to_logical(window.resolution.scale_factor() as f64); event_writers .touch_input .send(converters::convert_touch_input(touch, location)); @@ -619,7 +621,7 @@ pub fn winit_runner(mut app: App) { ); let prior_factor = window.resolution.scale_factor(); - window.resolution.set_scale_factor(scale_factor); + window.resolution.set_scale_factor(scale_factor as f32); let new_factor = window.resolution.scale_factor(); if let Some(forced_factor) = window.resolution.scale_factor_override() { @@ -628,7 +630,7 @@ pub fn winit_runner(mut app: App) { // incorporates any resize constraints. *new_inner_size = winit::dpi::LogicalSize::new(window.width(), window.height()) - .to_physical::(forced_factor); + .to_physical::(forced_factor as f64); } else if approx::relative_ne!(new_factor, prior_factor) { event_writers.window_scale_factor_changed.send( WindowScaleFactorChanged { @@ -638,8 +640,8 @@ pub fn winit_runner(mut app: App) { ); } - let new_logical_width = (new_inner_size.width as f64 / new_factor) as f32; - let new_logical_height = (new_inner_size.height as f64 / new_factor) as f32; + let new_logical_width = new_inner_size.width as f32 / new_factor; + let new_logical_height = new_inner_size.height as f32 / new_factor; if approx::relative_ne!(window.width(), new_logical_width) || approx::relative_ne!(window.height(), new_logical_height) { diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index 896466f3c7..c3f3c49a36 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -73,7 +73,7 @@ pub(crate) fn create_windows<'a>( window .resolution - .set_scale_factor(winit_window.scale_factor()); + .set_scale_factor(winit_window.scale_factor() as f32); commands .entity(entity) .insert(RawHandleWrapper { diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 501a438669..bd88b26f42 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -82,7 +82,7 @@ impl WinitWindows { let logical_size = LogicalSize::new(window.width(), window.height()); if let Some(sf) = window.resolution.scale_factor_override() { - winit_window_builder.with_inner_size(logical_size.to_physical::(sf)) + winit_window_builder.with_inner_size(logical_size.to_physical::(sf.into())) } else { winit_window_builder.with_inner_size(logical_size) } diff --git a/examples/ui/text_wrap_debug.rs b/examples/ui/text_wrap_debug.rs index 52a12a3f89..0bd928ebd3 100644 --- a/examples/ui/text_wrap_debug.rs +++ b/examples/ui/text_wrap_debug.rs @@ -11,11 +11,11 @@ use bevy::winit::WinitSettings; struct Args { #[argh(option)] /// window scale factor - scale_factor: Option, + scale_factor: Option, #[argh(option, default = "1.")] /// ui scale factor - ui_scale: f64, + ui_scale: f32, } fn main() { diff --git a/examples/ui/ui_scaling.rs b/examples/ui/ui_scaling.rs index 250d7b0f26..8ea8767113 100644 --- a/examples/ui/ui_scaling.rs +++ b/examples/ui/ui_scaling.rs @@ -99,21 +99,21 @@ fn change_scaling(input: Res>, mut ui_scale: ResMut f64 { + fn current_scale(&self) -> f32 { let completion = self.target_time.fraction(); - let multiplier = ease_in_expo(completion as f64); + let multiplier = ease_in_expo(completion); self.start_scale + (self.target_scale - self.start_scale) * multiplier } @@ -139,10 +139,10 @@ fn apply_scaling( ui_scale.0 = target_scale.current_scale(); } -fn ease_in_expo(x: f64) -> f64 { +fn ease_in_expo(x: f32) -> f32 { if x == 0. { 0. } else { - (2.0f64).powf(5. * x - 5.) + 2.0f32.powf(5. * x - 5.) } }