summaryrefslogtreecommitdiff
path: root/racer-tracer/src/scene.rs
diff options
context:
space:
mode:
authorSakarias Johansson <sakarias.johansson@goodbyekansas.com>2023-01-10 17:54:39 +0100
committerSakarias Johansson <sakarias.johansson@goodbyekansas.com>2023-01-11 19:36:38 +0100
commitbbecf67545c2bd6822b0680673aa850c5ddef9f3 (patch)
tree741b2fc03797a8fedcfe67e34687b4443fcf41f7 /racer-tracer/src/scene.rs
parent899f81eed6c221dce22333ad03704b12d7634a54 (diff)
downloadracer-tracer-bbecf67545c2bd6822b0680673aa850c5ddef9f3.tar.gz
racer-tracer-bbecf67545c2bd6822b0680673aa850c5ddef9f3.tar.xz
racer-tracer-bbecf67545c2bd6822b0680673aa850c5ddef9f3.zip
🔨 Refactors & Use rayon
- All data shared between threads are now Arcs since the data is immutable. - Remove tokio - Rustified main
Diffstat (limited to 'racer-tracer/src/scene.rs')
-rw-r--r--racer-tracer/src/scene.rs24
1 files changed, 2 insertions, 22 deletions
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<Box<dyn Hittable>>,
+ objects: Vec<Box<dyn Hittable + Sync + Send>>,
}
impl Scene {
@@ -11,27 +11,11 @@ impl Scene {
}
}
- pub fn add(&mut self, hittable: Box<dyn Hittable>) {
+ pub fn add(&mut self, hittable: Box<dyn Hittable + Sync + Send>) {
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<dyn Hittable> {
- Box::new(self.clone())
- }
}