From bbecf67545c2bd6822b0680673aa850c5ddef9f3 Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Tue, 10 Jan 2023 17:54:39 +0100 Subject: =?UTF-8?q?=F0=9F=94=A8=20Refactors=20&=20Use=20rayon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - All data shared between threads are now Arcs since the data is immutable. - Remove tokio - Rustified main --- racer-tracer/src/scene.rs | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'racer-tracer/src/scene.rs') diff --git a/racer-tracer/src/scene.rs b/racer-tracer/src/scene.rs index 2d530af..672b39b 100644 --- a/racer-tracer/src/scene.rs +++ b/racer-tracer/src/scene.rs @@ -1,7 +1,7 @@ use crate::geometry::Hittable; pub struct Scene { - objects: Vec>, + objects: Vec>, } impl Scene { @@ -11,27 +11,11 @@ impl Scene { } } - pub fn add(&mut self, hittable: Box) { + pub fn add(&mut self, hittable: Box) { self.objects.push(hittable); } } -// TODO: What to do? -// Cloning everything is nice since then every task can do whatever they like. -// Cloning everything is bad becuse you copy everything which takes time. -// Could also put locks on the Scene but then it becomes this global object that everyone -// wants to access at the same time. -// Will do some laborations later and decide on a solution. -impl Clone for Scene { - fn clone(&self) -> Self { - let mut objects = Vec::with_capacity(self.objects.capacity()); - for i in self.objects.iter() { - objects.push(i.clone_box()); - } - Self { objects } - } -} - impl Hittable for Scene { fn hit( &self, @@ -51,8 +35,4 @@ impl Hittable for Scene { rec } - - fn clone_box(&self) -> Box { - Box::new(self.clone()) - } } -- cgit v1.2.3