@Mattlekim wrote:
Hi everyone I am having issues with my algorithm for indexing my vertexs.
Here is my code.
public void IndexAllVertexs() { if (HaveIndexsVertexs) return; List<VertexPositionColourNormal> buffer = new List<VertexPositionColourNormal>(); //a buffer to store all unique vertes positions List<int> theindexs = new List<int>(); for (int i =0; i < _originVerts.Length; i++) { if (!buffer.Contains(_originVerts[i])) //if its not in the buffer { buffer.Add(_originVerts[i]); //add to the buffer theindexs.Add(buffer.Count - 1); //add to the index } else { //now if its already in the buffer find the location theindexs.Add(buffer.IndexOf(_originVerts[i])); } } IndexVertexs = theindexs.ToArray(); _originVerts = buffer.ToArray(); HaveIndexsVertexs = true; }
Now even though some of the vertexs are at the same positions my code is not removing the duplicates and then indexing the vertexs.
I wondered if it is something to do with the rounding errors on floats and therefore that the vector3 are not comparing?
Posts: 2
Participants: 2