• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BulletCollision.DbvtNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BulletXNA.BulletCollision.DbvtNode的典型用法代码示例。如果您正苦于以下问题:C# DbvtNode类的具体用法?C# DbvtNode怎么用?C# DbvtNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbvtNode类属于BulletXNA.BulletCollision命名空间,在下文中一共展示了DbvtNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Remove

 public void Remove(DbvtNode leaf)
 {
     RemoveLeaf(this, leaf);
     DeleteNode(this, leaf);
     --m_leaves;
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:6,代码来源:Dbvt.cs


示例2: Descent

 public bool Descent(DbvtNode n)
 {
     return true;
 }
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:DbvtBroadphase.cs


示例3: Process

        public void Process(DbvtNode na, DbvtNode nb)
        {
            if (na != nb)
            {
                DbvtProxy pa = na.data as DbvtProxy;
                DbvtProxy pb = nb.data as DbvtProxy;
#if DBVT_BP_SORTPAIRS
			    if(pa.m_uniqueId>pb.m_uniqueId) 
				    btSwap(pa,pb);
#endif
                pbp.m_paircache.AddOverlappingPair(pa, pb);
                ++pbp.m_newpairs;
            }
        }
开发者ID:Belxjander,项目名称:Asuna,代码行数:14,代码来源:DbvtBroadphase.cs


示例4: RecurseDeleteNode

 public static void RecurseDeleteNode(Dbvt pdbvt, DbvtNode node)
 {
     if (!node.IsLeaf())
     {
         RecurseDeleteNode(pdbvt, node._children[0]);
         RecurseDeleteNode(pdbvt, node._children[1]);
     }
     if (node == pdbvt.m_root)
     {
         pdbvt.m_root = null;
     }
     DeleteNode(pdbvt, node);
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:13,代码来源:Dbvt.cs


示例5: RemoveLeaf

 public static DbvtNode RemoveLeaf(Dbvt pdbvt, DbvtNode leaf)
 {
     if (leaf == pdbvt.Root)
     {
         pdbvt.Root = null;
         return null;
     }
     else
     {
         DbvtNode parent = leaf.parent;
         DbvtNode prev = parent.parent;
         DbvtNode sibling = parent._children[1 - IndexOf(leaf)];
         if (prev != null)
         {
             prev._children[IndexOf(parent)] = sibling;
             sibling.parent = prev;
             DeleteNode(pdbvt, parent);
             while (prev != null)
             {
                 DbvtAabbMm pb = prev.volume;
                 DbvtAabbMm.Merge(ref prev._children[0].volume, ref prev._children[1].volume, ref prev.volume);
                 if (DbvtAabbMm.NotEqual(ref pb, ref prev.volume))
                 {
                     sibling = prev;
                     prev = prev.parent;
                 }
                 else
                 {
                     break;
                 }
             }
             return (prev != null ? prev : pdbvt.Root);
         }
         else
         {
             pdbvt.Root = sibling;
             sibling.parent = null;
             DeleteNode(pdbvt, parent);
             return (pdbvt.Root);
         }
     }
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:42,代码来源:Dbvt.cs


示例6: CollideTT

        public static void CollideTT(DbvtNode root0, DbvtNode root1, ICollide collideable)
        {
            CollideTTCount++;
            Debug.Assert(CollideTTCount < 2);
            CollideTTStack.Clear();

            if (root0 != null && root1 != null)
            {
                int depth = 1;
                int treshold = DOUBLE_STACKSIZE - 4;
                CollideTTStack[0] = new sStkNN(root0, root1);

                do
                {
                    sStkNN p = CollideTTStack[--depth];

                    if (depth > treshold)
                    {
                        CollideTTStack.Resize(CollideTTStack.Count * 2);
                        treshold = CollideTTStack.Count - 4;
                    }

                    if (p.a == p.b)
                    {
                        if (p.a.IsInternal())
                        {
                            CollideTTStack[depth++] = new sStkNN(p.a._children[0], p.a._children[0]);
                            CollideTTStack[depth++] = new sStkNN(p.a._children[1], p.a._children[1]);
                            CollideTTStack[depth++] = new sStkNN(p.a._children[0], p.a._children[1]);
                        }
                    }
                    else if (DbvtAabbMm.Intersect(ref p.a.volume, ref p.b.volume))
                    {
                        if (p.a.IsInternal())
                        {
                            if (p.b.IsInternal())
                            {
                                CollideTTStack[depth++] = new sStkNN(p.a._children[0], p.b._children[0]);
                                CollideTTStack[depth++] = new sStkNN(p.a._children[1], p.b._children[0]);
                                CollideTTStack[depth++] = new sStkNN(p.a._children[0], p.b._children[1]);
                                CollideTTStack[depth++] = new sStkNN(p.a._children[1], p.b._children[1]);
                            }
                            else
                            {
                                CollideTTStack[depth++] = new sStkNN(p.a._children[0], p.b);
                                CollideTTStack[depth++] = new sStkNN(p.a._children[1], p.b);
                            }
                        }
                        else
                        {
                            if (p.b.IsInternal())
                            {
                                CollideTTStack[depth++] = new sStkNN(p.a, p.b._children[0]);
                                CollideTTStack[depth++] = new sStkNN(p.a, p.b._children[1]);
                            }
                            else
                            {
                                collideable.Process(p.a, p.b);
                            }
                        }
                    }
                } while (depth > 0);
            }
            CollideTTCount--;
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:65,代码来源:Dbvt.cs


示例7: CollideTTpersistentStack

        public static void CollideTTpersistentStack(DbvtNode root0,
                                  DbvtNode root1,
                                  ICollide collideable)
        {
            //CollideTT(root0, root1, collideable);
            //return;
            if (root0 != null && root1 != null)
            {
                int depth = 1;
                int treshold = DOUBLE_STACKSIZE - 4;

                m_stkStack.Resize(DOUBLE_STACKSIZE);
                m_stkStack[0] = new sStkNN(root0, root1);
                do
                {
                    sStkNN p = m_stkStack[--depth];
                    if (depth > treshold)
                    {
                        m_stkStack.Resize(m_stkStack.Count * 2);
                        treshold = m_stkStack.Count - 4;
                    }
                    if (p.a == p.b)
                    {
                        if (p.a.IsInternal())
                        {
                            m_stkStack[depth++] = new sStkNN(p.a._children[0], p.a._children[0]);
                            m_stkStack[depth++] = new sStkNN(p.a._children[1], p.a._children[1]);
                            m_stkStack[depth++] = new sStkNN(p.a._children[0], p.a._children[1]);
                        }
                    }
                    else if (DbvtAabbMm.Intersect(ref p.a.volume, ref p.b.volume))
                    {
                        if (p.a.IsInternal())
                        {
                            if (p.b.IsInternal())
                            {
                                m_stkStack[depth++] = new sStkNN(p.a._children[0], p.b._children[0]);
                                m_stkStack[depth++] = new sStkNN(p.a._children[1], p.b._children[0]);
                                m_stkStack[depth++] = new sStkNN(p.a._children[0], p.b._children[1]);
                                m_stkStack[depth++] = new sStkNN(p.a._children[1], p.b._children[1]);
                            }
                            else
                            {
                                m_stkStack[depth++] = new sStkNN(p.a._children[0], p.b);
                                m_stkStack[depth++] = new sStkNN(p.a._children[1], p.b);
                            }
                        }
                        else
                        {
                            if (p.b.IsInternal())
                            {
                                m_stkStack[depth++] = new sStkNN(p.a, p.b._children[0]);
                                m_stkStack[depth++] = new sStkNN(p.a, p.b._children[1]);
                            }
                            else
                            {
                                collideable.Process(p.a, p.b);
                            }
                        }
                    }
                } while (depth > 0);
            }
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:63,代码来源:Dbvt.cs


示例8: GetMaxDepth

 public static void GetMaxDepth(DbvtNode node, int depth, ref int maxDepth)
 {
     if (node.IsInternal())
     {
         GetMaxDepth(node._children[0], depth + 1, ref maxDepth);
         GetMaxDepth(node._children[1], depth + 1, ref maxDepth);
     }
     else
     {
         maxDepth = Math.Max(depth, maxDepth);
     }
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:12,代码来源:Dbvt.cs


示例9: EnumLeaves

 public static void EnumLeaves(DbvtNode root, ICollide collideable)
 {
     if (root.IsInternal())
     {
         EnumLeaves(root._children[0], collideable);
         EnumLeaves(root._children[1], collideable);
     }
     else
     {
         collideable.Process(root);
     }
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:12,代码来源:Dbvt.cs


示例10: FetchLeafs

 public static void FetchLeafs(Dbvt pdbvt, DbvtNode root, ObjectArray<DbvtNode> leafs, int depth)
 {
     if (root.IsInternal() && depth != 0)
     {
         FetchLeafs(pdbvt, root._children[0], leafs, depth - 1);
         FetchLeafs(pdbvt, root._children[1], leafs, depth - 1);
         DeleteNode(pdbvt, root);
     }
     else
     {
         leafs.Add(root);
     }
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:13,代码来源:Dbvt.cs


示例11: Sort

        public static DbvtNode Sort(DbvtNode n, DbvtNode r)
        {
            DbvtNode p = n.parent;
            Debug.Assert(n.IsInternal());
            if (p != null && (p.id > n.id))
            {
                int i = IndexOf(n);
                int j = 1 - i;
                DbvtNode s = p._children[j];
                DbvtNode q = p.parent;
                Debug.Assert(n == p._children[i]);
                if (q != null)
                {
                    q._children[IndexOf(p)] = n;
                }
                else
                {
                    r = n;
                }
                s.parent = n;
                p.parent = n;
                n.parent = q;
                p._children[0] = n._children[0];
                p._children[1] = n._children[1];
                n._children[0].parent = p;
                n._children[1].parent = p;
                n._children[i] = p;
                n._children[j] = s;

                // swap id's? as well - probably not.

                Swap(ref p.volume, ref n.volume);
                return (p);
            }
            return (n);
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:36,代码来源:Dbvt.cs


示例12: CreateNode

 //
 public static DbvtNode CreateNode(Dbvt pdbvt,
                             DbvtNode parent,
                             ref DbvtAabbMm volume0,
                             ref DbvtAabbMm volume1,
                             Object data)
 {
     DbvtNode node = CreateNode(pdbvt, parent, data);
     DbvtAabbMm.Merge(ref volume0, ref volume1, ref node.volume);
     return (node);
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:11,代码来源:Dbvt.cs


示例13: RayTest

        public static void RayTest(DbvtNode root,
                                ref IndexedVector3 rayFrom,
                                ref IndexedVector3 rayTo,
                                ICollide policy)
        {

            using (DbvtStackDataBlock stackDataBlock = BulletGlobals.DbvtStackDataBlockPool.Get())
            {
                if (root != null)
                {
                    IndexedVector3 rayDir = (rayTo - rayFrom);
                    rayDir.Normalize();

                    ///what about division by zero? -. just set rayDirection[i] to INF/BT_LARGE_FLOAT
                    IndexedVector3 rayDirectionInverse = new IndexedVector3(
                        rayDir.X == 0.0f ? MathUtil.BT_LARGE_FLOAT : 1.0f / rayDir.X,
                        rayDir.Y == 0.0f ? MathUtil.BT_LARGE_FLOAT : 1.0f / rayDir.Y,
                        rayDir.Z == 0.0f ? MathUtil.BT_LARGE_FLOAT : 1.0f / rayDir.Z);

                    stackDataBlock.signs[0] = rayDirectionInverse.X < 0.0f;
                    stackDataBlock.signs[1] = rayDirectionInverse.Y < 0.0f;
                    stackDataBlock.signs[2] = rayDirectionInverse.Z < 0.0f;


                    float lambda_max = IndexedVector3.Dot(rayDir, (rayTo - rayFrom));


                    int depth = 1;
                    int treshold = DOUBLE_STACKSIZE - 2;

                    stackDataBlock.stack.Resize(DOUBLE_STACKSIZE);
                    stackDataBlock.stack[0] = root;
                    do
                    {
                        DbvtNode node = stackDataBlock.stack[--depth];

                        stackDataBlock.bounds[0] = node.volume.Mins();
                        stackDataBlock.bounds[1] = node.volume.Maxs();

                        float tmin = 1.0f, lambda_min = 0.0f;
                        bool result1 = AabbUtil2.RayAabb2(ref rayFrom, ref rayDirectionInverse, stackDataBlock.signs, stackDataBlock.bounds, out tmin, lambda_min, lambda_max);

#if COMPARE_BTRAY_AABB2
				float param=1.0f;
				bool result2 = AabbUtil.RayAabb(ref rayFrom,ref rayTo,node.volume.Mins(),node.volume.Maxs(),param,resultNormal);
				Debug.Assert(result1 == result2);
#endif //TEST_BTRAY_AABB2

                        if (result1)
                        {
                            if (node.IsInternal())
                            {
                                if (depth > treshold)
                                {
                                    stackDataBlock.stack.Resize(stackDataBlock.stack.Count * 2);
                                    treshold = stackDataBlock.stack.Count - 2;
                                }
                                stackDataBlock.stack[depth++] = node._children[0];
                                stackDataBlock.stack[depth++] = node._children[1];
                            }
                            else
                            {
                                policy.Process(node);
                            }
                        }
                    } while (depth != 0);

                }
            }
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:70,代码来源:Dbvt.cs


示例14: DeleteNode

 public static void DeleteNode(Dbvt pdbvt, DbvtNode node)
 {
     //btAlignedFree(pdbvt.m_free);
     //pdbvt.m_free = node;
     node.Reset();
     BulletGlobals.DbvtNodePool.Free(node);
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:7,代码来源:Dbvt.cs


示例15: RayTestInternal

        public void RayTestInternal(DbvtNode root,
                                    ref IndexedVector3 rayFrom,
                                    ref IndexedVector3 rayTo,
                                    ref IndexedVector3 rayDirectionInverse,
                                    bool[] signs,
                                    float lambda_max,
                                    ref IndexedVector3 aabbMin,
                                    ref IndexedVector3 aabbMax,
                                    ICollide policy)
        {
            using (DbvtStackDataBlock stackDataBlock = BulletGlobals.DbvtStackDataBlockPool.Get())
            {
                //    (void) rayTo;
                //DBVT_CHECKTYPE
                if (root != null)
                {
                    IndexedVector3 resultNormal = new IndexedVector3(0, 1, 0);

                    int depth = 1;
                    int treshold = DOUBLE_STACKSIZE - 2;
                    stackDataBlock.stack[0] = root;
                    do
                    {
                        DbvtNode node = stackDataBlock.stack[--depth];
                        stackDataBlock.bounds[0] = node.volume.Mins() - aabbMax;
                        stackDataBlock.bounds[1] = node.volume.Maxs() - aabbMin;
                        float tmin = 1.0f, lambda_min = 0.0f;
                        bool result1 = AabbUtil2.RayAabb2(ref rayFrom, ref rayDirectionInverse, signs, stackDataBlock.bounds, out tmin, lambda_min, lambda_max);
                        if (result1)
                        {
                            if (node.IsInternal())
                            {
                                if (depth > treshold)
                                {
                                    stackDataBlock.stack.Resize(stackDataBlock.stack.Count * 2);
                                    treshold = stackDataBlock.stack.Count - 2;
                                }
                                stackDataBlock.stack[depth++] = node._children[0];
                                stackDataBlock.stack[depth++] = node._children[1];
                            }
                            else
                            {
                                policy.Process(node);
                            }
                        }
                    } while (depth != 0);
                }

            }
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:50,代码来源:Dbvt.cs


示例16: InsertLeaf

        public static void InsertLeaf(Dbvt pdbvt, DbvtNode root, DbvtNode leaf)
        {
            if (pdbvt.Root == null)
            {
                pdbvt.Root = leaf;
                leaf.parent = null;
            }
            else
            {
                if (!root.IsLeaf())
                {
                    do
                    {
                        root = root._children[DbvtAabbMm.Select(ref leaf.volume,
                        ref root._children[0].volume,
                        ref root._children[1].volume)];

                    } while (!root.IsLeaf());
                }
                DbvtNode prev = root.parent;
                DbvtAabbMm mergeResults = DbvtAabbMm.Merge(ref leaf.volume, ref root.volume);

                DbvtNode node = CreateNode2(pdbvt, prev, ref mergeResults, null);
                if (prev != null)
                {
                    prev._children[IndexOf(root)] = node;
                    node._children[0] = root;
                    root.parent = node;
                    node._children[1] = leaf;
                    leaf.parent = node;
                    do
                    {
                        if (!prev.volume.Contain(ref node.volume))
                        {
                            DbvtAabbMm.Merge(ref prev._children[0].volume, ref prev._children[1].volume, ref prev.volume);
                        }
                        else
                        {
                            break;
                        }
                        node = prev;
                    } while (null != (prev = node.parent));
                }
                else
                {
                    node._children[0] = root;
                    root.parent = node;
                    node._children[1] = leaf;
                    leaf.parent = node;
                    pdbvt.Root = node;
                }
            }
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:53,代码来源:Dbvt.cs


示例17: CollideTV

 public static void CollideTV(DbvtNode root, ref DbvtAabbMm volume, ICollide collideable)
 {
     CollideTVCount++;
     Debug.Assert(CollideTVCount < 2);
     CollideTVStack.Clear();
     if (root != null)
     {
         CollideTVStack.Push(root);
         do
         {
             DbvtNode n = CollideTVStack.Pop();
             if (DbvtAabbMm.Intersect(ref n.volume, ref volume))
             {
                 if (n.IsInternal())
                 {
                     CollideTVStack.Push(n._children[0]);
                     CollideTVStack.Push(n._children[1]);
                 }
                 else
                 {
                     collideable.Process(n);
                 }
             }
         } while (CollideTVStack.Count > 0);
     }
     CollideTVCount--;
 }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:27,代码来源:Dbvt.cs


示例18: Process

        public override void Process(DbvtNode leaf)
        {
            int index = leaf.dataAsInt;

            CompoundShape compoundShape = (CompoundShape)(m_compoundColObj.GetCollisionShape());
            CollisionShape childShape = compoundShape.GetChildShape(index);
            if (m_dispatchInfo.getDebugDraw() != null && (((m_dispatchInfo.getDebugDraw().GetDebugMode() & DebugDrawModes.DBG_DrawAabb)) != 0))
            {
                IndexedVector3 worldAabbMin;
                IndexedVector3 worldAabbMax;
                IndexedMatrix orgTrans = m_compoundColObj.GetWorldTransform();

                AabbUtil2.TransformAabb(leaf.volume.Mins(), leaf.volume.Maxs(), 0f, ref orgTrans, out worldAabbMin, out worldAabbMax);
                m_dispatchInfo.getDebugDraw().DrawAabb(worldAabbMin, worldAabbMax, new IndexedVector3(1, 0, 0));
            }
            ProcessChildShape(childShape, index);
        }
开发者ID:bsamuels453,项目名称:BulletXNA,代码行数:17,代码来源:CompoundCollisionAlgorithm.cs


示例19: CreateNode2

        public static DbvtNode CreateNode2(Dbvt tree, DbvtNode aparent, ref DbvtAabbMm avolume, Object adata)
        {
            DbvtNode node = BulletGlobals.DbvtNodePool.Get();
            node.volume = avolume;
            node.parent = aparent;
            node.data = adata;
            node._children[0] = null;
            node._children[1] = null;

            if (node.data is int)
            {
                Debug.Assert(false);
                node.dataAsInt = (int)node.data;
            }

            return node;
        }
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:17,代码来源:Dbvt.cs


示例20: AllLeaves

 public bool AllLeaves(DbvtNode n)
 {
     return true;
 }
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:DbvtBroadphase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BulletDynamics.RigidBody类代码示例发布时间:2022-05-24
下一篇:
C# BulletCollision.CollisionObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap