use crate::content::material::AlphaMode;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) enum Cull {
None,
Back,
Front,
}
impl Cull {
pub fn mirrored(self) -> Self {
match self {
Self::None => Self::None,
Self::Back => Self::Front,
Self::Front => Self::Back,
}
}
pub fn of(single_sided: Self, double_sided: bool, mirrored: bool) -> Self {
if double_sided {
Self::None
} else if mirrored {
single_sided.mirrored()
} else {
single_sided
}
}
pub(super) fn face(self) -> Option<wgpu::Face> {
match self {
Self::None => None,
Self::Back => Some(wgpu::Face::Back),
Self::Front => Some(wgpu::Face::Front),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) enum Alpha {
Opaque,
Mask,
Blend,
}
impl Alpha {
pub fn of(mode: AlphaMode) -> Self {
match mode {
AlphaMode::Opaque => Self::Opaque,
AlphaMode::Mask { .. } => Self::Mask,
AlphaMode::Blend { .. } => Self::Blend,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) struct Variant {
pub cull: Cull,
pub alpha: Alpha,
pub deformed: bool,
}
impl Variant {
pub const COUNT: usize = 18;
pub fn index(self) -> usize {
(usize::from(self.deformed) * 3 + self.cull as usize) * 3 + self.alpha as usize
}
}