Repository navigation
Decompile merged meshes without losing them; repair and compile refuse lost triangles - #109
Merged
Merged
Conversation
…e lost triangles Some binaries draw meshes of one texture as one: the receiving mesh's render index list holds its own faces' triangles and copies of the others' (the donors, render 0 with an empty list). The game draws index lists, so the model looks whole; the decompiler read only faces, so the copies were lost and the donors written invisible. Layonara's tin01 tiles lost their lower walls after a repair that way (nwn-module#476). The decompiler now reads each mesh's index list and writes every donor whose triangles are all among a receiver's copies with render 1, which draws the same triangles as a mesh of its own. Triangles are matched by texture coordinates and side lengths (within 1 mm), so placement doesn't matter; untextured meshes match by shape. Each receiver gets a note; a donor an animation moves gets one saying it now moves; triangles no donor accounts for get a warning, and repair, compile and check --fix refuse to write the model unless --force is given (decompile keeps its own --force). 1,015 base-game binaries and 342 in Layonara's haks hold merged meshes; all of them are put back fully. Round-tripped (decompile, compile), they draw every triangle the originals draw except degenerate ones; with v4.12.0 the same round trip lost 47% (game) and 34% (haks) of the drawn triangles. Ported to python/; parity and Go-vs-Python warnings and notes pass on the game's 25,597 binaries and the 342 haks models.
This was referenced Oct 21, 2026
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 the cause of layonara/nwn-module#476: walls lost their lower parts after
cleanmodels repair(haks PR #23).Cause. Some binaries draw meshes of one texture as one. The receiving mesh's render index list (MDL-BIN-049) holds its own faces' triangles plus copies of the others' (the donors). Each donor keeps its faces, but has render 0 and an empty index list. The game draws index lists, so the model looks whole. The decompiler read only faces, so the copies were lost and the donors were written invisible.
Fix.
pkg/mdl/binary_merged.go). It writes every donor whose triangles are all among a receiver's copies with render 1, which draws the same triangles as a mesh of its own.dag_*placeables.repair,compileandcheck --fixrefuse to write the model unless--forceis given.decompilekeeps its own--force. A test now checks that every subcommand's flags register.python/.Scale. 1,015 base-game binaries (tno01, tts02, ttf02 and tcn01 tiles first) and 342 in Layonara's haks hold merged meshes. All of them are put back fully, with no triangles lost.
Round trip (decompile, then compile) compared with the original, by the triangles drawn in world space:
Testing.
parity_test.pyon the game's 25,597 binaries) passes. Go and Python give the same warnings and notes on all of them, and the same ASCII, warnings and notes on the 342 haks models.Spec: plenarius/nwn-mdl-spec MDL-BIN-053 (separate PR).