mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02: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:
@@ -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()) {
|
||||
|
Reference in New Issue
Block a user