Sources/CryGame C++/Solution1/CryGame/XArea.cpp
//////////////////////////////////////////////////////////////////////
//	for editor use - if point is within - returns closest distance to border
//	if point is out - returns -1

for editor use - if point is within - returns closest distance to border
if point is out - returns -1
for editor use - if point is within - returns closest distance to border if point is out - returns - 1
float	CXArea::IsPointWithinDist(const a2DPoint& point) const
{
	int	cntr=0;	
	float	minDist=-1;
	float	dist;
	if( m_BBox.PointOutBBox2D( point ) )
		return -1;
	for(unsigned int sIdx=0; sIdx<m_vpSegments.size(); sIdx++)
	{
		if(m_vpSegments[sIdx]->isHorizontal)
			continue;
		if( m_vpSegments[sIdx]->k==0 )
			dist = m_vpSegments[sIdx]->b - point.x;
		else
			if(!m_vpSegments[sIdx]->bbox.PointOutBBox2D( point ))
				dist = m_vpSegments[sIdx]->GetIntersectX( point );
			else
				continue;
		if( dist<0 )
			dist = -dist;
		else
			cntr++;
		if( minDist>dist || minDist<0)
			minDist = dist;
	}
	if(cntr & 0x1)
		return	minDist;
	else
		return	-1;
}
float CXArea :: IsPointWithinDist ( const a2DPoint & point ) const { int cntr = 0 ; float minDist = -1 ; float dist ; if ( m_BBox . PointOutBBox2D ( point ) ) return -1 ; for ( unsigned int sIdx = 0 ; sIdx < m_vpSegments . size ( ) ; sIdx ++ ) { if ( m_vpSegments [ sIdx ] -> isHorizontal ) continue ; if ( m_vpSegments [ sIdx ] -> k == 0 ) dist = m_vpSegments [ sIdx ] -> b - point . x ; else if ( ! m_vpSegments [ sIdx ] -> bbox . PointOutBBox2D ( point ) ) dist = m_vpSegments [ sIdx ] -> GetIntersectX ( point ) ; else continue ; if ( dist < 0 ) dist = - dist ; else cntr ++ ; if ( minDist > dist || minDist < 0 ) minDist = dist ; } if ( cntr & 0x1 ) return minDist ; else return -1 ; }
for editor use - if point is within - returns closest distance to border
if point is out - returns -1
for editor use - if point is within - returns closest distance to border if point is out - returns - 1