コード例 #1
0
        private void BuildHeightfield()
        {
            int width;
            int depth;

            NMGen.DeriveSizeOfCellGrid(mTileConfig.BoundsMin
                                       , mTileConfig.BoundsMax
                                       , mConfig.XZCellSize
                                       , out width
                                       , out depth);

            Heightfield hf = Heightfield.Create(width, depth
                                                , mTileConfig.BoundsMin, mTileConfig.BoundsMax
                                                , mConfig.XZCellSize, mConfig.YCellSize);


            hf.AddTriangles(mBuildContext
                            , mGeometry.Mesh
                            , mTileConfig.boundsMin
                            , mTileConfig.boundsMax
                            , mConfig.WalkableStep); // Merge for any spans less than step.


            if (hf.GetSpanCount() < 1)
            {
                FinalizeNoResult("Complete at heightfield build. No spans.");
                return;
            }


            mBuildContext.Heightfield = hf;

            if (PostProcess() && PostHeightfieldCheck())
            {
                mBuildContext.Log("Voxelized triangles. Span count: " + hf.GetSpanCount(), this);
                mState = NMGenState.CompactFieldBuild;
            }
        }
コード例 #2
0
        private bool PostHeightfieldCheck()
        {
            Heightfield hf = mBuildContext.Heightfield;

            if (hf == null || hf.IsDisposed)
            {
                FinalizeAbort("Custom processors destroyed the heightfield. (" + mState + " Post)");
                return(false);
            }
            else if (hf.GetSpanCount() < 1)
            {
                FinalizeNoResult("Complete at heightfield build. No spans. (" + mState + " Post)");
                return(false);
            }
            return(true);
        }