コード例 #1
0
ファイル: GroupNodeQuadTree.cs プロジェクト: billwillman/PVS
        protected override void OnFree()
        {
            base.OnFree();

            QuadGroupNodeArray <T> array = m_Item as QuadGroupNodeArray <T>;

            if (array != null)
            {
                array.Dispose();
            }
            m_Item = null;
        }
コード例 #2
0
ファイル: GroupNodeQuadTree.cs プロジェクト: billwillman/PVS
        private static bool Combine(ref System.Object m_Item, QuadGroupNodeArray <T> array, Func <T, T, T, T, bool> onCompare, Func <T, T, T, T, T> onCreateCombine)
        {
            if (array == null || onCompare == null || onCreateCombine == null)
            {
                return(false);
            }
            bool ret = false;

            var n1 = array [0];
            var n2 = array [1];
            var n3 = array [2];
            var n4 = array [3];

            if (n1 != null && n2 != null && n3 != null && n4 != null)
            {
                var item1 = n1.Item;
                var item2 = n2.Item;
                var item3 = n3.Item;
                var item4 = n4.Item;
                if (item1 != null && item2 != null && item3 != null && item4 != null)
                {
                    ret = onCompare(item1, item2, item3, item4);
                    if (ret)
                    {
                        T newT = onCreateCombine(item1, item2, item3, item4);
                        array.Dispose();
                        m_Item = newT;
                    }
                }
                else
                {
                    var array1 = n1.ItemNode;
                    var array2 = n2.ItemNode;
                    var array3 = n3.ItemNode;
                    var array4 = n4.ItemNode;

                    if (array1 != null && array2 != null && array3 != null && array4 != null)
                    {
                        bool r1 = Combine(ref n1.m_Item, array1, onCompare, onCreateCombine);
                        bool r2 = Combine(ref n2.m_Item, array2, onCompare, onCreateCombine);
                        bool r3 = Combine(ref n3.m_Item, array3, onCompare, onCreateCombine);
                        bool r4 = Combine(ref n4.m_Item, array4, onCompare, onCreateCombine);
                        ret = r1 || r2 || r3 || r4;
                    }
                }
            }
            else
            {
                if (n1 != null)
                {
                    bool r1 = n1.Combine(onCompare, onCreateCombine);
                    if (r1 && !ret)
                    {
                        ret = true;
                    }
                }

                if (n2 != null)
                {
                    bool r2 = n2.Combine(onCompare, onCreateCombine);
                    if (r2 && !ret)
                    {
                        ret = true;
                    }
                }

                if (n3 != null)
                {
                    bool r3 = n3.Combine(onCompare, onCreateCombine);
                    if (r3 && !ret)
                    {
                        ret = true;
                    }
                }

                if (n4 != null)
                {
                    bool r4 = n4.Combine(onCompare, onCreateCombine);
                    if (r4 && !ret)
                    {
                        ret = true;
                    }
                }
            }


            return(ret);
        }