Commit Graph

11 Commits

Author SHA1 Message Date
Arseny Kapoulkine ba8ffe2169 gltfpack: Fix code style in MaterialInfo
Not sure why this used the wrong field naming convention. Also do a
minor rename in NodeInfo.
2024-06-06 11:48:20 -07:00
Arseny Kapoulkine dc251b2708 gltfpack: Fix row vs column indexing in decomposeTransform
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.
2023-09-26 10:58:18 +02:00
Arseny Kapoulkine 366e3499e1 Run clang-format 2020-10-10 15:58:44 -07:00
Arseny Kapoulkine ffc314f862 gltfpack: Preserve scenes during processing
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
2020-10-10 15:33:58 -07:00
Arseny Kapoulkine 90eef6842b gltfpack: Rework -kn and -km to explicitly assume naming
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.
2020-05-14 09:54:46 -07:00
Arseny Kapoulkine 9ed71f2125 gltfpack: Clean up decomposeTransform
This change now uses a more concise branchless version of Mike Day's
quaternion construction and adds a few structural comments.
2020-05-12 23:09:53 -07:00
Arseny Kapoulkine 622088a4af gltfpack: Clear instances after mesh merging
Right now this is inconsequential since we don't allow merging meshes
with instances, but this may change in the future.

Also clang-format.
2020-05-12 18:02:02 -07:00
Arseny Kapoulkine e5e275f260 gltfpack: Initial instancing implementation
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...
2020-05-11 23:38:53 -07:00
Arseny Kapoulkine d6ad1cb206 gltfpack: Change Mesh to support multiple node attachments
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.
2020-05-11 21:18:48 -07:00
Arseny Kapoulkine d336582089 gltf: Run clang-format on all sources
Also cleanup gltfpack.cpp includes
2020-02-07 18:34:50 -08:00
Arseny Kapoulkine e530c499cc gltf: Move node-related functionality to node.cpp 2020-02-07 18:31:56 -08:00