Repository navigation
feat: P3D section faces and UVs, PAA blocks for GPUs - #45
Merged
Merged
Conversation
- LodSection: the block after the stages (version 67 and up) is a flag and 11 floats, not a 4x3 matrix of 12. Reading 12 broke the next section: 34 of Arma 3's 6,682 models failed to load (collimator sights such as the ACO). All of them load now. The floats are kept as `unk_floats`, the flag was always 0 or 1. - Lod::section_faces: the face ranges of the sections. Their offsets count bytes, with a face's vertex count and each vertex index taking the size of an index (4 bytes from version 69, 2 before). Checked against the test models (versions 40 to 75) and all of Arma 3. - UVSet::uvs: the coordinates per vertex, from the discretized i16 values (version 45 and up) or the floats before. - Paa::from_reader_blocks: keeps DXT1 and DXT5 mipmaps as BC1 and BC3 blocks instead of decoding them, to upload them to a GPU as they are. - No more "Lod Index" printed for every LOD read. - Test data: rv-test-data-part-4.7z with the ACO sight.
Codecov Report❌ Patch coverage is
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes ODOL sections that failed to load, and adds what a renderer needs from P3D models and PAA textures: section face ranges, decoded UVs and BC blocks for GPUs. With this change all 6,682 models of Arma 3 load (v73), up from 6,648. The P3D viewer in arma.tools is built on it.
Format
LodSection, version 67 and up: after the stages comes ani32flag and, when it is set, 11f32s, not a 4x3 matrix of 12. Reading 12 put the next section 4 bytes off: 34 models failed with "failed to fill whole buffer" instages, all of them collimator sights and weapons carrying them (ACO, ARCO, ...). The flag was always 0 or 1. What the floats mean is not known.face_lower_indexandface_upper_indexare byte offsets into the faces, with a face's vertex count and each of its vertex indices taking the size of an index: 4 bytes from version 69 (a triangle takes 16, a quad 20), 2 bytes before. Sections follow each other without gaps and cover all faces. Checked on every LOD of the test models (versions 40 to 75) and of Arma 3.API
Lod::section_faces(): per section, its faces as a range ofLod::faces.UVSet::uvs(): one[u, v]per vertex. Discretized sets (version 45 and up) map theiri16s ontomin..=max(inf64, thef32result was off by 1e-4 on wide ranges), older ones aref32s, default-filled sets repeat their value.Paa::from_reader_blocks(): likefrom_reader, but DXT1 and DXT5 mipmaps stay BC1 and BC3 blocks (LZO decompressed) instead of being decoded to RGBA, to upload them to a GPU as they are. Other formats decode as before.LodSection::unk_matrix_exists/unk_matrix: TransformMatrixare nowhas_unk_floats/unk_floats: Option<[f32; 11]>.read_lodsno longer printsLod Index: nfor every LOD.Test data
rv-test-data-part-4.7zholds the ACO sight (acco_aco_f.p3d, 70 KB packed), encrypted like the other parts.aff-test-data-setupnow extracts parts 1 to 4. A checkout that already extracted the test data won't get the new file: the setup skips non-empty test data folders, so deletetests/real_virtuality/test-dataor extract part 4 by hand.Testing
All tests pass. New:
section_faces: every LOD of every test model is covered by its sections without gaps.uvs: every UV set has a coordinate per vertex, inside its range for discretized sets. Both kinds occur in the test models.section_unk_floats: the ACO loads, has sections with the 11 floats, and its section ranges resolve.paa_test::blocks: the blocks of DXT1 and DXT5 PAAs have the BC size of each mipmap and decode to whatfrom_readerreturns.blocks_other_formats: ARGB4444 decodes as before.Outside the tests, all 6,682 P3Ds of the Arma 3
Addonsfolder load and their section ranges resolve.