There are to major ways to even further optimize nifs:
- detection and removal of zero-scaled meshes (or zero-scaled NiNodes hosting regular-shaped meshes)
- mesh cloning. That is a trick I've seen some use with meshes that have repetitive shapes. If the script detect two or more identical shapes, it could direct all the NiTriStrips/NiTriShape nodes to use single NiTriStripsData/NiTriShapeData and remove the rest. Even better (though, highly unlikely) would be detection of identical shapes, but at different rotations/positions, and using single shape, but with modified translation/rotation to match the original.
- ignoring the names of NiMaterialProperty nodes when combining them (this could extend to NifSkoper as well). I don't think that the names are relevant to the game in any way (correct me, if I'm wrong)
Thanks for these good suggestions.
Mesh clone merging is actually already implemented (if you find a nif where it doesn't work, let me know!).
Merging NiMaterialProperties with different names but everything else the same should also already work... hmm or maybe I only implemented this for the blender nif scripts. Hah, yes, this would be something new to add, and easy too, since I've done it already elsewhere.
Do you have an example of a zero-scaled mesh (just to make sure I know what you are talking about)?
Cloning already implemented? Cool.
I've attached a file as an example.
Here NiTriStrips named "##SRLever:0" has scale set to 0, meaning it is goot to go. There are (but I can't find any examples right now) meshes that have NiNodes with scale set to 0, which is pretty much the same (not too smart) way to make a part of a mesh gone. I can't find any reason why would such mesh exist in the nif anyhow. I don't think the scale can be changed, except with embedded animation.
Sorry for not replying earlier.
I'll have a look at your suggestion regarding scale. But could you attach the file again? Somehow it did not get attached earlier apparently.
Example
Here is a perfect example of what zero-scaled meshes can be like. My guess is that those were vanilla meshes with extra parts, but someone haven't removed the parts properly. Instead, they set the scale to 0.
In this file there is ##MagRelease (NiNode, block 34) and ##Trigger:1 (NiTriStrips, block 46)
MagRelease is zero-scaled as node, meaning complete branch is nothing but bloat.
Trigger:1 is zero-scaled as mesh, but since it is the only child to the parenting node, the node is also obsolete. (The case would be different if there were non-zero scaled meshes as children ti that node).
There was one nif file with some mesh scale set to -1, making the mesh in question look inverted, but the mesh still was a bloat, since it wasn't visible.
I guess, the only check there should be preformed is whether or not there are embedded transformations that are changing the scales of those nodes/meshes.
Removal of zero scaled nodes is now implemented (not yet part of the standard optimization spell, will do so when it has seen a lot more testing).
http://github.com/amorilia/pyffi/commit/273d3064fb09a303810d98702047715f538e2fdb
Merging duplicate materials with different names is now implemented as well:
http://github.com/amorilia/pyffi/commit/d2d8dfb92d61af524c10045d0cec14e2b9959a85
Closing...
Beta installer which includes this is available: http://niftools.sourceforge.net/forum/viewtopic.php?f=32&t=2759