wip: parallelization

This commit is contained in:
djaidjai committed 2026-05-03 14:58:56 +02:00
1 parent eb90c36ae8
commit 10f9c0984d
23 files changed
+294 -211

No files matched your search

+31 -5
View File
@@ -10,14 +10,33 @@ use crate::{
#[derive(Debug)]
pub struct Scene {
pub camera: Camera,
pub _materials: Vec<Arc<dyn Material>>,
pub camera: Camera, // FIXME: should not be public
pub objects: Vec<Arc<dyn Hittable>>,
// image
pub filename: String,
pub image_width: u32,
pub image_height: u32,
// raytracing // TODO: think about organisation of these vars, also in Camera
pub max_depth: u32,
}
impl Scene {
pub fn render(&mut self) {
self.camera.render(&self.objects);
pub fn new(
camera: Camera,
objects: Vec<Arc<dyn Hittable>>,
filename: String,
image_width: u32,
image_height: u32,
max_depth: u32,
) -> Self {
Self {
camera,
objects,
filename,
image_width,
image_height,
max_depth,
}
}
}
@@ -26,6 +45,10 @@ struct SceneDef {
pub camera: RawCamera,
pub materials: Vec<MaterialDef>,
pub objects: Vec<HittableDef>,
pub filename: String,
pub image_width: u32,
pub image_height: u32,
pub max_depth: u32,
}
impl<'de> Deserialize<'de> for Scene {
@@ -46,8 +69,11 @@ impl<'de> Deserialize<'de> for Scene {
.collect();
Ok(Self {
camera: Camera::from(conc.camera),
_materials: mats,
objects: objs,
filename: conc.filename,
image_width: conc.image_width,
image_height: conc.image_height,
max_depth: conc.max_depth,
})
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.