public IEnumerator Generate()
        {
            Reset();

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

            // build distance field:
            int[]     tris  = input.triangles;
            Vector3[] verts = input.vertices;
            Oni.StartBuildingDistanceField(oniDistanceField, maxError, maxDepth, verts, tris, verts.Length, tris.Length / 3);

            int  i    = 0;
            bool done = false;

            while (!done)
            {
                for (int j = 0; j < 16; ++j)
                {
                    done |= Oni.ContinueBuildingDistanceField(oniDistanceField);
                }

                i += 16;
                yield return(new CoroutineJob.ProgressInfo("Processed nodes: " + i, 1));
            }

            // retrieve nodes:
            int count = Oni.GetDistanceFieldNodeCount(oniDistanceField);

            nodes = new Oni.DFNode[count];
            Oni.GetDistanceFieldNodes(oniDistanceField, nodes);

            // calculate min node size;
            minNodeSize = float.PositiveInfinity;
            for (int j = 0; j < nodes.Length; ++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);
        }