helix-toolkit/helix-toolkit — pull request #51 by dermeister0 (2014-09-13 06:43:17+00:00)
Title: Helix.Wpf.SharpDX: Fix ArgumentOutOfRangeException in MeshBuilder.ComputeNormals.

Current ComputeNormals method tries to access an item of zero-length list. The capacity property is initialized, but the Count is 0.

private static void ComputeNormals(Vector3Collection positions, IntCollection triangleIndices, out Vector3Collection normals)
{
normals = new Vector3Collection(positions.Count);

for (int t = 0; t < triangleIndices.Count; t += 3)
{
// ...

normals[i1] += (a * n); // ArgumentOutOfRangeException
normals[i2] += (a * n);
normals[i3] += (a * n);
}

// ...