Team Fortress 2 Source Code as on 22/4/2020
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.

112 lines
4.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef ICLIENTSHADOWMGR_H
  9. #define ICLIENTSHADOWMGR_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "igamesystem.h"
  14. #include "icliententityinternal.h"
  15. #include "engine/ishadowmgr.h"
  16. #include "ivrenderview.h"
  17. #include "toolframework/itoolentity.h"
  18. //-----------------------------------------------------------------------------
  19. // Forward decls
  20. //-----------------------------------------------------------------------------
  21. struct FlashlightState_t;
  22. //-----------------------------------------------------------------------------
  23. // Handles to a client shadow
  24. //-----------------------------------------------------------------------------
  25. enum ShadowReceiver_t
  26. {
  27. SHADOW_RECEIVER_BRUSH_MODEL = 0,
  28. SHADOW_RECEIVER_STATIC_PROP,
  29. SHADOW_RECEIVER_STUDIO_MODEL,
  30. };
  31. //-----------------------------------------------------------------------------
  32. // The class responsible for dealing with shadows on the client side
  33. //-----------------------------------------------------------------------------
  34. abstract_class IClientShadowMgr : public IGameSystemPerFrame
  35. {
  36. public:
  37. // Create, destroy shadows
  38. virtual ClientShadowHandle_t CreateShadow( ClientEntityHandle_t entity, int flags ) = 0;
  39. virtual void DestroyShadow( ClientShadowHandle_t handle ) = 0;
  40. // Create flashlight.
  41. // FLASHLIGHTFIXME: need to rename all of the shadow stuff to projectedtexture and have flashlights and shadows as instances.
  42. virtual ClientShadowHandle_t CreateFlashlight( const FlashlightState_t &lightState ) = 0;
  43. virtual void UpdateFlashlightState( ClientShadowHandle_t shadowHandle, const FlashlightState_t &lightState ) = 0;
  44. virtual void DestroyFlashlight( ClientShadowHandle_t handle ) = 0;
  45. // Indicate that the shadow should be recomputed due to a change in
  46. // the client entity
  47. virtual void UpdateProjectedTexture( ClientShadowHandle_t handle, bool force = false ) = 0;
  48. // Used to cause shadows to be re-projected against the world.
  49. virtual void AddToDirtyShadowList( ClientShadowHandle_t handle, bool force = false ) = 0;
  50. virtual void AddToDirtyShadowList( IClientRenderable *pRenderable, bool force = false ) = 0;
  51. // deals with shadows being added to shadow receivers
  52. virtual void AddShadowToReceiver( ClientShadowHandle_t handle,
  53. IClientRenderable* pRenderable, ShadowReceiver_t type ) = 0;
  54. virtual void RemoveAllShadowsFromReceiver(
  55. IClientRenderable* pRenderable, ShadowReceiver_t type ) = 0;
  56. // Re-renders all shadow textures for shadow casters that lie in the leaf list
  57. virtual void ComputeShadowTextures( const CViewSetup &view, int leafCount, LeafIndex_t* pLeafList ) = 0;
  58. // Frees shadow depth textures for use in subsequent view/frame
  59. virtual void UnlockAllShadowDepthTextures() = 0;
  60. // Renders the shadow texture to screen...
  61. virtual void RenderShadowTexture( int w, int h ) = 0;
  62. // Sets the shadow direction + color
  63. virtual void SetShadowDirection( const Vector& dir ) = 0;
  64. virtual const Vector &GetShadowDirection() const = 0;
  65. virtual void SetShadowColor( unsigned char r, unsigned char g, unsigned char b ) = 0;
  66. virtual void SetShadowDistance( float flMaxDistance ) = 0;
  67. virtual void SetShadowBlobbyCutoffArea( float flMinArea ) = 0;
  68. virtual void SetFalloffBias( ClientShadowHandle_t handle, unsigned char ucBias ) = 0;
  69. // Marks the render-to-texture shadow as needing to be re-rendered
  70. virtual void MarkRenderToTextureShadowDirty( ClientShadowHandle_t handle ) = 0;
  71. // Advance the frame
  72. virtual void AdvanceFrame() = 0;
  73. // Set and clear flashlight target renderable
  74. virtual void SetFlashlightTarget( ClientShadowHandle_t shadowHandle, EHANDLE targetEntity ) = 0;
  75. // Set flashlight light world flag
  76. virtual void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld ) = 0;
  77. virtual void SetShadowsDisabled( bool bDisabled ) = 0;
  78. virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0;
  79. };
  80. //-----------------------------------------------------------------------------
  81. // Singleton
  82. //-----------------------------------------------------------------------------
  83. extern IClientShadowMgr* g_pClientShadowMgr;
  84. #endif // ICLIENTSHADOWMGR_H