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.

100 lines
3.0 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. // NOTE: This has to be the last file included!
  8. #include "tier0/memdbgon.h"
  9. extern bool g_bDOFEnabled;
  10. extern float g_flDOFNearBlurDepth;
  11. extern float g_flDOFNearFocusDepth;
  12. extern float g_flDOFFarFocusDepth;
  13. extern float g_flDOFFarBlurDepth;
  14. extern float g_flDOFNearBlurRadius;
  15. extern float g_flDOFFarBlurRadius;
  16. EHANDLE g_hDOFControllerInUse = INVALID_EHANDLE;
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. class C_EnvDOFController : public C_BaseEntity
  21. {
  22. DECLARE_CLASS( C_EnvDOFController, C_BaseEntity );
  23. public:
  24. DECLARE_CLIENTCLASS();
  25. C_EnvDOFController();
  26. ~C_EnvDOFController();
  27. virtual void OnDataChanged( DataUpdateType_t updateType );
  28. private:
  29. bool m_bDOFEnabled;
  30. float m_flNearBlurDepth;
  31. float m_flNearFocusDepth;
  32. float m_flFarFocusDepth;
  33. float m_flFarBlurDepth;
  34. float m_flNearBlurRadius;
  35. float m_flFarBlurRadius;
  36. private:
  37. C_EnvDOFController( const C_EnvDOFController & );
  38. };
  39. IMPLEMENT_CLIENTCLASS_DT( C_EnvDOFController, DT_EnvDOFController, CEnvDOFController )
  40. RecvPropInt( RECVINFO(m_bDOFEnabled) ),
  41. RecvPropFloat( RECVINFO(m_flNearBlurDepth) ),
  42. RecvPropFloat( RECVINFO(m_flNearFocusDepth) ),
  43. RecvPropFloat( RECVINFO(m_flFarFocusDepth) ),
  44. RecvPropFloat( RECVINFO(m_flFarBlurDepth) ),
  45. RecvPropFloat( RECVINFO(m_flNearBlurRadius) ),
  46. RecvPropFloat( RECVINFO(m_flFarBlurRadius) )
  47. END_RECV_TABLE()
  48. //-----------------------------------------------------------------------------
  49. // Purpose:
  50. //-----------------------------------------------------------------------------
  51. C_EnvDOFController::C_EnvDOFController( void )
  52. : m_bDOFEnabled( true ),
  53. m_flNearBlurDepth( 50.0f ),
  54. m_flNearFocusDepth( 100.0f ),
  55. m_flFarFocusDepth( 250.0f ),
  56. m_flFarBlurDepth( 1000.0f ),
  57. m_flNearBlurRadius( 0.0f ), // no near blur by default
  58. m_flFarBlurRadius( 5.0f )
  59. {
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. //-----------------------------------------------------------------------------
  64. C_EnvDOFController::~C_EnvDOFController( void )
  65. {
  66. if ( g_hDOFControllerInUse == this )
  67. {
  68. g_bDOFEnabled = false;
  69. }
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. void C_EnvDOFController::OnDataChanged( DataUpdateType_t updateType )
  75. {
  76. BaseClass::OnDataChanged( updateType );
  77. g_bDOFEnabled = m_bDOFEnabled && ( ( m_flNearBlurRadius > 0.0f ) || ( m_flFarBlurRadius > 0.0f ) );
  78. g_flDOFNearBlurDepth = m_flNearBlurDepth;
  79. g_flDOFNearFocusDepth = m_flNearFocusDepth;
  80. g_flDOFFarFocusDepth = m_flFarFocusDepth;
  81. g_flDOFFarBlurDepth = m_flFarBlurDepth;
  82. g_flDOFNearBlurRadius = m_flNearBlurRadius;
  83. g_flDOFFarBlurRadius = m_flFarBlurRadius;
  84. g_hDOFControllerInUse = this;
  85. }