level/brush.c
/*
============
TestAddPlane

Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side
=============
*/
TestAddPlane
Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side
TestAddPlane Adds the given plane to the brush description if all of the original brush vertexes can be put on the front side
void TestAddPlane (plane_t *plane)
{
	int		i, c;
	vec_t	d;
	vec_t	*corner;
	plane_t	flip;
	vec3_t	inv;
	int		counts[3];
	plane_t	*pl;
	for (i=0 ; i<numbrushfaces ; i++)
	{
		pl = &faces[i].plane;
		if (VectorCompare (plane->normal, pl->normal) && fabs(plane->dist - pl->dist) < ON_EPSILON)
			return;
		VectorNegate (plane->normal, inv);
		if (VectorCompare (inv, pl->normal) && fabs(plane->dist + pl->dist) < ON_EPSILON)
			return;
	}
	counts[0] = counts[1] = counts[2] = 0;
	c = num_hull_points * 8;
	corner = hull_corners[0];
	for (i=0 ; i<c ; i++, corner += 3)
	{
		d = DotProduct (corner, plane->normal) - plane->dist;
		if (d < -ON_EPSILON)
		{
			if (counts[0])
				return;
			counts[1]++;
		}
		else if (d > ON_EPSILON)
		{
			if (counts[1])
				return;
			counts[0]++;
		}
		else
			counts[2]++;
	}
	if (counts[0])
	{
		VectorNegate (plane->normal, flip.normal);
		flip.dist = -plane->dist;
		plane = &flip;
	}
	AddBrushPlane (plane);
}
void TestAddPlane ( plane_t * plane ) { int i , c ; vec_t d ; vec_t * corner ; plane_t flip ; vec3_t inv ; int counts [ 3 ] ; plane_t * pl ; for ( i = 0 ; i < numbrushfaces ; i ++ ) { pl = & faces [ i ] . plane ; if ( VectorCompare ( plane -> normal , pl -> normal ) && fabs ( plane -> dist - pl -> dist ) < ON_EPSILON ) return ; VectorNegate ( plane -> normal , inv ) ; if ( VectorCompare ( inv , pl -> normal ) && fabs ( plane -> dist + pl -> dist ) < ON_EPSILON ) return ; } counts [ 0 ] = counts [ 1 ] = counts [ 2 ] = 0 ; c = num_hull_points * 8 ; corner = hull_corners [ 0 ] ; for ( i = 0 ; i < c ; i ++ , corner += 3 ) { d = DotProduct ( corner , plane -> normal ) - plane -> dist ; if ( d < - ON_EPSILON ) { if ( counts [ 0 ] ) return ; counts [ 1 ] ++ ; } else if ( d > ON_EPSILON ) { if ( counts [ 1 ] ) return ; counts [ 0 ] ++ ; } else counts [ 2 ] ++ ; } if ( counts [ 0 ] ) { VectorNegate ( plane -> normal , flip . normal ) ; flip . dist = - plane -> dist ; plane = & flip ; } AddBrushPlane ( plane ) ; }
TestAddPlane
Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side
TestAddPlane Adds the given plane to the brush description if all of the original brush vertexes can be put on the front side
// see if the plane has allready been added // check all the corner points // the plane is a seperator