ft: ran linter
This commit is contained in:
@@ -2,7 +2,6 @@ use core::f32::math::sqrt;
|
||||
use std::fmt::{self, Debug};
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::objects::hit::Hit;
|
||||
use crate::objects::materials::traits::Material;
|
||||
@@ -16,6 +15,7 @@ pub struct Sphere {
|
||||
material: Arc<dyn Material>,
|
||||
}
|
||||
|
||||
|
||||
impl Debug for Sphere {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Sphere")
|
||||
@@ -29,7 +29,7 @@ impl Debug for Sphere {
|
||||
impl Sphere {
|
||||
pub fn new(center: Vec3, r: f32, mat: Arc<dyn Material>) -> Self {
|
||||
Self {
|
||||
center: center,
|
||||
center,
|
||||
radius: r,
|
||||
material: mat,
|
||||
}
|
||||
@@ -42,16 +42,6 @@ impl Sphere {
|
||||
material: mat,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn center(&self) -> &Vec3 {
|
||||
&self.center
|
||||
}
|
||||
|
||||
pub fn set_center(&mut self, center: Vec3) {
|
||||
if self.center != center {
|
||||
self.center = center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Hittable for Sphere {
|
||||
@@ -83,12 +73,4 @@ impl Hittable for Sphere {
|
||||
fn normal_at(&self, p: &Vec3) -> Vec3 {
|
||||
(*p - self.center).get_unit()
|
||||
}
|
||||
|
||||
fn inside(&self, p: &Vec3) -> bool {
|
||||
(*p - self.center).length() < self.radius
|
||||
}
|
||||
|
||||
fn closest_on_surface(&self, p: &Vec3) -> Vec3 {
|
||||
self.normal_at(p) * self.radius
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user