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.

91 lines
3.6 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: a localized viewer for the Fog of War
  4. //
  5. // $NoKeywords: $
  6. //=====================================================================================//
  7. #ifndef FOW_VIEWER_H
  8. #define FOW_VIEWER_H
  9. #if defined( COMPILER_MSVC )
  10. #pragma once
  11. #endif
  12. #include "mathlib/vector.h"
  13. class CFoW;
  14. class CFoW_Viewer
  15. {
  16. public:
  17. // constructor to init this viewer with the id and temp
  18. CFoW_Viewer( int nID, unsigned nViewerTeam );
  19. // destructor to free up the local vis grids
  20. ~CFoW_Viewer( void );
  21. // update the radius of the viewer. this will realloc the local vis grids
  22. void UpdateSize( CFoW *pFoW, float flRadius );
  23. // update the location of the viewer
  24. bool UpdateLocation( CFoW *pFoW, const Vector &vLocation, Vector *pvOldLocation );
  25. // update the height group of this viewer
  26. void UpdateHeightGroup( uint8 nHeightGroup );
  27. //
  28. inline void Dirty( ) { m_bDirty = true; }
  29. //
  30. inline bool IsDirty( ) { return m_bDirty; }
  31. // get the team the viewer is on
  32. inline unsigned GetTeam( void ) { return m_nViewerTeam; }
  33. // get the radius of the viewer
  34. inline float GetSize( void ) { return m_flRadius; }
  35. // get the grid-centered location of the viewer
  36. inline Vector &GetLocation( void ) { return m_vLocation; }
  37. // get the real location of the viewer
  38. inline Vector &GetRealLocation( void ) { return m_vRealLocation; }
  39. // get the height group of the viewer
  40. inline uint8 GetHeightGroup( void ) { return m_nHeightGroup; }
  41. // get the grid units of the local vis. ( diameter / horizontal grid size ) rounded up
  42. inline int GetGridUnits( void ) { return m_nGridUnits; }
  43. // get the local visibility grid
  44. inline byte *GetVisibility( void ) { return m_pVisibility; }
  45. // get the visibility radius grid
  46. inline int *GetVisibilityRadius( void ) { return m_pVisibilityRadius; }
  47. // get the grid units of the radius grid ( circumference / horizontal grid size ) rounded up
  48. inline int GetRadiusUnits( void ) { return m_nRadiusUnits; }
  49. // get the upper left coords of this viewer
  50. void GetStartPosition( Vector2D &vResults );
  51. // get the lower right coords of this viewer
  52. void GetEndPosition( Vector2D &vResults );
  53. // calculate the localized visibility against all occluders.
  54. void CalcLocalizedVisibility( CFoW *pFoW );
  55. // clear the localized radius grid to the maximum distance
  56. void DefaultViewingRadius( CFoW *pFoW );
  57. //
  58. void DrawDebugInfo( Vector &vLocation, float flViewRadius, unsigned nFlags );
  59. //
  60. size_t GetAllocatedMemory( ) { return m_nAllocatedMemory; }
  61. private:
  62. // clear the localized visibility grid to just the raw radius
  63. void DefaultViewingArea( CFoW *pFoW );
  64. // turn the radius grid into the localized visibility grid
  65. void ResolveRadius( CFoW *pFoW );
  66. int m_nID; // the id of this viewer
  67. unsigned m_nViewerTeam; // the team this viewer belongs to
  68. float m_flRadius; // the radius of this viewer
  69. Vector m_vLocation; // the grid location of this viewer
  70. Vector m_vRealLocation; // the real location of this viewer
  71. byte *m_pVisibility; // the localized visibility grid
  72. int m_nGridUnits; // the grid units ( diameter / horizontal grid size ) rounded up
  73. int *m_pVisibilityRadius; // the localized visibility depth circle
  74. int m_nRadiusUnits; // the grid units of the radius grid ( circumference / horizontal grid size ) rounded up
  75. int *m_pVisibilityTable; // the visibility table to go from grid to radius
  76. bool m_bDirty; //
  77. uint8 m_nHeightGroup; // the height group this viewer belongs to
  78. size_t m_nAllocatedMemory; //
  79. };
  80. #endif // FOW_VIEWER_H