fmt: ran clippy

This commit is contained in:
2026-05-13 13:27:37 +02:00
parent 194328d92f
commit d4f4b6a715
8 changed files with 14 additions and 14 deletions

View File

@@ -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 {

View File

@@ -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,
);
)
}
}

View File

@@ -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!()
}

View File

@@ -20,11 +20,11 @@ impl Cylinder {
}
impl Hittable for Cylinder {
fn hit(&self, r: &crate::ray::Ray) -> Option<super::hit::Hit> {
fn hit(&self, _r: &crate::ray::Ray) -> Option<super::hit::Hit> {
todo!()
}
fn to_uv(&self, point: &Vec3) -> Vec3 {
fn to_uv(&self, _point: &Vec3) -> Vec3 {
todo!()
}
}

View File

@@ -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<Ray>, Vec3)> {
let (u, v) = hit.uv();
let col = self._at(u, 1. - v);
return Some((None, col));
Some((None, col))
}
}

View File

@@ -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,
);
)
}
}

View File

@@ -101,7 +101,7 @@ impl Triangle {
p,
normal,
material,
normal.dot(&r.dir()) < 0.,
normal.dot(r.dir()) < 0.,
*uvw.x(),
*uvw.y(),
))

View File

@@ -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()