pub mod dielectric;
pub mod lambertian;
pub mod metal;

use dielectric::Dielectric;
use lambertian::Lambertian;
use metal::Metal;

use crate::{hittable::HitRecord, ray::Ray, vec3::Color};

pub trait Material {
	fn scatter(&self, r_in: &Ray, hit_record: &HitRecord) -> Option<(Color, Ray)>;
}

#[derive(Debug, Clone, Copy)]
pub enum Materials {
	Lambertian(Lambertian),
	Metal(Metal),
	Dielectric(Dielectric),
}

impl Material for Materials {
	fn scatter(&self, r_in: &Ray, hit_record: &HitRecord) -> Option<(Color, Ray)> {
		match self {
			Materials::Lambertian(m) => m.scatter(r_in, hit_record),
			Materials::Metal(m) => m.scatter(r_in, hit_record),
			Materials::Dielectric(m) => m.scatter(r_in, hit_record),
		}
	}
}
