Skip to content

Conversation

@maxim-productengine
Copy link
Contributor

Use mesh optimizer to sort indices by vertex order to improve splits.


// remap 32 bit into multiple 16 bit ones
std::vector<U32> remap(faceVertices.size());
size_t vertex_count = meshopt_generateVertexRemap(&remap[0], &indices_32[0], indices_32.size(), &faceVertices[0], faceVertices.size(), sizeof(LLVolumeFace::VertexData));
Copy link
Contributor

@akleshchev akleshchev Jul 8, 2025

Choose a reason for hiding this comment

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

Please, consider leaving a comment like 'generateVertexRemap attempts to leave no gaps in the resulting sequence which should reduce amount of dupplicated indices after spliting'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, I'll add a comment.

std::vector<U32> optimized_indices(indices_32.size());
meshopt_remapIndexBuffer(&optimized_indices[0], &indices_32[0], indices_32.size(), &remap[0]);

// Sort indices to improve mesh splits
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it actually sorts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it actually reorders indices.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that it reorders, but does it apply distance or topology based sorting?

@maxim-productengine maxim-productengine merged commit 5a8b94b into project/gltf_mesh_import Jul 9, 2025
7 checks passed
@maxim-productengine maxim-productengine deleted the maxim/gltf_mesh_import-4324 branch July 9, 2025 10:03
@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Models with slightly more than or equal to 65535 vertices are bumped to considerably higher vertices in importer

4 participants