void OnDrawGizmos()
    {
        bool           success  = false;
        List <Vector3> testLine = test.Line.ToList();

        if (mathTest == MathTest.Collides)
        {
            success = ProcGenHelpers.CollidesWith(testLine[0], testLine[1], reference.Line.ToList(), true, out reference.markIndex);
        }
        else if (mathTest == MathTest.Ray)
        {
            reference.markIndex = -1;
            Vector3 pt = Vector3.one;
            success = ProcGenHelpers.RayInterceptsSegment(testLine[0], testLine[1] - testLine[0], reference.Line.ToList(), out pt);
            if (success)
            {
                Gizmos.color = Color.green;
                Gizmos.DrawSphere(pt, gizmosSize);
            }
        }
        else if (mathTest == MathTest.IsKnown)
        {
            success = ProcGenHelpers.IsKnownSegment(testLine[0], testLine[1], true, reference.Line.ToList());
        }


        test.lineColor = success ? Color.green : Color.gray;
    }
    bool MapCornerToCornerWall()
    {
        bool    room  = false;
        int     indx  = Random.Range(0, convex.Count);
        Vector3 a1    = convex[indx];
        int     indx2 = (indx + Random.Range(1, convex.Count - 1)) % convex.Count;
        Vector3 a2    = convex[indx2];
        //Debug.Log(string.Format("Using indices {0} {1} ({2})", indx, indx2, convex.Count));
        List <List <Vector3> > testPaths = new List <List <Vector3> >();

        if (a1.x == a2.x || a1.z == a2.z)
        {
            testPaths.Add(new List <Vector3>()
            {
                a1, a2
            });
            //Debug.Log(string.Format("Test simple wall {0} {1}", a1, a2));
        }
        else
        {
            Vector3[] c = new Vector3[2] {
                new Vector3(a1.x, 0, a2.z), new Vector3(a2.x, 0, a1.z)
            };
            for (int i = 0; i < 2; i++)
            {
                testPaths.Add(new List <Vector3>()
                {
                    a1, c[i], a2
                });
            }
        }

        for (int i = 0, l = testPaths.Count; i < l; i++)
        {
            List <Vector3> newWall = testPaths[i];
            int            testIndex;
            int            pathIndex;

            bool isKnown = false;
            for (int idW = 0, wL = newWall.Count; idW < wL - 1; idW++)
            {
                if (ProcGenHelpers.IsKnownSegment(newWall[idW], newWall[idW + 1], true, perimeter) ||
                    ProcGenHelpers.IsKnownSegment(newWall[idW], newWall[idW + 1], wallLines))
                {
                    isKnown = true;
                    break;
                }
            }

            if (isKnown)
            {
                //Debug.Log("Inner wall collided with previously known wall");
            }
            else if (ProcGenHelpers.CollidesWith(newWall, perimeter, true, out testIndex, out pathIndex))
            {
                Debug.Log(string.Format("Inner wall {0} {1} collides at ({2} | {3})", newWall[testIndex], newWall[testIndex + 1], testIndex, pathIndex));
            }
            else
            {
                int pathsIndex;
                if (ProcGenHelpers.CollidesWith(newWall, wallLines, out testIndex, out pathIndex, out pathsIndex))
                {
                    Debug.Log("Collides with inner wall");
                }
                else
                {
                    //Debug.Log(string.Format("Added curved wall {0} {1} {2}", newWall.Count, newWall[0], newWall[newWall.Count -1]));
                    wallLines.Add(newWall);
                    room = true;
                    if (newWall.Count == 3)
                    {
                        convex.Add(newWall[1]);
                    }

                    break;
                }
            }
        }

        return(room);
    }