BVB Source Codes

CRYENGINE Show SurfacesLookupTable.h Source code

Return Download CRYENGINE: download SurfacesLookupTable.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // ----------------------------------------------------------------------------------------
  4. //  File name:   SurfacesLookupTable.h
  5. //  Description: 2D look up table for surfaces
  6. //
  7. ////////////////////////////////////////////////////////////////////////////////////////////
  8.  
  9. #ifndef _SURFACES_LOOKUP_TABLE_H_
  10. #define _SURFACES_LOOKUP_TABLE_H_
  11.  
  12. #pragma once
  13.  
  14. namespace MaterialEffectsUtils
  15. {
  16. template<typename T>
  17. struct SSurfacesLookupTable
  18. {
  19.         void Create(size_t rows, size_t cols)
  20.         {
  21.                 SAFE_DELETE_ARRAY(m_pData);
  22.  
  23.                 m_nRows = rows;
  24.                 m_nCols = cols;
  25.                 m_pData = new T[m_nRows * m_nCols];
  26.  
  27.                 memset(m_pData, 0, m_nRows * m_nCols * sizeof(T));
  28.         }
  29.  
  30.         SSurfacesLookupTable()
  31.                 : m_pData(0)
  32.                 , m_nRows(0)
  33.                 , m_nCols(0)
  34.         {
  35.         }
  36.  
  37.         ~SSurfacesLookupTable()
  38.         {
  39.                 SAFE_DELETE_ARRAY(m_pData);
  40.         }
  41.  
  42.         void Free()
  43.         {
  44.                 SAFE_DELETE_ARRAY(m_pData);
  45.         }
  46.  
  47.         T* operator[](const size_t row) const
  48.         {
  49.                 CRY_ASSERT(m_pData);
  50.                 CRY_ASSERT((row >= 0) && (row < m_nRows));
  51.                 return &m_pData[row * m_nCols];
  52.         }
  53.  
  54.         T& operator()(const size_t row, const size_t col) const
  55.         {
  56.                 CRY_ASSERT(m_pData);
  57.                 CRY_ASSERT((row >= 0) && (row < m_nRows) && (col >= 0) && (col < m_nCols));
  58.                 return m_pData[row * m_nCols + col];
  59.         }
  60.  
  61.         T GetValue(const size_t row, const size_t col, const T& defaultValue) const
  62.         {
  63.                 return (m_pData && row >= 0 && row < m_nRows && col >= 0 && col < m_nCols) ? m_pData[row * m_nCols + col] : defaultValue;
  64.         }
  65.         void GetMemoryUsage(ICrySizer* s) const
  66.         {
  67.                 s->AddObject(m_pData, sizeof(T) * m_nRows * m_nCols);
  68.         }
  69.  
  70.         T*     m_pData;
  71.         size_t m_nRows;
  72.         size_t m_nCols;
  73. };
  74. }
  75.  
  76. #endif //_SURFACES_LOOKUP_TABLE_H_
  77.  
downloadSurfacesLookupTable.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