use crate::Float;
use crate::core::spectrum::{Spectrum, SpectrumTrait};
use crate::core::texture::TextureEvalContext;
use crate::spectra::{SampledSpectrum, SampledWavelengths};

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FloatConstantTexture {
    pub value: Float,
}

impl FloatConstantTexture {
    pub fn new(value: Float) -> Self {
        Self { value }
    }

    pub fn evaluate(&self, _ctx: &TextureEvalContext) -> Float {
        self.value
    }
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct SpectrumConstantTexture {
    pub value: Spectrum,
}

impl SpectrumConstantTexture {
    pub fn new(value: Spectrum) -> Self {
        Self { value }
    }

    pub fn evaluate(
        &self,
        _ctx: &TextureEvalContext,
        lambda: &SampledWavelengths,
    ) -> SampledSpectrum {
        self.value.sample(lambda)
    }
}
