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

aas_create.c File Reference

#include "qbsp.h"
#include "../botlib/aasfile.h"
#include "aas_create.h"
#include "aas_store.h"
#include "aas_gsubdiv.h"
#include "aas_facemerging.h"
#include "aas_areamerging.h"
#include "aas_edgemelting.h"
#include "aas_prunenodes.h"
#include "aas_cfg.h"
#include "../game/surfaceflags.h"

Include dependency graph for aas_create.c:

Include dependency graph

Go to the source code of this file.

Defines

#define AREAONFACESIDE(face, area)   (face->frontarea != area)

Functions

void AAS_AddFaceSideToArea (tmp_face_t *tmpface, int side, tmp_area_t *tmparea)
tmp_area_tAAS_AllocTmpArea (void)
tmp_face_tAAS_AllocTmpFace (void)
tmp_node_tAAS_AllocTmpNode (void)
void AAS_CheckArea (tmp_area_t *tmparea)
void AAS_CheckAreaSharedFaces (tmp_area_t *tmparea1, tmp_area_t *tmparea2)
void AAS_CheckAreaWindingPlanes (void)
void AAS_CheckFaceWindingPlane (tmp_face_t *face)
void AAS_CheckSharedFaces (void)
void AAS_Create (char *aasfile)
tmp_node_tAAS_CreateArea (node_t *node)
void AAS_CreateAreas (node_t *node)
tmp_node_tAAS_CreateAreas_r (node_t *node)
void AAS_CreateAreaSettings (void)
void AAS_FlipAreaFaces (tmp_area_t *tmparea)
void AAS_FlipFace (tmp_face_t *face)
void AAS_FlipSharedFaces (void)
void AAS_FreeTmpAAS (void)
void AAS_FreeTmpArea (tmp_area_t *tmparea)
void AAS_FreeTmpFace (tmp_face_t *tmpface)
void AAS_FreeTmpNode (tmp_node_t *tmpnode)
int AAS_GapFace (tmp_face_t *tmpface, int side)
int AAS_GroundFace (tmp_face_t *tmpface)
void AAS_InitTmpAAS (void)
void AAS_PrintNumGroundFaces (void)
void AAS_RemoveAreaFaceColinearPoints (void)
void AAS_RemoveFaceFromArea (tmp_face_t *tmpface, tmp_area_t *tmparea)
void AAS_RemoveTinyFaces (void)

Variables

tmp_aas_t tmpaasworld


Define Documentation

#define AREAONFACESIDE face,
area   )     (face->frontarea != area)
 

Definition at line 38 of file aas_create.c.


Function Documentation

void AAS_AddFaceSideToArea tmp_face_t tmpface,
int  side,
tmp_area_t tmparea
 

Definition at line 246 of file aas_create.c.

References tmp_face_s::backarea, Error(), tmp_face_s::frontarea, tmp_face_s::next, tmp_face_s::prev, tmp_area_t, tmp_face_t, and tmp_area_s::tmpfaces.

Referenced by AAS_CreateArea(), AAS_FlipFace(), AAS_SplitArea(), and AAS_TryMergeFaceAreas().

00247 {
00248     int tmpfaceside;
00249 
00250     if (side)
00251     {
00252         if (tmpface->backarea) Error("AAS_AddFaceSideToArea: already a back area\n");
00253     } //end if
00254     else
00255     {
00256         if (tmpface->frontarea) Error("AAS_AddFaceSideToArea: already a front area\n");
00257     } //end else
00258 
00259     if (side) tmpface->backarea = tmparea;
00260     else tmpface->frontarea = tmparea;
00261 
00262     if (tmparea->tmpfaces)
00263     {
00264         tmpfaceside = tmparea->tmpfaces->frontarea != tmparea;
00265         tmparea->tmpfaces->prev[tmpfaceside] = tmpface;
00266     } //end if
00267     tmpface->next[side] = tmparea->tmpfaces;
00268     tmpface->prev[side] = NULL;
00269     tmparea->tmpfaces = tmpface;
00270 } //end of the function AAS_AddFaceSideToArea

Here is the call graph for this function:

tmp_area_t* AAS_AllocTmpArea void   ) 
 

Definition at line 139 of file aas_create.c.

References tmp_area_s::areanum, tmp_aas_s::areanum, tmp_aas_s::areas, GetClearedMemory(), tmp_area_s::l_next, tmp_area_s::l_prev, tmp_aas_s::numareas, tmp_area_t, and tmpaasworld.

Referenced by AAS_CreateArea(), AAS_SplitArea(), and AAS_TryMergeFaceAreas().

00140 {
00141     tmp_area_t *tmparea;
00142 
00143     tmparea = (tmp_area_t *) GetClearedMemory(sizeof(tmp_area_t));
00144     tmparea->areanum = tmpaasworld.areanum++;
00145     tmparea->l_prev = NULL;
00146     tmparea->l_next = tmpaasworld.areas;
00147     if (tmpaasworld.areas) tmpaasworld.areas->l_prev = tmparea;
00148     tmpaasworld.areas = tmparea;
00149     tmpaasworld.numareas++;
00150     return tmparea;
00151 } //end of the function AAS_AllocTmpArea

Here is the call graph for this function:

tmp_face_t* AAS_AllocTmpFace void   ) 
 

Definition at line 103 of file aas_create.c.

References tmp_aas_s::facenum, tmp_aas_s::faces, GetClearedMemory(), tmp_face_s::l_next, tmp_face_s::l_prev, tmp_face_s::num, tmp_aas_s::numfaces, tmp_face_t, and tmpaasworld.

Referenced by AAS_CreateArea(), AAS_SplitArea(), and AAS_SplitFace().

00104 {
00105     tmp_face_t *tmpface;
00106 
00107     tmpface = (tmp_face_t *) GetClearedMemory(sizeof(tmp_face_t));
00108     tmpface->num = tmpaasworld.facenum++;
00109     tmpface->l_prev = NULL;
00110     tmpface->l_next = tmpaasworld.faces;
00111     if (tmpaasworld.faces) tmpaasworld.faces->l_prev = tmpface;
00112     tmpaasworld.faces = tmpface;
00113     tmpaasworld.numfaces++;
00114     return tmpface;
00115 } //end of the function AAS_AllocTmpFace

Here is the call graph for this function:

tmp_node_t* AAS_AllocTmpNode void   ) 
 

Definition at line 173 of file aas_create.c.

References GetClearedMemory(), tmp_nodebuf_s::next, tmp_aas_s::nodebuffer, tmp_nodebuf_s::nodes, tmp_nodebuf_s::numnodes, tmp_aas_s::numnodes, tmp_node_t, tmp_nodebuf_t, and tmpaasworld.

Referenced by AAS_CreateArea(), AAS_CreateAreas_r(), AAS_LadderSubdivideArea_r(), and AAS_SubdivideArea_r().

00174 {
00175     tmp_nodebuf_t *nodebuf;
00176 
00177     if (!tmpaasworld.nodebuffer ||
00178             tmpaasworld.nodebuffer->numnodes >= NODEBUF_SIZE)
00179     {
00180         nodebuf = (tmp_nodebuf_t *) GetClearedMemory(sizeof(tmp_nodebuf_t));
00181         nodebuf->next = tmpaasworld.nodebuffer;
00182         nodebuf->numnodes = 0;
00183         tmpaasworld.nodebuffer = nodebuf;
00184     } //end if
00185     tmpaasworld.numnodes++;
00186     return &tmpaasworld.nodebuffer->nodes[tmpaasworld.nodebuffer->numnodes++];
00187 } //end of the function AAS_AllocTmpNode

Here is the call graph for this function:

void AAS_CheckArea tmp_area_t tmparea  ) 
 

Definition at line 314 of file aas_create.c.

References tmp_area_s::areanum, plane_t::dist, DotProduct, fabs(), tmp_face_s::frontarea, tmp_area_s::invalid, Log_Print(), Log_Write(), mapplanes, n, tmp_face_s::next, plane_t::normal, tmp_face_s::num, tmp_face_s::planenum, tmp_area_t, tmp_face_t, tmp_area_s::tmpfaces, vec3_t, VectorAdd, VectorScale, tmp_face_s::winding, WindingCenter(), WindingError(), WindingErrorString(), and WindingPlane().

Referenced by AAS_CreateArea(), AAS_MergeAreaFaces(), AAS_SplitArea(), and AAS_TryMergeFaceAreas().

00315 {
00316     int side;
00317     tmp_face_t *face;
00318     plane_t *plane;
00319     vec3_t wcenter, acenter = {0, 0, 0};
00320     vec3_t normal;
00321     float n, dist;
00322 
00323     if (tmparea->invalid) Log_Print("AAS_CheckArea: invalid area\n");
00324     for (n = 0, face = tmparea->tmpfaces; face; face = face->next[side])
00325     {
00326         //side of the face the area is on
00327         side = face->frontarea != tmparea;
00328         WindingCenter(face->winding, wcenter);
00329         VectorAdd(acenter, wcenter, acenter);
00330         n++;
00331     } //end for
00332     n = 1 / n;
00333     VectorScale(acenter, n, acenter);
00334     for (face = tmparea->tmpfaces; face; face = face->next[side])
00335     {
00336         //side of the face the area is on
00337         side = face->frontarea != tmparea;
00338 
00339 #ifdef L_DEBUG
00340         if (WindingError(face->winding))
00341         {
00342             Log_Write("AAS_CheckArea: area %d face %d: %s\r\n", tmparea->areanum,
00343                         face->num, WindingErrorString());
00344         } //end if
00345 #endif L_DEBUG
00346 
00347         plane = &mapplanes[face->planenum ^ side];
00348 
00349         if (DotProduct(plane->normal, acenter) - plane->dist < 0)
00350         {
00351             Log_Print("AAS_CheckArea: area %d face %d is flipped\n", tmparea->areanum, face->num);
00352             Log_Print("AAS_CheckArea: area %d center is %f %f %f\n", tmparea->areanum, acenter[0], acenter[1], acenter[2]);
00353         } //end if
00354         //check if the winding plane is the same as the face plane
00355         WindingPlane(face->winding, normal, &dist);
00356         plane = &mapplanes[face->planenum];
00357 #ifdef L_DEBUG
00358         if (fabs(dist - plane->dist) > 0.4 ||
00359                 fabs(normal[0] - plane->normal[0]) > 0.0001 ||
00360                 fabs(normal[1] - plane->normal[1]) > 0.0001 ||
00361                 fabs(normal[2] - plane->normal[2]) > 0.0001)
00362         {
00363             Log_Write("AAS_CheckArea: area %d face %d winding plane unequal to face plane\r\n",
00364                                         tmparea->areanum, face->num);
00365         } //end if
00366 #endif L_DEBUG
00367     } //end for
00368 } //end of the function AAS_CheckArea

Here is the call graph for this function:

void AAS_CheckAreaSharedFaces tmp_area_t tmparea1,
tmp_area_t tmparea2
 

Definition at line 827 of file aas_create.c.

References tmp_area_s::areanum, tmp_face_s::backarea, tmp_face_s::frontarea, tmp_area_s::invalid, Log_Write(), tmp_face_s::next, tmp_face_s::num, tmp_face_s::planenum, tmp_area_t, tmp_face_t, and tmp_area_s::tmpfaces.

Referenced by AAS_CheckSharedFaces().

00828 {
00829     int numsharedfaces, side;
00830     tmp_face_t *face1, *sharedface;
00831 
00832     if (tmparea1->invalid || tmparea2->invalid) return;
00833 
00834     sharedface = NULL;
00835     numsharedfaces = 0;
00836     for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])
00837     {
00838         side = face1->frontarea != tmparea1;
00839         if (face1->backarea == tmparea2 || face1->frontarea == tmparea2)
00840         {
00841             sharedface = face1;
00842             numsharedfaces++;
00843         } //end if
00844     } //end if
00845     if (!sharedface) return;
00846     //the areas should only have one shared face
00847     if (numsharedfaces > 1)
00848     {
00849         Log_Write("---- tmp area %d and %d have %d shared faces\r\n",
00850                                     tmparea1->areanum, tmparea2->areanum, numsharedfaces);
00851         for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])
00852         {
00853             side = face1->frontarea != tmparea1;
00854             if (face1->backarea == tmparea2 || face1->frontarea == tmparea2)
00855             {
00856                 Log_Write("face %d, planenum = %d, face->frontarea = %d face->backarea = %d\r\n",
00857                                 face1->num, face1->planenum, face1->frontarea->areanum, face1->backarea->areanum);
00858             } //end if
00859         } //end if
00860     } //end if
00861 } //end of the function AAS_CheckAreaSharedFaces

Here is the call graph for this function:

void AAS_CheckAreaWindingPlanes void   ) 
 

Definition at line 430 of file aas_create.c.

References AAS_CheckFaceWindingPlane(), tmp_aas_s::areas, tmp_face_s::frontarea, tmp_area_s::invalid, tmp_area_s::l_next, Log_Write(), tmp_face_s::next, tmp_area_t, tmp_face_t, tmpaasworld, and tmp_area_s::tmpfaces.

00431 {
00432     int side;
00433     tmp_area_t *tmparea;
00434     tmp_face_t *face;
00435 
00436     Log_Write("AAS_CheckAreaWindingPlanes:\r\n");
00437     for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
00438     {
00439         if (tmparea->invalid) continue;
00440         for (face = tmparea->tmpfaces; face; face = face->next[side])
00441         {
00442             side = face->frontarea != tmparea;
00443             AAS_CheckFaceWindingPlane(face);
00444         } //end for
00445     } //end for
00446 } //end of the function AAS_CheckAreaWindingPlanes

Here is the call graph for this function:

void AAS_CheckFaceWindingPlane tmp_face_t face  ) 
 

Definition at line 375 of file aas_create.c.

References plane_t::dist, DotProduct, fabs(), FreeWinding(), Log_Write(), mapplanes, plane_t::normal, tmp_face_s::num, tmp_face_s::planenum, ReverseWinding(), tmp_face_t, vec3_t, VectorInverse(), w, tmp_face_s::winding, and WindingPlane().

Referenced by AAS_CheckAreaWindingPlanes(), and AAS_CreateArea().

00376 {
00377     float dist, sign1, sign2;
00378     vec3_t normal;
00379     plane_t *plane;
00380     winding_t *w;
00381 
00382     //check if the winding plane is the same as the face plane
00383     WindingPlane(face->winding, normal, &dist);
00384     plane = &mapplanes[face->planenum];
00385     //
00386     sign1 = DotProduct(plane->normal, normal);
00387     //
00388     if (fabs(dist - plane->dist) > 0.4 ||
00389             fabs(normal[0] - plane->normal[0]) > 0.0001 ||
00390             fabs(normal[1] - plane->normal[1]) > 0.0001 ||
00391             fabs(normal[2] - plane->normal[2]) > 0.0001)
00392     {
00393         VectorInverse(normal);
00394         dist = -dist;
00395         if (fabs(dist - plane->dist) > 0.4 ||
00396                 fabs(normal[0] - plane->normal[0]) > 0.0001 ||
00397                 fabs(normal[1] - plane->normal[1]) > 0.0001 ||
00398                 fabs(normal[2] - plane->normal[2]) > 0.0001)
00399         {
00400             Log_Write("AAS_CheckFaceWindingPlane: face %d winding plane unequal to face plane\r\n",
00401                                     face->num);
00402             //
00403             sign2 = DotProduct(plane->normal, normal);
00404             if ((sign1 < 0 && sign2 > 0) ||
00405                     (sign1 > 0 && sign2 < 0))
00406             {
00407                 Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n",
00408                                     face->num);
00409                 w = face->winding;
00410                 face->winding = ReverseWinding(w);
00411                 FreeWinding(w);
00412             } //end if
00413         } //end if
00414         else
00415         {
00416             Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n",
00417                                     face->num);
00418             w = face->winding;
00419             face->winding = ReverseWinding(w);
00420             FreeWinding(w);
00421         } //end else
00422     } //end if
00423 } //end of the function AAS_CheckFaceWindingPlane

Here is the call graph for this function:

void AAS_CheckSharedFaces void   ) 
 

Definition at line 868 of file aas_create.c.

References AAS_CheckAreaSharedFaces(), tmp_aas_s::areas, tmp_area_s::l_next, tmp_area_t, and tmpaasworld.

00869 {
00870     tmp_area_t *tmparea1, *tmparea2;
00871 
00872     for (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next)
00873     {
00874         for (tmparea2 = tmpaasworld.areas; tmparea2; tmparea2 = tmparea2->l_next)
00875         {
00876             if (tmparea1 == tmparea2) continue;
00877             AAS_CheckAreaSharedFaces(tmparea1, tmparea2);
00878         } //end for
00879     } //end for
00880 } //end of the function AAS_CheckSharedFaces

Here is the call graph for this function:

void AAS_Create char *  aasfile  ) 
 

Definition at line 1035 of file aas_create.c.

References AAS_CreateAreas(), AAS_CreateAreaSettings(), AAS_FlipSharedFaces(), AAS_FreeTmpAAS(), AAS_GravitationalSubdivision(), AAS_InitTmpAAS(), AAS_LadderSubdivision(), AAS_MeltAreaFaceWindings(), AAS_MergeAreaFaces(), AAS_MergeAreaPlaneFaces(), AAS_MergeAreas(), AAS_PruneNodes(), AAS_RemoveAreaFaceColinearPoints(), AAS_RemoveTinyFaces(), AAS_StoreFile(), e, entities, entity_num, Error(), FillOutside(), entity_t::firstbrush, FloodEntities(), I_FloatTime(), LeakFile(), Log_Print(), MakeTreePortals(), entity_t::numbrushes, ProcessWorldBrushes(), strcpy(), StripExtension(), ThreadSetDefault(), tree(), Tree_Free(), and Tree_PruneNodes().

Referenced by main().

01036 {
01037     entity_t    *e;
01038     tree_t *tree;
01039     double start_time;
01040 
01041     //for a possible leak file
01042     strcpy(source, aasfile);
01043     StripExtension(source);
01044     //the time started
01045     start_time = I_FloatTime();
01046     //set the default number of threads (depends on number of processors)
01047     ThreadSetDefault();
01048     //set the global entity number to the world model
01049     entity_num = 0;
01050     //the world entity
01051     e = &entities[entity_num];
01052     //process the whole world
01053     tree = ProcessWorldBrushes(e->firstbrush, e->firstbrush + e->numbrushes);
01054     //if the conversion is cancelled
01055     if (cancelconversion)
01056     {
01057         Tree_Free(tree);
01058         return;
01059     } //end if
01060     //display BSP tree creation time
01061     Log_Print("BSP tree created in %5.0f seconds\n", I_FloatTime() - start_time);
01062     //prune the bsp tree
01063     Tree_PruneNodes(tree->headnode);
01064     //if the conversion is cancelled
01065     if (cancelconversion)
01066     {
01067         Tree_Free(tree);
01068         return;
01069     } //end if
01070     //create the tree portals
01071     MakeTreePortals(tree);
01072     //if the conversion is cancelled
01073     if (cancelconversion)
01074     {
01075         Tree_Free(tree);
01076         return;
01077     } //end if
01078     //Marks all nodes that can be reached by entites
01079     if (FloodEntities(tree))
01080     {
01081         //fill out nodes that can't be reached
01082         FillOutside(tree->headnode);
01083     } //end if
01084     else
01085     {
01086         LeakFile(tree);
01087         Error("**** leaked ****\n");
01088         return;
01089     } //end else
01090     //create AAS from the BSP tree
01091     //==========================================
01092     //initialize tmp aas
01093     AAS_InitTmpAAS();
01094     //create the convex areas from the leaves
01095     AAS_CreateAreas(tree->headnode);
01096     //free the BSP tree because it isn't used anymore
01097     if (freetree) Tree_Free(tree);
01098     //try to merge area faces
01099     AAS_MergeAreaFaces();
01100     //do gravitational subdivision
01101     AAS_GravitationalSubdivision();
01102     //merge faces if possible
01103     AAS_MergeAreaFaces();
01104     AAS_RemoveAreaFaceColinearPoints();
01105     //merge areas if possible
01106     AAS_MergeAreas();
01107     //NOTE: prune nodes directly after area merging
01108     AAS_PruneNodes();
01109     //flip shared faces so they are all facing to the same area
01110     AAS_FlipSharedFaces();
01111     AAS_RemoveAreaFaceColinearPoints();
01112     //merge faces if possible
01113     AAS_MergeAreaFaces();
01114     //merge area faces in the same plane
01115     AAS_MergeAreaPlaneFaces();
01116     //do ladder subdivision
01117     AAS_LadderSubdivision();
01118     //FIXME: melting is buggy
01119     AAS_MeltAreaFaceWindings();
01120     //remove tiny faces
01121     AAS_RemoveTinyFaces();
01122     //create area settings
01123     AAS_CreateAreaSettings();
01124     //check if the winding plane is equal to the face plane
01125     //AAS_CheckAreaWindingPlanes();
01126     //
01127     //AAS_CheckSharedFaces();
01128     //==========================================
01129     //if the conversion is cancelled
01130     if (cancelconversion)
01131     {
01132         Tree_Free(tree);
01133         AAS_FreeTmpAAS();
01134         return;
01135     } //end if
01136     //store the created AAS stuff in the AAS file format and write the file
01137     AAS_StoreFile(aasfile);
01138     //free the temporary AAS memory
01139     AAS_FreeTmpAAS();
01140     //display creation time
01141     Log_Print("\nAAS created in %5.0f seconds\n", I_FloatTime() - start_time);
01142 } //end of the function AAS_Create

Here is the call graph for this function:

tmp_node_t* AAS_CreateArea node_t node  ) 
 

Definition at line 638 of file aas_create.c.

References AAS_AddFaceSideToArea(), AAS_AllocTmpArea(), AAS_AllocTmpFace(), AAS_AllocTmpNode(), AAS_CheckArea(), AAS_CheckFaceWindingPlane(), AAS_FlipAreaFaces(), AAS_GroundFace(), tmp_face_s::aasfacenum, cfg_s::allpresencetypes, tmp_area_s::areanum, cfg, tmp_node_s::children, tmp_area_s::contents, node_s::contents, CONTENTS_SLIME, CONTENTS_SOLID, CONTENTS_WATER, CopyWinding(), node_s::expansionbboxes, tmp_face_s::faceflags, node_s::modelnum, tmp_area_s::modelnum, portal_s::next, node_t, portal_s::nodes, p, tmp_node_s::planenum, portal_s::planenum, tmp_face_s::planenum, portal_t, node_s::portals, tmp_area_s::presencetype, qprintf(), ReverseWinding(), tmp_area_t, tmp_face_t, tmp_node_t, tmp_node_s::tmparea, portal_s::tmpface, tmp_area_s::tmpfaces, up, vec3_t, portal_s::winding, and tmp_face_s::winding.

Referenced by AAS_CreateAreas_r().

00639 {
00640     int pside;
00641     int areafaceflags;
00642     portal_t    *p;
00643     tmp_face_t *tmpface;
00644     tmp_area_t *tmparea;
00645     tmp_node_t *tmpnode;
00646     vec3_t up = {0, 0, 1};
00647 
00648     //create an area from this leaf
00649     tmparea = AAS_AllocTmpArea();
00650     tmparea->tmpfaces = NULL;
00651     //clear the area face flags
00652     areafaceflags = 0;
00653     //make aas faces from the portals
00654     for (p = node->portals; p; p = p->next[pside])
00655     {
00656         pside = (p->nodes[1] == node);
00657         //don't create faces from very small portals
00658 //      if (WindingArea(p->winding) < 1) continue;
00659         //if there's already a face created for this portal
00660         if (p->tmpface)
00661         {
00662             //add the back side of the face to the area
00663             AAS_AddFaceSideToArea(p->tmpface, 1, tmparea);
00664         } //end if
00665         else
00666         {
00667             tmpface = AAS_AllocTmpFace();
00668             //set the face pointer at the portal so we can see from
00669             //the portal there's a face created for it
00670             p->tmpface = tmpface;
00671             //FIXME: test this change
00672             //tmpface->planenum = (p->planenum & ~1) | pside;
00673             tmpface->planenum = p->planenum ^ pside;
00674             if (pside) tmpface->winding = ReverseWinding(p->winding);
00675             else tmpface->winding = CopyWinding(p->winding);
00676 #ifdef L_DEBUG
00677             //
00678             AAS_CheckFaceWindingPlane(tmpface);
00679 #endif //L_DEBUG
00680             //if there's solid at the other side of the portal
00681             if (p->nodes[!pside]->contents & (CONTENTS_SOLID | CONTENTS_PLAYERCLIP))
00682             {
00683                 tmpface->faceflags |= FACE_SOLID;
00684             } //end if
00685             //else there is no solid at the other side and if there
00686             //is a liquid at this side
00687             else if (node->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))
00688             {
00689                 tmpface->faceflags |= FACE_LIQUID;
00690                 //if there's no liquid at the other side
00691                 if (!(p->nodes[!pside]->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)))
00692                 {
00693                     tmpface->faceflags |= FACE_LIQUIDSURFACE;
00694                 } //end if
00695             } //end else
00696             //if there's ladder contents at other side of the portal
00697             if ((p->nodes[pside]->contents & CONTENTS_LADDER) ||
00698                     (p->nodes[!pside]->contents & CONTENTS_LADDER))
00699             {
00700 
00701                 //NOTE: doesn't have to be solid at the other side because
00702                 // when standing one can use a crouch area (which is not solid)
00703                 // as a ladder
00704                 // imagine a ladder one can walk underthrough,
00705                 // under the ladder against the ladder is a crouch area
00706                 // the (vertical) sides of this crouch area area also used as
00707                 // ladder sides when standing (not crouched)
00708                 tmpface->faceflags |= FACE_LADDER;
00709             } //end if
00710             //if it is possible to stand on the face
00711             if (AAS_GroundFace(tmpface))
00712             {
00713                 tmpface->faceflags |= FACE_GROUND;
00714             } //end if
00715             //
00716             areafaceflags |= tmpface->faceflags;
00717             //no aas face number yet (zero is a dummy in the aasworld faces)
00718             tmpface->aasfacenum = 0;
00719             //add the front side of the face to the area
00720             AAS_AddFaceSideToArea(tmpface, 0, tmparea);
00721         } //end else
00722     } //end for
00723     qprintf("\r%6d", tmparea->areanum);
00724     //presence type in the area
00725     tmparea->presencetype = ~node->expansionbboxes & cfg.allpresencetypes;
00726     //
00727     tmparea->contents = 0;
00728     if (node->contents & CONTENTS_CLUSTERPORTAL) tmparea->contents |= AREACONTENTS_CLUSTERPORTAL;
00729     if (node->contents & CONTENTS_MOVER) tmparea->contents |= AREACONTENTS_MOVER;
00730     if (node->contents & CONTENTS_TELEPORTER) tmparea->contents |= AREACONTENTS_TELEPORTER;
00731     if (node->contents & CONTENTS_JUMPPAD) tmparea->contents |= AREACONTENTS_JUMPPAD;
00732     if (node->contents & CONTENTS_DONOTENTER) tmparea->contents |= AREACONTENTS_DONOTENTER;
00733     if (node->contents & CONTENTS_WATER) tmparea->contents |= AREACONTENTS_WATER;
00734     if (node->contents & CONTENTS_LAVA) tmparea->contents |= AREACONTENTS_LAVA;
00735     if (node->contents & CONTENTS_SLIME) tmparea->contents |= AREACONTENTS_SLIME;
00736     if (node->contents & CONTENTS_NOTTEAM1) tmparea->contents |= AREACONTENTS_NOTTEAM1;
00737     if (node->contents & CONTENTS_NOTTEAM2) tmparea->contents |= AREACONTENTS_NOTTEAM2;
00738 
00739     //store the bsp model that's inside this node
00740     tmparea->modelnum = node->modelnum;
00741     //sorta check for flipped area faces (remove??)
00742     AAS_FlipAreaFaces(tmparea);
00743     //check if the area is ok (remove??)
00744     AAS_CheckArea(tmparea);
00745     //
00746     tmpnode = AAS_AllocTmpNode();
00747     tmpnode->planenum = 0;
00748     tmpnode->children[0] = 0;
00749     tmpnode->children[1] = 0;
00750     tmpnode->tmparea = tmparea;
00751     //
00752     return tmpnode;
00753 } //end of the function AAS_CreateArea

Here is the call graph for this function:

void AAS_CreateAreas node_t node  ) 
 

Definition at line 789 of file aas_create.c.

References AAS_CreateAreas_r(), Log_Write(), node_t, tmp_aas_s::nodes, tmp_aas_s::numareas, qprintf(), and tmpaasworld.

Referenced by AAS_Create().

00790 {
00791     Log_Write("AAS_CreateAreas\r\n");
00792     qprintf("%6d areas created", 0);
00793     tmpaasworld.nodes = AAS_CreateAreas_r(node);
00794     qprintf("\n");
00795     Log_Write("%6d areas created\r\n", tmpaasworld.numareas);
00796 } //end of the function AAS_CreateAreas

Here is the call graph for this function:

tmp_node_t* AAS_CreateAreas_r node_t node  ) 
 

Definition at line 760 of file aas_create.c.

References AAS_AllocTmpNode(), AAS_CreateArea(), node_s::children, tmp_node_s::children, node_s::contents, node_t, tmp_node_s::planenum, node_s::planenum, and tmp_node_t.

Referenced by AAS_CreateAreas().

00761 {
00762     tmp_node_t *tmpnode;
00763 
00764     //recurse down to leafs
00765     if (node->planenum != PLANENUM_LEAF)
00766     {
00767         //the first tmp node is a dummy
00768         tmpnode = AAS_AllocTmpNode();
00769         tmpnode->planenum = node->planenum;
00770         tmpnode->children[0] = AAS_CreateAreas_r(node->children[0]);
00771         tmpnode->children[1] = AAS_CreateAreas_r(node->children[1]);
00772         return tmpnode;
00773     } //end if
00774     //areas won't be created for solid leafs
00775     if (node->contents & CONTENTS_SOLID)
00776     {
00777         //just return zero for a solid leaf (in tmp AAS NULL is a solid leaf)
00778         return NULL;
00779     } //end if
00780 
00781     return AAS_CreateArea(node);
00782 } //end of the function AAS_CreateAreas_r

Here is the call graph for this function:

void AAS_CreateAreaSettings void   ) 
 

Definition at line 575 of file aas_create.c.

References AREACONTENTS_SLIME, AREACONTENTS_WATER, tmp_areasettings_s::areaflags, tmp_aas_s::areas, tmp_area_s::contents, tmp_areasettings_s::contents, tmp_face_s::faceflags, tmp_face_s::frontarea, GetClearedMemory(), i, tmp_area_s::invalid, tmp_area_s::l_next, Log_Print(), Log_Write(), tmp_area_s::modelnum, tmp_areasettings_s::modelnum, tmp_face_s::next, tmp_area_s::presencetype, tmp_areasettings_s::presencetype, qprintf(), tmp_area_s::settings, tmp_area_t, tmp_areasettings_t, tmp_face_t, tmpaasworld, and tmp_area_s::tmpfaces.

Referenced by AAS_Create().

00576 {
00577     int i, flags, side, numgrounded, numladderareas, numliquidareas;
00578     tmp_face_t *face;
00579     tmp_area_t *tmparea;
00580 
00581     numgrounded = 0;
00582     numladderareas = 0;
00583     numliquidareas = 0;
00584     Log_Write("AAS_CreateAreaSettings\r\n");
00585     i = 0;
00586     qprintf("%6d areas provided with settings", i);
00587     for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
00588     {
00589         //if the area is invalid there no need to create settings for it
00590         if (tmparea->invalid) continue;
00591 
00592         tmparea->settings = (tmp_areasettings_t *) GetClearedMemory(sizeof(tmp_areasettings_t));
00593         tmparea->settings->contents = tmparea->contents;
00594         tmparea->settings->modelnum = tmparea->modelnum;
00595         flags = 0;
00596         for (face = tmparea->tmpfaces; face; face = face->next[side])
00597         {
00598             side = face->frontarea != tmparea;
00599             flags |= face->faceflags;
00600         } //end for
00601         tmparea->settings->areaflags = 0;
00602         if (flags & FACE_GROUND)
00603         {
00604             tmparea->settings->areaflags |= AREA_GROUNDED;
00605             numgrounded++;
00606         } //end if
00607         if (flags & FACE_LADDER)
00608         {
00609             tmparea->settings->areaflags |= AREA_LADDER;
00610             numladderareas++;
00611         } //end if
00612         if (tmparea->contents & (AREACONTENTS_WATER |
00613                                             AREACONTENTS_SLIME |
00614                                             AREACONTENTS_LAVA))
00615         {
00616             tmparea->settings->areaflags |= AREA_LIQUID;
00617             numliquidareas++;
00618         } //end if
00619         //presence type of the area
00620         tmparea->settings->presencetype = tmparea->presencetype;
00621         //
00622         qprintf("\r%6d", ++i);
00623     } //end for
00624     qprintf("\n");
00625 #ifdef AASINFO
00626     Log_Print("%6d grounded areas\n", numgrounded);
00627     Log_Print("%6d ladder areas\n", numladderareas);
00628     Log_Print("%6d liquid areas\n", numliquidareas);
00629 #endif //AASINFO
00630 } //end of the function AAS_CreateAreaSettings

Here is the call graph for this function:

void AAS_FlipAreaFaces tmp_area_t tmparea  ) 
 

Definition at line