#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum LightmapData {
NonDirectional {
radiance: crate::ids::TextureId,
},
DominantDirection {
radiance: crate::ids::TextureId,
direction: crate::ids::TextureId,
},
AmbientOcclusion {
occlusion: crate::ids::TextureId,
},
Shadowmask {
radiance: crate::ids::TextureId,
shadowmask: crate::ids::TextureId,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum LightmapMode {
Replace,
Add,
AmbientOcclusion,
Subtractive,
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LightmapPlacement {
pub layer: u32,
pub scale_bias: [f32; 4],
}
impl LightmapPlacement {
pub const WHOLE: LightmapPlacement = LightmapPlacement {
layer: 0,
scale_bias: [1.0, 1.0, 0.0, 0.0],
};
pub fn new(layer: u32, scale_bias: [f32; 4]) -> Self {
Self { layer, scale_bias }
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LightmapPlacementId(std::num::NonZeroU32);
impl LightmapPlacementId {
pub fn from_index(index: usize) -> Self {
let n = u32::try_from(index)
.ok()
.and_then(|i| i.checked_add(1))
.expect("lightmap placement index out of range");
Self(std::num::NonZeroU32::new(n).expect("nonzero by construction"))
}
pub fn index(self) -> usize {
self.0.get() as usize - 1
}
}
impl Default for LightmapPlacement {
fn default() -> Self {
Self::WHOLE
}
}