diff --git a/src/camera.rs b/src/camera.rs index b9f10d1..933d0b4 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -120,7 +120,7 @@ impl Camera { } pub fn get_pixel_tl(&self, x: u32, y: u32) -> Vec3 { - return self.pixel00_loc + (x * self.pixel_delta_u) + (y * self.pixel_delta_v); + self.pixel00_loc + (x * self.pixel_delta_u) + (y * self.pixel_delta_v) } pub fn get_ray(&self, pixel_tl: Vec3, x: u32, y: u32) -> Ray { diff --git a/src/objects/circle.rs b/src/objects/circle.rs index 1f5cead..f2f35bd 100644 --- a/src/objects/circle.rs +++ b/src/objects/circle.rs @@ -51,7 +51,7 @@ impl Hittable for Circle { p, self.normal, self.material.clone(), - self.normal.dot(&r.dir()) < 0., + self.normal.dot(r.dir()) < 0., *uv.x(), *uv.y(), )); @@ -62,10 +62,10 @@ impl Hittable for Circle { fn to_uv(&self, point: &Vec3) -> Vec3 { let p = *point - self.center; // TODO: add rotated texture support - return Vec3::new( + Vec3::new( 0.5 + p.y().atan2(*p.x()) / (2. * PI), 1. - (p.z() / self.radius).acos() / PI, 0.0, - ); + ) } } diff --git a/src/objects/cube.rs b/src/objects/cube.rs index 3bd351d..297b361 100644 --- a/src/objects/cube.rs +++ b/src/objects/cube.rs @@ -42,7 +42,7 @@ impl Hittable for Cube { Hit::hit_list(&self.faces, r) } - fn to_uv(&self, point: &Vec3) -> Vec3 { + fn to_uv(&self, _point: &Vec3) -> Vec3 { // TODO: map to [0.1] relative to specific face todo!() } diff --git a/src/objects/cylinder.rs b/src/objects/cylinder.rs index 88759e7..2c72849 100644 --- a/src/objects/cylinder.rs +++ b/src/objects/cylinder.rs @@ -20,11 +20,11 @@ impl Cylinder { } impl Hittable for Cylinder { - fn hit(&self, r: &crate::ray::Ray) -> Option { + fn hit(&self, _r: &crate::ray::Ray) -> Option { todo!() } - fn to_uv(&self, point: &Vec3) -> Vec3 { + fn to_uv(&self, _point: &Vec3) -> Vec3 { todo!() } } diff --git a/src/objects/materials/texture.rs b/src/objects/materials/texture.rs index fac07f1..4234ccf 100644 --- a/src/objects/materials/texture.rs +++ b/src/objects/materials/texture.rs @@ -36,7 +36,7 @@ impl Texture { width: img.width(), height: img.height(), source: img, - stride: stride, + stride, } } @@ -51,7 +51,7 @@ impl Texture { let b = self.source.as_bytes(); let idx = self._idx(u, v); - Vec3::from_u8(b[self.stride * idx + 0], b[self.stride * idx + 2], b[self.stride * idx + 1]) + Vec3::from_u8(b[self.stride * idx], b[self.stride * idx + 2], b[self.stride * idx + 1]) } } @@ -59,6 +59,6 @@ impl Material for Texture { fn scatter(&self, hit: &Hit, _ray: &Ray) -> Option<(Option, Vec3)> { let (u, v) = hit.uv(); let col = self._at(u, 1. - v); - return Some((None, col)); + Some((None, col)) } } diff --git a/src/objects/sphere.rs b/src/objects/sphere.rs index 106c5df..ebf3282 100644 --- a/src/objects/sphere.rs +++ b/src/objects/sphere.rs @@ -75,10 +75,10 @@ impl Hittable for Sphere { fn to_uv(&self, point: &Vec3) -> Vec3 { let p = *point - self.center; // TODO: add rotated texture support - return Vec3::new( + Vec3::new( 0.5 + p.y().atan2(*p.x()) / (2. * PI), 1. - (p.z() / self.radius).acos() / PI, 0.0, - ); + ) } } diff --git a/src/objects/triangle.rs b/src/objects/triangle.rs index b743881..9c25ce3 100644 --- a/src/objects/triangle.rs +++ b/src/objects/triangle.rs @@ -101,7 +101,7 @@ impl Triangle { p, normal, material, - normal.dot(&r.dir()) < 0., + normal.dot(r.dir()) < 0., *uvw.x(), *uvw.y(), )) diff --git a/src/raytracer.rs b/src/raytracer.rs index 78a9545..5f60cec 100644 --- a/src/raytracer.rs +++ b/src/raytracer.rs @@ -27,7 +27,7 @@ pub fn render(scene: &mut Scene) { scene.init(); // TODO: currently splits per vertical line, but could be more granular (per chunk) - let mut pixels = vec![0 as u8; (scene.image_width * scene.image_height * 3) as usize]; + let mut pixels = vec![0_u8; (scene.image_width * scene.image_height * 3) as usize]; let scanlines: Vec<(usize, &mut [u8])> = pixels .chunks_mut(scene.image_width as usize * 3) .enumerate()