Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // vis.h
  9. #include "cmdlib.h"
  10. #include "mathlib/mathlib.h"
  11. #include "bsplib.h"
  12. #define MAX_PORTALS 65536
  13. #define PORTALFILE "PRT1"
  14. extern bool g_bUseRadius; // prototyping TF2, "radius vis" solution
  15. extern double g_VisRadius; // the radius for the TF2 "radius vis"
  16. struct plane_t
  17. {
  18. Vector normal;
  19. float dist;
  20. };
  21. #define MAX_POINTS_ON_WINDING 64
  22. #define MAX_POINTS_ON_FIXED_WINDING 12
  23. struct winding_t
  24. {
  25. qboolean original; // don't free, it's part of the portal
  26. int numpoints;
  27. Vector points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
  28. };
  29. winding_t *NewWinding (int points);
  30. void FreeWinding (winding_t *w);
  31. winding_t *CopyWinding (winding_t *w);
  32. typedef enum {stat_none, stat_working, stat_done} vstatus_t;
  33. struct portal_t
  34. {
  35. plane_t plane; // normal pointing into neighbor
  36. int leaf; // neighbor
  37. Vector origin; // for fast clip testing
  38. float radius;
  39. winding_t *winding;
  40. vstatus_t status;
  41. byte *portalfront; // [portals], preliminary
  42. byte *portalflood; // [portals], intermediate
  43. byte *portalvis; // [portals], final
  44. int nummightsee; // bit count on portalflood for sort
  45. };
  46. struct leaf_t
  47. {
  48. CUtlVector<portal_t *> portals;
  49. };
  50. struct pstack_t
  51. {
  52. byte mightsee[MAX_PORTALS/8]; // bit string
  53. pstack_t *next;
  54. leaf_t *leaf;
  55. portal_t *portal; // portal exiting
  56. winding_t *source;
  57. winding_t *pass;
  58. winding_t windings[3]; // source, pass, temp in any order
  59. int freewindings[3];
  60. plane_t portalplane;
  61. };
  62. struct threaddata_t
  63. {
  64. portal_t *base;
  65. int c_chains;
  66. pstack_t pstack_head;
  67. };
  68. extern int g_numportals;
  69. extern int portalclusters;
  70. extern portal_t *portals;
  71. extern leaf_t *leafs;
  72. extern int c_portaltest, c_portalpass, c_portalcheck;
  73. extern int c_portalskip, c_leafskip;
  74. extern int c_vistest, c_mighttest;
  75. extern int c_chains;
  76. extern byte *vismap, *vismap_p, *vismap_end; // past visfile
  77. extern int testlevel;
  78. extern byte *uncompressed;
  79. extern int leafbytes, leaflongs;
  80. extern int portalbytes, portallongs;
  81. void LeafFlow (int leafnum);
  82. void BasePortalVis (int iThread, int portalnum);
  83. void BetterPortalVis (int portalnum);
  84. void PortalFlow (int iThread, int portalnum);
  85. void WritePortalTrace( const char *source );
  86. extern portal_t *sorted_portals[MAX_MAP_PORTALS*2];
  87. extern int g_TraceClusterStart, g_TraceClusterStop;
  88. int CountBits (byte *bits, int numbits);
  89. #define CheckBit( bitstring, bitNumber ) ( (bitstring)[ ((bitNumber) >> 3) ] & ( 1 << ( (bitNumber) & 7 ) ) )
  90. #define SetBit( bitstring, bitNumber ) ( (bitstring)[ ((bitNumber) >> 3) ] |= ( 1 << ( (bitNumber) & 7 ) ) )
  91. #define ClearBit( bitstring, bitNumber ) ( (bitstring)[ ((bitNumber) >> 3) ] &= ~( 1 << ( (bitNumber) & 7 ) ) )