Use absolute paths to lookup materials, fixes karts with identical texture names being in conflict. Also, when a texture is misisng, log an error but don't abort
This commit is contained in:
parent
8798eda41b
commit
81bd79a736
@ -65,6 +65,8 @@ Material::Material(const XMLNode *node, bool deprecated)
|
|||||||
throw std::runtime_error("[Material] No texture name specified "
|
throw std::runtime_error("[Material] No texture name specified "
|
||||||
"in file\n");
|
"in file\n");
|
||||||
}
|
}
|
||||||
|
m_full_path = file_manager->getFileSystem()->getAbsolutePath(
|
||||||
|
file_manager->searchTexture(m_texname).c_str()).c_str();
|
||||||
init();
|
init();
|
||||||
|
|
||||||
node->get("lazy-load", &m_lazy_load);
|
node->get("lazy-load", &m_lazy_load);
|
||||||
@ -404,6 +406,8 @@ Material::Material(const std::string& fname, bool is_full_path,
|
|||||||
|
|
||||||
m_texname = fname;
|
m_texname = fname;
|
||||||
init();
|
init();
|
||||||
|
m_full_path = file_manager->getFileSystem()->getAbsolutePath(
|
||||||
|
file_manager->searchTexture(m_texname).c_str()).c_str();
|
||||||
|
|
||||||
if (load_texture)
|
if (load_texture)
|
||||||
install(is_full_path, complain_if_not_found);
|
install(is_full_path, complain_if_not_found);
|
||||||
|
@ -85,6 +85,8 @@ private:
|
|||||||
/** Name of the texture. */
|
/** Name of the texture. */
|
||||||
std::string m_texname;
|
std::string m_texname;
|
||||||
|
|
||||||
|
std::string m_full_path;
|
||||||
|
|
||||||
/** If true, the texture will not automatically be loaded and bound
|
/** If true, the texture will not automatically be loaded and bound
|
||||||
* at load time, it must be loaded elsewhere. This is used to store
|
* at load time, it must be loaded elsewhere. This is used to store
|
||||||
* material settings for font textures, without loading fonts for
|
* material settings for font textures, without loading fonts for
|
||||||
@ -288,6 +290,9 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::string&
|
const std::string&
|
||||||
getTexFname () const { return m_texname; }
|
getTexFname () const { return m_texname; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
const std::string&
|
||||||
|
getTexFullPath () const { return m_full_path; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isTransparent () const
|
bool isTransparent () const
|
||||||
|
@ -69,8 +69,17 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
|||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
return m_default_material;
|
return m_default_material;
|
||||||
|
|
||||||
const std::string image = StringUtils::getBasename(core::stringc(t->getName()).c_str());
|
core::stringc img_path = core::stringc(t->getName());
|
||||||
|
const std::string image = StringUtils::getBasename(img_path.c_str());
|
||||||
// Search backward so that temporary (track) textures are found first
|
// Search backward so that temporary (track) textures are found first
|
||||||
|
for (int i = (int)m_materials.size() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
std::string full_path = m_materials[i]->getTexFullPath();
|
||||||
|
if (m_materials[i]->getTexFullPath() == img_path.c_str())
|
||||||
|
{
|
||||||
|
return m_materials[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
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()==image)
|
if (m_materials[i]->getTexFname()==image)
|
||||||
|
@ -283,8 +283,9 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname)
|
|||||||
{
|
{
|
||||||
if (!mesh.textures[i])
|
if (!mesh.textures[i])
|
||||||
{
|
{
|
||||||
Log::fatal("STKMesh", "Missing texture %d for material %s", i, matname.c_str());
|
Log::error("STKMesh", "Missing texture %d for material %s", i, matname.c_str());
|
||||||
return;
|
// use unicolor texture to replace missing texture
|
||||||
|
mesh.textures[i] = getUnicolorTexture(video::SColor(255, 127, 127, 127));
|
||||||
}
|
}
|
||||||
compressTexture(mesh.textures[i], isSrgb);
|
compressTexture(mesh.textures[i], isSrgb);
|
||||||
if (CVS->isAZDOEnabled())
|
if (CVS->isAZDOEnabled())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user