diff --git a/Src/Graphics/New3D/TextureSheet.cpp b/Src/Graphics/New3D/TextureSheet.cpp index 4eca477..1039a57 100644 --- a/Src/Graphics/New3D/TextureSheet.cpp +++ b/Src/Graphics/New3D/TextureSheet.cpp @@ -31,14 +31,14 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format index = ToIndex(x, y); - auto range = m_texMap[format].equal_range(index); + auto range = m_texMap.equal_range(index); if (range.first == range.second) { // nothing found so create a new texture std::shared_ptr t(new Texture()); - m_texMap[format].insert(std::pair>(index, t)); + m_texMap.insert(std::pair>(index, t)); t->UploadTexture(src, m_temp.data(), format, mirrorU, mirrorV, x, y, width, height); return t; } @@ -52,7 +52,7 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format it->second->GetDetails(x2, y2, width2, height2, format2); - if (width == width2 && height == height2) { + if (width == width2 && height == height2 && format == format2) { return it->second; } } @@ -60,7 +60,7 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format // nothing found so create a new entry std::shared_ptr t(new Texture()); - m_texMap[format].insert(std::pair>(index, t)); + m_texMap.insert(std::pair>(index, t)); t->UploadTexture(src, m_temp.data(), format, mirrorU, mirrorV, x, y, width, height); return t; } @@ -68,9 +68,7 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format void TextureSheet::Release() { - for (int i = 0; i < 12; i++) { - m_texMap[i].clear(); - } + m_texMap.clear(); } void TextureSheet::Invalidate(int x, int y, int width, int height) @@ -116,23 +114,17 @@ void TextureSheet::Invalidate(int x, int y, int width, int height) int index = ToIndex(posX, posY); if (posX >= x && posY >= y) { // invalidate this area of memory - for (int j = 0; j < 12; j++) { - m_texMap[j].erase(index); - } + m_texMap.erase(index); } else { // check for overlapping data tiles and invalidate as necessary - for (int j = 0; j < 12; j++) { + auto range = m_texMap.equal_range(index); - auto range = m_texMap[j].equal_range(index); - - for (auto it = range.first; it != range.second; ++it) { - - if (it->second->CheckMapPos(x, x + width, y, y + height)) { - m_texMap[j].erase(index); - break; - } + for (auto it = range.first; it != range.second; ++it) { + if (it->second->CheckMapPos(x, x + width, y, y + height)) { + m_texMap.erase(index); + break; } } } diff --git a/Src/Graphics/New3D/TextureSheet.h b/Src/Graphics/New3D/TextureSheet.h index 59fb42d..84a17e6 100644 --- a/Src/Graphics/New3D/TextureSheet.h +++ b/Src/Graphics/New3D/TextureSheet.h @@ -25,7 +25,7 @@ private: int ToIndex(int x, int y); void CropTile(int oldX, int oldY, int &newX, int &newY, int &newWidth, int &newHeight); - std::unordered_multimap> m_texMap[12]; + std::unordered_multimap> m_texMap; // the key for the above maps is the x/y position in the 2048x2048 texture // array of 8 planes for each texture type