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.

144 lines
5.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef IDISPINFO_H
  10. #define IDISPINFO_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. //=============================================================================
  15. #include <assert.h>
  16. #include "bspfile.h"
  17. #include "mathlib/vmatrix.h"
  18. #include "dispnode.h"
  19. #include "builddisp.h"
  20. #include "utlvector.h"
  21. #include "engine/ishadowmgr.h"
  22. #include "getintersectingsurfaces_struct.h"
  23. #include "surfacehandle.h"
  24. struct model_t;
  25. struct Ray_t;
  26. struct RayDispOutput_t;
  27. struct decal_t;
  28. class CMeshBuilder;
  29. //-----------------------------------------------------------------------------
  30. // Handle to decals + shadows on displacements
  31. //-----------------------------------------------------------------------------
  32. typedef unsigned short DispDecalHandle_t;
  33. enum
  34. {
  35. DISP_DECAL_HANDLE_INVALID = (DispDecalHandle_t)~0
  36. };
  37. typedef unsigned short DispShadowHandle_t;
  38. enum
  39. {
  40. DISP_SHADOW_HANDLE_INVALID = (DispShadowHandle_t)~0
  41. };
  42. //-----------------------------------------------------------------------------
  43. // Displacement interface to the engine (and WorldCraft?)
  44. //-----------------------------------------------------------------------------
  45. abstract_class IDispInfo
  46. {
  47. public:
  48. virtual ~IDispInfo() {}
  49. // Builds a list of displacement triangles intersecting the sphere.
  50. virtual void GetIntersectingSurfaces( GetIntersectingSurfaces_Struct *pStruct ) = 0;
  51. virtual void RenderWireframeInLightmapPage( int pageId ) = 0;
  52. virtual void GetBoundingBox( Vector &bbMin, Vector &bbMax ) = 0;
  53. // Get and set the parent surfaces.
  54. virtual void SetParent( SurfaceHandle_t surfID ) = 0;
  55. virtual SurfaceHandle_t GetParent() = 0;
  56. // Add dynamic lights to the lightmap for this surface.
  57. virtual void AddDynamicLights( struct dlight_t *pLights, unsigned int lightMask ) = 0;
  58. // Compute the mask for the lights hitting this surface.
  59. virtual unsigned int ComputeDynamicLightMask( struct dlight_t *pLights ) = 0;
  60. // Add and remove decals.
  61. // flSize is like the radius of the decal so the decal isn't put on any disp faces it's too far away from.
  62. virtual DispDecalHandle_t NotifyAddDecal( decal_t *pDecal, float flSize ) = 0;
  63. virtual void NotifyRemoveDecal( DispDecalHandle_t h ) = 0;
  64. virtual DispShadowHandle_t AddShadowDecal( ShadowHandle_t shadowHandle ) = 0;
  65. virtual void RemoveShadowDecal( DispShadowHandle_t handle ) = 0;
  66. // Compute shadow fragments for a particular shadow, return the vertex + index count of all fragments
  67. virtual bool ComputeShadowFragments( DispShadowHandle_t h, int& vertexCount, int& indexCount ) = 0;
  68. // Tag the surface and check if it's tagged. You can untag all the surfaces
  69. // with DispInfo_ClearAllTags. Note: it just uses a frame counter to track the
  70. // tag state so it's really really fast to call ClearAllTags (just increments
  71. // a variable 99.999% of the time).
  72. virtual bool GetTag() = 0;
  73. virtual void SetTag() = 0;
  74. // Cast a ray against this surface
  75. virtual bool TestRay( Ray_t const& ray, float start, float end, float& dist, Vector2D* lightmapUV, Vector2D* textureUV ) = 0;
  76. // Computes the texture + lightmap coordinate given a displacement uv
  77. virtual void ComputeLightmapAndTextureCoordinate( RayDispOutput_t const& uv, Vector2D* luv, Vector2D* tuv ) = 0;
  78. };
  79. // ----------------------------------------------------------------------------- //
  80. // Adds shadow rendering data to a particular mesh builder
  81. // The function will return the new base index
  82. // ----------------------------------------------------------------------------- //
  83. int DispInfo_AddShadowsToMeshBuilder( CMeshBuilder& meshBuilder,
  84. DispShadowHandle_t h, int baseIndex );
  85. typedef void* HDISPINFOARRAY;
  86. // Use these to manage a list of IDispInfos.
  87. HDISPINFOARRAY DispInfo_CreateArray( int nElements );
  88. void DispInfo_DeleteArray( HDISPINFOARRAY hArray );
  89. IDispInfo* DispInfo_IndexArray( HDISPINFOARRAY hArray, int iElement );
  90. int DispInfo_ComputeIndex( HDISPINFOARRAY hArray, IDispInfo* pInfo );
  91. // Clear the tags for all displacements in the array.
  92. void DispInfo_ClearAllTags( HDISPINFOARRAY hArray );
  93. // Call this to render a list of displacements.
  94. // If bOrtho is true, then no backface removal is done on dispinfos.
  95. void DispInfo_RenderListWorld( class IMatRenderContext *pRenderContext, int nSortGroup, SurfaceHandle_t *pList, int listCount, bool bOrtho, unsigned long flags, int DepthMode );
  96. void DispInfo_RenderListDecalsAndOverlays( class IMatRenderContext *pRenderContext, int nSortGroup, SurfaceHandle_t *pList, int listCount, bool bOrtho, unsigned long flags );
  97. void DispInfo_RenderListDebug( IMatRenderContext *pRenderContext, SurfaceHandle_t *pList, int listCount );
  98. // This should be called from Map_LoadDisplacements (while the map file is open).
  99. // It loads the displacement data from the file and prepares the displacements for rendering.
  100. //
  101. // bRestoring is set to true when just restoring the data from the mapfile
  102. // (ie: displacements already are initialized but need new static buffers).
  103. bool DispInfo_LoadDisplacements( model_t *pWorld, bool bRestoring );
  104. // Deletes all the static vertex buffers.
  105. void DispInfo_ReleaseMaterialSystemObjects( model_t *pWorld );
  106. #endif // IDISPINFO_H