aboutsummaryrefslogtreecommitdiff
path: root/crates/render-core/src/tests.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-02-19 04:19:18 +0300
committerValentin Popov <valentin@popov.link>2026-02-19 04:19:18 +0300
commita281ffa32ea615670d369503692f057b2dc60e6f (patch)
tree321bcc1bfc489e2e7d0ff10dae620864ab08d054 /crates/render-core/src/tests.rs
parent18d4c6cf9fabc18282b29d103c8d30024f66e49b (diff)
downloadfparkan-a281ffa32ea615670d369503692f057b2dc60e6f.tar.xz
fparkan-a281ffa32ea615670d369503692f057b2dc60e6f.zip
feat: Enhance model and texture loading with improved error handling and new features
- Introduced `LoadedModel` and `LoadedTexture` structs for better encapsulation of model and texture data. - Added functions to load models and textures from archives, including support for resolving textures based on materials and wear entries. - Implemented error handling for missing textures, materials, and wear entries. - Updated the rendering pipeline to support texture loading and binding, including command-line arguments for texture customization. - Enhanced the `texm` crate with new decoding capabilities for various pixel formats, including indexed textures. - Added tests for texture decoding and loading to ensure reliability and correctness. - Updated documentation to reflect changes in the material and texture resolution process.
Diffstat (limited to 'crates/render-core/src/tests.rs')
-rw-r--r--crates/render-core/src/tests.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/crates/render-core/src/tests.rs b/crates/render-core/src/tests.rs
index 9c5eb5d..22103c6 100644
--- a/crates/render-core/src/tests.rs
+++ b/crates/render-core/src/tests.rs
@@ -74,9 +74,17 @@ fn build_render_mesh_for_real_models() {
if !mesh.vertices.is_empty() {
meshes_non_empty += 1;
}
- if compute_bounds(&mesh.vertices).is_some() {
+ if compute_bounds_for_mesh(&mesh.vertices).is_some() {
bounds_non_empty += 1;
}
+ for vertex in &mesh.vertices {
+ assert!(
+ vertex.uv0[0].is_finite() && vertex.uv0[1].is_finite(),
+ "UV must be finite for '{}' in {}",
+ entry.meta.name,
+ archive_path.display()
+ );
+ }
}
}
@@ -99,3 +107,25 @@ fn compute_bounds_handles_empty_and_non_empty() {
assert_eq!(bounds.0, [-2.0, -1.0, 0.5]);
assert_eq!(bounds.1, [1.0, 5.0, 9.0]);
}
+
+#[test]
+fn compute_bounds_for_mesh_handles_empty_and_non_empty() {
+ assert!(compute_bounds_for_mesh(&[]).is_none());
+ let bounds = compute_bounds_for_mesh(&[
+ RenderVertex {
+ position: [1.0, 2.0, 3.0],
+ uv0: [0.0, 0.0],
+ },
+ RenderVertex {
+ position: [-2.0, 5.0, 0.5],
+ uv0: [0.2, 0.3],
+ },
+ RenderVertex {
+ position: [0.0, -1.0, 9.0],
+ uv0: [1.0, 1.0],
+ },
+ ])
+ .expect("bounds expected");
+ assert_eq!(bounds.0, [-2.0, -1.0, 0.5]);
+ assert_eq!(bounds.1, [1.0, 5.0, 9.0]);
+}