From 8b9fb3c304c1d11dd44957b88cc158d1ae62a56f Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Sun, 6 Dec 2020 23:16:10 +0300 Subject: [PATCH] Clean up marbles code --- examples/marbles.rs | 2 -- src/shape/monomial_surface.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/marbles.rs b/examples/marbles.rs index bbafea4..8c10b33 100644 --- a/examples/marbles.rs +++ b/examples/marbles.rs @@ -83,13 +83,11 @@ fn main() -> color_eyre::Result<()> { pos = closest + glm::normalize(&vec) * R * 1.05; } pos.y = pos.y.max(R - 0.06); - print!("{} ", pos.y); scene.add( Object::new(sphere().scale(&glm::vec3(R, R, R)).translate(&pos)) .material(Material::specular(hex_color(colors[i % colors.len()]), 0.1)), ); } - println!(); scene.add( Object::new(polygon(&[ glm::vec3(20.0, -0.06, 20.0), diff --git a/src/shape/monomial_surface.rs b/src/shape/monomial_surface.rs index 51c9e71..f4a89c5 100644 --- a/src/shape/monomial_surface.rs +++ b/src/shape/monomial_surface.rs @@ -7,6 +7,8 @@ use crate::kdtree::{Bounded, BoundingBox}; /// Represents a glass-shaped surface with height and exp parameters /// /// Points satisfy the relation y = height * sqrt(x^2 + z^2)^exp, x^2 + z^2 <= 1. +/// +/// Normals and other things probably can't be generalized, so they work only for exp=4 for now pub struct MonomialSurface { /// The height of the surface pub height: f64, @@ -88,7 +90,6 @@ impl Shape for MonomialSurface { } record.time = r; - // TODO: this is valid only for exp = 4, not sure how to do it in general case record.normal = glm::normalize(&glm::vec3( self.height * 4.0 * pos.x * (pos.x * pos.x + pos.z * pos.z), -1.0, @@ -212,7 +213,6 @@ mod tests { } } }; - let _ = surf.closest_point(&glm::vec3(0., 0., 0.)); test_xz(0.0, 1.0); test_xz(0.0, -1.0); test_xz(0.23234, 0.723423);