static void DrawGizmoFor(CellMaker target, GizmoType gizmoType)
    {
        //測試2線段交叉
        Gizmos.DrawLine(target.P0.position, target.P1.position);
        Gizmos.DrawLine(target.P2.position, target.P3.position);

        var colliderRects = target.colliderRects;

        if (colliderRects != null)
        {
            foreach (var rect in colliderRects)
            {
                DrawRect(rect, colliderColor);
            }
        }

        //outer
        var OuterQuadRect = target.GetOuterQuadRect();

        foreach (var rect in OuterQuadRect)
        {
            DrawRect(rect, quadTreeOuter);
        }

        //innner
        var InnerQuadRect = target.GetInnerQuadRect();

        foreach (var rect in InnerQuadRect)
        {
            DrawRect(rect, quadTreeInner);
        }


        var nodes = target.GetRawPath();

        DrawPathList(nodes, target.nodeSize);

        var points = target.GetModifyPath();

        DrawPathList(points, target.modifyNodeSize);

        if (target.showNodeLink)
        {
            var HorizontalLinks = QuadTreeConnectedNode.GetHorizontalLinks();

            foreach (var link in HorizontalLinks)
            {
                DrawQuadTreeLink(link.from, link.to, quadTreeHorizontalLink);
            }

            var VerticaLinks = QuadTreeConnectedNode.GetVerticaLinks();

            foreach (var link in VerticaLinks)
            {
                DrawQuadTreeLink(link.from, link.to, quadTreeVerticalLink);
            }
        }
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        var splitLevel  = cellMaker.GetMaxSplitLeve();
        var columnCount = Mathf.Pow(2, splitLevel);

        GUILayout.Label("if not using quad tree:" + Mathf.Pow(columnCount, 2));

        var OuterQuadRectCount = cellMaker.GetOuterQuadRect().Count;

        GUILayout.Label("OuterQuadRectCount:" + OuterQuadRectCount);

        var InnerQuadRectCount = cellMaker.GetInnerQuadRect().Count;

        GUILayout.Label("InnerQuadRectCount:" + InnerQuadRectCount);

        var QuadRectCount = OuterQuadRectCount + InnerQuadRectCount;

        GUILayout.Label("QuadRectCount:" + QuadRectCount);

        if (GUILayout.Button("Get All BoxCollider & Generate QuadTree"))
        {
            cellMaker.GetAllBoxColliderMetaInfoInSceneAndGenerateRect();

            cellMaker.GenerateQuadTreeConnectedNode();
            cellMaker.MakeConnected();
            cellMaker.GenerateGraphNodeData();

            cellMaker.CollectOuterQuadRect();
            cellMaker.CollectInnerQuadRect();

            SceneView.RepaintAll();
            Debug.Log("Generate");
        }

        if (GUILayout.Button("TestIsIntersect"))
        {
            cellMaker.TestIsIntersect();
        }

        if (GUILayout.Button("TestPathFind"))
        {
            cellMaker.TestPathFind();
            SceneView.RepaintAll();
        }
    }