Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct Plane {
- pub p0: Point,
- pub normal: Vector3,
- pub color: Color,
- }
- pub enum Element {
- Sphere(Sphere),
- Plane(Plane),
- }
- impl Element {
- pub fn color(&self) -> &Color {
- match *self {
- Element::Sphere(ref s) => &s.color,
- Element::Plane(ref p) => &p.color,
- }
- }
- }
- impl Intersectable for Element {
- fn intersect(&self, ray: &Ray) -> Option<f64> {
- match *self {
- Element::Sphere(ref s) => s.intersect(ray),
- Element::Plane(ref p) => p.intersect(ray),
- }
- }
- }
- impl Intersectable for Plane {
- fn intersect(&self, ray: &Ray) -> Option<f64> {
- None
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement