Merge pull request #4901 from AdamCichocki/JoinVerticesProcessUsedVerticesMask

Optimized usedVertexIndices in JoinVerticesProcess by using bitmask instead of unordered_set
pull/4899/head^2
Kim Kulling 2023-01-31 21:25:46 +01:00 committed by GitHub
commit b55e29b915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -264,12 +264,12 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
// We should care only about used vertices, not all of them
// (this can happen due to original file vertices buffer being used by
// multiple meshes)
std::unordered_set<unsigned int> usedVertexIndices;
usedVertexIndices.reserve(pMesh->mNumVertices);
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
std::vector<bool> usedVertexIndicesMask;
usedVertexIndicesMask.resize(pMesh->mNumVertices, false);
for (unsigned int a = 0; a < pMesh->mNumFaces; a++) {
aiFace& face = pMesh->mFaces[a];
for( unsigned int b = 0; b < face.mNumIndices; b++) {
usedVertexIndices.insert(face.mIndices[b]);
for (unsigned int b = 0; b < face.mNumIndices; b++) {
usedVertexIndicesMask[face.mIndices[b]] = true;
}
}
@ -335,7 +335,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
int newIndex = 0;
for( unsigned int a = 0; a < pMesh->mNumVertices; a++) {
// if the vertex is unused Do nothing
if (usedVertexIndices.find(a) == usedVertexIndices.end()) {
if (!usedVertexIndicesMask[a]) {
continue;
}
// collect the vertex data