diff --git a/all-is-cubes-gpu/src/in_wgpu.rs b/all-is-cubes-gpu/src/in_wgpu.rs index 774f8110e..4c8f9d7bb 100644 --- a/all-is-cubes-gpu/src/in_wgpu.rs +++ b/all-is-cubes-gpu/src/in_wgpu.rs @@ -12,7 +12,7 @@ use all_is_cubes::content::palette; use all_is_cubes::drawing::embedded_graphics::{pixelcolor::Gray8, Drawable as _}; use all_is_cubes::euclid::Size2D; use all_is_cubes::listen::DirtyFlag; -use all_is_cubes::math::{notnan, VectorOps as _}; +use all_is_cubes::math::VectorOps as _; use all_is_cubes_render::camera::{Layers, RenderMethod, StandardCameras}; use all_is_cubes_render::info_text_drawable; use all_is_cubes_render::{Flaws, RenderError}; @@ -833,7 +833,7 @@ impl EverythingRenderer { ); } - if self.cameras.graphics_options().bloom_intensity > notnan!(0.0) { + if !self.cameras.graphics_options().bloom_intensity.is_zero() { if let Some(bloom) = &self.fb.bloom { bloom.run(&mut encoder); } diff --git a/all-is-cubes-render/src/raytracer/renderer.rs b/all-is-cubes-render/src/raytracer/renderer.rs index bbb258b75..6016a1c74 100644 --- a/all-is-cubes-render/src/raytracer/renderer.rs +++ b/all-is-cubes-render/src/raytracer/renderer.rs @@ -12,7 +12,7 @@ use all_is_cubes::character::Cursor; use all_is_cubes::content::palette; use all_is_cubes::euclid::{self, point2, vec2}; use all_is_cubes::listen::ListenableSource; -use all_is_cubes::math::{NotNan, Rgba}; +use all_is_cubes::math::{Rgba, ZeroOne}; use all_is_cubes::space::Space; use all_is_cubes::universe::Handle; @@ -253,7 +253,7 @@ impl RtRenderer<()> { let options = self.cameras.graphics_options(); let mut flaws = Flaws::empty(); - if options.bloom_intensity != NotNan::from(0u8) { + if options.bloom_intensity != ZeroOne::ZERO { flaws |= Flaws::NO_BLOOM; } if self.had_cursor { diff --git a/all-is-cubes/src/camera/graphics_options.rs b/all-is-cubes/src/camera/graphics_options.rs index 1aa6289ae..8a7ca6c18 100644 --- a/all-is-cubes/src/camera/graphics_options.rs +++ b/all-is-cubes/src/camera/graphics_options.rs @@ -3,7 +3,7 @@ use core::fmt; use num_traits::ConstOne as _; use ordered_float::NotNan; -use crate::math::{notnan, FreeCoordinate, PositiveSign, Rgb, Rgba, ZeroOne}; +use crate::math::{notnan, zo32, FreeCoordinate, PositiveSign, Rgb, Rgba, ZeroOne}; use crate::util::ShowStatus; #[cfg(doc)] @@ -53,7 +53,7 @@ pub struct GraphicsOptions { /// Proportion of bloom (blurred image) to mix into the original image. /// 0.0 is no bloom and 1.0 is no original image. - pub bloom_intensity: NotNan, + pub bloom_intensity: ZeroOne, /// Distance, in unit cubes, from the camera to the farthest visible point. /// @@ -134,7 +134,7 @@ impl GraphicsOptions { // TODO: Change tone mapping default once we have a good implementation. tone_mapping: ToneMappingOperator::Clamp, exposure: ExposureOption::Fixed(PositiveSign::::ONE), - bloom_intensity: notnan!(0.), + bloom_intensity: zo32(0.), view_distance: notnan!(200.), lighting_display: LightingOption::None, transparency: TransparencyOption::Volumetric, @@ -153,7 +153,6 @@ impl GraphicsOptions { #[must_use] pub fn repair(mut self) -> Self { self.fov_y = self.fov_y.clamp(NotNan::from(1), NotNan::from(189)); - self.bloom_intensity = self.bloom_intensity.clamp(notnan!(0.0), notnan!(1.0)); self.view_distance = self .view_distance .clamp(NotNan::from(1), NotNan::from(10000)); @@ -220,7 +219,7 @@ impl Default for GraphicsOptions { // TODO: Change tone mapping default once we have a good implementation. tone_mapping: ToneMappingOperator::Clamp, exposure: ExposureOption::default(), - bloom_intensity: notnan!(0.125), + bloom_intensity: zo32(0.125), view_distance: NotNan::from(200), lighting_display: LightingOption::Smooth, transparency: TransparencyOption::Volumetric, @@ -537,7 +536,7 @@ mod tests { fog: FogOption::None, tone_mapping: ToneMappingOperator::Clamp, exposure: ExposureOption::Fixed(PositiveSign::::ONE), - bloom_intensity: NotNan::from(0u8), + bloom_intensity: zo32(0.), lighting_display: LightingOption::None, antialiasing: AntialiasingOption::None, ..GraphicsOptions::default() diff --git a/test-renderers/src/test_cases.rs b/test-renderers/src/test_cases.rs index 7dd8d8a3b..6427726bd 100644 --- a/test-renderers/src/test_cases.rs +++ b/test-renderers/src/test_cases.rs @@ -150,7 +150,7 @@ async fn antialias(mut context: RenderTestContext, antialias_option: Antialiasin async fn bloom(mut context: RenderTestContext, bloom_intensity: f32) { let mut options = light_test_options(); - options.bloom_intensity = NotNan::new(bloom_intensity).unwrap(); + options.bloom_intensity = bloom_intensity.try_into().unwrap(); let scene = StandardCameras::from_constant_for_test(options, COMMON_VIEWPORT, context.universe()); context