diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index f81a9b3..79df5d6 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -2,7 +2,7 @@ #include "PolyHeader.h" #include "Texture.h" #include "Vec.h" -#include // needed by gcc +#include #include #include @@ -283,9 +283,9 @@ bool CNew3D::DrawModel(UINT32 modelAddr) // try to find meshes in the rom cache + m->meshes = m_romMap[modelAddr]; // will create an entry with a null pointer if empty - if (m_romMap.count(modelAddr)) { - m->meshes = m_romMap[modelAddr]; + if (m->meshes) { cached = true; } else { diff --git a/Src/Graphics/New3D/TextureSheet.cpp b/Src/Graphics/New3D/TextureSheet.cpp index 9612fdd..e2dc338 100644 --- a/Src/Graphics/New3D/TextureSheet.cpp +++ b/Src/Graphics/New3D/TextureSheet.cpp @@ -31,9 +31,11 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format index = ToIndex(x, y); - if (m_texMap[format&TEXTURE_DEBUG_MASK].count(index) == 0) { + auto range = m_texMap[format&TEXTURE_DEBUG_MASK].equal_range(index); - //no textures at this position or format so add it to the map + if (range.first == range.second) { + + // nothing found so create a new texture std::shared_ptr t(new Texture()); m_texMap[format&TEXTURE_DEBUG_MASK].insert(std::pair>(index, t)); @@ -41,10 +43,8 @@ std::shared_ptr TextureSheet::BindTexture(const UINT16* src, int format return t; } else { - //scan for duplicates - //only texture width/height and wrap modes can change here. Since key is based on x/y pos, and each map is a separate format - auto range = m_texMap[format&TEXTURE_DEBUG_MASK].equal_range(index); + // iterate to try and find a match for (auto it = range.first; it != range.second; ++it) { @@ -57,10 +57,11 @@ 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&TEXTURE_DEBUG_MASK].insert(std::pair>(index, t)); t->UploadTexture(src, m_temp.data(), format, mirrorU, mirrorV, x, y, width, height); - return t; } }