当前位置: 首页>>代码示例>>C#>>正文


C# AABB.combine方法代码示例

本文整理汇总了C#中AABB.combine方法的典型用法代码示例。如果您正苦于以下问题:C# AABB.combine方法的具体用法?C# AABB.combine怎么用?C# AABB.combine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AABB的用法示例。


在下文中一共展示了AABB.combine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: validateMetrics

        private void validateMetrics(int index)
        {
            if (index == TreeNode.NULL_NODE)
            {
                return;
            }

            TreeNode node = m_nodes[index];

            int child1 = node.child1;
            int child2 = node.child2;

            if (node.Leaf)
            {
                Debug.Assert(child1 == TreeNode.NULL_NODE);
                Debug.Assert(child2 == TreeNode.NULL_NODE);
                Debug.Assert(node.height == 0);
                return;
            }

            Debug.Assert(0 <= child1 && child1 < m_nodeCapacity);
            Debug.Assert(0 <= child2 && child2 < m_nodeCapacity);

            int height1 = m_nodes[child1].height;
            int height2 = m_nodes[child2].height;
            int height;
            height = 1 + MathUtils.max(height1, height2);
            Debug.Assert(node.height == height);

            AABB aabb = new AABB();
            aabb.combine(m_nodes[child1].aabb, m_nodes[child2].aabb);

            Debug.Assert(aabb.lowerBound.Equals(node.aabb.lowerBound));
            Debug.Assert(aabb.upperBound.Equals(node.aabb.upperBound));

            validateMetrics(child1);
            validateMetrics(child2);
        }
开发者ID:thdtjsdn,项目名称:box2dnet,代码行数:38,代码来源:DynamicTree.cs

示例2: rebuildBottomUp

        /// <summary>
        /// Build an optimal tree. Very expensive. For testing.
        /// </summary>
        public virtual void rebuildBottomUp()
        {
            int[] nodes = new int[m_nodeCount];
            int count = 0;

            // Build array of leaves. Free the rest.
            for (int i = 0; i < m_nodeCapacity; ++i)
            {
                if (m_nodes[i].height < 0)
                {
                    // free node in pool
                    continue;
                }

                if (m_nodes[i].Leaf)
                {
                    m_nodes[i].parent = TreeNode.NULL_NODE;
                    nodes[count] = i;
                    ++count;
                }
                else
                {
                    freeNode(i);
                }
            }

            AABB b = new AABB();
            while (count > 1)
            {
                float minCost = Single.MaxValue;
                int iMin = -1, jMin = -1;
                for (int i = 0; i < count; ++i)
                {
                    AABB aabbi = m_nodes[nodes[i]].aabb;

                    for (int j = i + 1; j < count; ++j)
                    {
                        AABB aabbj = m_nodes[nodes[j]].aabb;
                        b.combine(aabbi, aabbj);
                        float cost = b.Perimeter;
                        if (cost < minCost)
                        {
                            iMin = i;
                            jMin = j;
                            minCost = cost;
                        }
                    }
                }

                int index1 = nodes[iMin];
                int index2 = nodes[jMin];
                TreeNode child1 = m_nodes[index1];
                TreeNode child2 = m_nodes[index2];

                int parentIndex = allocateNode();
                TreeNode parent = m_nodes[parentIndex];
                parent.child1 = index1;
                parent.child2 = index2;
                parent.height = 1 + MathUtils.max(child1.height, child2.height);
                parent.aabb.combine(child1.aabb, child2.aabb);
                parent.parent = TreeNode.NULL_NODE;

                child1.parent = parentIndex;
                child2.parent = parentIndex;

                nodes[jMin] = nodes[count - 1];
                nodes[iMin] = parentIndex;
                --count;
            }

            m_root = nodes[0];

            validate();
        }
开发者ID:thdtjsdn,项目名称:box2dnet,代码行数:77,代码来源:DynamicTree.cs

示例3: rebuildBottomUp

        /**
           * Build an optimal tree. Very expensive. For testing.
           */
        public void rebuildBottomUp()
        {
            int[] nodes = new int[m_nodeCount];
            int count = 0;

            // Build array of leaves. Free the rest.
            for (int i = 0; i < m_nodeCapacity; ++i)
            {
                if (m_nodes[i].height < 0)
                {
                    // free node in pool
                    continue;
                }

                DynamicTreeNode node = m_nodes[i];
                if (node.child1 == null)
                {
                    node.parent = null;
                    nodes[count] = i;
                    ++count;
                }
                else
                {
                    freeNode(node);
                }
            }

            AABB b = new AABB();
            while (count > 1)
            {
                float minCost = float.MaxValue;
                int iMin = -1, jMin = -1;
                for (int i = 0; i < count; ++i)
                {
                    AABB aabbi = m_nodes[nodes[i]].aabb;

                    for (int j = i + 1; j < count; ++j)
                    {
                        AABB aabbj = m_nodes[nodes[j]].aabb;
                        b.combine(aabbi, aabbj);
                        float cost = b.getPerimeter();
                        if (cost < minCost)
                        {
                            iMin = i;
                            jMin = j;
                            minCost = cost;
                        }
                    }
                }

                int index1 = nodes[iMin];
                int index2 = nodes[jMin];
                DynamicTreeNode child1 = m_nodes[index1];
                DynamicTreeNode child2 = m_nodes[index2];

                DynamicTreeNode parent = allocateNode();
                parent.child1 = child1;
                parent.child2 = child2;
                parent.height = 1 + MathUtils.max(child1.height, child2.height);
                parent.aabb.combine(child1.aabb, child2.aabb);
                parent.parent = null;

                child1.parent = parent;
                child2.parent = parent;

                nodes[jMin] = nodes[count - 1];
                nodes[iMin] = parent.id;
                --count;
            }

            m_root = m_nodes[nodes[0]];

            validate();
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:77,代码来源:DynamicTree.cs

示例4: validateMetrics

        private void validateMetrics(DynamicTreeNode node)
        {
            if (node == null)
            {
                return;
            }

            DynamicTreeNode child1 = node.child1;
            DynamicTreeNode child2 = node.child2;

            if (node.child1 == null)
            {
                Debug.Assert(child1 == null);
                Debug.Assert(child2 == null);
                Debug.Assert(node.height == 0);
                return;
            }

            Debug.Assert(child1 != null && 0 <= child1.id && child1.id < m_nodeCapacity);
            Debug.Assert(child2 != null && 0 <= child2.id && child2.id < m_nodeCapacity);

            int height1 = child1.height;
            int height2 = child2.height;
            int height;
            height = 1 + MathUtils.max(height1, height2);
            Debug.Assert(node.height == height);

            AABB aabb = new AABB();
            aabb.combine(child1.aabb, child2.aabb);

            Debug.Assert(aabb.lowerBound.Equals(node.aabb.lowerBound));
            Debug.Assert(aabb.upperBound.Equals(node.aabb.upperBound));

            validateMetrics(child1);
            validateMetrics(child2);
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:36,代码来源:DynamicTree.cs

示例5: validateMetrics

        private void validateMetrics(int node)
        {
            if (node == NULL_NODE)
            {
                return;
            }

            int child1 = m_child1[node];
            int child2 = m_child2[node];

            if (child1 == NULL_NODE)
            {
                Debug.Assert(child1 == NULL_NODE);
                Debug.Assert(child2 == NULL_NODE);
                Debug.Assert(m_height[node] == 0);
                return;
            }

            Debug.Assert(child1 != NULL_NODE && 0 <= child1 && child1 < m_nodeCapacity);
            Debug.Assert(child2 != child1 && 0 <= child2 && child2 < m_nodeCapacity);

            int height1 = m_height[child1];
            int height2 = m_height[child2];
            int height;
            height = 1 + MathUtils.max(height1, height2);
            Debug.Assert(m_height[node] == height);

            AABB aabb = new AABB();
            aabb.combine(m_aabb[child1], m_aabb[child2]);

            Debug.Assert(aabb.lowerBound.Equals(m_aabb[node].lowerBound));
            Debug.Assert(aabb.upperBound.Equals(m_aabb[node].upperBound));

            validateMetrics(child1);
            validateMetrics(child2);
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:36,代码来源:DynamicTreeFlatNodes.cs


注:本文中的AABB.combine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。