Proverò anche in release.
Sono riuscito a farmi dare l'implementazione che sembrerebbe metterci solo 2 secondi. E' fatta in C#
Purtroppo nemmeno questo è codice compilabile. Sto cercando di capire un pò come fa.codice:protected static void Triangulize(Model3D model) { int totalVertices = 0; int strideSize = model.Stride; float[] vertexTemp = new float[strideSize]; List<float> newVerticesList = new List<float>(); List<int> newIndexList = new List<int>(); for (int i = 0; i < model.VertexCount; i++) { //per ogni vertice //salvo il vertice for (int j = 0; j < strideSize; j++) { vertexTemp[j] = model.Data[i * strideSize + j]; } //controlla se già esiste int currentVertex = -1; for (int j = 0; j < totalVertices; j++) { //confronta il vertice attuale con quelli già inseriti bool equal = true; for (int k = 0; k < strideSize; k++) { if (Math.Abs(vertexTemp[k] - newVerticesList[j * strideSize + k])<epsilon) { equal = false; break; } } if (equal) { currentVertex = j; break; } } if (currentVertex == -1) { //nuovo vertice, aggiungere newIndexList.Add(totalVertices); totalVertices++; for (int j = 0; j < strideSize; j++) newVerticesList.Add(vertexTemp[j]); } else { //il vertice già esiste, aggiungere solo l'indice newIndexList.Add(currentVertex); } } model.Data.Clear(); model.Data.AddRange(newVerticesList); model.IndexData.Clear(); model.IndexData.AddRange(newIndexList); }

Rispondi quotando