コード例 #1
0
    /// <summary>
    /// Modify points list by neighbour collision if collision circle intesect with bounding box of this
    /// </summary>
    public void InitNeighboursWithCollision(Vector2 pt, float radius)
    {
        for (int i = 0; i < neighbours.Count; i++)
        {
            Triangulator scTr = neighbours[i].GetComponent <Triangulator>();
            float        up   = scTr.boundingBoxUpLf.y;
            float        dw   = scTr.boundingBoxDwRg.y;
            float        rg   = scTr.boundingBoxDwRg.x;
            float        lf   = scTr.boundingBoxUpLf.x;
            //    if (RectA.Left < RectB.Right && RectA.Right > RectB.Left &&
            // RectA.Top > RectB.Bottom && RectA.Bottom < RectB.Top)

            if (lf < pt.x + radius && rg > pt.x - radius && up > pt.y - radius && dw < pt.y + radius)
            {
                scTr.InitCollision(pt, radius);
                //  Debug.Log("neighbour with number:" + i.ToString() + " overlaps");
            }
        }
        // if()
    }