public Subdivide Build(BuildContext data)
            {
                switch (state)
                {
                case State.None:

                    Subdivide c = Initialize(data);

                    state = (c == null) ? State.Complete : State.Right;

                    return(c);

                case State.Right:

                    state = State.Finalize;

                    return(data.Get(isplit, imax));

                case State.Finalize:

                    int iescape = data.curNode - icur;

                    // Negative index means escape.
                    data.nodes[inode].i = -iescape;

                    state = State.Complete;

                    break;
                }

                return(null);
            }
            public Subdivide Get(int imin, int imax)
            {
                if (mPool.Count == 0)
                {
                    return(new Subdivide(imin, imax));
                }

                Subdivide result = mPool.Pop();

                result.Reset(imin, imax);
                return(result);
            }
Example #3
0
            public BlockSpec Unwrap()
            {
                Contract.Requires(Subdivide != null);

                return(new BlockSpec(
                           Tags ?? (IEnumerable <KeyValuePair <string, string> >) new List <KeyValuePair <string, string> >(),
                           Guid.Parse(Id ?? Guid.NewGuid().ToString()),
                           Description,
                           Subdivide.Unwrap(),
                           (Adjustments ?? new BaseAdjustmentSpec.BaseContainer[0]).Select(a => a.Unwrap()).ToArray(),
                           (Lots ?? new LotSpec.BaseContainer[0]).Select(a => a.Unwrap()).ToArray()
                           ));
            }
        private void UpdateSubdivide()
        {
            mIter = 0;
            while (mStack.Count > 0 && mIter < mNodeIterations)
            {
                Subdivide c = mStack.Peek().Build(buildData);

                if (c == null)
                {
                    // Finished.
                    buildData.Return(mStack.Pop());
                }
                else
                {
                    // New sub-divide.
                    mStack.Push(c);
                }

                mIter++;
            }

            if (mStack.Count == 0)
            {
                mMesh = new ChunkyTriMesh(mVerts
                                          , mVertCount
                                          , buildData.tris
                                          , buildData.areas
                                          , mTriCount
                                          , buildData.nodes
                                          , buildData.curNode);

                buildData.Reset();  // Release references.

                mState = BuildState.Complete;
            }
        }
 public void Return(Subdivide item)
 {
     mPool.Push(item);
 }
Example #6
0
 // Start is called before the first frame update
 void Start()
 {
     subdivisionInstance = new Subdivide();
 }