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.

79 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VRAD_DISPCOLL_H
  8. #define VRAD_DISPCOLL_H
  9. #pragma once
  10. #include <assert.h>
  11. #include "DispColl_Common.h"
  12. //=============================================================================
  13. //
  14. // VRAD specific collision
  15. //
  16. #define VRAD_QUAD_SIZE 4
  17. struct CPatch;
  18. class CVRADDispColl : public CDispCollTree
  19. {
  20. public:
  21. // Creation/Destruction Functions
  22. CVRADDispColl();
  23. ~CVRADDispColl();
  24. bool Create( CCoreDispInfo *pDisp );
  25. // Patches.
  26. bool InitPatch( int iPatch, int iParentPatch, int iChild, Vector *pPoints, int *pIndices, float &flArea );
  27. bool InitParentPatch( int iPatch, Vector *pPoints, float &flArea );
  28. float CreateParentPatches( void );
  29. void CreateChildPatches( int iParentPatch, int nLevel );
  30. void CreateChildPatchesFromRoot( int iParentPatch, int *pChildPatch );
  31. void CreateChildPatchesSub( int iParentPatch );
  32. // Operations Functions
  33. void BaseFacePlaneToDispUV( Vector const &vecPlanePt, Vector2D &dispUV );
  34. void DispUVToSurfPoint( Vector2D const &dispUV, Vector &vecPoint, float flPushEps );
  35. void DispUVToSurfNormal( Vector2D const &dispUV, Vector &vecNormal );
  36. // Data.
  37. inline float GetSampleRadius2( void ) { return m_flSampleRadius2; }
  38. inline float GetPatchSampleRadius2( void ) { return m_flPatchSampleRadius2; }
  39. inline int GetParentIndex( void ) { return m_iParent; }
  40. inline void GetParentFaceNormal( Vector &vecNormal ) { vecNormal = m_vecStabDir; }
  41. inline void GetVert( int iVert, Vector &vecVert ) { Assert( ( iVert >= 0 ) && ( iVert < GetSize() ) ); vecVert = m_aVerts[iVert]; }
  42. inline void GetVertNormal( int iVert, Vector &vecNormal ) { Assert( ( iVert >= 0 ) && ( iVert < GetSize() ) ); vecNormal = m_aVertNormals[iVert]; }
  43. inline Vector2D const& GetLuxelCoord( int iLuxel ) { Assert( ( iLuxel >= 0 ) && ( iLuxel < GetSize() ) ); return m_aLuxelCoords[iLuxel]; }
  44. // Raytracing
  45. void AddPolysForRayTrace( void );
  46. protected:
  47. void CalcSampleRadius2AndBox( dface_t *pFace );
  48. // Utility.
  49. void DispUVToSurf_TriTLToBR( Vector &vecPoint, float flPushEps, float flU, float flV, int nSnapU, int nSnapV, int nWidth, int nHeight );
  50. void DispUVToSurf_TriBLToTR( Vector &vecPoint, float flPushEps, float flU, float flV, int nSnapU, int nSnapV, int nWidth, int nHeight );
  51. void GetSurfaceMinMax( Vector &boxMin, Vector &boxMax );
  52. void GetMinorAxes( Vector const &vecNormal, int &nAxis0, int &nAxis1 );
  53. protected:
  54. int m_iParent; // Parent index
  55. float m_flSampleRadius2; // Sampling radius
  56. float m_flPatchSampleRadius2; // Patch sampling radius (max bound)
  57. float m_flSampleWidth;
  58. float m_flSampleHeight;
  59. CUtlVector<Vector2D> m_aLuxelCoords; // Lightmap coordinates.
  60. CUtlVector<Vector> m_aVertNormals; // Displacement vertex normals
  61. };
  62. #endif // VRAD_DISPCOLL_H