예제 #1
0
파일: Dbvt.cs 프로젝트: d3x0r/Voxelarium
		public static void EnumLeaves( btDbvtNode root, ICollide collideable )
		{
			if( root.IsInternal() )
			{
				EnumLeaves( root._children0, collideable );
				EnumLeaves( root._children1, collideable );
			}
			else
			{
				collideable.Process( root );
			}
		}
예제 #2
0
파일: Dbvt.cs 프로젝트: d3x0r/Voxelarium
		public static void FetchLeafs( btDbvt pdbvt, btDbvtNode root, btList<btDbvtNode> leafs, int depth )
		{
			if( root.IsInternal() && depth != 0 )
			{
				FetchLeafs( pdbvt, root._children0, leafs, depth - 1 );
				FetchLeafs( pdbvt, root._children1, leafs, depth - 1 );
				DeleteNode( pdbvt, root );
			}
			else
			{
				leafs.Add( root );
			}
		}
예제 #3
0
파일: Dbvt.cs 프로젝트: d3x0r/Voxelarium
		public static void GetMaxDepth( btDbvtNode node, int depth, ref int maxDepth )
		{
			if( node.IsInternal() )
			{
				GetMaxDepth( node._children0, depth + 1, ref maxDepth );
				GetMaxDepth( node._children1, depth + 1, ref maxDepth );
			}
			else
			{
				maxDepth = Math.Max( depth, maxDepth );
			}
		}
예제 #4
0
파일: Dbvt.cs 프로젝트: d3x0r/Voxelarium
		public static btDbvtNode Sort( btDbvtNode n, btDbvtNode r )
		{
			btDbvtNode p = n.parent;
			Debug.Assert( n.IsInternal() );
			if( p != null && ( p.id > n.id ) )
			{
				int i = IndexOf( n );
				int j = 1 - i;
				btDbvtNode s = (j==0)?p._children0:p._children1;
				btDbvtNode q = p.parent;
				Debug.Assert( n == ((i==0)?p._children0:p._children1) );
				if( q != null )
				{
					if( IndexOf( p ) == 1 )
	                    q._children1 = n;
					else
						q._children0 = n;
				}
				else
				{
					r = n;
				}
				s.parent = n;
				p.parent = n;
				n.parent = q;
				p._children0 = n._children0;
				p._children1 = n._children1;
				n._children0.parent = p;
				n._children1.parent = p;
				if( i == 0 )
					n._children0 = p;
				else
					n._children1 = p;
				if( j == 0 )
					n._children0 = s;
				else
					n._children1 = s;

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

				swap( ref p.volume, ref n.volume );
				return ( p );
			}
			return ( n );
		}