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.

69 lines
1.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef IMAGEPACKER_H
  10. #define IMAGEPACKER_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "utlvector.h"
  15. #include "utlrbtree.h"
  16. #define MAX_MAX_LIGHTMAP_WIDTH 2048
  17. //-----------------------------------------------------------------------------
  18. // This packs a single lightmap
  19. //-----------------------------------------------------------------------------
  20. class CImagePacker
  21. {
  22. public:
  23. bool Reset( int nSortId, int maxLightmapWidth, int maxLightmapHeight );
  24. bool AddBlock( int width, int height,
  25. int *returnX, int *returnY );
  26. void GetMinimumDimensions( int *returnWidth, int *returnHeight );
  27. float GetEfficiency( void );
  28. int GetSortId() const;
  29. void IncrementSortId();
  30. protected:
  31. int GetMaxYIndex( int firstX, int width );
  32. int m_MaxLightmapWidth;
  33. int m_MaxLightmapHeight;
  34. int m_pLightmapWavefront[MAX_MAX_LIGHTMAP_WIDTH];
  35. int m_AreaUsed;
  36. int m_MinimumHeight;
  37. // For optimization purposes:
  38. // These store the width + height of the first image
  39. // that was unable to be stored in this image
  40. int m_MaxBlockWidth;
  41. int m_MaxBlockHeight;
  42. int m_nSortID;
  43. };
  44. //-----------------------------------------------------------------------------
  45. // Inline methods
  46. //-----------------------------------------------------------------------------
  47. inline int CImagePacker::GetSortId() const
  48. {
  49. return m_nSortID;
  50. }
  51. inline void CImagePacker::IncrementSortId()
  52. {
  53. ++m_nSortID;
  54. }
  55. #endif // IMAGEPACKER_H