vis.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // vis.h
  19. #include "cmdlib.h"
  20. #include "mathlib.h"
  21. #include "bspfile.h"
  22. #define MAX_PORTALS 32768
  23. #define PORTALFILE "PRT1"
  24. #define ON_EPSILON 0.1
  25. //#define MREDEBUG
  26. // seperator caching helps a bit
  27. #define SEPERATORCACHE
  28. // can't have more seperators than the max number of points on a winding
  29. #define MAX_SEPERATORS 64
  30. typedef struct
  31. {
  32. vec3_t normal;
  33. float dist;
  34. } plane_t;
  35. #define MAX_POINTS_ON_WINDING 64
  36. #define MAX_POINTS_ON_FIXED_WINDING 12
  37. typedef struct
  38. {
  39. int numpoints;
  40. vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
  41. } winding_t;
  42. winding_t *NewWinding (int points);
  43. void FreeWinding (winding_t *w);
  44. winding_t *CopyWinding (winding_t *w);
  45. typedef struct passage_s
  46. {
  47. struct passage_s *next;
  48. byte cansee[1]; //all portals that can be seen through this passage
  49. } passage_t;
  50. typedef enum {stat_none, stat_working, stat_done} vstatus_t;
  51. typedef struct
  52. {
  53. int num;
  54. qboolean hint; // true if this portal was created from a hint splitter
  55. qboolean removed;
  56. plane_t plane; // normal pointing into neighbor
  57. int leaf; // neighbor
  58. vec3_t origin; // for fast clip testing
  59. float radius;
  60. winding_t *winding;
  61. vstatus_t status;
  62. byte *portalfront; // [portals], preliminary
  63. byte *portalflood; // [portals], intermediate
  64. byte *portalvis; // [portals], final
  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. #define MAX_PORTALS_ON_LEAF 128
  70. typedef struct leaf_s
  71. {
  72. int numportals;
  73. int merged;
  74. vportal_t *portals[MAX_PORTALS_ON_LEAF];
  75. } leaf_t;
  76. typedef struct pstack_s
  77. {
  78. byte mightsee[MAX_PORTALS/8]; // bit string
  79. struct pstack_s *next;
  80. leaf_t *leaf;
  81. vportal_t *portal; // portal exiting
  82. winding_t *source;
  83. winding_t *pass;
  84. winding_t windings[3]; // source, pass, temp in any order
  85. int freewindings[3];
  86. plane_t portalplane;
  87. int depth;
  88. #ifdef SEPERATORCACHE
  89. plane_t seperators[2][MAX_SEPERATORS];
  90. int numseperators[2];
  91. #endif
  92. } pstack_t;
  93. typedef struct
  94. {
  95. vportal_t *base;
  96. int c_chains;
  97. pstack_t pstack_head;
  98. } threaddata_t;
  99. extern int numportals;
  100. extern int portalclusters;
  101. extern vportal_t *portals;
  102. extern leaf_t *leafs;
  103. extern int c_portaltest, c_portalpass, c_portalcheck;
  104. extern int c_portalskip, c_leafskip;
  105. extern int c_vistest, c_mighttest;
  106. extern int c_chains;
  107. extern byte *vismap, *vismap_p, *vismap_end; // past visfile
  108. extern int testlevel;
  109. extern byte *uncompressed;
  110. extern int leafbytes, leaflongs;
  111. extern int portalbytes, portallongs;
  112. void LeafFlow (int leafnum);
  113. void BasePortalVis(int portalnum);
  114. void BetterPortalVis(int portalnum);
  115. void PortalFlow(int portalnum);
  116. void PassagePortalFlow(int portalnum);
  117. void CreatePassages(int portalnum);
  118. void PassageFlow(int portalnum);
  119. extern vportal_t *sorted_portals[MAX_MAP_PORTALS*2];
  120. int CountBits (byte *bits, int numbits);