SHARE
TWEET

Untitled

a guest Mar 20th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub struct Plane {
  2.     pub p0: Point,
  3.     pub normal: Vector3,
  4.     pub color: Color,
  5. }
  6.  
  7. pub enum Element {
  8.     Sphere(Sphere),
  9.     Plane(Plane),
  10. }
  11. impl Element {
  12.     pub fn color(&self) -> &Color {
  13.         match *self {
  14.             Element::Sphere(ref s) => &s.color,
  15.             Element::Plane(ref p) => &p.color,
  16.         }
  17.     }
  18. }
  19. impl Intersectable for Element {
  20.     fn intersect(&self, ray: &Ray) -> Option<f64> {
  21.         match *self {
  22.             Element::Sphere(ref s) => s.intersect(ray),
  23.             Element::Plane(ref p) => p.intersect(ray),
  24.         }
  25.     }
  26. }
  27. impl Intersectable for Plane {
  28.     fn intersect(&self, ray: &Ray) -> Option<f64> {
  29.         None
  30.     }
  31. }
RAW Paste Data
Top