BananaMpq.View.Rendering.SceneGeometryRenderer.ComputeVertexNormals C# (CSharp) Method

ComputeVertexNormals() private static method

private static ComputeVertexNormals ( VertexPositionNormal vertices, IEnumerable triangles ) : void
vertices VertexPositionNormal
triangles IEnumerable
return void
        private static void ComputeVertexNormals(VertexPositionNormal[] vertices, IEnumerable<IndexedTriangleWithNormal> triangles)
        {
            foreach (var triangle in triangles)
            {
                var floats = triangle.Normal.ToArray();
                vertices[triangle.A].Normal += new Vector3(floats);
                vertices[triangle.B].Normal += new Vector3(floats);
                vertices[triangle.C].Normal += new Vector3(floats);
            }

            foreach (var v in vertices)
            {
                v.Normal.Normalize();
            }
        }