/* =============== LoadBrush Converts a mapbrush to a bsp brush =============== */ brush_t *LoadBrush (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].miptex]; if (hullnum == 0) { // textures which don't show up in the drawing hull if (!Q_strcasecmp(name, "clip")) return NULL; if (!Q_strcasecmp(name, "common/nodraw")) return NULL; if (!Q_strcasecmp(name, "textures/common/nodraw")) return NULL; if (!Q_strcasecmp(name, "textures/common/clip")) return NULL; if (!Q_strcasecmp(name, "textures/common/full_clip")) return NULL; } if (!Q_strcasecmp(name, "textures/editor/visportal")) return NULL; } name = miptex[texinfo[mb->faces->texinfo].miptex]; // g-cont. without this check e1m3 won't compile if (name[0] == '!' && worldmodel ) // entities never use water merging { if (!Q_strncasecmp(name+1,"lava",4)) contents = CONTENTS_LAVA; else if (!Q_strncasecmp(name+1,"slime",5)) contents = CONTENTS_SLIME; else contents = CONTENTS_WATER; } else if (!Q_strncasecmp (name, "sky",3) && hullnum == 0) contents = CONTENTS_SKY; else contents = CONTENTS_SOLID; if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY) 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; }
/* =============== LoadBrush Converts a mapbrush to a bsp brush =============== */ brush_t *LoadBrush (mbrush_t *mb, int hullnum) { brush_t *b; int contents; char *name; mface_t *f; // // check texture name for attributes // name = miptex[texinfo[mb->faces->texinfo].miptex]; if (!Q_strcasecmp(name, "clip") && hullnum == 0) return NULL; // "clip" brushes don't show up in the draw hull if (name[0] == '*' && worldmodel) // entities never use water merging { if (!Q_strncasecmp(name+1,"lava",4)) contents = CONTENTS_LAVA; else if (!Q_strncasecmp(name+1,"slime",5)) contents = CONTENTS_SLIME; else contents = CONTENTS_WATER; } else if (!Q_strncasecmp (name, "sky",3) && worldmodel && hullnum == 0) contents = CONTENTS_SKY; else contents = CONTENTS_SOLID; if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY) 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++; } CreateBrushFaces (); if (!brush_faces) { printf ("WARNING: couldn't create brush faces\n"); return NULL; } if (hullnum) { ExpandBrush (hullnum); CreateBrushFaces (); } // // create the brush // b = AllocBrush (); b->contents = contents; b->faces = brush_faces; VectorCopy (brush_mins, b->mins); VectorCopy (brush_maxs, b->maxs); return b; }
/* =============== LoadBrush Converts a mapbrush to a bsp brush =============== */ brush_t *LoadBrush (mbrush_t *mb, int hullnum) { brush_t *b; int contents, NoOfTex = 0, I, TexNo[3], MipTex1, MipTex2, Hull; char *name, Str[512]; mface_t *f; CurrLine = mb->Line; // // check texture name for attributes // name = miptex[MipTex1 = texinfo[mb->faces->texinfo].miptex]; if (!Q_strcasecmp(name, "clip") && hullnum == 0) return NULL; // "clip" brushes don't show up in the draw hull if (name[0] == '*' && worldmodel) // entities never use water merging { if (!Q_strncasecmp(name+1,"lava",4)) contents = CONTENTS_LAVA; else if (!Q_strncasecmp(name+1,"slime",5)) contents = CONTENTS_SLIME; else contents = CONTENTS_WATER; } else if (!options.SolidMap && !Q_strncasecmp (name, "sky",3) && worldmodel && hullnum == 0) contents = CONTENTS_SKY; else contents = CONTENTS_SOLID; if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY) 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 (numbrushfaces == MAX_FACES) Message (MSGERR, "LoadBrush: numbrushfaces == MAX_FACES (%d) on line %d", MAX_FACES, CurrLine); } CreateBrushFaces (); if (!brush_faces) { strcpy(Str, name); // Find max 3 extra unique texture names for (f = mb->faces; f; f = f->next) { MipTex2 = texinfo[f->texinfo].miptex; if (NoOfTex < 3 && MipTex2 != MipTex1) { for (I = 0; I < NoOfTex; ++I) { if (MipTex2 == TexNo[I]) break; } if (I == NoOfTex) TexNo[NoOfTex++] = MipTex2; } } for (I = 0; I < NoOfTex; ++I) { strcat(Str, " "); strcat(Str, miptex[TexNo[I]]); } Message (MSGWARN, "Couldn't create brush on line %d with %d faces, %s", CurrLine, numbrushfaces, Str); return NULL; } Hull = hullnum == 0 ? options.visiblehull : hullnum; if (Hull || options.HullExpansion[1] > 0) { ExpandBrush (Hull); FreeBrushFaces(brush_faces); CreateBrushFaces (); } // // create the brush // b = AllocBrush (); b->contents = contents; b->faces = brush_faces; VectorCopy (brush_mins, b->mins); VectorCopy (brush_maxs, b->maxs); return b; }