From 899f81eed6c221dce22333ad03704b12d7634a54 Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Sun, 8 Jan 2023 17:51:44 +0100 Subject: =?UTF-8?q?=F0=9F=8C=8D=20Add=20Geometry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created a trait for all geometry that has to implement a hit function. Depending on if the ray hits or not it returns an option with the color. - Add support for multiple samples per pixel Current issues: - Using cooperative multitasking which isn't that helpful in this situation since it's like running without async but without overhead. Should switch to rayon. - All data gets copied once per job. Will decide later what to do (copy or put locks and share data between jobs). --- racer-tracer/src/image.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'racer-tracer/src/image.rs') diff --git a/racer-tracer/src/image.rs b/racer-tracer/src/image.rs index 1b5f61e..2df11dc 100644 --- a/racer-tracer/src/image.rs +++ b/racer-tracer/src/image.rs @@ -3,14 +3,16 @@ pub struct Image { pub aspect_ratio: f64, pub width: usize, pub height: usize, + pub samples_per_pixel: usize, } impl Image { - pub fn new(aspect_ratio: f64, width: usize) -> Image { + pub fn new(aspect_ratio: f64, width: usize, samples_per_pixel: usize) -> Image { Image { aspect_ratio, width, height: (width as f64 / aspect_ratio) as usize, + samples_per_pixel, } } } -- cgit v1.2.3