Add basic color to spheres
This commit is contained in:
parent
9d188ed692
commit
cb87c1e70c
25
src/main.rs
25
src/main.rs
|
@ -11,19 +11,20 @@ mod camera; use camera::*;
|
|||
mod types; use types::*;
|
||||
mod object; use object::*;
|
||||
|
||||
fn cast_ray(ray: Ray, scene: &Scene) -> Color {
|
||||
//Color::new(0.0, -ray.direction.x, ray.direction.y)
|
||||
|
||||
let closest = scene.iter()
|
||||
fn trace(ray: Ray, scene: &Scene) -> Option<(&Object, f32)> {
|
||||
scene.iter()
|
||||
.filter_map(|obj| obj.intersect(ray)
|
||||
.map(|x| (obj, x)))
|
||||
.min_by(|a, b| a.1.partial_cmp(&b.1).unwrap_or(Ordering::Equal));
|
||||
|
||||
if closest.is_some() {
|
||||
Color::new(1.0, 1.0, 1.0)
|
||||
} else {
|
||||
Color::new(0.0, 0.0, 0.0)
|
||||
.min_by(|a, b| a.1.partial_cmp(&b.1).unwrap_or(Ordering::Equal))
|
||||
}
|
||||
|
||||
fn cast_ray(ray: Ray, scene: &Scene) -> Color {
|
||||
if let Some((obj, dist)) = trace(ray, scene) {
|
||||
let point = ray.project(dist);
|
||||
|
||||
obj.getcolor(point)
|
||||
}
|
||||
else { Color::black() }
|
||||
}
|
||||
|
||||
fn render(camera: &Camera, scene: &Scene, filename: &str) -> std::io::Result<()> {
|
||||
|
@ -54,8 +55,8 @@ fn main() -> std::io::Result<()> {
|
|||
let camera = Camera::new(Point3::new(0.0,0.0,0.0), Vector3::new(0.0,0.0,-1.0), 1.0, 2.0, 2.0, 400, 400);
|
||||
|
||||
let scene = vec![
|
||||
Object::Sphere(Sphere::new(0.0,0.0,-5.0,2.0)),
|
||||
Object::Sphere(Sphere::new(-3.0,0.0,-8.0,2.5))
|
||||
Object::Sphere(Sphere::new(0.0,0.0,-5.0,2.0, |_, _| Color::white())),
|
||||
Object::Sphere(Sphere::new(-3.0,0.0,-8.0,2.5, |_, _| Color::white()))
|
||||
];
|
||||
|
||||
render(&camera, &scene, "out.ppm")
|
||||
|
|
|
@ -4,7 +4,7 @@ mod triangle; pub use triangle::*;
|
|||
|
||||
use na::*;
|
||||
|
||||
use crate::types::Ray;
|
||||
use crate::types::*;
|
||||
|
||||
pub enum Object {
|
||||
Sphere(Sphere)
|
||||
|
@ -17,9 +17,15 @@ impl Object {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {
|
||||
pub fn getcolor(&self, point: Point3<f32>) -> Color {
|
||||
match *self {
|
||||
Object::Sphere(ref sphere) => sphere.normal(ray)
|
||||
Object::Sphere(ref sphere) => sphere.getcolor(point)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normal(&self, point: Point3<f32>) -> Unit<Vector3<f32>> {
|
||||
match *self {
|
||||
Object::Sphere(ref sphere) => sphere.normal(point)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extern crate nalgebra as na;
|
||||
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use na::*;
|
||||
use na::geometry::Point3;
|
||||
|
||||
|
@ -7,17 +9,26 @@ use crate::types::*;
|
|||
|
||||
pub struct Sphere {
|
||||
pub center: Point3<f32>,
|
||||
pub radius: f32
|
||||
pub radius: f32,
|
||||
|
||||
pub texture: Box<dyn Fn(f32, f32) -> Color>
|
||||
}
|
||||
|
||||
impl Sphere {
|
||||
pub fn new(x: f32, y: f32, z: f32, radius: f32) -> Self {
|
||||
pub fn new<F: 'static>(x: f32, y: f32, z: f32, radius: f32, texture: F) -> Self
|
||||
where F: Fn(f32, f32) -> Color
|
||||
{
|
||||
Sphere {
|
||||
center: Point3::new(x, y, z),
|
||||
radius: radius
|
||||
radius: radius,
|
||||
texture: Box::new(texture)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_solid(x: f32, y: f32, z: f32, radius: f32, color: Color) -> Self { Sphere::new(x, y, z, radius, Box::new(move |_, _| color)) }
|
||||
|
||||
// Determines if a ray intersects the circle.
|
||||
// If so, returns the distance to the intersection point.
|
||||
pub fn intersect(&self, ray: Ray) -> Option<f32> {
|
||||
fn solve_quadratic(a: f32, b: f32, c: f32) -> Option<(f32, f32)> {
|
||||
let discr = b * b - 4.0 * a * c;
|
||||
|
@ -46,7 +57,21 @@ impl Sphere {
|
|||
else { None }
|
||||
}
|
||||
|
||||
pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {
|
||||
unimplemented!()
|
||||
pub fn getcolor(&self, point: Point3<f32>) -> Color {
|
||||
let normal = self.normal(point);
|
||||
|
||||
// In this particular case, the normal is simular to a point on a unit sphere
|
||||
// centred around the origin. We can thus use the normal coordinates to compute
|
||||
// the spherical coordinates of the point.
|
||||
// atan2 returns a value in the range [-pi, pi] and we need to remap it to range [0, 1]
|
||||
// acosf returns a value in the range [0, pi] and we also need to remap it to the range [0, 1]
|
||||
let x = 0.5 + normal.z.atan2(normal.x) / (2.0 * PI);
|
||||
let y = normal.y.acos() / PI;
|
||||
|
||||
(*self.texture)(x, y)
|
||||
}
|
||||
|
||||
pub fn normal(&self, point: Point3<f32>) -> Unit<Vector3<f32>> {
|
||||
Unit::new_normalize(point - self.center)
|
||||
}
|
||||
}
|
||||
|
|
19
src/types.rs
19
src/types.rs
|
@ -47,4 +47,23 @@ impl Color {
|
|||
let blue = (255.0 * self.blue) as u8;
|
||||
[red, green, blue]
|
||||
}
|
||||
|
||||
pub fn black() -> Self {
|
||||
Color {
|
||||
red: 0.0,
|
||||
green: 0.0,
|
||||
blue: 0.0,
|
||||
|
||||
_private: ()
|
||||
}
|
||||
}
|
||||
pub fn white() -> Self {
|
||||
Color {
|
||||
red: 1.0,
|
||||
green: 1.0,
|
||||
blue: 1.0,
|
||||
|
||||
_private: ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{"message":"unused variable: `ray`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1323,"byte_end":1326,"line_start":49,"line_end":49,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_variables)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider prefixing with an underscore","code":null,"level":"help","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1323,"byte_end":1326,"line_start":49,"line_end":49,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":"_ray","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: unused variable: `ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:49:26\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m49\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11mhelp: consider prefixing with an underscore: `_ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(unused_variables)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"unused variable: `ray`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1429,"byte_end":1432,"line_start":52,"line_end":52,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_variables)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider prefixing with an underscore","code":null,"level":"help","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1429,"byte_end":1432,"line_start":52,"line_end":52,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":"_ray","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: unused variable: `ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:52:26\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m52\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11mhelp: consider prefixing with an underscore: `_ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(unused_variables)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `project`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\types.rs","byte_start":610,"byte_end":654,"line_start":21,"line_end":21,"column_start":5,"column_end":49,"is_primary":true,"text":[{"text":" pub fn project(&self, t: f32) -> Point3<f32> { self.origin + t * self.direction.into_inner() }","highlight_start":5,"highlight_end":49}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `project`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\types.rs:21:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m21\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn project(&self, t: f32) -> Point3<f32> { self.origin + t * self.direction.into_inner() }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(dead_code)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1302,"byte_end":1354,"line_start":49,"line_end":49,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:49:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m49\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `white`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\types.rs","byte_start":1565,"byte_end":1587,"line_start":60,"line_end":60,"column_start":5,"column_end":27,"is_primary":true,"text":[{"text":" pub fn white() -> Self {","highlight_start":5,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `white`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\types.rs:60:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m60\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn white() -> Self {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1408,"byte_end":1460,"line_start":52,"line_end":52,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:52:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m52\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object.rs","byte_start":339,"byte_end":391,"line_start":20,"line_end":20,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object.rs:20:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m20\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
{"message":"unused variable: `ray`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1306,"byte_end":1309,"line_start":49,"line_end":49,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_variables)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider prefixing with an underscore","code":null,"level":"help","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1306,"byte_end":1309,"line_start":49,"line_end":49,"column_start":26,"column_end":29,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":26,"highlight_end":29}],"label":null,"suggested_replacement":"_ray","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: unused variable: `ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:49:26\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m49\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11mhelp: consider prefixing with an underscore: `_ray`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(unused_variables)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `project`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\types.rs","byte_start":610,"byte_end":654,"line_start":21,"line_end":21,"column_start":5,"column_end":49,"is_primary":true,"text":[{"text":" pub fn project(&self, t: f32) -> Point3<f32> { self.origin + t * self.direction.into_inner() }","highlight_start":5,"highlight_end":49}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `project`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\types.rs:21:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m21\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn project(&self, t: f32) -> Point3<f32> { self.origin + t * self.direction.into_inner() }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(dead_code)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `new`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":193,"byte_end":245,"line_start":14,"line_end":14,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn new(center: Point3<f32>, radius: f32) -> Self {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `new`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:14:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m14\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn new(center: Point3<f32>, radius: f32) -> Self {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":1285,"byte_end":1337,"line_start":49,"line_end":49,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:49:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m49\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"variant is never constructed: `Sphere`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object.rs","byte_start":135,"byte_end":149,"line_start":10,"line_end":10,"column_start":5,"column_end":19,"is_primary":true,"text":[{"text":" Sphere(Sphere)","highlight_start":5,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: variant is never constructed: `Sphere`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object.rs:10:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m10\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m Sphere(Sphere)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object.rs","byte_start":339,"byte_end":391,"line_start":20,"line_end":20,"column_start":5,"column_end":57,"is_primary":true,"text":[{"text":" pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":57}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object.rs:20:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m20\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, ray: Ray) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `new`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\types.rs","byte_start":911,"byte_end":962,"line_start":34,"line_end":34,"column_start":5,"column_end":56,"is_primary":true,"text":[{"text":" pub fn new(red: f32, green: f32, blue: f32) -> Self {","highlight_start":5,"highlight_end":56}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `new`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\types.rs:34:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m34\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn new(red: f32, green: f32, blue: f32) -> Self {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m= \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15mnote\u001b[0m\u001b[0m: `#[warn(dead_code)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `new_solid`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object\\sphere.rs","byte_start":556,"byte_end":631,"line_start":28,"line_end":28,"column_start":5,"column_end":80,"is_primary":true,"text":[{"text":" pub fn new_solid(x: f32, y: f32, z: f32, radius: f32, color: Color) -> Self { Sphere::new(x, y, z, radius, Box::new(move |_, _| color)) }","highlight_start":5,"highlight_end":80}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `new_solid`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object\\sphere.rs:28:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m28\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn new_solid(x: f32, y: f32, z: f32, radius: f32, color: Color) -> Self { Sphere::new(x, y, z, radius, Box::new(move |_, _| color)) }\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"message":"method is never used: `normal`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src\\object.rs","byte_start":505,"byte_end":567,"line_start":26,"line_end":26,"column_start":5,"column_end":67,"is_primary":true,"text":[{"text":" pub fn normal(&self, point: Point3<f32>) -> Unit<Vector3<f32>> {","highlight_start":5,"highlight_end":67}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;11mwarning\u001b[0m\u001b[0m\u001b[1m\u001b[38;5;15m: method is never used: `normal`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m--> \u001b[0m\u001b[0msrc\\object.rs:26:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14m26\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m pub fn normal(&self, point: Point3<f32>) -> Unit<Vector3<f32>> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;14m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;11m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue