Ejemplo n.º 1
0
 public static void collideTT(Node root0, Node root1, Dispatcher dispatcher, ICollide policy)
 {
     if (root0 != null && root1 != null)
     {
         List <sStkNN> stack = new List <sStkNN>(DOUBLE_STACKSIZE);
         stack.Add(new sStkNN(root0, root1));
         do
         {
             sStkNN p = stack[stack.Count - 1];
             stack.RemoveAt(stack.Count - 1);
             if (p.a == p.b)
             {
                 if (p.a.isinternal())
                 {
                     stack.Add(new sStkNN(p.a.childs[0], p.a.childs[0]));
                     stack.Add(new sStkNN(p.a.childs[1], p.a.childs[1]));
                     stack.Add(new sStkNN(p.a.childs[0], p.a.childs[1]));
                 }
             }
             else if (DbvtAabbMm.Intersect(p.a.volume, p.b.volume))
             {
                 if (p.a.isinternal())
                 {
                     if (p.b.isinternal())
                     {
                         stack.Add(new sStkNN(p.a.childs[0], p.b.childs[0]));
                         stack.Add(new sStkNN(p.a.childs[1], p.b.childs[0]));
                         stack.Add(new sStkNN(p.a.childs[0], p.b.childs[1]));
                         stack.Add(new sStkNN(p.a.childs[1], p.b.childs[1]));
                     }
                     else
                     {
                         stack.Add(new sStkNN(p.a.childs[0], p.b));
                         stack.Add(new sStkNN(p.a.childs[1], p.b));
                     }
                 }
                 else
                 {
                     if (p.b.isinternal())
                     {
                         stack.Add(new sStkNN(p.a, p.b.childs[0]));
                         stack.Add(new sStkNN(p.a, p.b.childs[1]));
                     }
                     else
                     {
                         if (!dispatcher.needsCollision(p.a.data.collisionFilterGroup, p.a.data.collisionFilterMask, p.b.data.collisionFilterGroup, p.b.data.collisionFilterMask))
                         {
                             continue;
                         }
                         policy.Process(p.a, p.b);
                     }
                 }
             }
         }while (stack.Count > 0);
     }
 }
Ejemplo n.º 2
0
		public static void CollideTTpersistentStack( btDbvtNode root0,
								  btDbvtNode root1,
								  ICollide collideable )
		{
			//CollideTT(root0, root1, collideable);
			//return;
			if( root0 != null && root1 != null )
			{
				int depth = 1;
				int treshold = m_stkStack.Length - 4;

				//m_stkStack.Capacity = DOUBLE_STACKSIZE;
				m_stkStack[0].Initialize( root0, root1 );
				do
				{
					sStkNN p = m_stkStack[--depth];
					if( depth > treshold )
					{
						sStkNN[] newArray = new sStkNN[m_stkStack.Length * 2];
						for( int n = 0; n < depth; n++ )
							newArray[n] = m_stkStack[n];
						m_stkStack = newArray;
						treshold = newArray.Length - 4;
					}
					if( p.a == p.b )
					{
						if( p.a.IsInternal() )
						{
							m_stkStack[depth++].Initialize( p.a._children0, p.a._children0 );
							m_stkStack[depth++].Initialize( p.a._children1, p.a._children1 );
							m_stkStack[depth++].Initialize( p.a._children0, p.a._children1 );
						}
					}
					else if( btDbvtVolume.Intersect( ref p.a.volume, ref p.b.volume ) )
					{
						if( p.a.IsInternal() )
						{
							if( p.b.IsInternal() )
							{
								m_stkStack[depth++].Initialize( p.a._children0, p.b._children0 );
								m_stkStack[depth++].Initialize( p.a._children1, p.b._children0 );
								m_stkStack[depth++].Initialize( p.a._children0, p.b._children1 );
								m_stkStack[depth++].Initialize( p.a._children1, p.b._children1 );
							}
							else
							{
								m_stkStack[depth++].Initialize( p.a._children0, p.b );
								m_stkStack[depth++].Initialize( p.a._children1, p.b );
							}
						}
						else
						{
							if( p.b.IsInternal() )
							{
								m_stkStack[depth++].Initialize( p.a, p.b._children0 );
								m_stkStack[depth++].Initialize( p.a, p.b._children1 );
							}
							else
							{
								collideable.Process( p.a, p.b );
							}
						}
					}
				} while( depth > 0 );
			}
		}
Ejemplo n.º 3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(sStkNN obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }