Skip to content

Commit

Permalink
Clean up marbles code
Browse files Browse the repository at this point in the history
  • Loading branch information
scanhex committed Dec 6, 2020
1 parent ef0edce commit 8b9fb3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions examples/marbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/shape/monomial_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8b9fb3c

Please sign in to comment.