library: use enum_dispatch on Object related trait
This allows for easier testing (notable allowing for comparisons), better performance (thanks to inlining instead of vtable indirection), and should ease the deserialization of `Material`, `Shape`, and `Texture` traits. This should allow `Object` to be deserialized easily.
This commit is contained in:
parent
3ba17fac49
commit
05fb6601b2
9 changed files with 103 additions and 105 deletions
|
|
@ -1,26 +1,30 @@
|
|||
use super::{light_aggregate::LightAggregate, object::Object};
|
||||
use crate::core::Camera;
|
||||
use crate::core::LinearColor;
|
||||
use crate::{Point, Point2D, Vector};
|
||||
use crate::{
|
||||
core::{Camera, LinearColor},
|
||||
material::Material,
|
||||
shape::Shape,
|
||||
texture::Texture,
|
||||
{Point, Point2D, Vector},
|
||||
};
|
||||
use bvh::ray::Ray;
|
||||
use image::RgbImage;
|
||||
use rand::prelude::thread_rng;
|
||||
use rand::Rng;
|
||||
|
||||
/// Represent the scene being rendered.
|
||||
pub struct Scene<'a> {
|
||||
pub struct Scene {
|
||||
camera: Camera,
|
||||
lights: LightAggregate,
|
||||
objects: Vec<Object<'a>>,
|
||||
objects: Vec<Object>,
|
||||
aliasing_limit: u32,
|
||||
reflection_limit: u32,
|
||||
}
|
||||
|
||||
impl<'a> Scene<'a> {
|
||||
impl Scene {
|
||||
pub fn new(
|
||||
camera: Camera,
|
||||
lights: LightAggregate,
|
||||
objects: Vec<Object<'a>>,
|
||||
objects: Vec<Object>,
|
||||
aliasing_limit: u32,
|
||||
reflection_limit: u32,
|
||||
) -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue