pbrt_r3/core/sampler/
sampler.rs

1use crate::core::base::*;
2use crate::core::camera::*;
3
4use std::sync::Arc;
5use std::sync::RwLock;
6/*
7    virtual void StartPixel(const Point2i &p);
8    virtual Float Get1D() = 0;
9    virtual Point2f Get2D() = 0;
10    CameraSample GetCameraSample(const Point2i &pRaster);
11    void Request1DArray(int n);
12    void Request2DArray(int n);
13    virtual int RoundCount(int n) const { return n; }
14    const Float *Get1DArray(int n);
15    const Point2f *Get2DArray(int n);
16    virtual bool StartNextSample();
17    virtual std::unique_ptr<Sampler> Clone(int seed) = 0;
18    virtual bool SetSampleNumber(int64_t sampleNum);
19
20*/
21
22pub trait Sampler {
23    fn start_pixel(&mut self, _p: &Point2i) {}
24    fn get_1d(&mut self) -> Float;
25    fn get_2d(&mut self) -> Point2f;
26    fn get_camera_sample(&mut self, p: &Point2i) -> CameraSample {
27        let p_film = Point2f::new(p.x as Float, p.y as Float) + self.get_2d();
28        let p_lens = self.get_2d();
29        let time = self.get_1d();
30        //let _ = self.get_1d();
31        CameraSample {
32            p_film,
33            p_lens,
34            time,
35        }
36    }
37    fn request_1d_array(&mut self, _n: u32);
38    fn request_2d_array(&mut self, _n: u32);
39    fn get_1d_array(&mut self, n: u32) -> Option<Vec<Float>>;
40    fn get_2d_array(&mut self, n: u32) -> Option<Vec<Vector2f>>;
41    fn round_count(&self, n: u32) -> u32 {
42        return n;
43    }
44    fn start_next_sample(&mut self) -> bool {
45        return false;
46    }
47    fn clone_with_seed(&self, seed: u32) -> Arc<RwLock<dyn Sampler>>;
48    fn set_sample_number(&mut self, _sample_num: u32) -> bool {
49        return false;
50    }
51    fn get_samples_per_pixel(&self) -> u32;
52}