예제 #1
0
        private void DoFairyBatching()
        {
            _fBatchingRequested = false;

            if (_descendants == null)
            {
                _descendants = new List <DisplayObject>();
            }
            else
            {
                _descendants.Clear();
            }
            CollectChildren(this);

            int cnt = _descendants.Count;
            //Debug.Log("DoFairyBatching " + cnt);

            int i, j;

            for (i = 0; i < cnt; i++)
            {
                DisplayObject current = _descendants[i];
                Rect          bound   = current._internal_bounds;
                if ((object)current.material == null || current._skipInFairyBatching)
                {
                    continue;
                }

                for (j = i - 1; j >= 0; j--)
                {
                    DisplayObject test = _descendants[j];
                    if (test._skipInFairyBatching)
                    {
                        break;
                    }

                    if ((object)current.material == (object)test.material)
                    {
                        if (i != j + 1)
                        {
                            _descendants.RemoveAt(i);
                            _descendants.Insert(j + 1, current);
                        }
                        break;
                    }

                    if (ToolSet.Intersects(ref bound, ref test._internal_bounds))
                    {
                        break;
                    }
                }
            }
        }
예제 #2
0
        private void DoFairyBatching()
        {
            _fBatchingRequested = false;

            if (_descendants == null)
            {
                _descendants = new List <DisplayObject>();
            }
            else
            {
                _descendants.Clear();
            }
            CollectChildren(this);

            int cnt = _descendants.Count;

            int i, j;

            for (i = 0; i < cnt; i++)
            {
                DisplayObject current = _descendants[i];
                Rect          bound   = current.tmpBounds;
                if (current.material == null)
                {
                    continue;
                }

                for (j = i - 1; j >= 0; j--)
                {
                    DisplayObject test = _descendants[j];
                    if (current.material == test.material)
                    {
                        if (i != j + 1)
                        {
                            _descendants.RemoveAt(i);
                            _descendants.Insert(j + 1, current);
                        }
                        break;
                    }

                    if (ToolSet.Intersects(ref bound, ref test.tmpBounds))
                    {
                        break;
                    }
                }
            }

            for (i = 0; i < cnt; i++)
            {
                DisplayObject current = _descendants[i];
                Rect          bound   = current.tmpBounds;
                if (current.material == null)
                {
                    continue;
                }

                for (j = i + 1; j < cnt; j++)
                {
                    DisplayObject test = _descendants[j];
                    if (current.material == test.material)
                    {
                        if (i != j - 1)
                        {
                            _descendants.Insert(j, current);
                            _descendants.RemoveAt(i);
                            if (i == 0)
                            {
                                i--;
                            }
                            else
                            {
                                i -= 2;
                            }
                        }
                        break;
                    }

                    if (ToolSet.Intersects(ref bound, ref test.tmpBounds))
                    {
                        break;
                    }
                }
            }
        }