Exemple #1
0
    void OnRenderObject()
    {
        if (!mDebugEnabled)
        {
            return;
        }

        INavmeshData data = NavmeshData;

        if (!mNavmeshData || !data.HasNavmesh)
        {
            mDebugMesh = null;
            return;
        }

        if (mDebugMesh == null || data.Version != mDebugVersion)
        {
            mDebugMesh    = data.GetNavmesh();
            mDebugVersion = data.Version;

            if (mDebugMesh == null)
            {
                return;
            }
        }

        NavDebug.Draw(mDebugMesh, false);
    }
Exemple #2
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mPolyRef, 1);

            Color c = QEUtil.SelectColor;

            c.a = 0.25f;

            if (mHasPosition)
            {
                DebugDraw.DiamondMarker(mPosition.point, QEUtil.MarkerScaleNorm, c);
            }

            if (mHasNearestPoint)
            {
                c   = NavDebug.goalColor;
                c.a = 0.25f;

                DebugDraw.DiamondMarker(mNearest.point, QEUtil.MarkerScaleNorm, c);

                DebugDraw.Arrow(mPosition.point, mNearest.point
                                , 0, QEUtil.HeadScaleNorm
                                , NavDebug.goalColor);
            }
        }
Exemple #3
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mPolyRefs.buffer, mResultCount);

            if (mHasPosition)
            {
                DebugDraw.Circle(mPosition.point, mSearchRadius, QEUtil.SelectColor);
            }

            if (mResultCount > 0)
            {
                for (int i = 0; i < mResultCount; i++)
                {
                    if (mParentRefs[i] == 0)
                    {
                        continue;
                    }

                    Vector3 center = GetBufferedCentroid(mPolyRefs.buffer[i]);
                    Vector3 pcenter;

                    if (mParentRefs[i] == mPosition.polyRef)
                    {
                        pcenter = mPosition.point;
                    }
                    else
                    {
                        pcenter = GetBufferedCentroid(mParentRefs[i]);
                    }

                    DebugDraw.Arrow(pcenter, center, 0, QEUtil.HeadScaleSm, NavDebug.goalColor);
                }
            }
        }
Exemple #4
0
        private void OnSceneGUI(SceneView sceneView)
        {
            if (!(ScriptableObject)mNavmeshData)
            {
                Hide();
                return;
            }

            if (!mNavmeshData.HasNavmesh)
            {
                mDataVersion = -1;
                mNavmesh     = null;
                return;
            }

            if (mNavmesh == null || mNavmeshData.Version != mDataVersion)
            {
                mNavmesh     = mNavmeshData.GetNavmesh();
                mDataVersion = mNavmeshData.Version;

                if (mNavmesh == null)
                {
                    return;
                }
            }

            NavDebug.Draw(mNavmesh, mColorByArea);
        }
Exemple #5
0
        public virtual void OnRenderObject()
        {
            if (mShowClosedList)
            {
                NavDebug.Draw(helper.mesh, helper.query);
            }
            else
            {
                NavDebug.Draw(helper.mesh, path.buffer, pathCount);
            }

            Color c = QEUtil.SelectColor;

            c.a = 0.25f;

            if (position.polyRef != 0)
            {
                DebugDraw.DiamondMarker(position.point, QEUtil.MarkerScaleNorm, c);
            }

            c   = NavDebug.goalColor;
            c.a = 0.25f;

            if (goal.polyRef != 0)
            {
                DebugDraw.DiamondMarker(goal.point, QEUtil.MarkerScaleNorm, c);
            }
        }
Exemple #6
0
        public void OnRenderObject()
        {
            Color c = NavDebug.goalColor;

            c.a = 0.25f;

            if (mFoundPoly)
            {
                mSelectedPoly[0] = mNavmeshPoint.polyRef;
                NavDebug.Draw(mHelper.mesh, mSelectedPoly, 1);

                DebugDraw.DiamondMarker(mNavmeshPoint.point, QEUtil.MarkerScaleNorm, c);
            }
            else
            {
                NavDebug.Draw(mHelper.mesh, false);
            }

            if (mHasSearchPoint)
            {
                c = (mHelper.extents[0] < 0 || mHelper.extents[1] < 0)
                    ? Color.red
                    : QEUtil.SelectColor;

                DebugDraw.Extents(mSearchPoint, mHelper.extents, c);
            }
        }
Exemple #7
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mPolyRefs.buffer, mResultCount);

            if (mHasPosition)
            {
                Color c = (mHelper.extents.x < 0 || mHelper.extents.y < 0)
                    ? Color.red
                    : QEUtil.SelectColor;

                DebugDraw.Extents(mPosition, mHelper.extents, c);
            }
        }
    void OnRenderObject()
    {
        if (!mDebugEnabled || mAgent == null)
        {
            return;
        }

        if (mAgent.crowdAgent != null)
        {
            if (mCrowdDebug == null)
            {
                mCorners    = null;
                mCorridor   = null;
                mCrowdDebug = new CrowdAgentDebug(mAgent.navGroup.crowd.Navmesh);
            }
            mCrowdDebug.DrawAll(mAgent.crowdAgent);
        }
        else if ((mAgent.data.flags & NavFlag.CorridorInUse) != 0)
        {
            if (mCorridor == null)
            {
                mCorners    = new CornerData();
                mCorridor   = new PathCorridorData(mAgent.corridor.MaxPathSize);
                mCrowdDebug = null;
            }
            int n = mAgent.corridor.FindCorners(mCorners);
            mCorners.cornerCount = n; // v0.3.0 bug workaround.
            mAgent.corridor.GetData(mCorridor);
            NavDebug.Draw(mAgent.navGroup.mesh, mCorridor);
            NavDebug.Draw(mCorners);
        }

        if (mAgent.crowdAgent == null)
        {
            Vector3 pos    = mAgent.data.position.point;
            float   height = mAgent.crowdConfig.height; // Might be zero.

            Vector3 velocity = mAgent.data.desiredVelocity;
            DebugDraw.Arrow(pos + Vector3.up * height
                            , pos + velocity + Vector3.up * height
                            , 0, 0.05f, CrowdAgentDebug.desiredVelocityColor);
        }

        DebugDraw.DiamondMarker(mAgent.data.position.point
                                , 0.1f
                                , NavDebug.positionColor);

        DebugDraw.DiamondMarker(mAgent.data.goal.point
                                , 0.1f
                                , NavDebug.goalColor);
    }
Exemple #9
0
        public void Update()
        {
            // Must set message before returning.

            mHasPosition = false;
            mResultCount = 0;

            mYOffset += QEUtil.GetYFactor();

            Vector3 trash;

            QEUtil.SearchResult result =
                QEUtil.HandleStandardPolySearch(mHelper, out trash, out mPosition, out mMessage);

            mHasPosition = (result & QEUtil.SearchResult.HitNavmesh) != 0;

            if (!mHasPosition)
            {
                return;
            }

            Vector3 pos = mPosition.point;

            for (int i = 0; i < mSearchPoly.Length; i++)
            {
                mSearchPoly[i]    = pos + mBasePoly[i];
                mSearchPoly[i].y += mYOffset;
            }

            if (mPolyRefs.HandleResize())
            {
                int size = mPolyRefs.MaxElementCount;
                mParentRefs = new uint[size];
                mCosts      = new float[size];
                mCentroids  = new Vector3[size];
            }

            NavStatus status = mHelper.query.FindPolys(mPosition.polyRef, mSearchPoly
                                                       , mHelper.filter
                                                       , mPolyRefs.buffer, mParentRefs, mCosts, out mResultCount);

            mMessage = "FindPolys: " + status.ToString() + ".";

            if (mResultCount > 0)
            {
                NavDebug.GetCentroids(mHelper.mesh, mPolyRefs.buffer, mResultCount, mCentroids);
            }
        }
Exemple #10
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, false);

            if (mHasPosition)
            {
                DebugDraw.Circle(mPosition.point, mSearchRadius, QEUtil.SelectColor);
            }

            if (mHasWallHit)
            {
                DebugDraw.DiamondMarker(mWallHitPoint, QEUtil.MarkerScaleSm, Color.green);

                Vector3 normal = (mWallHitPoint + mWallNormal);
                DebugDraw.Arrow(mWallHitPoint, normal, 0, QEUtil.HeadScaleSm, NavDebug.goalColor);
            }
        }
Exemple #11
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mPolyRefs.buffer, mResultCount);

            Color c = QEUtil.SelectColor;

            c.a = 0.25f;

            if (mPosition.polyRef != 0)
            {
                DebugDraw.DiamondMarker(mPosition.point, QEUtil.MarkerScaleNorm, c);
            }

            c   = NavDebug.goalColor;
            c.a = 0.25f;

            if (mGoal.polyRef != 0)
            {
                DebugDraw.DiamondMarker(mGoal.point, QEUtil.MarkerScaleNorm, c);
            }

            if (mResultCount > 0)
            {
                if (mHitParam < 1)
                {
                    Vector3 hitPoint =
                        mPosition.point + (mGoal.point - mPosition.point) * mHitParam;

                    DebugDraw.Arrow(mPosition.point, hitPoint
                                    , 0, QEUtil.HeadScaleNorm
                                    , NavDebug.goalColor);

                    DebugDraw.Arrow(hitPoint, hitPoint + mHitNorm * 0.5f
                                    , 0, QEUtil.HeadScaleSm
                                    , NavDebug.goalColor);
                }
                else
                {
                    DebugDraw.Arrow(mPosition.point, mGoal.point
                                    , 0, QEUtil.HeadScaleNorm
                                    , NavDebug.goalColor);
                }
            }
        }
Exemple #12
0
        public void Update()
        {
            mHasPosition = false;
            mResultCount = 0;

            Vector3 trash;

            QEUtil.SearchResult result =
                QEUtil.HandleStandardPolySearch(mHelper, out trash, out mPosition, out mMessage);

            mHasPosition = (result & QEUtil.SearchResult.HitNavmesh) != 0;

            if (!mHasPosition)
            {
                return;
            }

            mYOffset          += QEUtil.GetYFactor();
            mPosition.point.y += mYOffset;

            mSearchRadius += QEUtil.GetXZFactor();

            if (mPolyRefs.HandleResize())
            {
                int size = mPolyRefs.MaxElementCount;
                mParentRefs = new uint[size];
                mCentroids  = new Vector3[size];
            }

            NavStatus status = mHelper.query.GetPolysLocal(mPosition, mSearchRadius
                                                           , mHelper.filter
                                                           , mPolyRefs.buffer, mParentRefs, out mResultCount);

            mMessage = "GetPolysLocal: " + status.ToString() + ".";

            if (mResultCount > 0)
            {
                NavDebug.GetCentroids(mHelper.mesh
                                      , mPolyRefs.buffer
                                      , mResultCount
                                      , mCentroids);
            }
        }
Exemple #13
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mSelectedPoly, 1);

            if (mSegmentCount == 0)
            {
                return;
            }

            DebugDraw.SimpleMaterial.SetPass(0);

            GL.Begin(GL.LINES);
            GL.Color(QEUtil.SelectColor);

            for (int i = 0; i < mSegmentCount; i++)
            {
                int p = i * 2;

                GL.Vertex(mSegments[p + 0]);
                GL.Vertex(mSegments[p + 1]);

                if (mSegmentRefs[i] == 0)
                {
                    continue;
                }

                Vector2 a = new Vector2(mSegments[p + 0].x, mSegments[p + 0].z);
                Vector2 b = new Vector2(mSegments[p + 1].x, mSegments[p + 1].z);

                Vector2 norm2 = Line2.GetNormalAB(a, b);
                Vector3 norm3 = new Vector3(norm2.x, 0, norm2.y) * -0.25f;

                Vector3 mid = new Vector3((a.x + b.x) / 2
                                          , (mSegments[p + 0].y + mSegments[p + 1].y) / 2
                                          , (a.y + b.y) / 2);

                DebugDraw.AppendArrow(mid, mid + norm3, 0, QEUtil.HeadScaleSm);
            }

            GL.End();
        }
Exemple #14
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mPolyRefs.buffer, mVisitedCount);

            Color c = QEUtil.SelectColor;

            c.a = 0.25f;

            if (mPosition.polyRef != 0)
            {
                DebugDraw.DiamondMarker(mPosition.point, QEUtil.MarkerScaleNorm, c);
            }

            c   = NavDebug.positionColor;
            c.a = 0.25f;

            if (mGoal.polyRef != 0)
            {
                DebugDraw.DiamondMarker(mGoal.point, QEUtil.MarkerScaleNorm, c);
            }

            c   = NavDebug.goalColor;
            c.a = 0.25f;

            if (mVisitedCount > 0)
            {
                DebugDraw.DiamondMarker(mTarget.point, QEUtil.MarkerScaleNorm, c);
            }

            if (mStraightCount > 0)
            {
                for (int i = 1; i < mStraightCount; i++)
                {
                    DebugDraw.Arrow(mStraightPath[i - 1], mStraightPath[i]
                                    , 0, QEUtil.HeadScaleNorm
                                    , NavDebug.goalColor);
                }
            }
        }
    void OnRenderObject()
    {
        if (Time.timeScale == 0 || mGroup.mesh == null)
        {
            return;
        }

        mCorridor.GetData(mCorridorData);
        NavDebug.Draw(mGroup.mesh, false);
        NavDebug.Draw(mGroup.mesh, mCorridorData);
        NavDebug.Draw(mCorridor.Corners);

        Color c = NavDebug.positionColor;

        c.a = 0.25f;

        if (mPathStart.polyRef != 0)
        {
            DebugDraw.DiamondMarker(mPathStart.point, 0.1f, c);
        }

        c   = NavDebug.goalColor;
        c.a = 0.25f;

        if (mPathEnd.polyRef != 0)
        {
            DebugDraw.DiamondMarker(mPathEnd.point, 0.1f, c);
        }

        if (mOptimizeTimer > 0)
        {
            c   = NavDebug.goalColor;
            c.a = mOptimizeTimer / TimerLength;
            DebugDraw.Arrow(mOptimizeStart, mOptimizeEnd, 0, 0.1f, c);
            DebugDraw.Circle(mOptimizeStart, optimizationRange, c);
        }
    }
Exemple #16
0
        public void OnRenderObject()
        {
            NavDebug.Draw(mHelper.mesh, mSelectedPoly, 1);

            if (mSegmentCount == 0)
            {
                return;
            }

            DebugDraw.SimpleMaterial.SetPass(0);

            GL.Begin(GL.LINES);
            GL.Color(QEUtil.SelectColor);

            for (int i = 0; i < mSegmentCount; i++)
            {
                int p = i * 2;

                GL.Vertex(mSegments[p + 0]);
                GL.Vertex(mSegments[p + 1]);
            }

            GL.End();
        }
Exemple #17
0
 private void OnSceneGUI(UnityEditor.SceneView sceneview)
 {
     NavDebug.Draw(BattleManager.instance.view.pathManager.navmesh, false);
 }
Exemple #18
0
 public void OnRenderObject()
 {
     NavDebug.Draw(mHelper.mesh, mPolyRef, 1);
 }
        private void HandleWorkingNavmesh(TileSelection selection)
        {
            NavmeshBuild  build = selection.Build;
            TileBuildData tdata = build.BuildData;

            if (mDebugObject == null)
            {
                Navmesh navmesh = null;

                if (tdata.BakeableCount() == 0)
                {
                    // Nothing to display.
                    return;
                }

                bool success = true;

                TileSetDefinition tdef = build.TileSetDefinition;

                NavmeshParams     nconfig;
                NavmeshTileData[] tiles;

                if (tdef == null)
                {
                    tiles = new NavmeshTileData[1] {
                        tdata.GetTileData(0, 0)
                    };
                    nconfig = NavUtil.DeriveConfig(tiles[0]);
                }
                else
                {
                    TileZone zone;

                    if (selection.HasSelection)
                    {
                        zone = selection.Zone;
                    }
                    else
                    {
                        zone = new TileZone(0, 0, tdef.Width - 1, tdef.Depth - 1);
                    }

                    success = tdata.GetMeshBuildData(tdef.BoundsMin.ToUnityVector3(), tdef.TileWorldSize, zone
                                                     , out nconfig, out tiles);
                }

                NavStatus status = NavStatus.Sucess;

                if (success)
                {
                    status = Navmesh.Create(nconfig, out navmesh);

                    if ((status & NavStatus.Failure) == 0)
                    {
                        foreach (NavmeshTileData tile in tiles)
                        {
                            uint trash;
                            status = navmesh.AddTile(tile, Navmesh.NullTile, out trash);

                            if ((status & NavStatus.Sucess) == 0)
                            {
                                navmesh = null;
                                break;
                            }
                        }
                    }
                }

                if ((status & NavStatus.Sucess) == 0)
                {
                    Show = MeshDebugOption.None;                      // Use property.
                    Debug.LogError("Mesh Debug View: Error creating working navigation mesh: "
                                   + status + ". Disabled display.", build);
                }
                else
                {
                    mDebugObject = navmesh;
                }
            }

            if (mDebugObject != null)
            {
                Navmesh nm = ( Navmesh )mDebugObject;
                NavDebug.Draw(nm, NavmeshSceneDraw.Instance.ColorByArea);
            }
        }