Fix for #161, texture priorities were not being properly taken into account

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2023-05-07 18:54:01 +02:00
parent 5016a9d873
commit 181dd1eef8
2 changed files with 9 additions and 5 deletions

View File

@ -110,7 +110,7 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, CObject* ob
texture = texturesCur; texture = texturesCur;
} }
std::vector<std::string> passTextures = passCur->getTextures (); const auto& passTextures = passCur->getTextures ();
if (textureNumber < passTextures.size ()) if (textureNumber < passTextures.size ())
passCur->setTexture (textureNumber, texture); passCur->setTexture (textureNumber, texture);

View File

@ -511,14 +511,14 @@ void CPass::setupUniforms ()
{ {
if (bindCur != bindEnd) if (bindCur != bindEnd)
{ {
this->m_finalTextures.insert (std::make_pair ((*bindCur).first, nullptr)); this->m_finalTextures [(*bindCur).first] = nullptr;
bindCur ++; bindCur ++;
} }
if (cur != end) if (cur != end)
{ {
if ((*cur) != nullptr) if ((*cur) != nullptr)
this->m_finalTextures.insert (std::make_pair (index, *cur)); this->m_finalTextures [index] = *cur;
index ++; index ++;
cur ++; cur ++;
@ -543,7 +543,9 @@ void CPass::setupUniforms ()
else else
textureRef = this->getContext ().resolveTexture (textureName); textureRef = this->getContext ().resolveTexture (textureName);
this->m_finalTextures.insert (std::make_pair ((*fragCur).first, textureRef)); // ensure there's no texture in that slot already, shader textures are defaults in case nothing is there
if (this->m_finalTextures.find ((*fragCur).first) == this->m_finalTextures.end ())
this->m_finalTextures [(*fragCur).first] = textureRef;
} }
catch (std::runtime_error& ex) catch (std::runtime_error& ex)
{ {
@ -572,7 +574,9 @@ void CPass::setupUniforms ()
else else
textureRef = this->getContext ().resolveTexture (textureName); textureRef = this->getContext ().resolveTexture (textureName);
this->m_finalTextures.insert (std::make_pair ((*vertCur).first, textureRef)); // ensure there's no texture in that slot already, shader textures are defaults in case nothing is there
if (this->m_finalTextures.find ((*vertCur).first) == this->m_finalTextures.end ())
this->m_finalTextures [(*vertCur).first] = textureRef;
} }
catch (std::runtime_error& ex) catch (std::runtime_error& ex)
{ {