vis.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #ifndef HLVIS_H__
  2. #define HLVIS_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #include "cmdlib.h"
  7. #include "messages.h"
  8. #include "win32fix.h"
  9. #include "log.h"
  10. #include "hlassert.h"
  11. #include "mathlib.h"
  12. #include "bspfile.h"
  13. #include "threads.h"
  14. #include "filelib.h"
  15. #include "zones.h"
  16. #ifdef HLVIS_MAXDIST // AJM: MVD
  17. #define DEFAULT_MAXDISTANCE_RANGE 0
  18. //#define DEFAULT_POST_COMPILE 0
  19. #define MAX_VISBLOCKERS 512
  20. #endif
  21. #ifdef ZHLT_PROGRESSFILE // AJM
  22. #define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
  23. #endif
  24. #define DEFAULT_FULLVIS false
  25. #define DEFAULT_CHART false
  26. #define DEFAULT_INFO true
  27. #ifdef SYSTEM_WIN32
  28. #define DEFAULT_ESTIMATE false
  29. #endif
  30. #ifdef SYSTEM_POSIX
  31. #define DEFAULT_ESTIMATE true
  32. #endif
  33. #define DEFAULT_FASTVIS false
  34. #define DEFAULT_NETVIS_PORT 21212
  35. #define DEFAULT_NETVIS_RATE 60
  36. #define MAX_PORTALS 32768
  37. //#define USE_CHECK_STACK
  38. #define RVIS_LEVEL_1
  39. #define RVIS_LEVEL_2
  40. #define PORTALFILE "PRT1" // WTF?
  41. #define MAX_POINTS_ON_FIXED_WINDING 32
  42. typedef struct
  43. {
  44. bool original; // don't free, it's part of the portal
  45. int numpoints;
  46. vec3_t points[MAX_POINTS_ON_FIXED_WINDING];
  47. } winding_t;
  48. typedef struct
  49. {
  50. vec3_t normal;
  51. float dist;
  52. } plane_t;
  53. typedef enum
  54. {
  55. stat_none,
  56. stat_working,
  57. stat_done
  58. } vstatus_t;
  59. typedef struct
  60. {
  61. plane_t plane; // normal pointing into neighbor
  62. int leaf; // neighbor
  63. winding_t* winding;
  64. vstatus_t status;
  65. byte* visbits;
  66. byte* mightsee;
  67. unsigned nummightsee;
  68. int numcansee;
  69. #ifdef ZHLT_NETVIS
  70. int fromclient; // which client did this come from
  71. #endif
  72. UINT32 zone; // Which zone is this portal a member of
  73. } portal_t;
  74. typedef struct seperating_plane_s
  75. {
  76. struct seperating_plane_s* next;
  77. plane_t plane; // from portal is on positive side
  78. } sep_t;
  79. typedef struct passage_s
  80. {
  81. struct passage_s* next;
  82. int from, to; // leaf numbers
  83. sep_t* planes;
  84. } passage_t;
  85. #define MAX_PORTALS_ON_LEAF 256
  86. typedef struct leaf_s
  87. {
  88. unsigned numportals;
  89. passage_t* passages;
  90. portal_t* portals[MAX_PORTALS_ON_LEAF];
  91. } leaf_t;
  92. typedef struct pstack_s
  93. {
  94. byte mightsee[MAX_MAP_LEAFS / 8]; // bit string
  95. #ifdef USE_CHECK_STACK
  96. struct pstack_s* next;
  97. #endif
  98. struct pstack_s* head;
  99. leaf_t* leaf;
  100. portal_t* portal; // portal exiting
  101. winding_t* source;
  102. winding_t* pass;
  103. winding_t windings[3]; // source, pass, temp in any order
  104. char freewindings[3];
  105. const plane_t* portalplane;
  106. #ifdef RVIS_LEVEL_2
  107. int clipPlaneCount;
  108. plane_t* clipPlane;
  109. #endif
  110. } pstack_t;
  111. typedef struct
  112. {
  113. byte* leafvis; // bit string
  114. // byte fullportal[MAX_PORTALS/8]; // bit string
  115. portal_t* base;
  116. pstack_t pstack_head;
  117. } threaddata_t;
  118. #ifdef HLVIS_MAXDIST
  119. // AJM: MVD
  120. // Special VISBLOCKER entity structure
  121. typedef struct
  122. {
  123. char name[64];
  124. int numplanes;
  125. plane_t planes[MAX_PORTALS_ON_LEAF];
  126. int numnames;
  127. int numleafs;
  128. int blockleafs[MAX_PORTALS];
  129. char blocknames[MAX_VISBLOCKERS][64];
  130. } visblocker_t;
  131. #endif
  132. extern bool g_fastvis;
  133. extern bool g_fullvis;
  134. extern int g_numportals;
  135. extern unsigned g_portalleafs;
  136. #ifdef HLVIS_MAXDIST // AJM: MVD
  137. extern unsigned int g_maxdistance;
  138. //extern bool g_postcompile;
  139. #endif
  140. extern portal_t*g_portals;
  141. extern leaf_t* g_leafs;
  142. #ifdef HLVIS_MAXDIST // AJM: MVD
  143. // Visblockers
  144. extern visblocker_t g_visblockers[MAX_VISBLOCKERS];
  145. extern int g_numvisblockers;
  146. extern byte* g_mightsee;
  147. #endif
  148. extern byte* g_uncompressed;
  149. extern unsigned g_bitbytes;
  150. extern unsigned g_bitlongs;
  151. extern volatile int g_vislocalpercent;
  152. extern Zones* g_Zones;
  153. extern void BasePortalVis(int threadnum);
  154. #ifdef HLVIS_MAXDIST // AJM: MVD
  155. extern visblocker_t *GetVisBlock(char *name);
  156. extern void BlockVis(int unused);
  157. extern void MaxDistVis(int threadnum);
  158. //extern void PostMaxDistVis(int threadnum);
  159. #endif
  160. extern void PortalFlow(portal_t* p);
  161. extern void CalcAmbientSounds();
  162. #ifdef ZHLT_NETVIS
  163. #include "packet.h"
  164. #include "c2cpp.h"
  165. #include "NetvisSession.h"
  166. #endif
  167. #endif // byte fullportal[MAX_PORTALS/8]; // bit string HLVIS_H__