Fix de-indexed head LOD import and safe vertex overwrite - #6
Open
Puderzo wants to merge 1 commit into
Open
Conversation
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.
PR: Fix de-indexed head LOD import and safe overwrite for external vertex buffers
Summary
This PR improves support for Star Wars Outlaws head meshes that use external type-12 vertex data, especially head LODs that are stored as de-indexed triangle lists.
Some head LODs, such as
head_mesh_LOD1andhead_mesh_LOD2, are stored withvertex_count == index_count == triangle_count * 3. When imported directly, Blender creates one isolated vertex per triangle corner. This makes the mesh appear to have more vertices than higher-detail LODs, prevents normal smooth shading from working properly, and makes the mesh difficult to edit safely.This PR detects those de-indexed LODs during import, merges identical positions into shared Blender topology for editing, and preserves the original source vertex-buffer order so Overwrite Vertices can write the edited positions back safely.
Why this is needed
Head meshes appear to use a special type-12 layout with external vertex data referenced by
data_y_offset.For example, tested head meshes showed patterns like:
head_mesh_LOD0data_y_offsetused for vertex positionshead_mesh_LOD1Before this change, imported de-indexed LODs behaved like triangle soups in Blender. Even if the visible LOD was lower detail than LOD0, the raw Blender vertex count could appear much higher because every triangle corner was imported as a separate vertex.
Also, full export is currently unsafe for LODs using external type-12 vertex data, because the current full export path rebuilds the normal mesh stream but does not relocate or update the external
data_y_offsetvertex buffer. This can leave the header pointing to invalid or missing data and causes re-import failures.What changed
Import
Detects de-indexed LODs where:
Merges identical vertex positions into shared Blender topology.
Preserves UVs as per-corner loop data.
Preserves a source vertex index per Blender face corner using a custom mesh attribute:
Remaps bone weights so deduplicated Blender vertices receive valid weights from their original source vertices.
Skips custom normal import when
normals_stride == 0, avoiding bogus custom normals from a non-existent normal stream.Overwrite Vertices
SWOMT_source_vertex_index..mmbstructure and offsets to remain intact.Export safety
data_y_offset.UI
rawsuffix.Tested workflows
Tested with head mesh assets using external type-12 vertex data.
head_mesh_LOD1Verified:
Result:
head_mesh_LOD0Verified:
Result:
Known limitation
This PR does not implement full export support for external type-12 vertex data.
Full export for these LODs would require relocating or rebuilding the external vertex data blocks and updating all related offsets, including
data_y_offsetand related type-12 metadata. Until that is implemented, Overwrite Vertices is the safe supported workflow for these LODs.Recommended workflow for affected head LODs
.mmbto verify the result.Do not use full Export for LODs that use external type-12 vertex data.