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


C# AABB.isValid方法代码示例

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


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

示例1: moveProxy

        public bool moveProxy(int proxyId, AABB aabb, Vec2 displacement)
        {
            Debug.Assert(aabb.isValid());
            Debug.Assert(0 <= proxyId && proxyId < m_nodeCapacity);
            DynamicTreeNode node = m_nodes[proxyId];
            Debug.Assert(node.child1 == null);

            AABB nodeAABB = node.aabb;
            // if (nodeAABB.contains(aabb)) {
            if (nodeAABB.lowerBound.x <= aabb.lowerBound.x && nodeAABB.lowerBound.y <= aabb.lowerBound.y
                && aabb.upperBound.x <= nodeAABB.upperBound.x && aabb.upperBound.y <= nodeAABB.upperBound.y)
            {
                return false;
            }

            removeLeaf(node);

            // Extend AABB
            Vec2 lowerBound = nodeAABB.lowerBound;
            Vec2 upperBound = nodeAABB.upperBound;
            lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
            lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
            upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
            upperBound.y = aabb.upperBound.y + Settings.aabbExtension;

            // Predict AABB displacement.
            float dx = displacement.x*Settings.aabbMultiplier;
            float dy = displacement.y*Settings.aabbMultiplier;
            if (dx < 0.0f)
            {
                lowerBound.x += dx;
            }
            else
            {
                upperBound.x += dx;
            }

            if (dy < 0.0f)
            {
                lowerBound.y += dy;
            }
            else
            {
                upperBound.y += dy;
            }

            insertLeaf(proxyId);
            return true;
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:49,代码来源:DynamicTree.cs

示例2: query

        public void query(TreeCallback callback, AABB aabb)
        {
            Debug.Assert(aabb.isValid());
            nodeStackIndex = 0;
            nodeStack[nodeStackIndex++] = m_root;

            while (nodeStackIndex > 0)
            {
                DynamicTreeNode node = nodeStack[--nodeStackIndex];
                if (node == null)
                {
                    continue;
                }

                if (AABB.testOverlap(node.aabb, aabb))
                {
                    if (node.child1 == null)
                    {
                        bool proceed = callback.treeCallback(node.id);
                        if (!proceed)
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (nodeStack.Length - nodeStackIndex - 2 <= 0)
                        {
                            DynamicTreeNode[] newBuffer = new DynamicTreeNode[nodeStack.Length*2];
                            Array.Copy(nodeStack, 0, newBuffer, 0, nodeStack.Length);
                            nodeStack = newBuffer;
                        }
                        nodeStack[nodeStackIndex++] = node.child1;
                        nodeStack[nodeStackIndex++] = node.child2;
                    }
                }
            }
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:38,代码来源:DynamicTree.cs

示例3: createProxy

        public int createProxy(AABB aabb, object userData)
        {
            Debug.Assert(aabb.isValid());
            DynamicTreeNode node = allocateNode();
            int proxyId = node.id;
            // Fatten the aabb
            AABB nodeAABB = node.aabb;
            nodeAABB.lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
            nodeAABB.lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
            nodeAABB.upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
            nodeAABB.upperBound.y = aabb.upperBound.y + Settings.aabbExtension;
            node.userData = userData;

            insertLeaf(proxyId);

            return proxyId;
        }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:17,代码来源:DynamicTree.cs


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