Skip to content

Commit

Permalink
Merge pull request #4901 from AdamCichocki/JoinVerticesProcessUsedVer…
Browse files Browse the repository at this point in the history
…ticesMask

Optimized usedVertexIndices in JoinVerticesProcess by using bitmask instead of unordered_set
  • Loading branch information
kimkulling committed Jan 31, 2023
2 parents e4c8564 + 5caae1a commit b55e29b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions code/PostProcessing/JoinVerticesProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b55e29b

Please sign in to comment.