Пример #1
0
        /// <summary>
        /// Recalculates a mesh's normals while retaining smoothed common vertices.
        /// </summary>
        /// <param name="mesh"></param>
        internal static void RecalculateNormals(PolyMesh mesh)
        {
            //null checks
            if (mesh == null)
            {
                return;
            }

            int[][] smooth = GetSmoothSeamLookup(mesh);

            mesh.RecalculateNormals();

            if (smooth != null)
            {
                Vector3[] normals = mesh.normals;

                for (int i = 0; i < smooth.Length; ++i)
                {
                    int[]   l = smooth[i];
                    Vector3 n = Math.Average(normals, l);

                    for (int j = 0; j < l.Length; ++j)
                    {
                        normals[l[j]] = n;
                    }
                }

                mesh.normals = normals;
            }
        }
Пример #2
0
        /// <summary>
        /// Recalculates a mesh's normals while retaining smoothed common vertices.
        /// </summary>
        /// <param name="mesh"></param>
        internal static void RecalculateNormals(PolyMesh mesh)
        {
            //null checks
            if (mesh == null)
            {
                return;
            }

            List <List <int> > smooth = GetSmoothSeamLookup(mesh);

            mesh.RecalculateNormals();

            if (smooth != null)
            {
                Vector3[] normals = mesh.normals;

                foreach (List <int> l in smooth)
                {
                    Vector3 n = PolyMath.Average(normals, l);

                    foreach (int i in l)
                    {
                        normals[i] = n;
                    }
                }

                mesh.normals = normals;
            }
        }