Example #1
0
        public void UpdateCP(Vector2Int i, CP cp)
        {
            var cl = new Vector2Int(nlx, nly);
            var ol = cl - order * 2 * Vector2.one;

            // corner condition
            if (i.x == 0 && i.y == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[nidx(x, y)] = cp;
                    }
                }
            }
            else if (i.x == 0 && i.y == ol.y - 1)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[nidx(x, cl.y - y - 1)] = cp;
                    }
                }
            }
            else if (i.x == ol.x - 1 && i.y == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[nidx(cl.x - x - 1, y)] = cp;
                    }
                }
            }
            else if (i.x == ol.x - 1 && i.y == ol.y - 1)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[nidx(cl.x - x - 1, cl.y - y - 1)] = cp;
                    }
                }
            }
            // edge condition
            else if (i.x == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    cps[nidx(x, i.y + order)] = cp;
                }
            }
            else if (i.y == 0)
            {
                for (int y = 0; y <= order; y++)
                {
                    cps[nidx(i.x + order, y)] = cp;
                }
            }
            else if (i.x == ol.x - 1)
            {
                for (int j = 0; j <= order; j++)
                {
                    cps[nidx(cl.x - j - 1, i.y + order)] = cp;
                }
            }
            else if (i.y == ol.y - 1)
            {
                for (int j = 0; j <= order; j++)
                {
                    cps[nidx(i.x + order, cl.y - j - 1)] = cp;
                }
            }
            // other point condition
            else
            {
                cps[nidx(i.x + order, i.y + order)] = cp;
            }
        }
Example #2
0
        public void UpdateCP(Vector2Int i, CP cp)
        {
            var cl = new Vector2Int(cps.GetLength(0), cps.GetLength(1));
            var ol = cl - order * 2 * Vector2.one;

            // corner condition
            if (i.x == 0 && i.y == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[x, y] = cp;
                    }
                }
            }
            else if (i.x == 0 && i.y == ol.y - 1)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[x, cl.y - y - 1] = cp;
                    }
                }
            }
            else if (i.x == ol.x - 1 && i.y == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[cl.x - x - 1, y] = cp;
                    }
                }
            }
            else if (i.x == ol.x - 1 && i.y == ol.y - 1)
            {
                for (int x = 0; x <= order; x++)
                {
                    for (int y = 0; y <= order; y++)
                    {
                        cps[cl.x - x - 1, cl.y - y - 1] = cp;
                    }
                }
            }
            // edge condition
            else if (i.x == 0)
            {
                for (int x = 0; x <= order; x++)
                {
                    cps[x, i.y + order] = cp;
                }
            }
            else if (i.y == 0)
            {
                for (int y = 0; y <= order; y++)
                {
                    cps[i.x + order, y] = cp;
                }
            }
            else if (i.x == ol.x - 1)
            {
                for (int j = 0; j <= order; j++)
                {
                    cps[cl.x - j - 1, i.y + order] = cp;
                }
            }
            else if (i.y == ol.y - 1)
            {
                for (int j = 0; j <= order; j++)
                {
                    cps[i.x + order, cl.y - j - 1] = cp;
                }
            }
            // other point condition
            else
            {
                cps[i.x + order, i.y + order] = cp;
            }
        }