We accidentally computed scale using columns instead of rows, which led to
rotation affecting scale for non-uniform scale factors.
The adjusted implementation has been validated against cgltf node->matrix
function and appears to round trip within floating point precision and
modulo redundancy wrt scale sign that is inherent during reconstruction.
This fixes mesh instancing for scenes with non-uniform scale & rotation.
Before this change gltfack wasn't scene aware, and would process all
nodes regardless of which scene they come from.
With this change, we now output the same number of scenes that the input
file contained. When merging meshes and converting nodes to mesh instances,
the process is limited to cases where the mesh is not used in multiple
scenes.
Fixes#184
The behavior of -kn is still the same as it used to be - it keeps named
nodes and maintains the transform effects of these nodes on the rest of
the scene, including prohibiting mesh merging for attached meshes. The
setting was renamed to keep_nodes to reflect that better.
The behavior of -km is now matching that for materials - it keeps named
materials, prevents merging them with other materials and keeps them in
the file.
We decompose each node's transform into T/R/S and compress them
individually using the same format and settings we use for animation
data.
Note that we are explicitly disabling cross-mesh merging in presence of
instancing - in theory it's possible to use it but it doesn't seem like
it's very important to do so...
Instead of an optional node pointer we now have an array of nodes.
When merging, the rule is that the node arrays must be pairwise
compatible with each other wrt transforms. This hopefully will maintain
mergeability for common cases without requiring splitting mesh sets.
The rest of the code is adjusted in a trivial manner; when writing node
attachments, we need to write a new quantization node for each target
node because a node can only have one parent.