level/solidbsp.c
/*	Determines the contents of the leaf and creates the final list of
	original faces that have some fragment inside this leaf
*/
Determines the contents of the leaf and creates the final list of
original faces that have some fragment inside this leaf
Determines the contents of the leaf and creates the final list of original faces that have some fragment inside this leaf
void LinkConvexFaces( surface_t *planelist, node_t *leafnode )
{
	int			i, count;
	face_t		*f, *next;
	surface_t	*surf, *pnext;
	leafnode->faces = NULL;
	leafnode->contents = 0;
	leafnode->planenum = -1;
	count = 0;
	for( surf = planelist; surf; surf = surf->next )
	{
		for( f = surf->faces; f; f = f->next )
		{
			count++;
			if( !leafnode->contents )
				leafnode->contents = f->contents[0];
			else if( leafnode->contents != f->contents[0] )
				Error ("LinkConvexFaces: Mixed face contents in leafnode");
		}
	}
	if( !leafnode->contents )
		leafnode->contents = BSP_CONTENTS_SOLID;
	switch( leafnode->contents ) {
		case BSP_CONTENTS_EMPTY:
			c_empty++;
			break;
		case BSP_CONTENTS_SOLID:
			c_solid++;
			break;
		case BSP_CONTENTS_WATER:
			c_water++;
			break;
		case BSP_CONTENTS_SLIME:
			c_slime++;
			break;
		case BSP_CONTENTS_LAVA:
			c_lava++;
			break;
		case BSP_CONTENTS_SKY:
			c_sky++;
			break;
		default:
			Error ("LinkConvexFaces: bad contents number");
	}
	leaffaces += count;
	leafnode->markfaces = (face_t**)qmalloc( sizeof(face_t *) * (count + 1) );
	for( i = 0, surf = planelist; surf; surf = pnext )
	{
		pnext = surf->next;
		for( f = surf->faces; f; f = next, i++ )
		{
			next = f->next;
			leafnode->markfaces[i] = f->original;
			FreeFace( f );
		}
		FreeSurface( surf );
	}
	leafnode->markfaces[i] = NULL;	
}
void LinkConvexFaces ( surface_t * planelist , node_t * leafnode ) { int i , count ; face_t * f , * next ; surface_t * surf , * pnext ; leafnode -> faces = NULL ; leafnode -> contents = 0 ; leafnode -> planenum = -1 ; count = 0 ; for ( surf = planelist ; surf ; surf = surf -> next ) { for ( f = surf -> faces ; f ; f = f -> next ) { count ++ ; if ( ! leafnode -> contents ) leafnode -> contents = f -> contents [ 0 ] ; else if ( leafnode -> contents != f -> contents [ 0 ] ) Error ( " " ) ; } } if ( ! leafnode -> contents ) leafnode -> contents = BSP_CONTENTS_SOLID ; switch ( leafnode -> contents ) { case BSP_CONTENTS_EMPTY : c_empty ++ ; break ; case BSP_CONTENTS_SOLID : c_solid ++ ; break ; case BSP_CONTENTS_WATER : c_water ++ ; break ; case BSP_CONTENTS_SLIME : c_slime ++ ; break ; case BSP_CONTENTS_LAVA : c_lava ++ ; break ; case BSP_CONTENTS_SKY : c_sky ++ ; break ; default : Error ( " " ) ; } leaffaces += count ; leafnode -> markfaces = ( face_t * * ) qmalloc ( sizeof ( face_t * ) * ( count + 1 ) ) ; for ( i = 0 , surf = planelist ; surf ; surf = pnext ) { pnext = surf -> next ; for ( f = surf -> faces ; f ; f = next , i ++ ) { next = f -> next ; leafnode -> markfaces [ i ] = f -> original ; FreeFace ( f ) ; } FreeSurface ( surf ) ; } leafnode -> markfaces [ i ] = NULL ; }
Determines the contents of the leaf and creates the final list of
original faces that have some fragment inside this leaf
Determines the contents of the leaf and creates the final list of original faces that have some fragment inside this leaf
// write the list of faces, and free the originals // sentinel