Original Post
I want to speed up my 3ds max exporter by having a faster way of determining if a vertex is already present.
Currently my algorithm is something like this:
Obviously looping through m_VertexList each time is the bottleneck but I'm not sure of a better way to do it. I'd use a map or something but I need to compare 3 variables to determine uniqueness.
Currently my algorithm is something like this:
for (int faceId = 0; faceId < mesh.getNumFaces(); faceId++) { // Iterate over each vertex for this face for ( int i = 0; i < 3; ++i ) { // We need to check to see if the vertex/normal/texcoord combo already exists in the list uint myIndex = -1; // Check to see if this vertex is already present for (uint c = 0; c < bsMesh.m_VertexList.size(); ++c) { if (bsMesh.m_VertexList[c].Matches(uniVert.pos, uniVert.normal, uniVert.uv)) { // Existing entry -- remember the index myIndex = c; break; } } // if vertex doesn't exist we add it if (myIndex == -1) { // add vertex, etc } }}Obviously looping through m_VertexList each time is the bottleneck but I'm not sure of a better way to do it. I'd use a map or something but I need to compare 3 variables to determine uniqueness.