Bugfix delayed-loaded textures bug

This commit is contained in:
auria.mg 2016-12-25 22:00:11 -05:00
parent 4aa31dc56e
commit 059c2c8573

View File

@ -88,7 +88,6 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
core::stringc img_path = core::stringc(t->getName());
img_path.make_lower();
const std::string image = StringUtils::getBasename(img_path.c_str());
if (!img_path.empty() && (img_path.findFirst('/') != -1 || img_path.findFirst('\\') != -1))
{
// Search backward so that temporary (track) textures are found first
@ -107,10 +106,15 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
}
else
{
core::stringc image(StringUtils::getBasename(img_path.c_str()).c_str());
image.make_lower();
for (int i = (int)m_materials.size() - 1; i >= 0; i--)
{
//Log::info("DEBUG_TEX2", "<%s> <%s>", m_materials[i]->getTexFname().c_str(), image.c_str());
if (m_materials[i]->getTexFname() == image)
core::stringc texfname(m_materials[i]->getTexFname().c_str());
texfname.make_lower();
if (texfname == image)
{
return m_materials[i];
}
@ -347,10 +351,16 @@ Material *MaterialManager::getMaterial(const std::string& fname,
else
basename = fname;
core::stringc basename_lower(basename.c_str());
basename_lower.make_lower();
// Search backward so that temporary (track) textures are found first
for(int i = (int)m_materials.size()-1; i>=0; i-- )
for (int i = (int)m_materials.size()-1; i>=0; i-- )
{
if(m_materials[i]->getTexFname()==basename) return m_materials[i];
core::stringc fname(m_materials[i]->getTexFname().c_str());
fname.make_lower();
if (fname == basename_lower)
return m_materials[i];
}
// Add the new material