AddTriangles error/fix

Apr 8, 2012 at 2:32 AM

Hi

there seemed to be an error in the triangleIndices code for AddTriangles as i had points in all wrong places i have added code that fixes it below

//Not working (old code)

 /*
            int indexEnd = this.positions.Count;
            for (int i = index0; i + 2 < indexEnd; i++)
            {
                this.triangleIndices.Add(i);
                this.triangleIndices.Add(i + 1);
                this.triangleIndices.Add(i + 2);
            }
             */


//Working

           for (int i = 0; i < this.positions.Count; i+=3)
            {
                this.triangleIndices.Add(i);
                this.triangleIndices.Add(i + 1);
                this.triangleIndices.Add(i + 2);
            }

 

Coordinator
Apr 8, 2012 at 11:10 AM

thanks! I submitted a fix on the AddTriangles method. Notice that the triangle indices should be based on the index of the first point added (this will allow AddTriangles to be called multiple times). I also corrected some errors in the argument checks.

I found that this method is currently not in use in the library, but I will leave it there in case someone use it. Will add more unit tests/examples for the mesh builder later.

Apr 8, 2012 at 11:24 AM

Oh great objo yea i realised about the index afterwards as i was adding my object all in one go good point 

great work on the whole library btw,,,