level/brush.c
/*
============
AddHullEdge

Creates all of the hull planes around the given edge, if not done allready
=============
*/
AddHullEdge
Creates all of the hull planes around the given edge, if not done allready
AddHullEdge Creates all of the hull planes around the given edge if not done allready
void AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
{
	int		pt1, pt2;
	int		i;
	int		a, b, c, d, e;
	vec3_t	edgevec, planeorg, planevec;
	plane_t	plane;
	vec_t	length;
	pt1 = AddHullPoint (p1, hullnum);
	pt2 = AddHullPoint (p2, hullnum);
	for (i=0 ; i<num_hull_edges ; i++)
		if ((hull_edges[i][0] == pt1 && hull_edges[i][1] == pt2) || (hull_edges[i][0] == pt2 && hull_edges[i][1] == pt1))
			return;	
	if (num_hull_edges == MAX_HULL_EDGES)
		Error ("AddHullEdge: MAX_HULL_EDGES");
	hull_edges[num_hull_edges][0] = pt1;
	hull_edges[num_hull_edges][1] = pt2;
	num_hull_edges++;
	VectorSubtract(p1, p2, edgevec);
	VectorNormalize(edgevec);
	for (a=0 ; a<3 ; a++)
	{
		b = (a+1)%3;
		c = (a+2)%3;
		planevec[a] = 1;
		planevec[b] = 0;
		planevec[c] = 0;
		CrossProduct(planevec, edgevec, plane.normal);
		length = VectorNormalize(plane.normal);
		if (length < ANGLE_EPSILON)
			continue;
		for (d = 0 ; d < 2 ; d++)
		{
			for (e = 0 ; e < 2 ; e++)
			{
				VectorCopy(p1, planeorg);
				planeorg[b] -= hullinfo.hullsizes[hullnum][d^1][b];
				planeorg[c] -= hullinfo.hullsizes[hullnum][e^1][c];
				plane.dist = DotProduct(planeorg, plane.normal);
				TestAddPlane(&plane);
			}
		}
	}
}
void AddHullEdge ( vec3_t p1 , vec3_t p2 , int hullnum ) { int pt1 , pt2 ; int i ; int a , b , c , d , e ; vec3_t edgevec , planeorg , planevec ; plane_t plane ; vec_t length ; pt1 = AddHullPoint ( p1 , hullnum ) ; pt2 = AddHullPoint ( p2 , hullnum ) ; for ( i = 0 ; i < num_hull_edges ; i ++ ) if ( ( hull_edges [ i ] [ 0 ] == pt1 && hull_edges [ i ] [ 1 ] == pt2 ) || ( hull_edges [ i ] [ 0 ] == pt2 && hull_edges [ i ] [ 1 ] == pt1 ) ) return ; if ( num_hull_edges == MAX_HULL_EDGES ) Error ( " " ) ; hull_edges [ num_hull_edges ] [ 0 ] = pt1 ; hull_edges [ num_hull_edges ] [ 1 ] = pt2 ; num_hull_edges ++ ; VectorSubtract ( p1 , p2 , edgevec ) ; VectorNormalize ( edgevec ) ; for ( a = 0 ; a < 3 ; a ++ ) { b = ( a + 1 ) % 3 ; c = ( a + 2 ) % 3 ; planevec [ a ] = 1 ; planevec [ b ] = 0 ; planevec [ c ] = 0 ; CrossProduct ( planevec , edgevec , plane . normal ) ; length = VectorNormalize ( plane . normal ) ; if ( length < ANGLE_EPSILON ) continue ; for ( d = 0 ; d < 2 ; d ++ ) { for ( e = 0 ; e < 2 ; e ++ ) { VectorCopy ( p1 , planeorg ) ; planeorg [ b ] -= hullinfo . hullsizes [ hullnum ] [ d ^ 1 ] [ b ] ; planeorg [ c ] -= hullinfo . hullsizes [ hullnum ] [ e ^ 1 ] [ c ] ; plane . dist = DotProduct ( planeorg , plane . normal ) ; TestAddPlane ( & plane ) ; } } } }
AddHullEdge
Creates all of the hull planes around the given edge, if not done allready
AddHullEdge Creates all of the hull planes around the given edge if not done allready
// already added /* If this edge is almost parallel to the hull edge, skip it. */