Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

map.c File Reference

#include "qbsp.h"
#include "l_bsp_hl.h"
#include "l_bsp_q1.h"
#include "l_bsp_q2.h"
#include "l_bsp_q3.h"
#include "l_bsp_sin.h"
#include "l_mem.h"
#include "../botlib/aasfile.h"
#include "aas_store.h"
#include "aas_cfg.h"

Include dependency graph for map.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  idheader_t

Defines

#define DIST_EPSILON   0.02
#define NORMAL_EPSILON   0.0001
#define PLANE_HASHES   1024
#define Q2_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
#define Q2_BSPVERSION   38
#define Sign(x)   (x < 0 ? 1 : 0)
#define SIN_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
#define SIN_BSPVERSION   41
#define SINGAME_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'R')
#define SINGAME_BSPVERSION   1
#define USE_HASHING

Functions

void AddBrushBevels (mapbrush_t *b)
void AddPlaneToHash (plane_t *p)
int BrushExists (mapbrush_t *brush)
int CreateNewFloatPlane (vec3_t normal, vec_t dist)
int FindFloatPlane (vec3_t normal, vec_t dist)
mapbrush_tGetAreaPortalBrush (entity_t *mapent)
int LoadMapFromBSP (struct quakefile_s *qf)
qboolean MakeBrushWindings (mapbrush_t *ob)
void MarkBrushBevels (mapbrush_t *brush)
qboolean PlaneEqual (plane_t *p, vec3_t normal, vec_t dist)
int PlaneFromPoints (int *p0, int *p1, int *p2)
int PlaneSignBits (vec3_t normal)
int PlaneTypeForNormal (vec3_t normal)
void PrintMapInfo (void)
void ResetMapLoading (void)
void SnapPlane (vec3_t normal, vec_t *dist)
void SnapVector (vec3_t normal)
qboolean WriteMapBrush (FILE *fp, mapbrush_t *brush, vec3_t origin)
void WriteMapFile (char *filename)
qboolean WriteMapFileSafe (FILE *fp)
qboolean WriteOriginBrush (FILE *fp, vec3_t origin)

Variables

side_t brushsides [MAX_MAPFILE_BRUSHSIDES]
int c_areaportals
int c_boxbevels
int c_clipbrushes
int c_edgebevels
int c_squattbrushes
int c_writtenbrushes
int loadedmaptype
vec3_t map_maxs
vec3_t map_mins
int map_numtexinfo
map_texinfo_t map_texinfo [MAX_MAPFILE_TEXINFO]
mapbrush_t mapbrushes [MAX_MAPFILE_BRUSHES]
plane_t mapplanes [MAX_MAPFILE_PLANES]
int mapplaneusers [MAX_MAPFILE_PLANES]
int nummapbrushes
int nummapbrushsides
int nummapplanes
plane_tplanehash [PLANE_HASHES]
brush_texture_t side_brushtextures [MAX_MAPFILE_BRUSHSIDES]
textureref_t side_newrefs [MAX_MAPFILE_BRUSHSIDES]


Define Documentation

#define DIST_EPSILON   0.02
 

Definition at line 132 of file map.c.

#define NORMAL_EPSILON   0.0001
 

Definition at line 130 of file map.c.

#define PLANE_HASHES   1024
 

Definition at line 47 of file map.c.

Referenced by AddPlaneToHash(), FindFloatPlane(), and ResetMapLoading().

#define Q2_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
 

Definition at line 1189 of file map.c.

Referenced by LoadMapFromBSP().

#define Q2_BSPVERSION   38
 

Definition at line 1190 of file map.c.

#define Sign  )     (x < 0 ? 1 : 0)
 

Definition at line 34 of file map.c.

Referenced by main(), PlaneSignBits(), and TH_PlaneSignBits().

#define SIN_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
 

Definition at line 1195 of file map.c.

#define SIN_BSPVERSION   41
 

Definition at line 1196 of file map.c.

#define SINGAME_BSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'R')
 

Definition at line 1192 of file map.c.

#define SINGAME_BSPVERSION   1
 

Definition at line 1193 of file map.c.

#define USE_HASHING
 

Definition at line 60 of file map.c.


Function Documentation

void AddBrushBevels mapbrush_t b  ) 
 

Definition at line 336 of file map.c.

00337 {
00338     int     axis, dir;
00339     int     i, j, k, l, order;
00340     side_t  sidetemp;
00341     brush_texture_t tdtemp;
00342 #ifdef SIN
00343    textureref_t trtemp;
00344 #endif
00345     side_t  *s, *s2;
00346     vec3_t  normal;
00347     float   dist;
00348     winding_t   *w, *w2;
00349     vec3_t  vec, vec2;
00350     float   d;
00351 
00352     //
00353     // add the axial planes
00354     //
00355     order = 0;
00356     for (axis=0 ; axis <3 ; axis++)
00357     {
00358         for (dir=-1 ; dir <= 1 ; dir+=2, order++)
00359         {
00360             // see if the plane is allready present
00361             for (i=0, s=b->original_sides ; i<b->numsides ; i++,s++)
00362             {
00363                 if (mapplanes[s->planenum].normal[axis] == dir)
00364                     break;
00365             }
00366 
00367             if (i == b->numsides)
00368             {   // add a new side
00369                 if (nummapbrushsides == MAX_MAP_BRUSHSIDES)
00370                     Error ("MAX_MAP_BRUSHSIDES");
00371                 nummapbrushsides++;
00372                 b->numsides++;
00373                 VectorClear (normal);
00374                 normal[axis] = dir;
00375                 if (dir == 1)
00376                     dist = b->maxs[axis];
00377                 else
00378                     dist = -b->mins[axis];
00379                 s->planenum = FindFloatPlane (normal, dist);
00380                 s->texinfo = b->original_sides[0].texinfo;
00381 #ifdef SIN
00382                 s->lightinfo = b->original_sides[0].lightinfo;
00383 #endif
00384                 s->contents = b->original_sides[0].contents;
00385                 s->flags |= SFL_BEVEL;
00386                 c_boxbevels++;
00387             }
00388 
00389             // if the plane is not in it canonical order, swap it
00390             if (i != order)
00391             {
00392                 sidetemp = b->original_sides[order];
00393                 b->original_sides[order] = b->original_sides[i];
00394                 b->original_sides[i] = sidetemp;
00395 
00396                 j = b->original_sides - brushsides;
00397                 tdtemp = side_brushtextures[j+order];
00398                 side_brushtextures[j+order] = side_brushtextures[j+i];
00399                 side_brushtextures[j+i] = tdtemp;
00400 
00401 #ifdef SIN
00402                 trtemp = side_newrefs[j+order];
00403                 side_newrefs[j+order] = side_newrefs[j+i];
00404                 side_newrefs[j+i] = trtemp;
00405 #endif
00406             }
00407         }
00408     }
00409 
00410     //
00411     // add the edge bevels
00412     //
00413     if (b->numsides == 6)
00414         return;     // pure axial
00415 
00416     // test the non-axial plane edges
00417     for (i=6 ; i<b->numsides ; i++)
00418     {
00419         s = b->original_sides + i;
00420         w = s->winding;
00421         if (!w)
00422             continue;
00423         for (j=0 ; j<w->numpoints ; j++)
00424         {
00425             k = (j+1)%w->numpoints;
00426             VectorSubtract (w->p[j], w->p[k], vec);
00427             if (VectorNormalize (vec) < 0.5)
00428                 continue;
00429             SnapVector (vec);
00430             for (k=0 ; k<3 ; k++)
00431                 if ( vec[k] == -1 || vec[k] == 1)
00432                     break;  // axial
00433             if (k != 3)
00434                 continue;   // only test non-axial edges
00435 
00436             // try the six possible slanted axials from this edge
00437             for (axis=0 ; axis <3 ; axis++)
00438             {
00439                 for (dir=-1 ; dir <= 1 ; dir+=2)
00440                 {
00441                     // construct a plane
00442                     VectorClear (vec2);
00443                     vec2[axis] = dir;
00444                     CrossProduct (vec, vec2, normal);
00445                     if (VectorNormalize (normal) < 0.5)
00446                         continue;
00447                     dist = DotProduct (w->p[j], normal);
00448 
00449                     // if all the points on all the sides are
00450                     // behind this plane, it is a proper edge bevel
00451                     for (k=0 ; k<b->numsides ; k++)
00452                     {
00453                         // if this plane has allready been used, skip it
00454                         if (PlaneEqual (&mapplanes[b->original_sides[k].planenum]
00455                             , normal, dist) )
00456                             break;
00457 
00458                         w2 = b->original_sides[k].winding;
00459                         if (!w2)
00460                             continue;
00461                         for (l=0 ; l<w2->numpoints ; l++)
00462                         {
00463                             d = DotProduct (w2->p[l], normal) - dist;
00464                             if (d > 0.1)
00465                                 break;  // point in front
00466                         }
00467                         if (l != w2->numpoints)
00468                             break;
00469                     }
00470 
00471                     if (k != b->numsides)
00472                         continue;   // wasn't part of the outer hull
00473                     // add this plane
00474                     if (nummapbrushsides == MAX_MAP_BRUSHSIDES)
00475                         Error ("MAX_MAP_BRUSHSIDES");
00476                     nummapbrushsides++;
00477                     s2 = &b->original_sides[b->numsides];
00478                     s2->planenum = FindFloatPlane (normal, dist);
00479                     s2->texinfo = b->original_sides[0].texinfo;
00480 #ifdef SIN
00481                     s2->lightinfo = b->original_sides[0].lightinfo;
00482 #endif
00483                     s2->contents = b->original_sides[0].contents;
00484                     s2->flags |= SFL_BEVEL;
00485                     c_edgebevels++;
00486                     b->numsides++;
00487                 }
00488             }
00489         }
00490     }
00491 } //end of the function AddBrushBevels

void AddPlaneToHash plane_t p  ) 
 

Definition at line 157 of file map.c.

References plane_t::dist, fabs(), p, PLANE_HASHES, and planehash.

00158 {
00159     int     hash;
00160 
00161     hash = (int)fabs(p->dist) / 8;
00162     hash &= (PLANE_HASHES-1);
00163 
00164     p->hash_chain = planehash[hash];
00165     planehash[hash] = p;
00166 } //end of the function AddPlaneToHash

Here is the call graph for this function:

int BrushExists mapbrush_t brush  ) 
 

Definition at line 613 of file map.c.

References mapbrush_s::entitynum, i, mapbrush_t, mapbrushes, mapbrush_s::numsides, mapbrush_s::original_sides, side_s::planenum, and side_t.

Referenced by Q2_BSPBrushToMapBrush(), Q2_ParseBrush(), Q3_BSPBrushToMapBrush(), and Sin_BSPBrushToMapBrush().

00614 {
00615     int i, s1, s2;
00616     side_t *side1, *side2;
00617     mapbrush_t *brush1, *brush2;
00618 
00619     for (i = 0; i < nummapbrushes; i++)
00620     {
00621         brush1 = brush;
00622         brush2 = &mapbrushes[i];
00623         //compare the brushes
00624         if (brush1->entitynum != brush2->entitynum) continue;
00625         //if (brush1->contents != brush2->contents) continue;
00626         if (brush1->numsides != brush2->numsides) continue;
00627         for (s1 = 0; s1 < brush1->numsides; s1++)
00628         {
00629             side1 = brush1->original_sides + s1;
00630             //
00631             for (s2 = 0; s2 < brush2->numsides; s2++)
00632             {
00633                 side2 = brush2->original_sides + s2;
00634                 //
00635                 if ((side1->planenum & ~1) == (side2->planenum & ~1)
00636 //                      && side1->texinfo == side2->texinfo
00637 //                      && side1->contents == side2->contents
00638 //                      && side1->surf == side2->surf
00639                     ) break;
00640             } //end if
00641             if (s2 >= brush2->numsides) break;
00642         } //end for
00643         if (s1 >= brush1->numsides) return true;
00644     } //end for
00645     return false;
00646 } //end of the function BrushExists

int CreateNewFloatPlane vec3_t  normal,
vec_t  dist
 

Definition at line 173 of file map.c.

References AddPlaneToHash(), plane_t::dist, Error(), mapplanes, plane_t::normal, nummapplanes, p, PlaneSignBits(), PlaneTypeForNormal, plane_t::type, vec3_origin, VectorCopy, VectorLength(), and VectorSubtract.

00174 {
00175     plane_t *p, temp;
00176 
00177     if (VectorLength(normal) < 0.5)
00178         Error ("FloatPlane: bad normal");
00179     // create a new plane
00180     if (nummapplanes+2 > MAX_MAPFILE_PLANES)
00181         Error ("MAX_MAPFILE_PLANES");
00182 
00183     p = &mapplanes[nummapplanes];
00184     VectorCopy (normal, p->normal);
00185     p->dist = dist;
00186     p->type = (p+1)->type = PlaneTypeForNormal (p->normal);
00187     p->signbits = PlaneSignBits(p->normal);
00188 
00189     VectorSubtract (vec3_origin, normal, (p+1)->normal);
00190     (p+1)->dist = -dist;
00191     (p+1)->signbits = PlaneSignBits((p+1)->normal);
00192 
00193     nummapplanes += 2;
00194 
00195     // allways put axial planes facing positive first
00196     if (p->type < 3)
00197     {
00198         if (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0)
00199         {
00200             // flip order
00201             temp = *p;
00202             *p = *(p+1);
00203             *(p+1) = temp;
00204 
00205             AddPlaneToHash (p);
00206             AddPlaneToHash (p+1);
00207             return nummapplanes - 1;
00208         }
00209     }
00210 
00211     AddPlaneToHash (p);
00212     AddPlaneToHash (p+1);
00213     return nummapplanes - 2;
00214 } //end of the function CreateNewFloatPlane

Here is the call graph for this function:

int FindFloatPlane vec3_t  normal,
vec_t  dist
 

Definition at line 280 of file map.c.

00281 {
00282     int i;
00283     plane_t *p;
00284     int hash, h;
00285 
00286     SnapPlane (normal, &dist);
00287     hash = (int)fabs(dist) / 8;
00288     hash &= (PLANE_HASHES-1);
00289 
00290     // search the border bins as well
00291     for (i = -1; i <= 1; i++)
00292     {
00293         h = (hash+i)&(PLANE_HASHES-1);
00294         for (p = planehash[h]; p; p = p->hash_chain)
00295         {
00296             if (PlaneEqual(p, normal, dist))
00297             {
00298                 mapplaneusers[p-mapplanes]++;
00299                 return p - mapplanes;
00300             } //end if
00301         } //end for
00302     } //end for
00303     i = CreateNewFloatPlane (normal, dist);
00304     mapplaneusers[i]++;
00305     return i;
00306 } //end of the function FindFloatPlane

mapbrush_t* GetAreaPortalBrush entity_t mapent  ) 
 

Definition at line 908 of file map.c.

References entity_t::areaportalnum, mapbrush_s::contents, mapbrush_s::entitynum, Log_Print(), mapbrush_t, mapbrushes, mapent, and nummapbrushes.

Referenced by WriteMapFileSafe().

00909 {
00910     int portalnum, bn;
00911     mapbrush_t *brush;
00912 
00913     //the area portal number
00914     portalnum = mapent->areaportalnum;
00915     //find the area portal brush in the world brushes
00916     for (bn = 0; bn < nummapbrushes && portalnum; bn++)
00917     {
00918         brush = &mapbrushes[bn];
00919         //must be in world entity
00920         if (brush->entitynum == 0)
00921         {
00922             if (brush->contents & CONTENTS_AREAPORTAL)
00923             {
00924                 portalnum--;
00925             } //end if
00926         } //end if
00927     } //end for
00928     if (bn < nummapbrushes)
00929     {
00930         return brush;
00931     } //end if
00932     else
00933     {
00934         Log_Print("area portal %d brush not found\n", mapent->areaportalnum);
00935         return NULL;
00936     } //end else
00937 } //end of the function GetAreaPortalBrush

Here is the call graph for this function:

int LoadMapFromBSP struct quakefile_s qf  ) 
 

Definition at line 1204 of file map.c.

References Error(), quakefile_s::filename, HL_AllocMaxBSP(), HL_FreeMaxBSP(), HL_LoadMapFromBSP(), idheader_t::ident, quakefile_s::length, LittleLong(), quakefile_s::offset, Q1_AllocMaxBSP(), Q1_FreeMaxBSP(), Q1_LoadMapFromBSP(), Q2_AllocMaxBSP(), Q2_BSPHEADER, Q2_FreeMaxBSP(), Q2_LoadMapFromBSP(), Q3_BSP_IDENT, Q3_FreeMaxBSP(), Q3_LoadMapFromBSP(), ReadQuakeFile(), ResetMapLoading(), Sin_AllocMaxBSP(), SIN_BSPHEADER, Sin_FreeMaxBSP(), Sin_LoadMapFromBSP(), SINGAME_BSPHEADER, and idheader_t::version.

Referenced by main().

01205 {
01206     idheader_t idheader;
01207 
01208     if (ReadQuakeFile(qf, &idheader, 0, sizeof(idheader_t)) != sizeof(idheader_t))
01209     {
01210         return false;
01211     } //end if
01212 
01213     idheader.ident = LittleLong(idheader.ident);
01214     idheader.version = LittleLong(idheader.version);
01215     //Quake3 BSP file
01216     if (idheader.ident == Q3_BSP_IDENT && idheader.version == Q3_BSP_VERSION)
01217     {
01218         ResetMapLoading();
01219         Q3_LoadMapFromBSP(qf);
01220         Q3_FreeMaxBSP();
01221     } //end if
01222     //Quake2 BSP file
01223     else if (idheader.ident == Q2_BSPHEADER && idheader.version == Q2_BSPVERSION)
01224     {
01225         ResetMapLoading();
01226         Q2_AllocMaxBSP();
01227         Q2_LoadMapFromBSP(qf->filename, qf->offset, qf->length);
01228         Q2_FreeMaxBSP();
01229     } //endif
01230     //Sin BSP file
01231     else if ((idheader.ident == SIN_BSPHEADER && idheader.version == SIN_BSPVERSION) ||
01232                 //the dorks gave the same format another ident and verions
01233                 (idheader.ident == SINGAME_BSPHEADER && idheader.version == SINGAME_BSPVERSION))
01234     {
01235         ResetMapLoading();
01236         Sin_AllocMaxBSP();
01237         Sin_LoadMapFromBSP(qf->filename, qf->offset, qf->length);
01238         Sin_FreeMaxBSP();
01239     } //end if
01240     //the Quake1 bsp files don't have a ident only a version
01241     else if (idheader.ident == Q1_BSPVERSION)
01242     {
01243         ResetMapLoading();
01244         Q1_AllocMaxBSP();
01245         Q1_LoadMapFromBSP(qf->filename, qf->offset, qf->length);
01246         Q1_FreeMaxBSP();
01247     } //end if
01248     //Half-Life also only uses a version number
01249     else if (idheader.ident == HL_BSPVERSION)
01250     {
01251         ResetMapLoading();
01252         HL_AllocMaxBSP();
01253         HL_LoadMapFromBSP(qf->filename, qf->offset, qf->length);
01254         HL_FreeMaxBSP();
01255     } //end if
01256     else
01257     {
01258         Error("unknown BSP format %c%c%c%c, version %d\n",
01259                                         (idheader.ident & 0xFF),
01260                                         ((idheader.ident >> 8) & 0xFF),
01261                                         ((idheader.ident >> 16) & 0xFF),
01262                                         ((idheader.ident >> 24) & 0xFF), idheader.version);
01263         return false;
01264     } //end if
01265     //
01266     return true;
01267 } //end of the function LoadMapFromBSP

Here is the call graph for this function:

qboolean MakeBrushWindings mapbrush_t ob  ) 
 

Definition at line 499 of file map.c.

References AddPointToBounds(), BaseWindingForPlane(), mapbrush_s::brushnum, ChopWindingInPlace(), ClearBounds(), plane_t::dist, mapbrush_s::entitynum, side_s::flags, i, j, Log_Print(), mapbrush_t, mapplanes, MAX_MAP_BOUNDS, mapbrush_s::maxs, mapbrush_s::mins, plane_t::normal, winding_t::numpoints, mapbrush_s::numsides, mapbrush_s::original_sides, winding_t::p, side_s::planenum, qboolean, side_t, w, and side_s::winding.

Referenced by AAS_CreateCurveBrushes(), HL_BSPBrushToMapBrush(), Q1_BSPBrushToMapBrush(), Q2_BSPBrushToMapBrush(), Q2_ParseBrush(), Q2_ParseMapEntity(), Q3_BSPBrushToMapBrush(), and Sin_BSPBrushToMapBrush().

00500 {
00501     int         i, j;
00502     winding_t   *w;
00503     side_t      *side;
00504     plane_t     *plane;
00505 
00506     ClearBounds (ob->mins, ob->maxs);
00507 
00508     for (i = 0; i < ob->numsides; i++)
00509     {
00510         plane = &mapplanes[ob->original_sides[i].planenum];
00511         w = BaseWindingForPlane(plane->normal, plane->dist);
00512         for (j = 0; j <ob->numsides && w; j++)
00513         {
00514             if (i == j) continue;
00515             if (ob->original_sides[j].flags & SFL_BEVEL) continue;
00516             plane = &mapplanes[ob->original_sides[j].planenum^1];
00517             ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
00518         }
00519 
00520         side = &ob->original_sides[i];
00521         side->winding = w;
00522         if (w)
00523         {
00524             side->flags |= SFL_VISIBLE;
00525             for (j = 0; j < w->numpoints; j++)
00526                 AddPointToBounds (w->p[j], ob->mins, ob->maxs);
00527         }
00528     }
00529 
00530     for (i = 0; i < 3; i++)
00531     {
00532         //IDBUG: all the indexes into the mins and maxs were zero (not using i)
00533         if (ob->mins[i] < -MAX_MAP_BOUNDS || ob->maxs[i] > MAX_MAP_BOUNDS)
00534         {
00535             Log_Print("entity %i, brush %i: bounds out of range\n", ob->entitynum, ob->brushnum);
00536             ob->numsides = 0; //remove the brush
00537             break;
00538         } //end if
00539         if (ob->mins[i] > MAX_MAP_BOUNDS || ob->maxs[i] < -MAX_MAP_BOUNDS)
00540         {
00541             Log_Print("entity %i, brush %i: no visible sides on brush\n", ob->entitynum, ob->brushnum);
00542             ob->numsides = 0; //remove the brush
00543             break;
00544         } //end if
00545     } //end for
00546     return true;
00547 } //end of the function MakeBrushWindings

Here is the call graph for this function:

void MarkBrushBevels mapbrush_t brush  ) 
 

Definition at line 557 of file map.c.

References mapbrush_s::brushnum, c_boxbevels, c_edgebevels, side_s::flags, i, Log_Write(), mapbrush_t, mapplanes, mapbrush_s::numsides, mapbrush_s::original_sides, side_s::planenum, s, side_t, plane_t::type, WE_NOTENOUGHPOINTS, WE_POINTBOGUSRANGE, WE_SMALLAREA, side_s::winding, WindingError(), WindingErrorString(), and WindingIsTiny().

Referenced by Q2_BSPBrushToMapBrush(), Q3_BSPBrushToMapBrush(), and Sin_BSPBrushToMapBrush().

00558 {
00559     int i;
00560     int we;
00561     side_t *s;
00562 
00563     //check all the sides of the brush
00564     for (i = 0; i < brush->numsides; i++)
00565     {
00566         s = brush->original_sides + i;
00567         //if the side has no winding
00568         if (!s->winding)
00569         {
00570             Log_Write("MarkBrushBevels: brush %d no winding", brush->brushnum);
00571             s->flags |= SFL_BEVEL;
00572         } //end if
00573         //if the winding is tiny
00574         else if (WindingIsTiny(s->winding))
00575         {
00576             s->flags |= SFL_BEVEL;
00577             Log_Write("MarkBrushBevels: brush %d tiny winding", brush->brushnum);
00578         } //end else if
00579         //if the winding has errors
00580         else
00581         {
00582             we = WindingError(s->winding);
00583             if (we == WE_NOTENOUGHPOINTS
00584                     || we == WE_SMALLAREA
00585                     || we == WE_POINTBOGUSRANGE
00586 //                  || we == WE_NONCONVEX
00587                     )
00588             {
00589                 Log_Write("MarkBrushBevels: brush %d %s", brush->brushnum, WindingErrorString());
00590                 s->flags |= SFL_BEVEL;
00591             } //end else if
00592         } //end else
00593         if (s->flags & SFL_BEVEL)
00594         {
00595             s->flags &= ~SFL_VISIBLE;
00596             //if the side has a valid plane
00597             if (s->planenum > 0 && s->planenum < nummapplanes)
00598             {
00599                 //if it is an axial plane
00600                 if (mapplanes[s->planenum].type < 3) c_boxbevels++;
00601                 else c_edgebevels++;
00602             } //end if
00603         } //end if
00604     } //end for
00605 } //end of the function MarkBrushBevels

Here is the call graph for this function:

qboolean PlaneEqual plane_t p,
vec3_t  normal,
vec_t  dist
 

Definition at line 133 of file map.c.

References plane_t::dist, fabs(), plane_t::normal, NORMAL_EPSILON, p, and qboolean.

00134 {
00135 #if 1
00136     if (
00137        fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON
00138     && fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON
00139     && fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON
00140     && fabs(p->dist - dist) < DIST_EPSILON )
00141         return true;
00142 #else
00143     if (p->normal[0] == normal[0]
00144         && p->normal[1] == normal[1]
00145         && p->normal[2] == normal[2]
00146         && p->dist == dist)
00147         return true;
00148 #endif
00149     return false;
00150 } //end of the function PlaneEqual

Here is the call graph for this function:

int PlaneFromPoints int *  p0,
int *  p1,
int *  p2
 

Definition at line 314 of file map.c.

00315 {
00316     vec3_t  t1, t2, normal;
00317     vec_t   dist;
00318 
00319     VectorSubtract (p0, p1, t1);
00320     VectorSubtract (p2, p1, t2);
00321     CrossProduct (t1, t2, normal);
00322     VectorNormalize (normal);
00323 
00324     dist = DotProduct (p0, normal);
00325 
00326     return FindFloatPlane (normal, dist);
00327 } //end of the function PlaneFromPoints

int PlaneSignBits vec3_t  normal  ) 
 

Definition at line 84 of file map.c.

References i, and Sign.

Referenced by CreateNewFloatPlane().

00085 {
00086     int i, signbits;
00087 
00088     signbits = 0;
00089     for (i = 2; i >= 0; i--)
00090     {
00091         signbits = (signbits << 1) + Sign(normal[i]);
00092     } //end for
00093     return signbits;
00094 } //end of the function PlaneSignBits

int PlaneTypeForNormal vec3_t  normal  ) 
 

Definition at line 101 of file map.c.

00102 {
00103     vec_t   ax, ay, az;
00104     
00105 // NOTE: should these have an epsilon around 1.0?       
00106     if (normal[0] == 1.0 || normal[0] == -1.0)
00107         return PLANE_X;
00108     if (normal[1] == 1.0 || normal[1] == -1.0)
00109         return PLANE_Y;
00110     if (normal[2] == 1.0 || normal[2] == -1.0)
00111         return PLANE_Z;
00112         
00113     ax = fabs(normal[0]);
00114     ay = fabs(normal[1]);
00115     az = fabs(normal[2]);
00116     
00117     if (ax >= ay && ax >= az)
00118         return PLANE_ANYX;
00119     if (ay >= ax && ay >= az)
00120         return PLANE_ANYY;
00121     return PLANE_ANYZ;
00122 } //end of the function PlaneTypeForNormal

void PrintMapInfo void   ) 
 

Definition at line 1099 of file map.c.

References Log_Print(), nummapbrushes, and nummapbrushsides.

Referenced by Q2_LoadMapFile(), and Q2_LoadMapFromBSP().

01100 {
01101     Log_Print("\n");
01102     Log_Print("%6i brushes\n", nummapbrushes);
01103     Log_Print("%6i brush sides\n", nummapbrushsides);
01104 //  Log_Print("%6i clipbrushes\n", c_clipbrushes);
01105 //  Log_Print("%6i total sides\n", nummapbrushsides);
01106 //  Log_Print("%6i boxbevels\n", c_boxbevels);
01107 //  Log_Print("%6i edgebevels\n", c_edgebevels);
01108 //  Log_Print("%6i entities\n", num_entities);
01109 //  Log_Print("%6i planes\n", nummapplanes);
01110 //  Log_Print("%6i areaportals\n", c_areaportals);
01111 //  Log_Print("%6i squatt brushes\n", c_squattbrushes);
01112 //  Log_Print("size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", map_mins[0],map_mins[1],map_mins[2],
01113 //      map_maxs[0],map_maxs[1],map_maxs[2]);
01114 } //end of the function PrintMapInfo

Here is the call graph for this function:

void ResetMapLoading void   ) 
 

Definition at line 1121 of file map.c.

References brushsides, c_areaportals, c_boxbevels, c_clipbrushes, c_edgebevels, c_writtenbrushes, entities, epair_t, entity_t::epairs, FreeMemory(), FreeWinding(), i, epair_s::key, map_maxs, map_mins, map_numtexinfo, map_texinfo, mapbrush_t, mapbrushes, mapplanes, MAX_MAP_ENTITIES, MAX_MAPFILE_BRUSHES, MAX_MAPFILE_BRUSHSIDES, MAX_MAPFILE_PLANES, MAX_MAPFILE_TEXINFO, memset(), epair_s::next, num_entities, nummapbrushes, nummapbrushsides, nummapplanes, PLANE_HASHES, plane_t, planehash, Q2_ResetMapLoading(), side_brushtextures, side_t, Sin_ResetMapLoading(), epair_s::value, VectorClear, and side_s::winding.

Referenced by LoadMapFromBSP(), and Q2_LoadMapFile().

01122 {
01123     int i;
01124     epair_t *ep, *nextep;
01125 
01126     Q2_ResetMapLoading();
01127     Sin_ResetMapLoading();
01128 
01129     //free all map brush side windings
01130     for (i = 0; i < nummapbrushsides; i++)
01131     {
01132         if (brushsides[i].winding)
01133         {
01134             FreeWinding(brushsides[i].winding);
01135         } //end for
01136     } //end for
01137 
01138     //reset regular stuff
01139     nummapbrushes = 0;
01140     memset(mapbrushes, 0, MAX_MAPFILE_BRUSHES * sizeof(mapbrush_t));
01141     //
01142     nummapbrushsides = 0;
01143     memset(brushsides, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(side_t));
01144     memset(side_brushtextures, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(brush_texture_t));
01145     //
01146     nummapplanes = 0;
01147     memset(mapplanes, 0, MAX_MAPFILE_PLANES * sizeof(plane_t));
01148     //
01149     memset(planehash, 0, PLANE_HASHES * sizeof(plane_t *));
01150     //
01151     memset(map_texinfo, 0, MAX_MAPFILE_TEXINFO * sizeof(map_texinfo_t));
01152     map_numtexinfo = 0;
01153     //
01154     VectorClear(map_mins);
01155     VectorClear(map_maxs);
01156     //
01157     c_boxbevels = 0;
01158     c_edgebevels = 0;
01159     c_areaportals = 0;
01160     c_clipbrushes = 0;
01161     c_writtenbrushes = 0;
01162     //clear the entities
01163     for (i = 0; i < num_entities; i++)
01164     {
01165         for (ep = entities[i].epairs; ep; ep = nextep)
01166         {
01167             nextep = ep->next;
01168             FreeMemory(ep->key);
01169             FreeMemory(ep->value);
01170             FreeMemory(ep);
01171         } //end for
01172     } //end for
01173     num_entities = 0;
01174     memset(entities, 0, MAX_MAP_ENTITIES * sizeof(entity_t));
01175 } //end of the function ResetMapLoading

Here is the call graph for this function: