Repository navigation
cleanmodels v4.18.3
Compiling now follows the game's own compiler (nwmain-linux compilemodel) in five cases where v4.18.1 and v4.18.2 differed from it. Each rule was tested by compiling a probe model with the game; the probes and rules are in nwn-mdl-spec (plenarius/nwn-mdl-spec#33). Fixed in #149.
Two nodes with the same name (MDL-NODE-002)
A parent line, or an animation node, that names a node the model has twice now goes to the first one in tree order, as the game's FindMdlNode does. cleanmodels used to pick the nearer one, which moved parts: a horn on some weapons by 1.1 m, a ring on a ring model, a creature's forearm that stopped animating.
The decompiler also keeps a binary model's real parents now, and warns when no node order in the ASCII can reproduce them.
Danglymesh constraints (MDL-MESH-013)
When a compile merges or reorders a dangly mesh's vertices, each constraint now moves with its vertex. Before, the constraints stayed in source order whenever the vertex count didn't change, so the wrong parts swayed: a beard swung at the root and held still at the tip.
A second root node
When a model has more than one parent NULL node, the game keeps the last root and drops the earlier trees (it still counts their nodes). cleanmodels kept the first and dropped the rest, so a model whose geometry hung under the later root drew nothing.
A list given twice
- Vertex lists given twice: the second vertex lists are used, together with the first face list.
- A key list given twice on one node: the second one wins.
Before, the lists were added together, which drew extra overlapping triangles.
Face normals
Face normals are now made unit length the same way the game does it. This changes the bytes of most compiled models by one unit in the last place (ulp), but nothing looks different. Vertex normals were already the game's.
Not changed
When a vertex has more than four skin weights, the game keeps the first four as written. cleanmodels keeps the four heaviest and renormalises them, on purpose (see RELEASE-v4.md, "Smart skin-bone truncation"). This is now listed under Known divergences in COMPILE.md (MDL-SKIN-002).
Result
Layonara compiled every hak model and compared it with today's: on the 1,700 affected models, every dangly, duplicate-name, doubled-list and second-root difference is gone. On 13 real models compiled by the game itself, v4.18.3 shows no difference the spec requires to match (v4.18.1 had one on 11).
The Python port has the same changes (PORTED_FROM = "v4.18.3").