fx: ran linter
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::{f32::consts::PI, sync::Arc};
|
||||
|
||||
use log::{info, warn};
|
||||
use log::info;
|
||||
|
||||
use crate::{
|
||||
objects::{hit::Hit, traits::Hittable},
|
||||
|
||||
@@ -43,7 +43,7 @@ impl Hittable for Cube {
|
||||
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!()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::Deserialize;
|
||||
use crate::{
|
||||
objects::{hit::Hit, materials::traits::Material},
|
||||
ray::Ray,
|
||||
vec3::{Colour, Vec3},
|
||||
vec3::Colour,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::objects::traits::Hittable;
|
||||
use crate::objects::triangle::Triangle;
|
||||
use crate::ray::Ray;
|
||||
use crate::{objects::materials::traits::Material, vec3::Vec3};
|
||||
use log::{info, warn};
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -29,12 +28,12 @@ impl Quad {
|
||||
}
|
||||
}
|
||||
pub fn corner_spheres(&self) -> Vec<Sphere> {
|
||||
let mut out: Vec<Sphere> = vec![];
|
||||
out.push(Sphere::new(self.p1, 1., self.material.clone()));
|
||||
out.push(Sphere::new(self.p2, 1., self.material.clone()));
|
||||
out.push(Sphere::new(self.p3, 1., self.material.clone()));
|
||||
out.push(Sphere::new(self.p4, 1., self.material.clone()));
|
||||
return out;
|
||||
vec![
|
||||
Sphere::new(self.p1, 1., self.material.clone()),
|
||||
Sphere::new(self.p2, 1., self.material.clone()),
|
||||
Sphere::new(self.p3, 1., self.material.clone()),
|
||||
Sphere::new(self.p4, 1., self.material.clone()),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn hit(
|
||||
@@ -51,7 +50,7 @@ impl Quad {
|
||||
if isct1.is_some() {
|
||||
return isct1;
|
||||
}
|
||||
return isct2;
|
||||
isct2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +81,6 @@ impl Hittable for Quad {
|
||||
|
||||
fn normal_at(&self, _p: &Vec3) -> Vec3 {
|
||||
// FIXME: might cause ownership issues
|
||||
return self.normal;
|
||||
self.normal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ impl Triangle {
|
||||
|
||||
let diff = (a4 - a1 - a2 - a3).abs();
|
||||
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 {
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,6 @@ impl Hittable for Triangle {
|
||||
|
||||
fn normal_at(&self, _p: &Vec3) -> Vec3 {
|
||||
// FIXME: might cause ownership issues
|
||||
return self.normal;
|
||||
self.normal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,22 +40,6 @@ impl Debug for 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) {
|
||||
self.camera.render(&self.objects);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use core::f32::math::sqrt;
|
||||
use is_close::default;
|
||||
use log::warn;
|
||||
use rand::RngExt;
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use std::{
|
||||
|
||||
Reference in New Issue
Block a user