level/brush.c
/*	Converts a mapbrush to a bsp brush
*/
Converts a mapbrush to a bsp brush
Converts a mapbrush to a bsp brush
brush_t *LoadBrush (entity_t *eCurrent, mbrush_t *mb, int brushnum, int hullnum)
{
	brush_t		*b;
	int			contents;
	char		*name;
	mface_t		*f;
	 check texture name for attributes
	for (f = mb->faces;f;f = f->next)
	{
		name = miptex[texinfo[f->texinfo].iMipTex];
		if (hullnum == 0)
			 textures which don't show up in the drawing hull
			if (!Q_strcasecmp(name, "clip"))
				return NULL;
	}
	name = miptex[texinfo[mb->faces->texinfo].iMipTex];
	if ((name[0] == '*') || (name[0] == '#'))		 entities never use water merging
	{
		if(!Q_strncasecmp(name+1,"lava",4))
			contents = BSP_CONTENTS_LAVA;
		else if(!Q_strncasecmp(name+1,"slime",5))
			contents = BSP_CONTENTS_SLIME;
		else
			contents = BSP_CONTENTS_WATER;
	}
	else if ((!strncmp(name, "sky", 3) || !strncmp(name, "sky3d", 5)) && hullnum == 0)
		contents = BSP_CONTENTS_SKY;
	else
		contents = BSP_CONTENTS_SOLID;
	if ((hullnum && contents != BSP_CONTENTS_SOLID && contents != BSP_CONTENTS_SKY) &&
		 Work around for seperate brush entities.
		 TODO: Better solution...
		(eCurrent == &entities[0]))
		return NULL;		 water brushes don't show up in clipping hulls
	 no seperate textures on clip hull
	 create the faces
	brush_faces = NULL;
	numbrushfaces = 0;
	for(f = mb->faces; f; f = f->next)
	{
		faces[numbrushfaces] = *f;
		if(hullnum)
			faces[numbrushfaces].texinfo = 0;
		numbrushfaces++;
	}
	if(hullnum)
		ExpandBrush (hullnum);
	CreateBrushFaces();
	if (!brush_faces)
	{
		printf ("WARNING: couldn't create faces for brush %i in entity %i (incomplete brush?)\n", brushnum, (int)(CurrentEntity - entities));
		return NULL;
	}
	 create the brush
	b = AllocBrush ();
	b->contents = contents;
	b->faces = brush_faces;
	VectorCopy (brush_mins, b->mins);
	VectorCopy (brush_maxs, b->maxs);
	 debugging code
	printf("mapbrush\n");
	for (f=mb->faces ; f ; f=f->next)
		printf("face %f %f %f %f \"%s\"\n", f->plane.normal[0], f->plane.normal[1], f->plane.normal[2], f->plane.dist, miptex[texinfo[f->texinfo].miptex]);
	printf("bspbrush %i\n", numbrushfaces);
	face_t		*face;
	for (face=b->faces ; face ; face=face->next)
		printf("bspface %f %f %f %f\n", mapplanes[face->planenum].normal[0], mapplanes[face->planenum].normal[1], mapplanes[face->planenum].normal[2], mapplanes[face->planenum].dist);
	return b;
}
brush_t * LoadBrush ( entity_t * eCurrent , mbrush_t * mb , int brushnum , int hullnum ) { brush_t * b ; int contents ; char * name ; mface_t * f ; for ( f = mb -> faces ; f ; f = f -> next ) { name = miptex [ texinfo [ f -> texinfo ] . iMipTex ] ; if ( hullnum == 0 ) if ( ! Q_strcasecmp ( name , " " ) ) return NULL ; } name = miptex [ texinfo [ mb -> faces -> texinfo ] . iMipTex ] ; if ( ( name [ 0 ] == ' ' ) || ( name [ 0 ] == ' ' ) ) { if ( ! Q_strncasecmp ( name + 1 , " " , 4 ) ) contents = BSP_CONTENTS_LAVA ; else if ( ! Q_strncasecmp ( name + 1 , " " , 5 ) ) contents = BSP_CONTENTS_SLIME ; else contents = BSP_CONTENTS_WATER ; } else if ( ( ! strncmp ( name , " " , 3 ) || ! strncmp ( name , " " , 5 ) ) && hullnum == 0 ) contents = BSP_CONTENTS_SKY ; else contents = BSP_CONTENTS_SOLID ; if ( ( hullnum && contents != BSP_CONTENTS_SOLID && contents != BSP_CONTENTS_SKY ) && ( eCurrent == & entities [ 0 ] ) ) return NULL ; brush_faces = NULL ; numbrushfaces = 0 ; for ( f = mb -> faces ; f ; f = f -> next ) { faces [ numbrushfaces ] = * f ; if ( hullnum ) faces [ numbrushfaces ] . texinfo = 0 ; numbrushfaces ++ ; } if ( hullnum ) ExpandBrush ( hullnum ) ; CreateBrushFaces ( ) ; if ( ! brush_faces ) { printf ( " \n " , brushnum , ( int ) ( CurrentEntity - entities ) ) ; return NULL ; } b = AllocBrush ( ) ; b -> contents = contents ; b -> faces = brush_faces ; VectorCopy ( brush_mins , b -> mins ) ; VectorCopy ( brush_maxs , b -> maxs ) ; return b ; }
Converts a mapbrush to a bsp brush
Converts a mapbrush to a bsp brush
// // check texture name for attributes // // textures which don't show up in the drawing hull // entities never use water merging // Work around for seperate brush entities. // TODO: Better solution... // water brushes don't show up in clipping hulls // no seperate textures on clip hull // // create the faces // // // create the brush // // debugging code //printf("mapbrush\n"); //for (f=mb->faces ; f ; f=f->next) //	printf("face %f %f %f %f \"%s\"\n", f->plane.normal[0], f->plane.normal[1], f->plane.normal[2], f->plane.dist, miptex[texinfo[f->texinfo].miptex]); //printf("bspbrush %i\n", numbrushfaces); //face_t		*face; //for (face=b->faces ; face ; face=face->next) //	printf("bspface %f %f %f %f\n", mapplanes[face->planenum].normal[0], mapplanes[face->planenum].normal[1], mapplanes[face->planenum].normal[2], mapplanes[face->planenum].dist);