Intersects() public method

Returns whether or not this sphere interects a box.
public Intersects ( AxisAlignedBox box ) : bool
box AxisAlignedBox
return bool
Exemplo n.º 1
0
 /// <summary>
 /// /
 /// </summary>
 /// <param name="sphere"></param>
 /// <param name="terrainList"></param>
 public void SphereIntersects(Sphere sphere, out List<Terrain> terrainList)
 {
     terrainList = new List<Terrain>();
     foreach (TerrainSlot i in _terrainSlots.Values)
     {
         if (i.Instance != null && sphere.Intersects(i.Instance.WorldAABB))
             terrainList.Add(i.Instance);
     }
 }
Exemplo n.º 2
0
		public override void FindNodes( Sphere t,
									 ref List<PCZSceneNode> list,
									 List<Portal> visitedPortals,
									 bool includeVisitors,
									 bool recurseThruPortals,
									 PCZSceneNode exclude )
		{
			// if this zone has an enclosure, check against the enclosure AABB first
			if ( null != mEnclosureNode )
			{
				if ( !mEnclosureNode.WorldAABB.Intersects( t ) )
				{
					// AABB of zone does not intersect t, just return.
					return;
				}
			}

			// check nodes at home in this zone
			foreach ( PCZSceneNode pczsn in mHomeNodeList )
			{
				if ( pczsn != exclude )
				{
					// make sure node is not already in the list (might have been added in another
					// zone it was visiting)
					if ( !list.Contains( pczsn ) )
					{
						bool nsect = t.Intersects( pczsn.WorldAABB );
						if ( nsect )
						{
							list.Add( pczsn );
						}
					}
				}
			}

			if ( includeVisitors )
			{
				// check visitor nodes
				foreach ( PCZSceneNode pczsn in mVisitorNodeList )
				{
					if ( pczsn != exclude )
					{
						// make sure node is not already in the list (might have been added in another
						// zone it was visiting)
						if ( !list.Contains( pczsn ) )
						{
							bool nsect = t.Intersects( pczsn.WorldAABB );
							if ( nsect )
							{
								list.Add( pczsn );
							}
						}
					}
				}
			}

			// if asked to, recurse through portals
			if ( recurseThruPortals )
			{
				foreach ( Portal portal in mPortals )
				{
					// check portal versus boundign box
					if ( portal.intersects( t ) )
					{
						// make sure portal hasn't already been recursed through
						if ( !visitedPortals.Contains( portal ) )
						{
							// save portal to the visitedPortals list
							visitedPortals.Add( portal );
							// recurse into the connected zone
							portal.getTargetZone().FindNodes( t,
																ref list,
																visitedPortals,
																includeVisitors,
																recurseThruPortals,
																exclude );
						}
					}
				}
			}

		}
Exemplo n.º 3
0
		// Check if a portal intersects a sphere
		// NOTE: This check is not exact.
		public bool intersects( Sphere sphere )
		{
			// Only check if portal is open
			if ( mOpen )
			{
				switch ( mType )
				{
					case PORTAL_TYPE.PORTAL_TYPE_QUAD:
						// since ogre doesn't have built in support for a quad, just check
						// if the sphere intersects both the sphere of the portal and the plane
						// this can result in false positives, but they will be minimal
						if ( !sphere.Intersects( mDerivedSphere ) )
						{
							return false;
						}
						if ( sphere.Intersects( mDerivedPlane ) )
						{
							return true;
						}
						break;
					case PORTAL_TYPE.PORTAL_TYPE_AABB:
						{
							// aab to aab check
							AxisAlignedBox aabb = new AxisAlignedBox( mDerivedCorners[ 0 ], mDerivedCorners[ 1 ] );
							return ( aabb.Intersects( sphere ) );
						}
					case PORTAL_TYPE.PORTAL_TYPE_SPHERE:
						return ( mDerivedSphere.Intersects( sphere ) );
				}
			}
			return false;
		}