Example #1
0
    private void DrawBeachLine()
    {
        if (!m_showBeachLine)
        {
            return;
        }

        if (m_inputPoints == null || m_inputPoints.Length == 0)
        {
            return;
        }

        m_voronoiDiagram = new VoronoiDiagram(m_inputPoints, new VBorder(m_width, m_height), m_sweepLine);

        Gizmos.color = m_beachLineColor;
        Vector3 point1;
        Vector3 point2;

        for (int x = 0; x < m_beachLineDivision; x++)
        {
            point1   = m_voronoiDiagram.GetBeachLine(GetDivisionX(x), m_sweepLine);
            point2   = m_voronoiDiagram.GetBeachLine(GetDivisionX(x + 1), m_sweepLine);
            point1.z = Mathf.Clamp(point1.z, -HalfHeight, HalfHeight);
            point2.z = Mathf.Clamp(point2.z, -HalfHeight, HalfHeight);

            if (point1.z == HalfHeight && point2.z == HalfHeight)
            {
                continue;
            }

            if (point1.z == -HalfHeight && point2.z == -HalfHeight)
            {
                continue;
            }

            DrawThickLine(point1, point2);
        }
    }