home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / util / q2source.exe / utils3 / bsp / qvis3 / vis.h < prev   
Encoding:
C/C++ Source or Header  |  1997-11-18  |  2.5 KB  |  130 lines

  1. // vis.h
  2.  
  3. #include "cmdlib.h"
  4. #include "mathlib.h"
  5. #include "bspfile.h"
  6.  
  7. #define    MAX_PORTALS    32768
  8.  
  9. #define    PORTALFILE    "PRT1"
  10.  
  11. #define    ON_EPSILON    0.1
  12.  
  13. typedef struct
  14. {
  15.     vec3_t        normal;
  16.     float        dist;
  17. } plane_t;
  18.  
  19. #define MAX_POINTS_ON_WINDING    64
  20. #define    MAX_POINTS_ON_FIXED_WINDING    12
  21.  
  22. typedef struct
  23. {
  24.     qboolean    original;            // don't free, it's part of the portal
  25.     int        numpoints;
  26.     vec3_t    points[MAX_POINTS_ON_FIXED_WINDING];            // variable sized
  27. } winding_t;
  28.  
  29. winding_t    *NewWinding (int points);
  30. void        FreeWinding (winding_t *w);
  31. winding_t    *CopyWinding (winding_t *w);
  32.  
  33.  
  34. typedef enum {stat_none, stat_working, stat_done} vstatus_t;
  35. typedef struct
  36. {
  37.     plane_t        plane;    // normal pointing into neighbor
  38.     int            leaf;    // neighbor
  39.     
  40.     vec3_t        origin;    // for fast clip testing
  41.     float        radius;
  42.  
  43.     winding_t    *winding;
  44.     vstatus_t    status;
  45.     byte        *portalfront;    // [portals], preliminary
  46.     byte        *portalflood;    // [portals], intermediate
  47.     byte        *portalvis;        // [portals], final
  48.  
  49.     int            nummightsee;    // bit count on portalflood for sort
  50. } portal_t;
  51.  
  52. typedef struct seperating_plane_s
  53. {
  54.     struct seperating_plane_s *next;
  55.     plane_t        plane;        // from portal is on positive side
  56. } sep_t;
  57.  
  58.  
  59. typedef struct passage_s
  60. {
  61.     struct passage_s    *next;
  62.     int            from, to;        // leaf numbers
  63.     sep_t                *planes;
  64. } passage_t;
  65.  
  66. #define    MAX_PORTALS_ON_LEAF        128
  67. typedef struct leaf_s
  68. {
  69.     int            numportals;
  70.     passage_t    *passages;
  71.     portal_t    *portals[MAX_PORTALS_ON_LEAF];
  72. } leaf_t;
  73.  
  74.     
  75. typedef struct pstack_s
  76. {
  77.     byte        mightsee[MAX_PORTALS/8];        // bit string
  78.     struct pstack_s    *next;
  79.     leaf_t        *leaf;
  80.     portal_t    *portal;    // portal exiting
  81.     winding_t    *source;
  82.     winding_t    *pass;
  83.  
  84.     winding_t    windings[3];    // source, pass, temp in any order
  85.     int            freewindings[3];
  86.  
  87.     plane_t        portalplane;
  88. } pstack_t;
  89.  
  90. typedef struct
  91. {
  92.     portal_t    *base;
  93.     int            c_chains;
  94.     pstack_t    pstack_head;
  95. } threaddata_t;
  96.  
  97.  
  98.  
  99. extern    int            numportals;
  100. extern    int            portalclusters;
  101.  
  102. extern    portal_t    *portals;
  103. extern    leaf_t        *leafs;
  104.  
  105. extern    int            c_portaltest, c_portalpass, c_portalcheck;
  106. extern    int            c_portalskip, c_leafskip;
  107. extern    int            c_vistest, c_mighttest;
  108. extern    int            c_chains;
  109.  
  110. extern    byte    *vismap, *vismap_p, *vismap_end;    // past visfile
  111.  
  112. extern    int            testlevel;
  113.  
  114. extern    byte        *uncompressed;
  115.  
  116. extern    int        leafbytes, leaflongs;
  117. extern    int        portalbytes, portallongs;
  118.  
  119.  
  120. void LeafFlow (int leafnum);
  121.  
  122.  
  123. void BasePortalVis (int portalnum);
  124. void BetterPortalVis (int portalnum);
  125. void PortalFlow (int portalnum);
  126.  
  127. extern    portal_t    *sorted_portals[MAX_MAP_PORTALS*2];
  128.  
  129. int CountBits (byte *bits, int numbits);
  130.