Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gltfpack: Take account of primitive extras #802

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

JulienIcon
Copy link
Contributor

@JulienIcon JulienIcon commented Nov 13, 2024

GLTF format allows extras in primitives, gltfpack ignore it and merge primitives even when extras are present and different.

Fix #808

gltf/mesh.cpp Outdated
@@ -238,6 +238,9 @@ static bool canMergeMeshes(const Mesh& lhs, const Mesh& rhs, const Settings& set
if (lhs.streams.size() != rhs.streams.size())
return false;

if (lhs.extras.data && rhs.extras.data && strcmp(lhs.extras.data, rhs.extras.data))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison should only work if keep_extras is set. Also, this will not work if one of the mesh has empty extras. See material.cpp/areExtrasEqual for the correct way to implement this.

@zeux
Copy link
Owner

zeux commented Nov 20, 2024

Also missing some support in deduplication, probably enough to disable deduplication by returning false from canDedupMesh - again, only if keep_extras is set.

@JulienIcon
Copy link
Contributor Author

JulienIcon commented Nov 21, 2024

I take account of your comments but I also added :

  • writing, only if keep_extras is set, the scene extras
  • writing the mesh name

@zeux
Copy link
Owner

zeux commented Nov 21, 2024

I'm not interested in merging mesh name preservation, as meshes are very ephemeral and they get reconstructed by many different optimizations in gltfpack.

Scene extras are fine I guess. I don't see why they should be part of this PR, but it's just a couple of lines so maybe it's fine.

@JulienIcon
Copy link
Contributor Author

I'm not interested in merging mesh name preservation, as meshes are very ephemeral and they get reconstructed by many different optimizations in gltfpack.

Scene extras are fine I guess. I don't see why they should be part of this PR, but it's just a couple of lines so maybe it's fine.

Ok 👍 I removed the code related to saving mesh name.

@zeux zeux merged commit b243775 into zeux:master Nov 22, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gltfpack: Support primitive extras when -ke is specified
2 participants