mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Refactor the way you set material properties
Instead of using SMaterial::setFlag, you now set them directly on SMaterial or SMaterialLayer.
This commit is contained in:
parent
128d22e6ee
commit
307e380f30
15 changed files with 202 additions and 171 deletions
|
@ -113,7 +113,9 @@ void ShadowRenderer::disable()
|
|||
}
|
||||
|
||||
for (auto node : m_shadow_node_array)
|
||||
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
node.node->forEachMaterial([] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void ShadowRenderer::initialize()
|
||||
|
@ -183,12 +185,16 @@ void ShadowRenderer::addNodeToShadowList(
|
|||
// node should never be ClientMap
|
||||
assert(strcmp(node->getName(), "ClientMap") != 0);
|
||||
|
||||
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
node->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
});
|
||||
}
|
||||
|
||||
void ShadowRenderer::removeNodeFromShadowList(scene::ISceneNode *node)
|
||||
{
|
||||
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
node->forEachMaterial([] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
});
|
||||
for (auto it = m_shadow_node_array.begin(); it != m_shadow_node_array.end();) {
|
||||
if (it->node == node) {
|
||||
it = m_shadow_node_array.erase(it);
|
||||
|
@ -258,7 +264,9 @@ void ShadowRenderer::updateSMTextures()
|
|||
assert(shadowMapTextureFinal != nullptr);
|
||||
|
||||
for (auto &node : m_shadow_node_array)
|
||||
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
node.node->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_shadow_node_array.empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue