Revert "feat(engine): per-theme nearest-sampling opt-in for pixel-art themes"

This reverts commit 17e3112502.
This commit is contained in:
funman300
2026-05-06 19:38:13 -07:00
parent aad8bb9c83
commit e41def8c89
7 changed files with 0 additions and 54 deletions
-1
View File
@@ -2681,7 +2681,6 @@ mod tests {
author: "test".into(),
version: "0".into(),
card_aspect: (2, 3),
pixel_art: false,
},
faces: HashMap::<CardKey, Handle<bevy::image::Image>>::new(),
back: theme_back.clone(),
-1
View File
@@ -2458,7 +2458,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (2, 3),
pixel_art: false,
},
}],
});
-1
View File
@@ -478,7 +478,6 @@ mod tests {
author: "Tester".into(),
version: "1.0.0".into(),
card_aspect: (2, 3),
pixel_art: false,
}
}
-1
View File
@@ -87,7 +87,6 @@ mod tests {
author: "Solitaire Quest".into(),
version: "1.0.0".into(),
card_aspect: (2, 3),
pixel_art: false,
}
}
-16
View File
@@ -164,18 +164,6 @@ pub struct ThemeMeta {
/// the artwork's intended proportions when the player resizes the
/// window. Standard playing cards are 2:3.
pub card_aspect: (u32, u32),
/// Whether this theme's art should render with nearest-neighbor
/// (point) sampling instead of Bevy's default bilinear filtering.
///
/// Set `true` for pixel-art themes (each face is a small grid of
/// hand-placed pixels) so non-integer scales preserve crisp edges.
/// Leave `false` for SVG-rasterised or photographic art where
/// bilinear smooths downscale aliasing.
///
/// `#[serde(default)]` keeps older manifests (which pre-date this
/// field) loading cleanly with the smooth-sampling default.
#[serde(default)]
pub pixel_art: bool,
}
/// Errors surfaced by [`ThemeMeta::validate`].
@@ -283,7 +271,6 @@ mod tests {
author: "Solitaire Quest".into(),
version: "1.0.0".into(),
card_aspect: (2, 3),
pixel_art: false,
};
assert_eq!(meta.validate(), Ok(()));
}
@@ -296,7 +283,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (2, 3),
pixel_art: false,
};
assert_eq!(meta.validate(), Err(ThemeMetaError::EmptyId));
}
@@ -309,7 +295,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (2, 3),
pixel_art: false,
};
assert!(matches!(
meta.validate(),
@@ -325,7 +310,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (0, 3),
pixel_art: false,
};
assert_eq!(meta.validate(), Err(ThemeMetaError::ZeroNumerator));
meta.card_aspect = (2, 0);
-32
View File
@@ -187,7 +187,6 @@ fn sync_card_image_set_with_active_theme(
themes: Res<Assets<CardTheme>>,
mut card_image_set: Option<ResMut<CardImageSet>>,
mut state_events: MessageWriter<StateChangedEvent>,
mut images: ResMut<Assets<Image>>,
) {
let Some(active) = active else { return };
let active_id = active.0.id();
@@ -208,9 +207,6 @@ fn sync_card_image_set_with_active_theme(
let Some(theme) = themes.get(&active.0) else {
return;
};
if theme.meta.pixel_art {
apply_nearest_sampler_to_theme_images(theme, &mut images);
}
let Some(card_image_set) = card_image_set.as_deref_mut() else {
return;
};
@@ -218,32 +214,6 @@ fn sync_card_image_set_with_active_theme(
state_events.write(StateChangedEvent);
}
/// Overrides the texture sampler on every face + back `Image` in
/// `theme` to nearest-neighbor (point) sampling, so non-integer
/// downscales preserve crisp pixel-grid edges instead of bilinear
/// blur.
///
/// Called only for themes whose manifest sets `meta.pixel_art = true`.
/// SVG-rasterised themes leave the field at its `false` default and
/// keep Bevy's smooth-downscale sampler — pixel-art and SVG paths use
/// different filters from the same loader pipeline because they
/// optimise for different artwork tradeoffs.
fn apply_nearest_sampler_to_theme_images(
theme: &CardTheme,
images: &mut Assets<Image>,
) {
use bevy::image::{ImageSampler, ImageSamplerDescriptor};
let nearest = ImageSampler::Descriptor(ImageSamplerDescriptor::nearest());
for handle in theme.faces.values() {
if let Some(image) = images.get_mut(handle) {
image.sampler = nearest.clone();
}
}
if let Some(image) = images.get_mut(&theme.back) {
image.sampler = nearest;
}
}
/// Pure helper that copies the theme's image handles into the
/// `[suit][rank]` face matrix and into the dedicated `theme_back`
/// slot. Split out so it can be unit-tested without spinning up a
@@ -489,7 +459,6 @@ mod tests {
author: "test".into(),
version: "0".into(),
card_aspect: (2, 3),
pixel_art: false,
},
faces: HashMap::new(),
back: Handle::default(),
@@ -754,7 +723,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (2, 3),
pixel_art: false,
},
}],
});
-2
View File
@@ -118,7 +118,6 @@ fn default_entry() -> ThemeEntry {
author: "Solitaire Quest".to_string(),
version: "1.0".to_string(),
card_aspect: (2, 3),
pixel_art: false,
},
}
}
@@ -345,7 +344,6 @@ mod tests {
author: "x".into(),
version: "x".into(),
card_aspect: (2, 3),
pixel_art: false,
},
});