@@ -26,9 +26,9 @@ impl Material {
2626
2727 pub fn scatter < R : Rng > ( & self , r : & Ray , hit_record : & HitRecord , rng : & mut R ) -> Option < Ray > {
2828 match self {
29- Material :: Lambertian ( lamb) => lamb. scatter ( r, hit_record, rng) ,
29+ Material :: Lambertian ( lamb) => Some ( lamb. scatter ( r, hit_record, rng) ) ,
3030 Material :: Metal ( met) => met. scatter ( r, hit_record, rng) ,
31- Material :: Dielectric ( diel) => diel. scatter ( r, hit_record, rng) ,
31+ Material :: Dielectric ( diel) => Some ( diel. scatter ( r, hit_record, rng) ) ,
3232 }
3333 }
3434
@@ -47,11 +47,11 @@ pub struct Lambertian {
4747}
4848
4949impl Lambertian {
50- fn scatter < R : Rng > ( & self , _r : & Ray , hit_record : & HitRecord , rng : & mut R ) -> Option < Ray > {
50+ fn scatter < R : Rng > ( & self , _r : & Ray , hit_record : & HitRecord , rng : & mut R ) -> Ray {
5151 let scatter_dir =
5252 hit_record. out_normal + Vec3 :: random_in_hemisphere ( & hit_record. out_normal , rng) ;
5353
54- Some ( Ray :: new ( hit_record. hit_point , scatter_dir) )
54+ Ray :: new ( hit_record. hit_point , scatter_dir)
5555 }
5656
5757 fn attenuation ( & self ) -> Vec3 {
@@ -93,7 +93,7 @@ pub struct Dielectric {
9393}
9494
9595impl Dielectric {
96- fn scatter < R : Rng > ( & self , r : & Ray , hit_record : & HitRecord , rng : & mut R ) -> Option < Ray > {
96+ fn scatter < R : Rng > ( & self , r : & Ray , hit_record : & HitRecord , rng : & mut R ) -> Ray {
9797 let reflect = |v : & Vec3 , norm : & Vec3 | -> Vec3 { v - 2. * Vec3 :: dot ( v, norm) * norm } ;
9898 let refraction_ratio = if hit_record. front_face {
9999 1. / self . refraction
@@ -114,7 +114,7 @@ impl Dielectric {
114114 self . refract ( & unit_dir, & hit_record. out_normal , refraction_ratio)
115115 } ;
116116
117- Some ( Ray :: new ( hit_record. hit_point , direction) )
117+ Ray :: new ( hit_record. hit_point , direction)
118118 }
119119
120120 fn refract ( & self , uv : & Vec3 , n : & Vec3 , eta : f64 ) -> Vec3 {
0 commit comments