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.

648 lines
21 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef VRAD_H
  14. #define VRAD_H
  15. #pragma once
  16. #include "commonmacros.h"
  17. #include "worldsize.h"
  18. #include "cmdlib.h"
  19. #include "mathlib/mathlib.h"
  20. #include "bsplib.h"
  21. #include "polylib.h"
  22. #include "threads.h"
  23. #include "builddisp.h"
  24. #include "VRAD_DispColl.h"
  25. #include "UtlMemory.h"
  26. #include "UtlHash.h"
  27. #include "UtlVector.h"
  28. #include "iincremental.h"
  29. #include "raytrace.h"
  30. #ifdef _WIN32
  31. #include <windows.h>
  32. #endif
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35. #pragma warning(disable: 4142 4028)
  36. #include <io.h>
  37. #pragma warning(default: 4142 4028)
  38. #include <fcntl.h>
  39. #include <direct.h>
  40. #include <ctype.h>
  41. // Can remove these options if they don't generate problems.
  42. //#define SAMPLEHASH_USE_AREA_PATCHES // Add patches to sample hash based on their AABB instead of as a single point.
  43. #define SAMPLEHASH_QUERY_ONCE // Big optimization - causes way less sample hash queries.
  44. extern float dispchop; // "-dispchop" tightest number of luxel widths for a patch, used on edges
  45. extern float g_MaxDispPatchRadius;
  46. //-----------------------------------------------------------------------------
  47. // forward declarations
  48. //-----------------------------------------------------------------------------
  49. struct Ray_t;
  50. #define TRANSFER_EPSILON 0.0000001
  51. struct directlight_t
  52. {
  53. int index;
  54. directlight_t *next;
  55. dworldlight_t light;
  56. byte *pvs; // accumulated domain of the light
  57. int facenum; // domain of attached lights
  58. int texdata; // texture source of traced lights
  59. Vector snormal;
  60. Vector tnormal;
  61. float sscale;
  62. float tscale;
  63. float soffset;
  64. float toffset;
  65. // Flag indicating that even though light.type is emit_skylight, treat this light as a
  66. // directional light source in vrad
  67. bool m_bSkyLightIsDirectionalLight;
  68. float m_flSkyLightSunAngularExtent;
  69. int dorecalc; // position, vector, spot angle, etc.
  70. IncrementalLightID m_IncrementalID;
  71. // hard-falloff lights (lights that fade to an actual zero). between m_flStartFadeDistance and
  72. // m_flEndFadeDistance, a smoothstep to zero will be done, so that the light goes to zero at
  73. // the end.
  74. float m_flStartFadeDistance;
  75. float m_flEndFadeDistance;
  76. float m_flCapDist; // max distance to feed in
  77. directlight_t(void)
  78. {
  79. m_bSkyLightIsDirectionalLight = false;
  80. m_flSkyLightSunAngularExtent = 0.0f;
  81. m_flEndFadeDistance = -1.0; // end<start indicates not set
  82. m_flStartFadeDistance= 0.0;
  83. m_flCapDist = 1.0e22;
  84. }
  85. };
  86. struct bumplights_t
  87. {
  88. Vector light[NUM_BUMP_VECTS+1];
  89. };
  90. struct transfer_t
  91. {
  92. int patch;
  93. float transfer;
  94. };
  95. struct LightingValue_t
  96. {
  97. Vector m_vecLighting;
  98. float m_flDirectSunAmount;
  99. FORCEINLINE bool IsValid( void ) const
  100. {
  101. return ( m_vecLighting.x >= 0 &&
  102. m_vecLighting.y >= 0 &&
  103. m_vecLighting.z >= 0 &&
  104. m_vecLighting.x < 1e10 &&
  105. m_vecLighting.y < 1e10 &&
  106. m_vecLighting.z < 1e10 );
  107. }
  108. FORCEINLINE void Zero( void )
  109. {
  110. m_vecLighting.Init( 0, 0, 0 );
  111. m_flDirectSunAmount = 0.0;
  112. }
  113. FORCEINLINE void Scale( float m_flScale )
  114. {
  115. m_vecLighting *= m_flScale;
  116. m_flDirectSunAmount *= m_flScale;
  117. }
  118. FORCEINLINE void AddWeighted( LightingValue_t const &src, float flWeight )
  119. {
  120. m_vecLighting += flWeight * src.m_vecLighting;
  121. m_flDirectSunAmount += flWeight * src.m_flDirectSunAmount;
  122. }
  123. FORCEINLINE void AddWeighted( Vector const &src, float flWeight )
  124. {
  125. m_vecLighting += flWeight * src;
  126. }
  127. FORCEINLINE float Intensity( void ) const
  128. {
  129. return m_vecLighting.x + m_vecLighting.y + m_vecLighting.z;
  130. }
  131. FORCEINLINE void AddLight( float flAmount, Vector const &vecColor, float flSunAmount = 0.0 )
  132. {
  133. VectorMA( m_vecLighting, flAmount, vecColor, m_vecLighting );
  134. m_flDirectSunAmount += flSunAmount;
  135. Assert( this->IsValid() );
  136. }
  137. FORCEINLINE void AddLight( LightingValue_t const &src )
  138. {
  139. m_vecLighting += src.m_vecLighting;
  140. m_flDirectSunAmount += src.m_flDirectSunAmount;
  141. Assert( this->IsValid() );
  142. }
  143. FORCEINLINE void Init( float x, float y, float z )
  144. {
  145. m_vecLighting.Init( x, y, z );
  146. m_flDirectSunAmount = 0.0;
  147. }
  148. };
  149. #define MAX_PATCHES (4*65536)
  150. struct CPatch
  151. {
  152. winding_t *winding;
  153. Vector mins, maxs, face_mins, face_maxs;
  154. Vector origin; // adjusted off face by face normal
  155. dplane_t *plane; // plane (corrected for facing)
  156. unsigned short m_IterationKey; // Used to prevent touching the same patch multiple times in the same query.
  157. // See IncrementPatchIterationKey().
  158. // these are packed into one dword
  159. unsigned int normalMajorAxis : 2; // the major axis of base face normal
  160. unsigned int sky : 1;
  161. unsigned int needsBumpmap : 1;
  162. unsigned int pad : 28;
  163. Vector normal; // adjusted for phong shading
  164. float planeDist; // Fixes up patch planes for brush models with an origin brush
  165. float chop; // smallest acceptable width of patch face
  166. float luxscale; // average luxels per world coord
  167. float scale[2]; // Scaling of texture in s & t
  168. bumplights_t totallight; // accumulated by radiosity
  169. // does NOT include light
  170. // accounted for by direct lighting
  171. Vector baselight; // emissivity only
  172. float basearea; // surface per area per baselight instance
  173. Vector directlight; // direct light value
  174. float area;
  175. Vector reflectivity; // Average RGB of texture, modified by material type.
  176. Vector samplelight;
  177. float samplearea; // for averaging direct light
  178. int faceNumber;
  179. int clusterNumber;
  180. int parent; // patch index of parent
  181. int child1; // patch index for children
  182. int child2;
  183. int ndxNext; // next patch index in face
  184. int ndxNextParent; // next parent patch index in face
  185. int ndxNextClusterChild; // next terminal child index in cluster
  186. // struct patch_s *next; // next in face
  187. // struct patch_s *nextparent; // next in face
  188. // struct patch_s *nextclusterchild; // next terminal child in cluster
  189. int staticPropIdx; // Static prop this patch is from.
  190. int numtransfers;
  191. transfer_t *transfers;
  192. short indices[3]; // displacement use these for subdivision
  193. };
  194. extern CUtlVector<CPatch> g_Patches;
  195. extern CUtlVector<int> g_FacePatches; // constains all patches, children first
  196. extern CUtlVector<int> faceParents; // contains only root patches, use next parent to iterate
  197. extern CUtlVector<int> clusterChildren;
  198. struct sky_camera_t
  199. {
  200. Vector origin;
  201. float world_to_sky;
  202. float sky_to_world;
  203. int area;
  204. };
  205. extern int num_sky_cameras;
  206. extern sky_camera_t sky_cameras[MAX_MAP_AREAS];
  207. extern int area_sky_cameras[MAX_MAP_AREAS];
  208. void ProcessSkyCameras();
  209. extern entity_t *face_entity[MAX_MAP_FACES];
  210. extern Vector face_offset[MAX_MAP_FACES]; // for rotating bmodels
  211. extern Vector face_centroids[MAX_MAP_EDGES];
  212. extern int leafparents[MAX_MAP_LEAFS];
  213. extern int nodeparents[MAX_MAP_NODES];
  214. extern float lightscale;
  215. extern float dlight_threshold;
  216. extern float coring;
  217. extern qboolean g_bDumpPatches;
  218. extern bool bRed2Black;
  219. extern bool g_bNoSkyRecurse;
  220. extern bool bDumpNormals;
  221. extern bool g_bFastAmbient;
  222. extern float maxchop;
  223. extern FileHandle_t pFileSamples[4][4];
  224. extern qboolean g_bLowPriority;
  225. extern qboolean do_fast;
  226. extern bool g_bInterrupt; // Was used with background lighting in WC. Tells VRAD to stop lighting.
  227. extern IIncremental *g_pIncremental; // null if not doing incremental lighting
  228. extern float g_flSkySampleScale; // extra sampling factor for indirect light
  229. extern float g_flStaticPropSampleScale; // extra sampling factor for indirect light (for static props)
  230. extern bool g_bLargeDispSampleRadius;
  231. extern bool g_bStaticPropPolys;
  232. extern bool g_bTextureShadows;
  233. extern bool g_bShowStaticPropNormals;
  234. extern bool g_bDisablePropSelfShadowing;
  235. extern bool g_bFiniteFalloffModel; // whether to use 1/xxx or not
  236. extern bool g_bFastStaticProps;
  237. extern bool g_bDumpBumpStaticProps;
  238. extern bool g_bDisableStaticPropVertexInSolidTest;
  239. extern bool g_bStaticPropBounce;
  240. extern float g_flStaticPropBounceBoost;
  241. extern CUtlVector<char const *> g_NonShadowCastingMaterialStrings;
  242. extern void ForceTextureShadowsOnModel( const char *pModelName );
  243. extern bool IsModelTextureShadowsForced( const char *pModelName );
  244. extern int LoadShadowTexture( const char *pMaterialName );
  245. extern int AddShadowTextureTriangle( int shadowTextureIndex, const Vector2D &t0, const Vector2D &t1, const Vector2D &t2 );
  246. extern float ComputeCoverageForTriangle( int shadowTextureIndex, const Vector2D &t0, const Vector2D &t1, const Vector2D &t2 );
  247. extern void GetShadowTextureMapping( int shadowTextureIndex, int *pWidth, int *pHeight );
  248. // Raytracing
  249. #define TRACE_ID_SKY 0x01000000 // sky face ray blocker
  250. #define TRACE_ID_OPAQUE 0x02000000 // everyday light blocking face
  251. #define TRACE_ID_STATICPROP 0x04000000 // static prop - lower bits are prop ID
  252. #define TRACE_ID_PATCH 0x08000000 // patch - lower bits are patch ID
  253. extern RayTracingEnvironment g_RtEnv;
  254. extern RayTracingEnvironment g_RtEnv_LightBlockers;
  255. extern RayTracingEnvironment g_RtEnv_RadiosityPatches; // Contains patches for final gather of indirect light for static prop lighting.
  256. #include "mpivrad.h"
  257. void MakeShadowSplits (void);
  258. //==============================================
  259. void BuildVisMatrix (void);
  260. void BuildClusterTable( void );
  261. void AddDispsToClusterTable( void );
  262. void AddStaticPropPatchesToClusterTable();
  263. void FreeVisMatrix (void);
  264. // qboolean CheckVisBit (unsigned int p1, unsigned int p2);
  265. void TouchVMFFile (void);
  266. //==============================================
  267. extern qboolean do_extra;
  268. extern qboolean do_fast;
  269. extern qboolean do_centersamples;
  270. extern int extrapasses;
  271. extern Vector ambient;
  272. extern float maxlight;
  273. extern unsigned numbounce;
  274. extern qboolean g_bLogHashData;
  275. extern bool debug_extra;
  276. extern directlight_t *activelights;
  277. extern directlight_t *freelights;
  278. // because of hdr having two face lumps (light styles can cause them to be different, among other
  279. // things), we need to always access (r/w) face data though this pointer
  280. extern dface_t *g_pFaces;
  281. extern bool g_bMPIProps;
  282. extern byte nodehit[MAX_MAP_NODES];
  283. extern float gamma;
  284. extern float indirect_sun;
  285. extern float smoothing_threshold;
  286. extern int dlight_map;
  287. extern float g_flMaxDispSampleSize;
  288. extern float g_SunAngularExtent;
  289. extern char source[MAX_PATH];
  290. // Used by incremental lighting to trivial-reject faces.
  291. // There is a bit in here for each face telling whether or not any of the
  292. // active lights can see the face.
  293. extern CUtlVector<byte> g_FacesVisibleToLights;
  294. void MakeTnodes (dmodel_t *bm);
  295. void PairEdges (void);
  296. void SaveVertexNormals( void );
  297. qboolean IsIncremental(char *filename);
  298. int SaveIncremental(char *filename);
  299. int PartialHead (void);
  300. void BuildFacelights (int facenum, int threadnum);
  301. void BuildStaticPropPatchlights( int iThread, int nPatch );
  302. void PrecompLightmapOffsets();
  303. void FinalLightFace (int threadnum, int facenum);
  304. void PvsForOrigin (Vector& org, byte *pvs);
  305. void ConvertRGBExp32ToRGBA8888( const ColorRGBExp32 *pSrc, unsigned char *pDst );
  306. inline byte PVSCheck( const byte *pvs, int iCluster )
  307. {
  308. if ( iCluster >= 0 )
  309. {
  310. return pvs[iCluster >> 3] & ( 1 << ( iCluster & 7 ) );
  311. }
  312. else
  313. {
  314. // PointInLeaf still returns -1 for valid points sometimes and rather than
  315. // have black samples, we assume the sample is in the PVS.
  316. return 1;
  317. }
  318. }
  319. // outputs 1 in fractionVisible if no occlusion, 0 if full occlusion, and in-between values
  320. void TestLine( FourVectors const& start, FourVectors const& stop, fltx4 *pFractionVisible, int static_prop_index_to_ignore=-1);
  321. void TestLine_IgnoreSky( FourVectors const& start, FourVectors const& stop, fltx4 *pFractionVisible, int static_prop_index_to_ignore=-1);
  322. void TestLine_LightBlockers( const FourVectors& start, const FourVectors& stop, fltx4 *pFractionVisible );
  323. // returns 1 if the ray sees the sky, 0 if it doesn't, and in-between values for partial coverage
  324. void TestLine_DoesHitSky( FourVectors const& start, FourVectors const& stop,
  325. fltx4 *pFractionVisible, bool canRecurse = true, int static_prop_to_skip=-1, bool bDoDebug = false );
  326. // converts any marked brush entities to triangles for shadow casting
  327. void ExtractBrushEntityShadowCasters ( void );
  328. void AddBrushesForRayTrace ( void );
  329. void BaseLightForFace( dface_t *f, Vector& light, float *parea, Vector& reflectivity );
  330. void CreateDirectLights (void);
  331. void GetPhongNormal( int facenum, Vector const& spot, Vector& phongnormal );
  332. int LightForString( char *pLight, Vector& intensity );
  333. void MakeTransfer( int ndxPatch1, int ndxPatch2, transfer_t *all_transfers );
  334. void MakeScales( int ndxPatch, transfer_t *all_transfers );
  335. // Run startup code like initialize mathlib.
  336. void VRAD_Init();
  337. // Load the BSP file and prepare to do the lighting.
  338. // This is called after any command-line parameters have been set.
  339. void VRAD_LoadBSP( char const *pFilename );
  340. int VRAD_Main(int argc, char **argv);
  341. // This performs an actual lighting pass.
  342. // Returns true if the process was interrupted (with g_bInterrupt).
  343. bool RadWorld_Go();
  344. dleaf_t *PointInLeaf (Vector const& point);
  345. int ClusterFromPoint( Vector const& point );
  346. winding_t *WindingFromFace (dface_t *f, Vector& origin );
  347. void WriteWinding (FileHandle_t out, winding_t *w, Vector& color );
  348. void WriteNormal( FileHandle_t out, Vector const &nPos, Vector const &nDir,
  349. float length, Vector const &color );
  350. void WriteLine( FileHandle_t out, const Vector &vecPos1, const Vector &vecPos2, const Vector &color );
  351. void WriteTrace( const char *pFileName, const FourRays &rays, const RayTracingResult& result );
  352. #ifdef STATIC_FOG
  353. qboolean IsFog( dface_t * f );
  354. #endif
  355. #define CONTENTS_EMPTY 0
  356. #define TEX_SPECIAL (SURF_SKY|SURF_NOLIGHT)
  357. //=============================================================================
  358. // trace.cpp
  359. bool AddDispCollTreesToWorld( void );
  360. int PointLeafnum( Vector const &point );
  361. float TraceLeafBrushes( int leafIndex, const Vector &start, const Vector &end, CBaseTrace &traceOut );
  362. //=============================================================================
  363. // dispinfo.cpp
  364. struct SSE_sampleLightOutput_t
  365. {
  366. fltx4 m_flDot[NUM_BUMP_VECTS+1];
  367. fltx4 m_flSunAmount[NUM_BUMP_VECTS + 1];
  368. fltx4 m_flFalloff;
  369. };
  370. #define GATHERLFLAGS_FORCE_FAST 1 /* Use 4x fewer rays when sampling area lights */
  371. #define GATHERLFLAGS_IGNORE_NORMALS 2 /* Ignore surface normals in lighting calculations */
  372. #define GATHERLFLAGS_NO_OCCLUSION 4 /* Ignore occlusion for local lights (but not sun, sky or bounce lighting) */
  373. #define GATHERLFLAGS_STATICPROP 8 /* Paths for static props */
  374. // SSE Gather light stuff
  375. void GatherSampleLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
  376. FourVectors const& pos, FourVectors *pNormals, int normalCount, int iThread,
  377. int nLFlags = 0, // GATHERLFLAGS_xxx
  378. int static_prop_to_skip=-1,
  379. float flEpsilon = 0.0 );
  380. //void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
  381. // FourVectors const& pos, FourVectors *pNormals, int normalCount, int iThread,
  382. // int nLFlags = 0,
  383. // int static_prop_to_skip=-1,
  384. // float flEpsilon = 0.0 );
  385. //void GatherSampleAmbientSkySSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
  386. // FourVectors const& pos, FourVectors *pNormals, int normalCount, int iThread,
  387. // int nLFlags = 0, // GATHERLFLAGS_xxx
  388. // int static_prop_to_skip=-1,
  389. // float flEpsilon = 0.0 );
  390. //void GatherSampleStandardLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
  391. // FourVectors const& pos, FourVectors *pNormals, int normalCount, int iThread,
  392. // int nLFlags = 0, // GATHERLFLAGS_xxx
  393. // int static_prop_to_skip=-1,
  394. // float flEpsilon = 0.0 );
  395. void ComputeDirectLightingAtPoint( Vector &position, Vector *normals, Vector *outColors, float *outSunAmount, int numNormals, bool bSkipSkyLight, int iThread,
  396. int static_prop_id_to_skip = -1, int nLFlags = 0 );
  397. //-----------------------------------------------------------------------------
  398. // VRad Displacements
  399. //-----------------------------------------------------------------------------
  400. struct facelight_t;
  401. typedef struct radial_s radial_t;
  402. struct lightinfo_t;
  403. // NOTE: should probably come up with a bsptreetested_t struct or something,
  404. // see below (PropTested_t)
  405. struct DispTested_t
  406. {
  407. int m_Enum;
  408. int *m_pTested;
  409. };
  410. class IVRadDispMgr
  411. {
  412. public:
  413. // creation/destruction
  414. virtual void Init( void ) = 0;
  415. virtual void Shutdown( void ) = 0;
  416. // "CalcPoints"
  417. virtual bool BuildDispSamples( lightinfo_t *pLightInfo, facelight_t *pFaceLight, int ndxFace ) = 0;
  418. virtual bool BuildDispLuxels( lightinfo_t *pLightInfo, facelight_t *pFaceLight, int ndxFace ) = 0;
  419. virtual bool BuildDispSamplesAndLuxels_DoFast( lightinfo_t *pLightInfo, facelight_t *pFaceLight, int ndxFace ) = 0;
  420. // patching functions
  421. virtual void MakePatches( void ) = 0;
  422. virtual void SubdividePatch( int iPatch ) = 0;
  423. // pre "FinalLightFace"
  424. virtual void InsertSamplesDataIntoHashTable( void ) = 0;
  425. virtual void InsertPatchSampleDataIntoHashTable( void ) = 0;
  426. // "FinalLightFace"
  427. virtual radial_t *BuildLuxelRadial( int ndxFace, int ndxStyle, bool bBump ) = 0;
  428. virtual bool SampleRadial( int ndxFace, radial_t *pRadial, Vector const &vPos, int ndxLxl, LightingValue_t *pLightSample, int sampleCount, bool bPatch ) = 0;
  429. virtual radial_t *BuildPatchRadial( int ndxFace, bool bBump ) = 0;
  430. // utility
  431. virtual void GetDispSurfNormal( int ndxFace, Vector &pt, Vector &ptNormal, bool bInside ) = 0;
  432. virtual void GetDispSurfPointAndNormalFromUV( int ndxFace, Vector &pt, Vector &ptNormal,
  433. Vector2D &uv, bool bInside ) = 0;
  434. virtual void GetDispSurf( int ndxFace, CVRADDispColl **ppDispTree ) = 0;
  435. // bsp tree functions
  436. virtual bool ClipRayToDisp( DispTested_t &dispTested, Ray_t const &ray ) = 0;
  437. virtual bool ClipRayToDispInLeaf( DispTested_t &dispTested, Ray_t const &ray, int ndxLeaf ) = 0;
  438. virtual void ClipRayToDispInLeaf( DispTested_t &dispTested, Ray_t const &ray,
  439. int ndxLeaf, float& dist, dface_t*& pFace, Vector2D& luxelCoord ) = 0;
  440. virtual void ClipRayToDispInLeaf( DispTested_t &dispTested, Ray_t const &ray,
  441. int ndxLeaf, float& dist, Vector *pNormal ) = 0;
  442. virtual void StartRayTest( DispTested_t &dispTested ) = 0;
  443. virtual void AddPolysForRayTrace() = 0;
  444. // general timing -- should be moved!!
  445. virtual void StartTimer( const char *name ) = 0;
  446. virtual void EndTimer( void ) = 0;
  447. };
  448. IVRadDispMgr *StaticDispMgr( void );
  449. //-----------------------------------------------------------------------------
  450. //-----------------------------------------------------------------------------
  451. inline bool ValidDispFace( dface_t *pFace )
  452. {
  453. if( !pFace ) { return false; }
  454. if( pFace->dispinfo == -1 ) { return false; }
  455. if( pFace->numedges != 4 ) { return false; }
  456. return true;
  457. }
  458. #define SAMPLEHASH_VOXEL_SIZE 64.0f
  459. typedef unsigned int SampleHandle_t; // the upper 16 bits = facelight index (works because max face are 65536)
  460. // the lower 16 bits = sample index inside of facelight
  461. struct sample_t;
  462. struct SampleData_t
  463. {
  464. unsigned short x, y, z;
  465. CUtlVector<SampleHandle_t> m_Samples;
  466. };
  467. struct PatchSampleData_t
  468. {
  469. unsigned short x, y, z;
  470. CUtlVector<int> m_ndxPatches;
  471. };
  472. UtlHashHandle_t SampleData_AddSample( sample_t *pSample, SampleHandle_t sampleHandle );
  473. void PatchSampleData_AddSample( CPatch *pPatch, int ndxPatch );
  474. unsigned short IncrementPatchIterationKey();
  475. void SampleData_Log( void );
  476. extern CUtlHash<SampleData_t> g_SampleHashTable;
  477. extern CUtlHash<PatchSampleData_t> g_PatchSampleHashTable;
  478. extern int samplesAdded;
  479. extern int patchSamplesAdded;
  480. //-----------------------------------------------------------------------------
  481. // Computes lighting for the detail props
  482. //-----------------------------------------------------------------------------
  483. void ComputeDetailPropLighting( int iThread );
  484. void ComputeIndirectLightingAtPoint( Vector &position, Vector &normal, Vector &outColor,
  485. int iThread, bool force_fast = false, bool bIgnoreNormals = false, int nStaticPropToSkip = -1 );
  486. void ComputeIndirectLightingAtPoint( Vector &position, Vector *normals, Vector *outColors, int numNormals,
  487. int iThread, bool force_fast = false, bool bIgnoreNormals = false, int nStaticPropToSkip = -1 );
  488. //-----------------------------------------------------------------------------
  489. // VRad static props
  490. //-----------------------------------------------------------------------------
  491. class IPhysicsCollision;
  492. struct PropTested_t
  493. {
  494. int m_Enum;
  495. int* m_pTested;
  496. IPhysicsCollision *pThreadedCollision;
  497. };
  498. class IVradStaticPropMgr
  499. {
  500. public:
  501. // methods of IStaticPropMgr
  502. virtual void Init() = 0;
  503. virtual void Shutdown() = 0;
  504. virtual void ComputeLighting( int iThread ) = 0;
  505. virtual void AddPolysForRayTrace() = 0;
  506. virtual void MakePatches() = 0;
  507. };
  508. //extern PropTested_t s_PropTested[MAX_TOOL_THREADS+1];
  509. extern DispTested_t s_DispTested[MAX_TOOL_THREADS+1];
  510. IVradStaticPropMgr* StaticPropMgr();
  511. extern float ComputeCoverageFromTexture( float b0, float b1, float b2, int32 hitID );
  512. #endif // VRAD_H