Revert "use unordered_set to accelerate the vertix merging"
This reverts commit 0ffb91fbf1
.
pull/4527/head
parent
0ffb91fbf1
commit
5d8b1649a4
|
@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/TinyFormatter.h>
|
#include <assimp/TinyFormatter.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -258,7 +259,7 @@ return seed;
|
||||||
template<>
|
template<>
|
||||||
struct std::equal_to<Vertex> {
|
struct std::equal_to<Vertex> {
|
||||||
bool operator()(const Vertex &lhs, const Vertex &rhs) const {
|
bool operator()(const Vertex &lhs, const Vertex &rhs) const {
|
||||||
return lhs.position.Equal(rhs.position);
|
return areVerticesEqual(lhs, rhs, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
|
@ -333,9 +334,10 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices);
|
uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unordered_set<Vertex> m;
|
std::unordered_map<Vertex,int> vertex2Index;
|
||||||
m.reserve(pMesh->mNumVertices);
|
vertex2Index.reserve(pMesh->mNumVertices);
|
||||||
// Now check each vertex if it brings something new to the table
|
// Now check each vertex if it brings something new to the table
|
||||||
|
int newIndex = 0;
|
||||||
for( unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
for( unsigned int a = 0; a < pMesh->mNumVertices; a++) {
|
||||||
if (usedVertexIndices.find(a) == usedVertexIndices.end()) {
|
if (usedVertexIndices.find(a) == usedVertexIndices.end()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -343,17 +345,22 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
|
|
||||||
// collect the vertex data
|
// collect the vertex data
|
||||||
Vertex v(pMesh,a);
|
Vertex v(pMesh,a);
|
||||||
auto it = m.find(v);
|
auto it = vertex2Index.find(v);
|
||||||
if (it == m.end()) {
|
if (it == vertex2Index.end()) {
|
||||||
m.insert(v);
|
vertex2Index[v] = newIndex;
|
||||||
|
replaceIndex[a] = newIndex++;
|
||||||
uniqueVertices.push_back(v);
|
uniqueVertices.push_back(v);
|
||||||
if (hasAnimMeshes) {
|
if (hasAnimMeshes) {
|
||||||
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
||||||
Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a);
|
Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a);
|
||||||
uniqueAnimatedVertices[animMeshIndex].push_back(aniMeshVertex);
|
uniqueAnimatedVertices[animMeshIndex].push_back(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
replaceIndex[a] = it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue