Beispiel #1
0
/*
============
idAASLocal::TestIfBarrierIsolatesReachability
============
*/
bool idAASLocal::TestIfBarrierIsolatesReachability
(
	idReachability* p_reachability,
	int areaIndex,
	idBounds barrierBounds
) const
{
	/*
	* Test params
	*/
	if ( p_reachability == NULL)
	{
		return false;
	}

	// Test the paths from the reachability to all other reachabilities leaving
	// the area.  If a reachability has no path to another reachability that does not 
	// intersect the barrier, then return true. Also if there are no other reachbilities
	// return true.  Otherwise return false;

	// Iterate the other reachabilities
	bool b_hadPath = false;
	bool b_foundClearPath = false;
	idReachability* p_reach2 = GetAreaFirstReachability(areaIndex);

	while (p_reach2 != NULL)
	{
		if (p_reach2 != p_reachability)
		{
			b_hadPath = true;

			// Test if path between the reachabilities is blocked by the barrier bounds
			if (barrierBounds.LineIntersection (p_reachability->start, p_reach2->start))
			{
				// Blocked
				return true;
			}
			/*
				// Its not blocked
				b_foundClearPath = true;
			}
			*/

		} // Not same reachability

		// Is it blocked?
		if (b_foundClearPath)
		{
			// End iteration early if we already found a clear path
			p_reach2 = NULL;
		}
		else
		{
			p_reach2 = p_reach2->next;
		}
	
	} // Next other reachability on same area

	return false;

	/*

	// Return result of test
	if ( (b_hadPath) && (!b_foundClearPath) )
	{
		// Its isolated by the bounds given
		return true;
	}
	else
	{
		// Its not isolated by the bounds given
		return false;
	}
	*/

}