Просмотр исходного кода

add optional mip and face lookups for gbitmap::getcolor

AzaezelX 2 недель назад
Родитель
Сommit
17326b2d8c
2 измененных файлов с 5 добавлено и 4 удалено
  1. 4 3
      Engine/source/gfx/bitmap/gBitmap.cpp
  2. 1 1
      Engine/source/gfx/bitmap/gBitmap.h

+ 4 - 3
Engine/source/gfx/bitmap/gBitmap.cpp

@@ -721,12 +721,13 @@ LinearColorF GBitmap::sampleTexel(F32 u, F32 v, bool retAlpha) const
 }
 
 //--------------------------------------------------------------------------
-bool GBitmap::getColor(const U32 x, const U32 y, ColorI& rColor) const
+bool GBitmap::getColor(const U32 x, const U32 y, ColorI& rColor, const U32 mipLevel, const U32 face) const
 {
    if (x >= mWidth || y >= mHeight)
       return false;
-
-   const U8* p = getAddress(x, y);
+   U32 targMip = getNumMipLevels() < mipLevel ? getNumMipLevels()-1 : mipLevel;
+   U32 targFace = getNumFaces() < face ? getNumFaces()-1 : face;
+   const U8* p = getAddress(x, y, targMip, targFace);
 
    switch (mInternalFormat)
    {

+ 1 - 1
Engine/source/gfx/bitmap/gBitmap.h

@@ -223,7 +223,7 @@ public:
    bool        checkForTransparency();
 
    LinearColorF      sampleTexel(F32 u, F32 v, bool retAlpha = false) const;
-   bool        getColor(const U32 x, const U32 y, ColorI& rColor) const;
+   bool        getColor(const U32 x, const U32 y, ColorI& rColor, const U32 mipLevel = 0, const U32 face = 0) const;
    bool        setColor(const U32 x, const U32 y, const ColorI& rColor);
    U8          getChanelValueAt(U32 x, U32 y, U32 chan);
    U32         getNumFaces() const { return mNumFaces; }