Esempio n. 1
0
        public IEnumerator Generate()
        {
            Reset();

            if (input == null)
            {
                yield break;
            }

            int[]     tris  = input.triangles;
            Vector3[] verts = input.vertices;

            nodes = new List <DFNode>();
            var buildingCoroutine = ASDF.Build(maxError, maxDepth, verts, tris, nodes);

            int i = 0;

            while (buildingCoroutine.MoveNext())
            {
                yield return(new CoroutineJob.ProgressInfo("Processed nodes: " + (++i), 1));
            }

            // calculate min node size;
            minNodeSize = float.PositiveInfinity;
            for (int j = 0; j < nodes.Count; ++j)
            {
                minNodeSize = Mathf.Min(minNodeSize, nodes[j].center[3] * 2);
            }

            // get bounds:
            float max = Mathf.Max(bounds.size[0], Mathf.Max(bounds.size[1], bounds.size[2])) + 0.2f;

            bounds.size = new Vector3(max, max, max);
        }