Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to egui 0.30.0 #79

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

cargo-machete:
runs-on: ubuntu-latest
steps:
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: Machete
uses: bnjbvr/cargo-machete@main
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: taiki-e/[email protected]
with:
bin: raytracing
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/rust-linux.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/rust-macos.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/rust-windows.yml

This file was deleted.

39 changes: 20 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -56,44 +56,44 @@ 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
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.217", 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.21.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
Expand All @@ -106,15 +106,16 @@ 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 }
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 }
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ fn main() -> anyhow::Result<()> {
viewport,
renderer: Renderer::Wgpu,
depth_buffer: 32,
follow_system_theme: true,
centered: true,
..Default::default()
},
Expand Down
7 changes: 4 additions & 3 deletions src/ui/preview/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::<f32>() as u64 * (3 + 3 + 3 + 1),
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Preview {
}

pub fn show(&mut self, ui: &mut Ui, scene: &mut Option<Scene>) {
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();
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Preview {
}
}

pub fn show_hover_overlay(ctx: &Context, scene: &Option<Scene>, 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 =
Expand Down
17 changes: 11 additions & 6 deletions src/ui/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
);
});
});
Expand Down Expand Up @@ -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) {
Expand All @@ -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");
Expand All @@ -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),
);
}
});
Expand Down Expand Up @@ -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")));
Expand Down
6 changes: 3 additions & 3 deletions src/ui/yamlmenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -182,7 +182,7 @@ impl YamlMenu {
});
}

fn save_scene(scene: &Option<Scene>) {
fn save_scene(scene: Option<&Scene>) {
match scene {
Some(scene) => {
serde_yml::to_string(scene)
Expand Down
2 changes: 2 additions & 0 deletions typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["locales/*"]
Loading