Пример #1
0
        private InputAssets BuildInput(bool ownProgress)
        {
            InputBuildOption options =
                (mBuild.AutoCleanGeometry ? InputBuildOption.AutoCleanGeometry : 0);

            InputBuilder builder =
                InputBuilder.Create(mBuild.SceneQuery, mBuild.GetInputProcessors(), options);

            if (builder == null)
            {
                mContext.LogError("Could not create input builder.", mBuild);
                return(new InputAssets());
            }

            try
            {
                while (!builder.IsFinished)
                {
                    builder.Build();
                    if (EditorUtility.DisplayCancelableProgressBar("Compile Input"
                                                                   , InputBuilder.ToLabel(builder.State)
                                                                   , InputBuilder.ToProgress(builder.State)))
                    {
                        return(new InputAssets());
                    }
                }
            }
            finally
            {
                if (ownProgress)
                {
                    EditorUtility.ClearProgressBar();
                }
            }

            mContext.Log(builder.Messages);

            if (builder.State != InputBuildState.Complete)
            {
                mContext.LogError("Input builder aborted.", mBuild);
                return(new InputAssets());
            }

            InputAssets assets = builder.Result;

            org.critterai.geom.TriangleMesh mesh = assets.geometry;

            if (!InputGeometryBuilder.IsValid(mesh, assets.areas))
            {
                mContext.LogError("Input geometry failed validation. (Malformed data.)", mBuild);
                return(new InputAssets());
            }

            return(builder.Result);
        }
Пример #2
0
        private void UpdateBuilder()
        {
            if (!mBuilder.IsFinished)
            {
                mBuilder.Build();
                return;
            }

            mLogger.Log(mBuilder.Messages);

            NavmeshBuild build = mContext.Build;  // Caller has validated.

            if (mBuilder.State == InputBuildState.Aborted)
            {
                FinalizeOnFail("Input data compile failed: Builder aborted.", true);
                return;
            }

            mAssets = mBuilder.Result;

            TriangleMesh mesh = mAssets.geometry;

            if (!InputGeometryBuilder.IsValid(mesh, mAssets.areas))
            {
                FinalizeOnFail("Input geometry failed validation. (Malformed data.)", true);
                return;
            }

            InputGeometryBuilder gbuilder = InputGeometryBuilder.UnsafeCreate(mesh
                                                                              , mAssets.areas
                                                                              , build.Config.GetConfig().WalkableSlope
                                                                              , true);

            if (gbuilder == null)
            {
                FinalizeOnFail("Could not create input geometry builder. (Internal error.)", true);
                return;
            }

            // Release unneeded assets.
            mAssets.geometry = null;
            mAssets.areas    = null;
            mBuilder         = null;

            mTask = InputBuildTask.Create(gbuilder, BuildTaskProcessor.HighPriority);

            if (mTask == null)
            {
                FinalizeOnFail("Task creation failed. (Internal error.)", true);
            }
            else if (mContext.QueueTask(mTask))
            {
                mLogger.PostTrace("Completed input build. Submitted geometry build task."
                                  , mContext.Build);
                mState = State.Task;
            }
            else
            {
                FinalizeOnFail("Task submission failed. (Internal error.)", true);
            }
        }