library: render: scene: add deserialization
This commit is contained in:
parent
c8ca438091
commit
a8d23782a4
|
@ -10,9 +10,10 @@ use bvh::ray::Ray;
|
|||
use image::RgbImage;
|
||||
use rand::prelude::thread_rng;
|
||||
use rand::Rng;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Represent the scene being rendered.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct Scene {
|
||||
camera: Camera,
|
||||
lights: LightAggregate,
|
||||
|
@ -180,3 +181,15 @@ fn reflected(incident: Vector, normal: Vector) -> Vector {
|
|||
let delt = normal * (proj * 2.);
|
||||
incident - delt
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn deserialization_works() {
|
||||
let yaml = std::include_str!("../../examples/scene.yaml");
|
||||
let _: Scene = serde_yaml::from_str(yaml).unwrap();
|
||||
// FIXME: actually test the equality ?
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue