fx: ran linter

This commit is contained in:
2026-05-02 14:02:06 +02:00
parent 17ad6e30db
commit a44e61c1f7
7 changed files with 14 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
use std::{f32::consts::PI, sync::Arc}; use std::{f32::consts::PI, sync::Arc};
use log::{info, warn}; use log::info;
use crate::{ use crate::{
objects::{hit::Hit, traits::Hittable}, objects::{hit::Hit, traits::Hittable},

View File

@@ -43,7 +43,7 @@ impl Hittable for Cube {
Hit::hit_list(&self.faces, r) Hit::hit_list(&self.faces, r)
} }
fn normal_at(&self, p: &Vec3) -> Vec3 { fn normal_at(&self, _p: &Vec3) -> Vec3 {
// TODO: normal calc for cube // TODO: normal calc for cube
todo!() todo!()
} }

View File

@@ -6,7 +6,7 @@ use serde::Deserialize;
use crate::{ use crate::{
objects::{hit::Hit, materials::traits::Material}, objects::{hit::Hit, materials::traits::Material},
ray::Ray, ray::Ray,
vec3::{Colour, Vec3}, vec3::Colour,
}; };
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View File

@@ -4,7 +4,6 @@ use crate::objects::traits::Hittable;
use crate::objects::triangle::Triangle; use crate::objects::triangle::Triangle;
use crate::ray::Ray; use crate::ray::Ray;
use crate::{objects::materials::traits::Material, vec3::Vec3}; use crate::{objects::materials::traits::Material, vec3::Vec3};
use log::{info, warn};
use std::fmt::Debug; use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
@@ -29,12 +28,12 @@ impl Quad {
} }
} }
pub fn corner_spheres(&self) -> Vec<Sphere> { pub fn corner_spheres(&self) -> Vec<Sphere> {
let mut out: Vec<Sphere> = vec![]; vec![
out.push(Sphere::new(self.p1, 1., self.material.clone())); Sphere::new(self.p1, 1., self.material.clone()),
out.push(Sphere::new(self.p2, 1., self.material.clone())); Sphere::new(self.p2, 1., self.material.clone()),
out.push(Sphere::new(self.p3, 1., self.material.clone())); Sphere::new(self.p3, 1., self.material.clone()),
out.push(Sphere::new(self.p4, 1., self.material.clone())); Sphere::new(self.p4, 1., self.material.clone()),
return out; ]
} }
pub fn hit( pub fn hit(
@@ -51,7 +50,7 @@ impl Quad {
if isct1.is_some() { if isct1.is_some() {
return isct1; return isct1;
} }
return isct2; isct2
} }
} }
@@ -82,6 +81,6 @@ impl Hittable for Quad {
fn normal_at(&self, _p: &Vec3) -> Vec3 { fn normal_at(&self, _p: &Vec3) -> Vec3 {
// FIXME: might cause ownership issues // FIXME: might cause ownership issues
return self.normal; self.normal
} }
} }

View File

@@ -54,9 +54,9 @@ impl Triangle {
let diff = (a4 - a1 - a2 - a3).abs(); let diff = (a4 - a1 - a2 - a3).abs();
if diff < 0.001 { if diff < 0.001 {
return Some(Hit::new(t, p, normal, material, normal.dot(&-r.dir()) > 0.)); Some(Hit::new(t, p, normal, material, normal.dot(&-r.dir()) > 0.))
} else { } else {
return None; None
} }
} }
} }
@@ -86,6 +86,6 @@ impl Hittable for Triangle {
fn normal_at(&self, _p: &Vec3) -> Vec3 { fn normal_at(&self, _p: &Vec3) -> Vec3 {
// FIXME: might cause ownership issues // FIXME: might cause ownership issues
return self.normal; self.normal
} }
} }

View File

@@ -40,22 +40,6 @@ impl Debug for Scene {
} }
impl Scene { impl Scene {
pub fn new(image_width: u32, image_height: u32) -> Self {
Self {
camera: Camera::new(image_width, image_height),
materials: vec![],
objects: vec![],
}
}
pub fn camera(&mut self) -> &mut Camera {
&mut self.camera
}
pub fn add_hittable(&mut self, hittable: Arc<dyn Hittable>) {
self.objects.push(hittable);
}
pub fn render(&mut self) { pub fn render(&mut self) {
self.camera.render(&self.objects); self.camera.render(&self.objects);
} }

View File

@@ -1,6 +1,5 @@
use core::f32::math::sqrt; use core::f32::math::sqrt;
use is_close::default; use is_close::default;
use log::warn;
use rand::RngExt; use rand::RngExt;
use serde::{Deserialize, Serialize, Serializer}; use serde::{Deserialize, Serialize, Serializer};
use std::{ use std::{