Axiom.Math.AxisAlignedBox.Intersects C# (CSharp) Method

Intersects() public method

Returns whether or not this box intersects another.
public Intersects ( AxisAlignedBox box2 ) : bool
box2 AxisAlignedBox
return bool
		public bool Intersects( AxisAlignedBox box2 )
		{
			// Early-fail for nulls
			if ( this.IsNull || box2.IsNull )
				return false;

			if ( this.IsInfinite || box2.IsInfinite )
				return true;

			// Use up to 6 separating planes
			if ( this.maxVector.x < box2.minVector.x )
				return false;
			if ( this.maxVector.y < box2.minVector.y )
				return false;
			if ( this.maxVector.z < box2.minVector.z )
				return false;

			if ( this.minVector.x > box2.maxVector.x )
				return false;
			if ( this.minVector.y > box2.maxVector.y )
				return false;
			if ( this.minVector.z > box2.maxVector.z )
				return false;

			// otherwise, must be intersecting
			return true;
		}

Same methods

AxisAlignedBox::Intersects ( Plane plane ) : bool
AxisAlignedBox::Intersects ( Sphere sphere ) : bool
AxisAlignedBox::Intersects ( Vector3 vector ) : bool

Usage Example

Example #1
0
		// --- find nodes which intersect various types of BV's ---
		public override void FindNodes( AxisAlignedBox 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;
				}
			}

			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 bounding 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 );
						}
					}
				}
			}
		}
All Usage Examples Of Axiom.Math.AxisAlignedBox::Intersects