I've written an x parser which reads datas to a hiearchy. I read positions, position indices, normals, normal indices and texcoords per mesh. I have to "mix" these datas to create an array from my vertex structure.

It is the slowest pass of my parser. I downloaded the crytek-boosted sponza model (which is ~300k poly), worked a little with it and exported to a text x file (it is ~20mb), and the "mesh-creating" pass was impossible slow... I am wondering if anyone can help me. Here is the source:

int positionIndex = 0; Vector3 normal = Vector3::Zero; int size = m_PositionIndices.size(); for (int i = 0; i != size; i++) { positionIndex = m_PositionIndices[i]; normal = m_Normals[m_NormalIndices[i]]; //position, texcoord, normal, tangent, binormal VertexNTB vertex = VertexNTB(m_Positions[positionIndex], m_Texcoords[positionIndex], normal, Vector3::Zero, Vector3::Zero); //vertex exist? bool exist = false; int vertSize = m_Vertices.size(); for (int k = 0; k != vertSize; k++) { //vertex exist if (m_Vertices[k] == vertex) { exist = true; m_VertexIndices.push_back(k); break; } } //if vertex exist if (exist) { //move to next index continue; } //create vertex and add new index m_Vertices.push_back(vertex); m_VertexIndices.push_back(m_Vertices.size()-1); }

Thanks for your help, and sorry for my bad english.