diff options
| author | Valentin Popov <valentin@popov.link> | 2026-02-19 12:46:23 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-02-19 12:46:23 +0300 |
| commit | efab61a45c8837d3c2aaec464d8f6243fecb7a38 (patch) | |
| tree | b511f1cab917f5f2931d6bc2ae2676b553bb8ef9 /crates/texm/src/lib.rs | |
| parent | 0d7ae6a017b8b2bf26c5c14c39cb62b599e8262d (diff) | |
| download | fparkan-efab61a45c8837d3c2aaec464d8f6243fecb7a38.tar.xz fparkan-efab61a45c8837d3c2aaec464d8f6243fecb7a38.zip | |
feat(render-core): add default UV scale and refactor UV mapping logic
- Introduced a constant `DEFAULT_UV_SCALE` for UV scaling.
- Refactored UV mapping in `build_render_mesh` to use the new constant.
- Simplified `compute_bounds` functions by extracting common logic into `compute_bounds_impl`.
test(render-core): add tests for rendering with empty and multi-node models
- Added tests to verify behavior when building render meshes from models with no slots and multiple nodes.
- Ensured UV scaling is correctly applied in tests.
feat(render-demo): add FOV argument and improve error handling
- Added a `--fov` command-line argument to set the field of view.
- Enhanced error messages for texture resolution failures.
- Updated MVP computation to use the new FOV parameter.
fix(rsli): improve error handling in LZH decompression
- Added checks to prevent out-of-bounds access in LZH decoding logic.
refactor(texm): streamline texture parsing and decoding tests
- Created a helper function `build_texm_payload` for constructing test payloads.
- Added tests for various texture formats including RGB565, RGB556, ARGB4444, and Luminance Alpha.
- Improved error handling for invalid TEXM headers and mip bounds.
Diffstat (limited to 'crates/texm/src/lib.rs')
| -rw-r--r-- | crates/texm/src/lib.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/texm/src/lib.rs b/crates/texm/src/lib.rs index 5d8b594..7a166f3 100644 --- a/crates/texm/src/lib.rs +++ b/crates/texm/src/lib.rs @@ -36,6 +36,7 @@ impl PixelFormat { match self { Self::Indexed8 => 1, Self::Rgb565 | Self::Rgb556 | Self::Argb4444 | Self::LuminanceAlpha88 => 2, + // Parkan stores format 888 as 32-bit RGBX in texture payloads. Self::Rgb888 | Self::Argb8888 => 4, } } @@ -173,14 +174,8 @@ pub fn parse_texm(payload: &[u8]) -> Result<Texture> { offset: level_offset, size: level_size, }); - w = w.max(1) >> 1; - h = h.max(1) >> 1; - if w == 0 { - w = 1; - } - if h == 0 { - h = 1; - } + w = (w >> 1).max(1); + h = (h >> 1).max(1); } let page_rects = parse_page_tail(payload, offset)?; @@ -240,7 +235,8 @@ pub fn decode_mip_rgba8(texture: &Texture, payload: &[u8], mip_index: usize) -> break; } let poff = usize::from(index).saturating_mul(4); - if poff + 3 >= palette.len() { + // Keep this form to accept the last palette item (index 255). + if poff + 4 > palette.len() { continue; } let out = i.saturating_mul(4); |
