BVB Source Codes

CRYENGINE Show BlockPacker.h Source code

Return Download CRYENGINE: download BlockPacker.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __POWEROF2BLOCKPACKER_H__
  4. #define __POWEROF2BLOCKPACKER_H__
  5.  
  6. #if defined(FEATURE_SVO_GI)
  7.  
  8.         #include <vector>         // STL vector<>
  9.  
  10. struct SBlockMinMax
  11. {
  12.         SBlockMinMax()
  13.         {
  14.                 ZeroStruct(*this);
  15.                 MarkFree();
  16.         }
  17.  
  18.         uint8         m_dwMinX; // 0xffffffff if free, included
  19.         uint8         m_dwMinY; // not defined if free, included
  20.         uint8         m_dwMinZ; // not defined if free, included
  21.         uint8         m_dwMaxX; // not defined if free, not included
  22.         uint8         m_dwMaxY; // not defined if free, not included
  23.         uint8         m_dwMaxZ; // not defined if free, not included
  24.         uint16        m_nDataSize;
  25.         void*         m_pUserData;
  26.         uint32        m_nLastVisFrameId;
  27.  
  28.         SBlockMinMax* m_pNext, * m_pPrev;
  29.  
  30.         bool          IsFree() const
  31.         {
  32.                 return m_dwMinX == 0xff;
  33.         }
  34.  
  35.         void MarkFree()
  36.         {
  37.                 m_dwMinX = 0xff;
  38.                 m_pUserData = 0;
  39.                 m_nDataSize = m_nLastVisFrameId = 0;
  40.         }
  41. };
  42.  
  43. class CBlockPacker3D
  44. {
  45. public:
  46.         float m_fLastUsed;
  47.  
  48. public:
  49.         // constructor
  50.         // Arguments:
  51.         //   dwLogHeight - e.g. specify 5 for 32, keep is small like ~ 5 or 6, don't use pixel size
  52.         //   dwLogHeight - e.g. specify 5 for 32, keep is small like ~ 5 or 6, don't use pixel size
  53.         CBlockPacker3D(const uint32 dwLogWidth, const uint32 dwLogHeight, const uint32 dwLogDepth, const bool bNonPow = false);
  54.  
  55.         // Arguments:
  56.         //   dwLogHeight - e.g. specify 5 for 32
  57.         //   dwLogHeight - e.g. specify 5 for 32
  58.         // Returns:
  59.         //   block * or 0 if there was no free space
  60.         SBlockMinMax* AddBlock(const uint32 dwLogWidth, const uint32 dwLogHeight, const uint32 dwLogDepth, void* pUserData, uint32 nCreateFrameId, uint32 nDataSize);
  61.  
  62.         // Arguments:
  63.         //   dwBlockID - as it was returned from AddBlock()
  64.         SBlockMinMax* GetBlockInfo(const uint32 dwBlockID);
  65.  
  66.         void          UpdateSize(int nW, int nH, int nD);
  67.  
  68.         // Arguments:
  69.         //   dwBlockID - as it was returned from AddBlock()
  70.         void   RemoveBlock(const uint32 dwBlockID);
  71.         void   RemoveBlock(SBlockMinMax* pInfo);
  72.  
  73.         uint32 GetNumSubBlocks() const
  74.         {
  75.                 return m_nUsedBlocks;
  76.         }
  77.  
  78.         uint32 GetNumBlocks() const
  79.         {
  80.                 return m_Blocks.size();
  81.         }
  82.  
  83.         //      void MarkAsInUse(SBlockMinMax * pInfo);
  84.  
  85.         //      SBlockMinMax * CBlockPacker3D::GetLruBlock();
  86.  
  87. private: // ----------------------------------------------------------
  88.  
  89.         // -----------------------------------------------------------------
  90.  
  91.         //      TDoublyLinkedList<SBlockMinMax> m_BlocksList;
  92.         std::vector<SBlockMinMax> m_Blocks;                 //
  93.         std::vector<uint32>       m_BlockBitmap;            // [m_dwWidth*m_dwHeight*m_dwDepth], elements are 0xffffffff if not used
  94.         std::vector<byte>         m_BlockUsageGrid;
  95.         uint32                    m_dwWidth;                // >0
  96.         uint32                    m_dwHeight;               // >0
  97.         uint32                    m_dwDepth;                // >0
  98.         uint32                    m_nUsedBlocks;
  99.         // -----------------------------------------------------------------
  100.  
  101.         //
  102.         void FillRect(const SBlockMinMax& rect, uint32 dwValue);
  103.  
  104.         bool IsFree(const SBlockMinMax& rect);
  105.  
  106.         int  GetUsedSlotsCount(const SBlockMinMax& rect);
  107.  
  108.         void UpdateUsageGrid(const SBlockMinMax& rectIn);
  109.  
  110.         //
  111.         uint32 FindFreeBlockIDOrCreateNew();
  112. };
  113.  
  114. #endif
  115.  
  116. #endif
  117.  
downloadBlockPacker.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top