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.

70 lines
1.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "materialsystem/imaterialproxy.h"
  8. #include "materialsystem/imaterial.h"
  9. #include "materialsystem/imaterialvar.h"
  10. #include "c_world.h"
  11. #include "imaterialproxydict.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. class CWorldDimsProxy : public IMaterialProxy
  15. {
  16. public:
  17. CWorldDimsProxy();
  18. virtual ~CWorldDimsProxy();
  19. virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  20. virtual void OnBind( void *pC_BaseEntity );
  21. virtual void Release( void ) { delete this; }
  22. virtual IMaterial *GetMaterial();
  23. public:
  24. IMaterialVar *m_pMinsVar;
  25. IMaterialVar *m_pMaxsVar;
  26. };
  27. CWorldDimsProxy::CWorldDimsProxy()
  28. {
  29. m_pMinsVar = m_pMaxsVar = NULL;
  30. }
  31. CWorldDimsProxy::~CWorldDimsProxy()
  32. {
  33. }
  34. bool CWorldDimsProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
  35. {
  36. m_pMinsVar = pMaterial->FindVar( "$world_mins", NULL, false );
  37. m_pMaxsVar = pMaterial->FindVar( "$world_maxs", NULL, false );
  38. return true;
  39. }
  40. void CWorldDimsProxy::OnBind( void *pC_BaseEntity )
  41. {
  42. if ( m_pMinsVar && m_pMaxsVar )
  43. {
  44. C_World *pWorld = GetClientWorldEntity();
  45. if ( pWorld )
  46. {
  47. m_pMinsVar->SetVecValue( (const float*)&pWorld->m_WorldMins, 3 );
  48. m_pMaxsVar->SetVecValue( (const float*)&pWorld->m_WorldMaxs, 3 );
  49. }
  50. }
  51. }
  52. IMaterial *CWorldDimsProxy::GetMaterial()
  53. {
  54. return m_pMinsVar->GetOwningMaterial();
  55. }
  56. EXPOSE_MATERIAL_PROXY( CWorldDimsProxy, WorldDims );