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.

88 lines
2.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A little helper class that computes a spline patch
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef SPLINEPATCH_H
  14. #define SPLINEPATCH_H
  15. #pragma once
  16. #include "mathlib/vector4d.h"
  17. //-----------------------------------------------------------------------------
  18. // Spline patch:
  19. //-----------------------------------------------------------------------------
  20. class CSplinePatch
  21. {
  22. public:
  23. // The last argument represents the number of float channels in addition to position
  24. CSplinePatch( );
  25. ~CSplinePatch();
  26. // Call this to initialize the patch
  27. void Init( int w, int h, int extraChannels );
  28. // 0 = linear, 1 = spliney!
  29. void SetLinearBlend( float factor );
  30. // Hooks the patch up to externally controlled data...
  31. void SetControlPositions( Vector const** pPositions );
  32. void SetChannelData( int channel, float* pChannel );
  33. // This interface isn't wonderful; it's limited by optimization issues...
  34. // Call this before querying the patch for data at (i,j)
  35. void SetupPatchQuery( float i, float j );
  36. // Gets the point and normal at (i,j) specified above
  37. void GetPointAndNormal( Vector& position, Vector& normal ) const;
  38. // Gets at other channels
  39. float GetChannel( int channel ) const;
  40. // Gets at the dimensions
  41. int Width() const { return m_Width; }
  42. int Height() const { return m_Height; }
  43. public:
  44. // The integer + float values for the patch query
  45. int m_is, m_it;
  46. float m_fs, m_ft;
  47. private:
  48. enum
  49. {
  50. MAX_CHANNELS = 4
  51. };
  52. // no copy constructor
  53. CSplinePatch( const CSplinePatch& );
  54. // Computes indices of the samples to read for this interpolation
  55. void ComputeIndices( );
  56. // input data
  57. int m_Width;
  58. int m_Height;
  59. int m_ChannelCount;
  60. Vector const** m_ppPositions;
  61. float const* m_pChannel[MAX_CHANNELS];
  62. // temporary data used for a single patch query
  63. int m_SampleIndices[4][4];
  64. Vector4D m_SVec;
  65. Vector4D m_TVec;
  66. float m_LinearFactor;
  67. };
  68. #endif // SPLINEPATCH_H