Skip to content

Commit

Permalink
gltfpack: Add temporary command line option to disable mesh deduplica…
Browse files Browse the repository at this point in the history
…tion

In theory, deduplication should not result in any issues as any changes
only concern the internal file structure, and it should be beneficial in
most cases (and when it's penalizing draw call counts, existing options
provide enough control), but just in case we now can disable this
feature entirely using -mdd.

The goal is to remove this option in the future, it's just here in case
anyone reports issues in the wild.

Not running dedupMeshes means no mesh has geometry_duplicate flag set,
so no dedup related code activates.
  • Loading branch information
zeux committed Oct 6, 2024
1 parent 4cc9fb5 commit 82e0332
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gltf/gltfpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ static void process(cgltf_data* data, const char* input_path, const char* output
markAnimated(data, nodes, animations);

mergeMeshMaterials(data, meshes, settings);
dedupMeshes(meshes);
if (settings.mesh_dedup)
dedupMeshes(meshes);

for (size_t i = 0; i < meshes.size(); ++i)
detachMesh(meshes[i], data, nodes, settings);
Expand Down Expand Up @@ -427,7 +428,6 @@ static void process(cgltf_data* data, const char* input_path, const char* output
meshes.insert(meshes.end(), debug_meshes.begin(), debug_meshes.end());
#endif


filterEmptyMeshes(meshes); // some meshes may become empty after processing

QuantizationPosition qp = prepareQuantizationPosition(meshes, settings);
Expand Down Expand Up @@ -1186,6 +1186,7 @@ Settings defaults()
settings.rot_bits = 12;
settings.scl_bits = 16;
settings.anim_freq = 30;
settings.mesh_dedup = true;
settings.simplify_ratio = 1.f;
settings.simplify_error = 1e-2f;
settings.texture_scale = 1.f;
Expand Down Expand Up @@ -1323,6 +1324,11 @@ int main(int argc, char** argv)
{
settings.keep_attributes = true;
}
else if (strcmp(arg, "-mdd") == 0)
{
fprintf(stderr, "Warning: option -mdd disables mesh deduplication and is only provided as a safety measure; it will be removed in the future\n");
settings.mesh_dedup = false;
}
else if (strcmp(arg, "-mm") == 0)
{
settings.mesh_merge = true;
Expand Down
1 change: 1 addition & 0 deletions gltf/gltfpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ struct Settings
bool keep_extras;
bool keep_attributes;

bool mesh_dedup;
bool mesh_merge;
bool mesh_instancing;

Expand Down

0 comments on commit 82e0332

Please sign in to comment.