diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cc57faa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + ci: + name: Testing on ${{ matrix.os }} + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + + - name: cargo build + run: cargo build + + - name: cargo fmt + run: cargo fmt --all -- --check + + - name: cargo clippy + run: cargo clippy -- -D warnings + + - name: Run tests + run: cargo test + + typos: + name: Typos + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.19.0 + + cargo-machete: + runs-on: ubuntu-latest + steps: + - uses: Swatinem/rust-cache@v2 + - uses: actions/checkout@v4 + - name: Machete + uses: bnjbvr/cargo-machete@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b33c3c3..885638e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - windows-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: taiki-e/upload-rust-binary-action@v1.21.1 with: bin: raytracing diff --git a/.github/workflows/rust-linux.yml b/.github/workflows/rust-linux.yml deleted file mode 100644 index e40860c..0000000 --- a/.github/workflows/rust-linux.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Linux - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/rust-macos.yml b/.github/workflows/rust-macos.yml deleted file mode 100644 index b59c750..0000000 --- a/.github/workflows/rust-macos.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: MacOS - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/rust-windows.yml b/.github/workflows/rust-windows.yml deleted file mode 100644 index b4296c2..0000000 --- a/.github/workflows/rust-windows.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Windows - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/Cargo.toml b/Cargo.toml index 397f2ad..732c2c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,10 +41,10 @@ short_description = "A Raytracer written in Rust." [dependencies] # error handling -anyhow = "1.0.89" +anyhow = "1.0.95" # image loading and saving -image = { version = "0.25.2", default-features = false, features = [ +image = { version = "0.25.5", default-features = false, features = [ "png", "jpeg", "tiff", @@ -56,7 +56,7 @@ log = "0.4.22" simplelog = "0.12.2" # linear algebra -nalgebra = { version = "0.33.0", features = ["glam022"] } +nalgebra = { version = "0.33.2", features = ["glam022"] } rand = "0.8.5" # obj file loading @@ -64,36 +64,36 @@ obj = "0.10.2" # automatic parallelization rayon = "1.10.0" -bytemuck = { version = "1.18", features = ["derive"] } +bytemuck = { version = "1.21", features = ["derive"] } # total order for floats -ordered-float = "4.2.2" +ordered-float = "4.6.0" # generic serialization / deserialization -serde = { version = "1.0.210", features = ["derive"] } +serde = { version = "1.0.216", features = ["derive"] } serde_yml = "0.0.12" # GUI -eframe = { version = "0.28.1", features = [ +eframe = { version = "0.30.0", features = [ "wgpu", "accesskit", "default_fonts", "wayland", "x11", ], default-features = false } -egui = { version = "0.28.1", features = ["log", "color-hex"] } -egui-wgpu = { version = "0.28.1" } -egui_file = "0.18.0" -egui_extras = { version = "0.28.1", features = ["svg", "image"] } +egui = { version = "0.30.0", features = ["log", "color-hex"] } +egui-wgpu = { version = "0.30.0" } +egui_file = "0.20.0" +egui_extras = { version = "0.30.0", features = ["svg", "image"] } # BVH bvh = "0.10.0" rust-i18n = "3.1.2" -sys-locale = "0.3.1" +sys-locale = "0.3.2" [build-dependencies] -anyhow = "1.0.89" -winresource = "0.1.17" +anyhow = "1.0.95" +winresource = "0.1.19" [profile.dev] opt-level = 3 @@ -106,9 +106,10 @@ debug = true unsafe_code = "forbid" [lints.clippy] -nursery = { level = "deny", priority = 0 } -pedantic = { level = "deny", priority = 1 } -enum_glob_use = { level = "deny", priority = 2 } +all = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = 0 } +pedantic = { level = "warn", priority = 1 } +enum_glob_use = { level = "warn", priority = 2 } module_name_repetitions = { level = "allow", priority = 3 } cast_precision_loss = { level = "allow", priority = 4 } cast_possible_truncation = { level = "allow", priority = 5 } @@ -116,5 +117,5 @@ cast_sign_loss = { level = "allow", priority = 6 } out_of_bounds_indexing = { level = "allow", priority = 7 } perf = { level = "warn", priority = 8 } style = { level = "warn", priority = 9 } -unwrap_used = { level = "deny", priority = 10 } -expect_used = { level = "deny", priority = 11 } +unwrap_used = { level = "warn", priority = 10 } +expect_used = { level = "warn", priority = 11 } diff --git a/src/main.rs b/src/main.rs index d6dfe2b..7e2a302 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,6 @@ fn main() -> anyhow::Result<()> { viewport, renderer: Renderer::Wgpu, depth_buffer: 32, - follow_system_theme: true, centered: true, ..Default::default() }, diff --git a/src/ui/preview/gpu.rs b/src/ui/preview/gpu.rs index d2e456a..2ca5e34 100644 --- a/src/ui/preview/gpu.rs +++ b/src/ui/preview/gpu.rs @@ -205,7 +205,7 @@ impl CallbackTrait for WgpuPainter { fn paint<'a>( &'a self, _info: egui::PaintCallbackInfo, - render_pass: &mut wgpu::RenderPass<'a>, + render_pass: &mut wgpu::RenderPass<'static>, callback_resources: &'a egui_wgpu::CallbackResources, ) { let resources = callback_resources @@ -281,7 +281,7 @@ pub fn init_wgpu(render_state: &egui_wgpu::RenderState) { layout: Some(&pipeline_layout), vertex: VertexState { module: &shader, - entry_point: "vs_main", + entry_point: Some("vs_main"), buffers: &[VertexBufferLayout { // 3x f32 for position, 3x f32 for normal, 3x f32 for color, 1x u32 for transform index array_stride: std::mem::size_of::() as u64 * (3 + 3 + 3 + 1), @@ -317,7 +317,7 @@ pub fn init_wgpu(render_state: &egui_wgpu::RenderState) { }, fragment: Some(FragmentState { module: &shader, - entry_point: "fs_main", + entry_point: Some("fs_main"), targets: &[Some(ColorTargetState { format: render_state.target_format, blend: None, @@ -343,6 +343,7 @@ pub fn init_wgpu(render_state: &egui_wgpu::RenderState) { }), multisample: MultisampleState::default(), multiview: None, + cache: None, }); let uniform_buffer = device.create_buffer(&BufferDescriptor { diff --git a/src/ui/preview/mod.rs b/src/ui/preview/mod.rs index a180ce6..0d2a657 100644 --- a/src/ui/preview/mod.rs +++ b/src/ui/preview/mod.rs @@ -51,7 +51,7 @@ impl Preview { } pub fn show(&mut self, ui: &mut Ui, scene: &mut Option) { - Self::show_hover_overlay(ui.ctx(), scene, ui.available_rect_before_wrap()); + Self::show_hover_overlay(ui.ctx(), scene.as_ref(), ui.available_rect_before_wrap()); ui.ctx().input(|i| { if !i.raw.dropped_files.is_empty() { //self.dropped_files = i.raw.dropped_files.clone(); @@ -181,7 +181,7 @@ impl Preview { } } - pub fn show_hover_overlay(ctx: &Context, scene: &Option, rect: Rect) { + pub fn show_hover_overlay(ctx: &Context, scene: Option<&Scene>, rect: Rect) { //TODO: show only when hovering over preview if !ctx.input(|i| i.raw.hovered_files.is_empty()) { let painter = diff --git a/src/ui/properties.rs b/src/ui/properties.rs index 9f6e0ab..7bfce11 100644 --- a/src/ui/properties.rs +++ b/src/ui/properties.rs @@ -6,7 +6,7 @@ use crate::{ use anyhow::Context; use egui::{ color_picker, hex_color, include_image, Align, Button, CollapsingHeader, DragValue, FontFamily, - ImageButton, Layout, RichText, Slider, Ui, + ImageButton, Layout, RichText, Slider, SliderClamping, Ui, }; use egui_file::FileDialog; use log::warn; @@ -80,7 +80,7 @@ impl Properties { Slider::new(&mut scene.camera.fov, 0.0..=consts::PI) .step_by(0.01) .custom_formatter(|x, _| format!("{:.2}°", x.to_degrees())) - .clamp_to_range(true), + .clamping(SliderClamping::Edits), ); }); }); @@ -109,7 +109,10 @@ impl Properties { color_picker::color_edit_button_rgb(ui, scene.settings.ambient_color.as_mut()); ui.label(format!("{}:", t!("ambient_intensity"))); - ui.add(Slider::new(&mut scene.settings.ambient_intensity, 0.0..=1.0).clamp_to_range(true)); + ui.add( + Slider::new(&mut scene.settings.ambient_intensity, 0.0..=1.0) + .clamping(SliderClamping::Edits), + ); } fn render_options(ui: &mut Ui, render: &Render, scene: &mut Scene) { @@ -118,7 +121,7 @@ impl Properties { ui.add_enabled_ui(render.thread.is_none(), |ui| { ui.vertical(|ui| { let text = Self::format_render_size(scene.camera.resolution); - egui::ComboBox::from_id_source(0) + egui::ComboBox::from_id_salt(0) .selected_text(text) .show_ui(ui, |ui| { ui.selectable_value(&mut scene.camera.resolution, (1280, 720), "HD"); @@ -140,7 +143,8 @@ impl Properties { if scene.settings.anti_aliasing { ui.label("Samples per pixel:"); ui.add( - Slider::new(&mut scene.settings.samples, 1..=128).clamp_to_range(true), + Slider::new(&mut scene.settings.samples, 1..=128) + .clamping(SliderClamping::Edits), ); } }); @@ -268,7 +272,8 @@ impl Properties { ui.label(format!("{}:", t!("intensity"))); ui.add( - Slider::new(&mut light.intensity, 0.0..=100.0).clamp_to_range(true), + Slider::new(&mut light.intensity, 0.0..=100.0) + .clamping(SliderClamping::Edits), ); ui.label(format!("{}:", t!("color"))); diff --git a/src/ui/yamlmenu.rs b/src/ui/yamlmenu.rs index be8b0f1..588eb6d 100644 --- a/src/ui/yamlmenu.rs +++ b/src/ui/yamlmenu.rs @@ -55,7 +55,7 @@ impl YamlMenu { settings: Settings::default(), }); - Self::save_scene(scene); + Self::save_scene(scene.as_ref()); } None => { warn!("Create yaml dialog selected but returned no path"); @@ -145,7 +145,7 @@ impl YamlMenu { ) .on_hover_text(t!("save_scene")) .clicked() - .then(|| Self::save_scene(scene)); + .then(|| Self::save_scene(scene.as_ref())); }); // new button @@ -182,7 +182,7 @@ impl YamlMenu { }); } - fn save_scene(scene: &Option) { + fn save_scene(scene: Option<&Scene>) { match scene { Some(scene) => { serde_yml::to_string(scene) diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..0bb429a --- /dev/null +++ b/typos.toml @@ -0,0 +1,2 @@ +[files] +extend-exclude = ["locales/*"]