Ejemplo n.º 1
0
        /// <summary>
        /// Reverse face orientation on a subset of triangles
        /// </summary>
        public void ReverseTriangles(IEnumerable <int> triangles, bool bFlipVtxNormals = true)
        {
            if (bFlipVtxNormals == false)
            {
                foreach (int tid in triangles)
                {
                    Mesh.ReverseTriOrientation(tid);
                }
            }
            else
            {
                BitArray donev = new BitArray(Mesh.MaxVertexID);

                foreach (int tid in triangles)
                {
                    Mesh.ReverseTriOrientation(tid);

                    Index3i tri = Mesh.GetTriangle(tid);
                    for (int j = 0; j < 3; ++j)
                    {
                        int vid = tri[j];
                        if (donev[vid] == false)
                        {
                            Mesh.SetVertexNormal(vid, -Mesh.GetVertexNormal(vid));
                            donev[vid] = true;
                        }
                    }
                }
            }
        }