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

vis.h File Reference

#include "cmdlib.h"
#include "mathlib.h"
#include "bspfile.h"

Include dependency graph for vis.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  leaf_s
struct  passage_s
struct  plane_t
struct  pstack_s
struct  threaddata_t
struct  vportal_t
struct  winding_t

Defines

#define MAX_POINTS_ON_FIXED_WINDING   12
#define MAX_POINTS_ON_WINDING   64
#define MAX_PORTALS   32768
#define MAX_PORTALS_ON_LEAF   128
#define MAX_SEPERATORS   64
#define ON_EPSILON   0.1
#define PORTALFILE   "PRT1"
#define SEPERATORCACHE

Typedefs

typedef leaf_s leaf_t
typedef passage_s passage_t
typedef pstack_s pstack_t

Enumerations

enum  vstatus_t { stat_none, stat_working, stat_done }

Functions

void BasePortalVis (int portalnum)
void BetterPortalVis (int portalnum)
winding_tCopyWinding (winding_t *w)
int CountBits (byte *bits, int numbits)
void CreatePassages (int portalnum)
void FreeWinding (winding_t *w)
void LeafFlow (int leafnum)
winding_tNewWinding (int points)
void PassageFlow (int portalnum)
void PassagePortalFlow (int portalnum)
void PortalFlow (int portalnum)

Variables

int c_chains
int c_leafskip
int c_mighttest
int c_portalcheck
int c_portalpass
int c_portalskip
int c_portaltest
int c_vistest
int leafbytes
int leaflongs
leaf_tleafs
int numportals
int portalbytes
int portalclusters
int portallongs
vportal_tportals
vportal_tsorted_portals [MAX_MAP_PORTALS *2]
int testlevel
byteuncompressed
bytevismap
bytevismap_end
bytevismap_p


Define Documentation

#define MAX_POINTS_ON_FIXED_WINDING   12
 

Definition at line 49 of file vis.h.

#define MAX_POINTS_ON_WINDING   64
 

Definition at line 48 of file vis.h.

#define MAX_PORTALS   32768
 

Definition at line 28 of file vis.h.

#define MAX_PORTALS_ON_LEAF   128
 

Definition at line 91 of file vis.h.

#define MAX_SEPERATORS   64
 

Definition at line 40 of file vis.h.

Referenced by CreatePassages().

#define ON_EPSILON   0.1
 

Definition at line 32 of file vis.h.

#define PORTALFILE   "PRT1"
 

Definition at line 30 of file vis.h.

#define SEPERATORCACHE
 

Definition at line 37 of file vis.h.


Typedef Documentation

typedef struct leaf_s leaf_t
 

Referenced by CheckStack(), ClusterMerge(), CreatePassages(), LoadPortals(), MergeLeafPortals(), MergeLeaves(), PassageMemory(), prl(), RecursiveLeafBitFlow(), RecursiveLeafFlow(), RecursivePassageFlow(), RecursivePassagePortalFlow(), SimpleFlood(), and TryMergeLeaves().

typedef struct passage_s passage_t
 

Referenced by CreatePassages(), PassageMemory(), RecursivePassageFlow(), and RecursivePassagePortalFlow().

typedef struct pstack_s pstack_t
 

Referenced by AllocStackWinding(), CheckStack(), ClipToSeperators(), FreeStackWinding(), RecursiveLeafFlow(), RecursivePassageFlow(), RecursivePassagePortalFlow(), and VisChopWinding().


Enumeration Type Documentation

enum vstatus_t
 

Enumeration values:
stat_none 
stat_working 
stat_done 

Definition at line 68 of file vis.h.

00068 {stat_none, stat_working, stat_done} vstatus_t;


Function Documentation

void BasePortalVis int  portalnum  ) 
 

Definition at line 1505 of file visflow.c.

References c_flood, CountBits(), d, plane_t::dist, DotProduct, j, k, vportal_t::leaf, malloc(), memset(), plane_t::normal, vportal_t::nummightsee, winding_t::numpoints, numportals, p, vportal_t::plane, winding_t::points, portalbytes, vportal_t::portalflood, vportal_t::portalfront, portals, vportal_t::portalvis, vportal_t::removed, SimpleFlood(), w, and vportal_t::winding.

Referenced by CalcVis().

01506 {
01507     int         j, k;
01508     vportal_t   *tp, *p;
01509     float       d;
01510     winding_t   *w;
01511 
01512     p = portals+portalnum;
01513 
01514     if (p->removed)
01515         return;
01516 
01517     p->portalfront = malloc (portalbytes);
01518     memset (p->portalfront, 0, portalbytes);
01519 
01520     p->portalflood = malloc (portalbytes);
01521     memset (p->portalflood, 0, portalbytes);
01522     
01523     p->portalvis = malloc (portalbytes);
01524     memset (p->portalvis, 0, portalbytes);
01525     
01526     for (j=0, tp = portals ; j<numportals*2 ; j++, tp++)
01527     {
01528         if (j == portalnum)
01529             continue;
01530         if (tp->removed)
01531             continue;
01532         /*
01533         if (farplanedist >= 0)
01534         {
01535             vec3_t dir;
01536             VectorSubtract(p->origin, tp->origin, dir);
01537             if (VectorLength(dir) > farplanedist - p->radius - tp->radius)
01538                 continue;
01539         }
01540         */
01541         w = tp->winding;
01542         for (k=0 ; k<w->numpoints ; k++)
01543         {
01544             d = DotProduct (w->points[k], p->plane.normal)
01545                 - p->plane.dist;
01546             if (d > ON_EPSILON)
01547                 break;
01548         }
01549         if (k == w->numpoints)
01550             continue;   // no points on front
01551 
01552         w = p->winding;
01553         for (k=0 ; k<w->numpoints ; k++)
01554         {
01555             d = DotProduct (w->points[k], tp->plane.normal)
01556                 - tp->plane.dist;
01557             if (d < -ON_EPSILON)
01558                 break;
01559         }
01560         if (k == w->numpoints)
01561             continue;   // no points on front
01562 
01563         p->portalfront[j>>3] |= (1<<(j&7));
01564     }
01565     
01566     SimpleFlood (p, p->leaf);
01567 
01568     p->nummightsee = CountBits (p->portalflood, numportals*2);
01569 //  _printf ("portal %i: %i mightsee\n", portalnum, p->nummightsee);
01570     c_flood += p->nummightsee;
01571 }

Here is the call graph for this function:

void BetterPortalVis int  portalnum  ) 
 

Definition at line 1641 of file visflow.c.

References c_vis, CountBits(), vportal_t::leaf, vportal_t::nummightsee, numportals, p, vportal_t::portalflood, portals, vportal_t::portalvis, RecursiveLeafBitFlow(), and vportal_t::removed.

01642 {
01643     vportal_t   *p;
01644 
01645     p = portals+portalnum;
01646 
01647     if (p->removed)
01648         return;
01649 
01650     RecursiveLeafBitFlow (p->leaf, p->portalflood, p->portalvis);
01651 
01652     // build leaf vis information
01653     p->nummightsee = CountBits (p->portalvis, numportals*2);
01654     c_vis += p->nummightsee;
01655 }

Here is the call graph for this function:

winding_t* CopyWinding winding_t w  ) 
 

Definition at line 322 of file l_poly.c.

References AllocWinding(), c, memcpy(), winding_t::numpoints, winding_t::p, and w.

Referenced by AAS_CreateArea(), AddWindingToConvexHull(), BspFaceForPortal(), ClipSidesIntoTree(), ClipWindingEpsilon(), CM_AddFacetBevels(), CopyBrush(), FaceFromPortal(), HL_FaceOnWinding(), HL_SplitBrush(), MakeBspBrushList(), MakeStructuralBspFaceList(), MakeVisibleBspFaceList(), Q1_FaceOnWinding(), Q1_SplitBrush(), Q2_FaceOnWinding(), Q3_FaceOnWinding(), Sin_FaceOnWinding(), and SplitBrush().

00323 {
00324     int         size;
00325     winding_t   *c;
00326 
00327     c = AllocWinding (w->numpoints);
00328     size = (int)((winding_t *)0)->p[w->numpoints];
00329     memcpy (c, w, size);
00330     return c;
00331 }

Here is the call graph for this function:

int CountBits byte bits,
int  numbits
 

Definition at line 43 of file visflow.c.

References bits, byte, c, and i.

Referenced by BasePortalVis(), BetterPortalVis(), LeafVectorFromPortalVector(), and PortalFlow().

00044 {
00045     int     i;
00046     int     c;
00047 
00048     c = 0;
00049     for (i=0 ; i<numbits ; i++)
00050         if (bits[i>>3] & (1<<(i&7)) )
00051             c++;
00052 
00053     return c;
00054 }

void CreatePassages int  portalnum  ) 
 

Definition at line 1303 of file visflow.c.

References _printf(), AddSeperators(), passage_s::cansee, d, plane_t::dist, DotProduct, i, in, j, k, vportal_t::leaf, leaf_t, leafs, malloc(), MAX_SEPERATORS, memcpy(), memset(), n, passage_s::next, plane_t::normal, winding_t::numpoints, leaf_s::numportals, numportals, vportal_t::origin, p, passage_t, PassageChopWinding(), vportal_t::passages, winding_t::points, portalbytes, vportal_t::portalflood, leaf_s::portals, portals, qfalse, qtrue, vportal_t::radius, vportal_t::removed, sorted_portals, vportal_t::status, w, and vportal_t::winding.

Referenced by CalcPassagePortalVis(), and CalcPassageVis().

01304 {
01305     int i, j, k, n, numseperators, numsee;
01306     float d;
01307     vportal_t *portal, *p, *target;
01308     leaf_t *leaf;
01309     passage_t   *passage, *lastpassage;
01310     plane_t seperators[MAX_SEPERATORS*2];
01311     winding_t *w;
01312     winding_t in, out, *res;
01313 
01314 #ifdef MREDEBUG
01315     _printf("\r%6d", portalnum);
01316 #endif
01317 
01318     portal = sorted_portals[portalnum];
01319 
01320     if (portal->removed)
01321     {
01322         portal->status = stat_done;
01323         return;
01324     }
01325 
01326     lastpassage = NULL;
01327     leaf = &leafs[portal->leaf];
01328     for (i = 0; i < leaf->numportals; i++)
01329     {
01330         target = leaf->portals[i];
01331         if (target->removed)
01332             continue;
01333 
01334         passage = (passage_t *) malloc(sizeof(passage_t) + portalbytes);
01335         memset(passage, 0, sizeof(passage_t) + portalbytes);
01336         numseperators = AddSeperators(portal->winding, target->winding, qfalse, seperators, MAX_SEPERATORS*2);
01337         numseperators += AddSeperators(target->winding, portal->winding, qtrue, &seperators[numseperators], MAX_SEPERATORS*2-numseperators);
01338 
01339         passage->next = NULL;
01340         if (lastpassage)
01341             lastpassage->next = passage;
01342         else
01343             portal->passages = passage;
01344         lastpassage = passage;
01345 
01346         numsee = 0;
01347         //create the passage->cansee
01348         for (j = 0; j < numportals * 2; j++)
01349         {
01350             p = &portals[j];
01351             if (p->removed)
01352                 continue;
01353             if ( ! (target->portalflood[j >> 3] & (1<<(j&7)) ) )
01354                 continue;
01355             if ( ! (portal->portalflood[j >> 3] & (1<<(j&7)) ) )
01356                 continue;
01357             for (k = 0; k < numseperators; k++)
01358             {
01359                 //
01360                 d = DotProduct (p->origin, seperators[k].normal) - seperators[k].dist;
01361                 //if completely at the back of the seperator plane
01362                 if (d < -p->radius + ON_EPSILON)
01363                     break;
01364                 w = p->winding;
01365                 for (n = 0; n < w->numpoints; n++)
01366                 {
01367                     d = DotProduct (w->points[n], seperators[k].normal) - seperators[k].dist;
01368                     //if at the front of the seperator
01369                     if (d > ON_EPSILON)
01370                         break;
01371                 }
01372                 //if no points are at the front of the seperator
01373                 if (n >= w->numpoints)
01374                     break;
01375             }
01376             if (k < numseperators)
01377                 continue;
01378             memcpy(&in, p->winding, sizeof(winding_t));
01379             for (k = 0; k < numseperators; k++)
01380             {
01381                 res = PassageChopWinding(&in, &out, &seperators[k]);
01382                 if (res == &out)
01383                     memcpy(&in, &out, sizeof(winding_t));
01384                 if (res == NULL)
01385                     break;
01386             }
01387             if (k < numseperators)
01388                 continue;
01389             passage->cansee[j >> 3] |= (1<<(j&7));
01390             numsee++;
01391         }
01392     }
01393 }

Here is the call graph for this function:

void FreeWinding winding_t w  ) 
 

Definition at line 92 of file l_poly.c.

References c_active_windings, c_windingmemory, Error(), free(), FreeMemory(), MemorySize(), numthreads, and w.

Referenced by AAS_CheckFaceWindingPlane(), AAS_FlipFace(), AAS_FreeTmpAAS(), AAS_FreeTmpFace(), AAS_LadderSubdivideArea_r(), AAS_MeltFaceWinding(), AAS_MergePlaneFaces(), AAS_SplitFace(), AAS_StoreArea(), AAS_TestSplitPlane(), AAS_TryMergeFaces(), AddWindingToConvexHull(), ChopFaceByBrush(), ChopWinding(), ChopWindingInPlace(), ClipSideIntoTree_r(), CM_AddFacetBevels(), CM_DrawDebugSurface(), CM_ValidateFacet(), CreateBrushWindings(), CreateSurfaceLights(), FilterMapDrawSurfIntoTree_r(), FilterSideIntoTree_r(), FreeBrush(), FreeBrushWindings(), FreeBspFace(), FreeFace(), FreePortal(), HL_FaceOnWinding(), HL_SplitBrush(), MakeNodePortal(), MergeLeafPortals(), OutputPortal(), Q1_FaceOnWinding(), Q1_SplitBrush(), Q2_FaceOnWinding(), Q2_FixTextureReferences(), Q3_FaceOnWinding(), Q3_FindVisibleBrushSides(), RemoveLightsInSolid(), ResetMapLoading(), Sin_FaceOnWinding(), Sin_FixTextureReferences(), SplitBrush(), SplitNodePortals(), SubdivideAreaLight(), TestExpandBrushes(), VL_CreateFakeSurfaceLights(), VL_SubdivideAreaLight(), VS_CreateFakeSurfaceLights(), VS_SubdivideAreaLight(), WriteBspBrushMap(), WriteMapBrush(), and WriteOriginBrush().

00093 {
00094     if (*(unsigned *)w == 0xdeaddead)
00095         Error ("FreeWinding: freed a freed winding");
00096 
00097     if (numthreads == 1)
00098     {
00099         c_active_windings--;
00100         c_windingmemory -= MemorySize(w);
00101     } //end if
00102 
00103     *(unsigned *)w = 0xdeaddead;
00104 
00105     FreeMemory(w);
00106 } //end of the function FreeWinding

Here is the call graph for this function:

void LeafFlow int  leafnum  ) 
 

winding_t* NewWinding int  points  ) 
 

Definition at line 91 of file vis.c.

References Error(), malloc(), memset(), winding_t::points, points, and w.

Referenced by LoadPortals(), and TryMergeWinding().

00092 {
00093     winding_t   *w;
00094     int         size;
00095     
00096     if (points > MAX_POINTS_ON_WINDING)
00097         Error ("NewWinding: %i points", points);
00098     
00099     size = (int)((winding_t *)0)->points[points];
00100     w = malloc (size);
00101     memset (w, 0, size);
00102     
00103     return w;
00104 }

Here is the call graph for this function:

void PassageFlow int  portalnum  ) 
 

Definition at line 751 of file visflow.c.

References _printf(), data, i, memset(), p, vportal_t::plane, vportal_t::portalflood, RecursivePassageFlow(), vportal_t::removed, sorted_portals, vportal_t::status, and vportal_t::winding.

Referenced by CalcPassageVis().

00752 {
00753     threaddata_t    data;
00754     int             i;
00755     vportal_t       *p;
00756 //  int             c_might, c_can;
00757 
00758 #ifdef MREDEBUG
00759     _printf("\r%6d", portalnum);
00760 #endif
00761 
00762     p = sorted_portals[portalnum];
00763 
00764     if (p->removed)
00765     {
00766         p->status = stat_done;
00767         return;
00768     }
00769 
00770     p->status = stat_working;
00771 
00772 //  c_might = CountBits (p->portalflood, numportals*2);
00773 
00774     memset (&data, 0, sizeof(data));
00775     data.base = p;
00776     
00777     data.pstack_head.portal = p;
00778     data.pstack_head.source = p->winding;
00779     data.pstack_head.portalplane = p->plane;
00780     data.pstack_head.depth = 0;
00781     for (i=0 ; i<portallongs ; i++)
00782         ((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];
00783 
00784     RecursivePassageFlow (p, &data, &data.pstack_head);
00785 
00786     p->status = stat_done;
00787 
00788     /*
00789     c_can = CountBits (p->portalvis, numportals*2);
00790 
00791     qprintf ("portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\n", 
00792         (int)(p - portals), c_might, c_can, data.c_chains);
00793     */
00794 }

Here is the call graph for this function:

void PassagePortalFlow int  portalnum  ) 
 

Definition at line 1014 of file visflow.c.

References _printf(), data, i, memset(), p, vportal_t::plane, vportal_t::portalflood, RecursivePassagePortalFlow(), vportal_t::removed, sorted_portals, vportal_t::status, and vportal_t::winding.

Referenced by CalcPassagePortalVis().

01015 {
01016     threaddata_t    data;
01017     int             i;
01018     vportal_t       *p;
01019 //  int             c_might, c_can;
01020 
01021 #ifdef MREDEBUG
01022     _printf("\r%6d", portalnum);
01023 #endif
01024 
01025     p = sorted_portals[portalnum];
01026 
01027     if (p->removed)
01028     {
01029         p->status = stat_done;
01030         return;
01031     }
01032 
01033     p->status = stat_working;
01034 
01035 //  c_might = CountBits (p->portalflood, numportals*2);
01036 
01037     memset (&data, 0, sizeof(data));
01038     data.base = p;
01039     
01040     data.pstack_head.portal = p;
01041     data.pstack_head.source = p->winding;
01042     data.pstack_head.portalplane = p->plane;
01043     data.pstack_head.depth = 0;
01044     for (i=0 ; i<portallongs ; i++)
01045         ((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];
01046 
01047     RecursivePassagePortalFlow (p, &data, &data.pstack_head);
01048 
01049     p->status = stat_done;
01050 
01051     /*
01052     c_can = CountBits (p->portalvis, numportals*2);
01053 
01054     qprintf ("portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\n", 
01055         (int)(p - portals), c_might, c_can, data.c_chains);
01056     */
01057 }

Here is the call graph for this function:

void PortalFlow int  portalnum  ) 
 

Definition at line 624 of file visflow.c.

References _printf(), CountBits(), data, i, vportal_t::leaf, memset(), numportals, p, vportal_t::plane, vportal_t::portalflood, portals, vportal_t::portalvis, qprintf(), RecursiveLeafFlow(), vportal_t::removed, sorted_portals, vportal_t::status, and vportal_t::winding.

Referenced by CalcPortalVis().

00625 {
00626     threaddata_t    data;
00627     int             i;
00628     vportal_t       *p;
00629     int             c_might, c_can;
00630 
00631 #ifdef MREDEBUG
00632     _printf("\r%6d", portalnum);
00633 #endif
00634 
00635     p = sorted_portals[portalnum];
00636 
00637     if (p->removed)
00638     {
00639         p->status = stat_done;
00640         return;
00641     }
00642 
00643     p->status = stat_working;
00644 
00645     c_might = CountBits (p->portalflood, numportals*2);
00646 
00647     memset (&data, 0, sizeof(data));
00648     data.base = p;
00649     
00650     data.pstack_head.portal = p;
00651     data.pstack_head.source = p->winding;
00652     data.pstack_head.portalplane = p->plane;
00653     data.pstack_head.depth = 0;
00654     for (i=0 ; i<portallongs ; i++)
00655         ((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];
00656 
00657     RecursiveLeafFlow (p->leaf, &data, &data.pstack_head);
00658 
00659     p->status = stat_done;
00660 
00661     c_can = CountBits (p->portalvis, numportals*2);
00662 
00663     qprintf ("portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\n", 
00664         (int)(p - portals), c_might, c_can, data.c_chains);
00665 }

Here is the call graph for this function:


Variable Documentation

int c_chains
 

int c_leafskip
 

Definition at line 57 of file visflow.c.

int c_mighttest
 

Definition at line 58 of file visflow.c.

int c_portalcheck
 

Definition at line 48 of file vis.c.

int c_portalpass
 

Definition at line 48 of file vis.c.

int c_portalskip
 

Definition at line 57 of file visflow.c.

int c_portaltest
 

Definition at line 48 of file vis.c.

int c_vistest
 

Definition at line 58 of file visflow.c.

int leafbytes
 

Definition at line 50 of file vis.c.

Referenced by CalcPHS(), ClusterMerge(), and LoadPortals().

int leaflongs
 

Definition at line 51 of file vis.c.

Referenced by LoadPortals().

leaf_t* leafs
 

Definition at line 204 of file lightv.c.

int numportals
 

Definition at line 203 of file lightv.c.

int portalbytes
 

Definition at line 53 of file vis.c.

Referenced by BasePortalVis(), ClusterMerge(), CreatePassages(), LoadPortals(), RecursivePassageFlow(), and RecursivePassagePortalFlow().

int portalclusters
 

Definition at line 203 of file lightv.c.

int portallongs
 

Definition at line 53 of file vis.c.

Referenced by LoadPortals().

vportal_t* portals
 

Definition at line 205 of file lightv.c.

vportal_t* sorted_portals[MAX_MAP_PORTALS *2]
 

Definition at line 66 of file vis.c.

Referenced by CreatePassages(), PassageFlow(), PassageMemory(), PassagePortalFlow(), PortalFlow(), and SortPortals().

int testlevel
 

Definition at line 62 of file vis.c.

Referenced by VisMain().

byte* uncompressed
 

Referenced by CalcPHS(), and ClusterMerge().

byte* vismap
 

byte * vismap_end
 

byte * vismap_p
 


Generated on Thu Aug 25 17:18:55 2005 for Quake III Arena by  doxygen 1.3.9.1