home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / Pvs.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  5KB  |  119 lines

  1.  
  2. #ifndef __GAME_PVS_H__
  3. #define __GAME_PVS_H__
  4.  
  5. /*
  6. ===================================================================================
  7.  
  8.     PVS
  9.  
  10.     Note: mirrors and other special view portals are not taken into account
  11.  
  12. ===================================================================================
  13. */
  14.  
  15.  
  16. typedef struct pvsHandle_s {
  17.     int                    i;            // index to current pvs
  18.     unsigned int        h;            // handle for current pvs
  19. } pvsHandle_t;
  20.  
  21. typedef struct pvsCurrent_s {
  22.     pvsHandle_t            handle;        // current pvs handle
  23.     byte *                pvs;        // current pvs bit string
  24. } pvsCurrent_t;
  25.  
  26. // must be a power of 2
  27. // base was 8, MP now stores client PVS from frame to frame ( MAX_CLIENTS )
  28. #define MAX_CURRENT_PVS        64
  29.  
  30. typedef enum {
  31.     PVS_NORMAL                = 0,    // PVS through portals taking portal states into account
  32.     PVS_ALL_PORTALS_OPEN    = 1,    // PVS through portals assuming all portals are open
  33.     PVS_CONNECTED_AREAS        = 2        // PVS considering all topologically connected areas visible
  34. } pvsType_t;
  35.  
  36.  
  37. class idPVS {
  38. public:
  39.                         idPVS( void );
  40.                         ~idPVS( void );
  41.                         // setup for the current map
  42.     void                Init( void );
  43.     void                Shutdown( void );
  44.                         // get the area(s) the source is in
  45.     int                    GetPVSArea( const idVec3 &point ) const;        // returns the area number
  46.     int                    GetPVSAreas( const idBounds &bounds, int *areas, int maxAreas ) const;    // returns number of areas
  47.                         // setup current PVS for the source
  48.     pvsHandle_t            SetupCurrentPVS( const idVec3 &source, const pvsType_t type = PVS_NORMAL ) const;
  49.     pvsHandle_t            SetupCurrentPVS( const idBounds &source, const pvsType_t type = PVS_NORMAL ) const;
  50.     pvsHandle_t            SetupCurrentPVS( const int sourceArea, const pvsType_t type = PVS_NORMAL ) const;
  51.     pvsHandle_t            SetupCurrentPVS( const int *sourceAreas, const int numSourceAreas, const pvsType_t type = PVS_NORMAL ) const;
  52.     pvsHandle_t            MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const;
  53.     void                FreeCurrentPVS( pvsHandle_t handle ) const;
  54.                         // returns true if the target is within the current PVS
  55.     bool                InCurrentPVS( const pvsHandle_t handle, const idVec3 &target ) const;
  56.     bool                InCurrentPVS( const pvsHandle_t handle, const idBounds &target ) const;
  57.     bool                InCurrentPVS( const pvsHandle_t handle, const int targetArea ) const;
  58.     bool                InCurrentPVS( const pvsHandle_t handle, const int *targetAreas, int numTargetAreas ) const;
  59.                         // draw all portals that are within the PVS of the source
  60.     void                DrawPVS( const idVec3 &source, const pvsType_t type = PVS_NORMAL ) const;
  61.     void                DrawPVS( const idBounds &source, const pvsType_t type = PVS_NORMAL ) const;
  62.                         // visualize the PVS the handle points to
  63.     void                DrawCurrentPVS( const pvsHandle_t handle, const idVec3 &source ) const;
  64.  
  65. #if ASYNC_WRITE_PVS
  66.     void                WritePVS( const pvsHandle_t handle, idBitMsg &msg );
  67.     void                ReadPVS( const pvsHandle_t handle, const idBitMsg &msg );
  68. #endif
  69.  
  70. // RAVEN BEGIN
  71. // mwhitlock: Xenon texture streaming
  72. #if defined(_XENON)
  73.     bool                JustOutOfView(const int *targetAreas, int numTargetAreas ) const;
  74.     int                    DetermineAreasJustOutOfView( int srcArea );
  75. #endif
  76. // RAVEN END
  77.  
  78. private:
  79.     int                    numAreas;
  80.     int                    numPortals;
  81.     bool *                connectedAreas;
  82. // RAVEN BEGIN
  83. // mwhitlock: Xenon texture streaming
  84. #if defined(_XENON)
  85.     byte *                justOutOfViewAreasBits;
  86. #endif
  87. // RAVEN END
  88.     int *                areaQueue;
  89.     byte *                areaPVS;
  90.  
  91.                         // current PVS for a specific source possibly taking portal states (open/closed) into account
  92.     mutable pvsCurrent_t currentPVS[MAX_CURRENT_PVS];
  93.                         // used to create PVS
  94.     int                    portalVisBytes;
  95.     int                    portalVisLongs;
  96.     int                    areaVisBytes;
  97.     int                    areaVisLongs;
  98.     struct pvsPortal_s *pvsPortals;
  99.     struct pvsArea_s *    pvsAreas;
  100.  
  101. private:
  102.     int                    GetPortalCount( void ) const;
  103.     void                CreatePVSData( void );
  104.     void                DestroyPVSData( void );
  105.     void                CopyPortalPVSToMightSee( void ) const;
  106.     void                FloodFrontPortalPVS_r( struct pvsPortal_s *portal, int areaNum ) const;
  107.     void                FrontPortalPVS( void ) const;
  108.     struct pvsStack_s *    FloodPassagePVS_r( struct pvsPortal_s *source, const struct pvsPortal_s *portal, struct pvsStack_s *prevStack ) const;
  109.     void                PassagePVS( void ) const;
  110.     void                AddPassageBoundaries( const idWinding &source, const idWinding &pass, bool flipClip, idPlane *bounds, int &numBounds, int maxBounds ) const;
  111.     void                CreatePassages( void ) const;
  112.     void                DestroyPassages( void ) const;
  113.     int                    AreaPVSFromPortalPVS( void ) const;
  114.     void                GetConnectedAreas( int srcArea, bool *connectedAreas ) const;
  115.     pvsHandle_t            AllocCurrentPVS( unsigned int h ) const;
  116. };
  117.  
  118. #endif /* !__GAME_PVS_H__ */
  119.