rs_pbrt/filters/
boxfilter.rs1use crate::core::filter::Filter;
3use crate::core::geometry::{Point2f, Vector2f};
4use crate::core::paramset::ParamSet;
5use crate::core::pbrt::Float;
6
7#[derive(Debug, Default, Copy, Clone)]
10pub struct BoxFilter {
11 pub radius: Vector2f,
13 pub inv_radius: Vector2f,
14}
15
16impl BoxFilter {
17 pub fn create(ps: &ParamSet) -> Box<Filter> {
18 let xw: Float = ps.find_one_float("xwidth", 0.5);
19 let yw: Float = ps.find_one_float("ywidth", 0.5);
20 let box_filter: Box<Filter> = Box::new(Filter::Bx(BoxFilter {
21 radius: Vector2f { x: xw, y: yw },
22 inv_radius: Vector2f {
23 x: 1.0 / xw,
24 y: 1.0 / yw,
25 },
26 }));
27 box_filter
28 }
29 pub fn evaluate(&self, _p: Point2f) -> Float {
31 1.0
32 }
33 pub fn get_radius(&self) -> Vector2f {
34 Vector2f {
35 x: self.radius.x,
36 y: self.radius.y,
37 }
38 }
39}