home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / vis.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  3.0 KB  |  142 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. //#define MREDEBUG
  14.  
  15. // seperator caching helps a bit
  16. #define SEPERATORCACHE
  17.  
  18. // can't have more seperators than the max number of points on a winding
  19. #define MAX_SEPERATORS        64
  20.  
  21. typedef struct
  22. {
  23.     vec3_t        normal;
  24.     float        dist;
  25. } plane_t;
  26.  
  27. #define MAX_POINTS_ON_WINDING    64
  28. #define    MAX_POINTS_ON_FIXED_WINDING    12
  29.  
  30. typedef struct
  31. {
  32.     int        numpoints;
  33.     vec3_t    points[MAX_POINTS_ON_FIXED_WINDING];            // variable sized
  34. } winding_t;
  35.  
  36. winding_t    *NewWinding (int points);
  37. void        FreeWinding (winding_t *w);
  38. winding_t    *CopyWinding (winding_t *w);
  39.  
  40.  
  41. typedef struct passage_s
  42. {
  43.     struct passage_s    *next;
  44.     byte                cansee[1];    //all portals that can be seen through this passage
  45. } passage_t;
  46.  
  47. typedef enum {stat_none, stat_working, stat_done} vstatus_t;
  48. typedef struct
  49. {
  50.     int            num;
  51.     qboolean    hint;    // true if this portal was created from a hint splitter
  52.     qboolean    removed;
  53.     plane_t        plane;    // normal pointing into neighbor
  54.     int            leaf;    // neighbor
  55.     
  56.     vec3_t        origin;    // for fast clip testing
  57.     float        radius;
  58.  
  59.     winding_t    *winding;
  60.     vstatus_t    status;
  61.     byte        *portalfront;    // [portals], preliminary
  62.     byte        *portalflood;    // [portals], intermediate
  63.     byte        *portalvis;        // [portals], final
  64.  
  65.     int            nummightsee;    // bit count on portalflood for sort
  66.     passage_t    *passages;        // there are just as many passages as there
  67.                                 // are portals in the leaf this portal leads to
  68. } vportal_t;
  69.  
  70. #define    MAX_PORTALS_ON_LEAF        128
  71. typedef struct leaf_s
  72. {
  73.     int            numportals;
  74.     int            merged;
  75.     vportal_t    *portals[MAX_PORTALS_ON_LEAF];
  76. } leaf_t;
  77.  
  78.     
  79. typedef struct pstack_s
  80. {
  81.     byte        mightsee[MAX_PORTALS/8];        // bit string
  82.     struct pstack_s    *next;
  83.     leaf_t        *leaf;
  84.     vportal_t    *portal;    // portal exiting
  85.     winding_t    *source;
  86.     winding_t    *pass;
  87.  
  88.     winding_t    windings[3];    // source, pass, temp in any order
  89.     int            freewindings[3];
  90.  
  91.     plane_t        portalplane;
  92.     int depth;
  93. #ifdef SEPERATORCACHE
  94.     plane_t seperators[2][MAX_SEPERATORS];
  95.     int numseperators[2];
  96. #endif
  97. } pstack_t;
  98.  
  99. typedef struct
  100. {
  101.     vportal_t    *base;
  102.     int            c_chains;
  103.     pstack_t    pstack_head;
  104. } threaddata_t;
  105.  
  106.  
  107.  
  108. extern    int            numportals;
  109. extern    int            portalclusters;
  110.  
  111. extern    vportal_t    *portals;
  112. extern    leaf_t        *leafs;
  113.  
  114. extern    int            c_portaltest, c_portalpass, c_portalcheck;
  115. extern    int            c_portalskip, c_leafskip;
  116. extern    int            c_vistest, c_mighttest;
  117. extern    int            c_chains;
  118.  
  119. extern    byte    *vismap, *vismap_p, *vismap_end;    // past visfile
  120.  
  121. extern    int            testlevel;
  122.  
  123. extern    byte        *uncompressed;
  124.  
  125. extern    int        leafbytes, leaflongs;
  126. extern    int        portalbytes, portallongs;
  127.  
  128.  
  129. void LeafFlow (int leafnum);
  130.  
  131.  
  132. void BasePortalVis(int portalnum);
  133. void BetterPortalVis(int portalnum);
  134. void PortalFlow(int portalnum);
  135. void PassagePortalFlow(int portalnum);
  136. void CreatePassages(int portalnum);
  137. void PassageFlow(int portalnum);
  138.  
  139. extern    vportal_t    *sorted_portals[MAX_MAP_PORTALS*2];
  140.  
  141. int CountBits (byte *bits, int numbits);
  142.