library: render: pathtracer: use map_or_else
This commit is contained in:
parent
482e6bea3f
commit
c1801a7a78
|
@ -59,11 +59,12 @@ impl Pathtracer {
|
||||||
fn pixel_ray(&self, x: f32, y: f32) -> LinearColor {
|
fn pixel_ray(&self, x: f32, y: f32) -> LinearColor {
|
||||||
let (x, y) = self.scene.camera.film().pixel_ratio(x, y);
|
let (x, y) = self.scene.camera.film().pixel_ratio(x, y);
|
||||||
let ray = self.scene.camera.ray_with_ratio(x, y);
|
let ray = self.scene.camera.ray_with_ratio(x, y);
|
||||||
if let Some(_) = self.cast_ray(ray) {
|
self.cast_ray(ray).map_or_else(
|
||||||
LinearColor::new(1., 1., 1.) // FIXME: calculate real color
|
|| self.scene.background.clone(),
|
||||||
} else {
|
|(t, obj)| {
|
||||||
LinearColor::black()
|
LinearColor::new(1., 1., 1.) // FIXME: calculate real color
|
||||||
}
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cast_ray(&self, ray: Ray) -> Option<(f32, &Object)> {
|
fn cast_ray(&self, ray: Ray) -> Option<(f32, &Object)> {
|
||||||
|
|
Loading…
Reference in a new issue