use super::*;
use crate::globals::get_options;
use anyhow::Result;
use shared::core::sampler::IndependentSampler;

impl CreateSampler for IndependentSampler {
    fn create(
        params: &ParameterDictionary,
        _full_res: Point2i,
        _loc: &FileLoc,
        arena: &Arena,
    ) -> Result<Sampler> {
        let options = get_options();

        let nsamp = if let Some(n) = options.quick_render.then_some(1).or(options.pixel_samples) {
            n
        } else {
            params.get_one_int("pixelsamples", 16)?
        };

        let seed = params.get_one_int("seed", options.seed)?;
        let sampler = Self::new(nsamp, seed as u64);
        arena.alloc(sampler);
        Ok(Sampler::Independent(sampler))
    }
}
