Skip to content

Commit

Permalink
support previous ssbh_data matl json
Browse files Browse the repository at this point in the history
  • Loading branch information
ScanMountGoat committed Jul 23, 2024
1 parent 7ea39ee commit 7e91cdd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ssbh_data/src/matl_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub struct MatlEntryData {
pub rasterizer_states: Vec<RasterizerStateParam>,
pub samplers: Vec<SamplerParam>,
pub textures: Vec<TextureParam>,
#[cfg_attr(feature = "serde", serde(default))]
pub uv_transforms: Vec<UvTransformParam>,
}

Expand Down Expand Up @@ -141,6 +142,7 @@ impl<T> ParamData<T> {

/// Data associated with a [Sampler].
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Debug, PartialEq, Clone)]
pub struct SamplerData {
Expand All @@ -155,9 +157,18 @@ pub struct SamplerData {
pub lod_bias: f32,
/// The amount of anisotropic filtering to used.
/// A value of [MaxAnisotropy::One] disables anisotropic filtering.
#[cfg_attr(feature = "serde", serde(deserialize_with = "parse_max_anisotropy"))]
pub max_anisotropy: MaxAnisotropy,
}

#[cfg(feature = "serde")]
fn parse_max_anisotropy<'de, D>(d: D) -> Result<MaxAnisotropy, D::Error>
where
D: serde::Deserializer<'de>,
{
serde::Deserialize::deserialize(d).map(|x: Option<_>| x.unwrap_or_default())
}

impl Default for SamplerData {
fn default() -> Self {
// Standard texture filtering and wrapping.
Expand Down Expand Up @@ -238,6 +249,7 @@ impl From<&SamplerData> for Sampler {

/// Data associated with a [BlendStateV15] or [BlendStateV16].
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct BlendStateData {
Expand Down

0 comments on commit 7e91cdd

Please sign in to comment.