Skip to content

Commit

Permalink
update docs & use new serde_yml (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
bircni committed May 10, 2024
1 parent a45078e commit af15219
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ short_description = "A Raytracer."
[dependencies]

# error handling
anyhow = "1.0.81"
anyhow = "1.0.83"

# image loading and saving
image = { version = "0.25.1", default-features = false, features = [
Expand Down Expand Up @@ -56,8 +56,8 @@ bytemuck = { version = "1.15.0", features = ["derive"] }
ordered-float = "4.2.0"

# generic serialization / deserialization
serde = { version = "1.0.197", features = ["derive"] }
serde_yaml = "0.9.34"
serde = { version = "1.0.201", features = ["derive"] }
serde_yml = "0.0.5"

# GUI
eframe = { version = "0.27.2", features = [
Expand Down
4 changes: 2 additions & 2 deletions src/raytracer/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::sync::{

pub struct Render {
pub texture: TextureHandle,
/// Progress of the rendering in the range [0, u16::MAX]
/// Progress of the rendering in the range [0, `u16::MAX`]
pub progress: Arc<AtomicU16>,
pub thread: Option<std::thread::JoinHandle<()>>,
/// Cancel the rendering if true
Expand Down Expand Up @@ -76,7 +76,7 @@ struct RenderingThread {
image: Arc<Mutex<RgbImage>>,
/// Cancel the rendering if true
cancel: Arc<AtomicBool>,
/// Progress of the rendering in the range [0, u16::MAX]
/// Progress of the rendering in the range [0, `u16::MAX`]
progress: Arc<AtomicU16>,
/// Write the rendering time in milliseconds
time: Arc<AtomicU32>,
Expand Down
8 changes: 4 additions & 4 deletions src/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'de, P: AsRef<std::path::Path> + std::marker::Sync> serde::de::DeserializeS
where
D: serde::Deserializer<'de>,
{
let map = <serde_yaml::Value as serde::Deserialize>::deserialize(deserializer)?;
let map = <serde_yml::Value as serde::Deserialize>::deserialize(deserializer)?;

let objects = map
.get("models")
Expand All @@ -75,7 +75,7 @@ impl<'de, P: AsRef<std::path::Path> + std::marker::Sync> serde::de::DeserializeS
})?
.par_iter()
.map(|v| object::WithRelativePath(self.0.as_ref()).deserialize(v))
.collect::<Result<Vec<Object>, serde_yaml::Error>>()
.collect::<Result<Vec<Object>, serde_yml::Error>>()
.map_err(serde::de::Error::custom)?;

let lights = map
Expand All @@ -87,7 +87,7 @@ impl<'de, P: AsRef<std::path::Path> + std::marker::Sync> serde::de::DeserializeS
})?
.iter()
.map(Light::deserialize)
.collect::<Result<Vec<Light>, serde_yaml::Error>>()
.collect::<Result<Vec<Light>, serde_yml::Error>>()
.map_err(serde::de::Error::custom)?;

let camera = map
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Scene {
))?;

WithRelativePath(path.as_ref())
.deserialize(serde_yaml::Deserializer::from_str(&s))
.deserialize(serde_yml::Deserializer::from_str(&s))
.map_err(|e| {
anyhow::anyhow!(
"Failed to deserialize scene from path: {}\n{}",
Expand Down
3 changes: 2 additions & 1 deletion src/ui/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ impl Preview {
Self::show_hover_overlay(ui.ctx(), scene, ui.available_rect_before_wrap());
ui.ctx().input(|i| {
if !i.raw.dropped_files.is_empty() {
self.dropped_files = i.raw.dropped_files.clone();
//self.dropped_files = i.raw.dropped_files.clone();
self.dropped_files.clone_from(&i.raw.dropped_files);
if let Some(path) = self.dropped_files.first().and_then(|p| p.path.as_ref()) {
Self::handle_file(path, scene);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/yamlmenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl YamlMenu {
fn save_scene(scene: &Option<Scene>) {
match scene {
Some(scene) => {
serde_yaml::to_string(scene)
serde_yml::to_string(scene)
.context("Failed to serialize scene")
.and_then(|str| {
fs::write(scene.path.as_path(), str).context("Failed to save config")
Expand Down

0 comments on commit af15219

Please sign in to comment.