1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Shadow list improvements (#12898)

* Remove redundant checks when attaching SM texture to entities.
  Some of the checks were broken, leading to crashes when shadow intensity is set to 0
* Avoid memory leak in shadow casters list when wield mesh changes item stacks
This commit is contained in:
x2048 2022-10-26 22:26:09 +02:00 committed by GitHub
parent 16266397ed
commit 88820cd31c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View file

@ -107,8 +107,7 @@ void ShadowRenderer::disable()
}
for (auto node : m_shadow_node_array)
if (node.shadowMode & E_SHADOW_MODE::ESM_RECEIVE)
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
}
void ShadowRenderer::initialize()
@ -180,8 +179,7 @@ void ShadowRenderer::addNodeToShadowList(
if (!node)
return;
m_shadow_node_array.emplace_back(node, shadowMode);
if (shadowMode == ESM_RECEIVE || shadowMode == ESM_BOTH)
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
}
void ShadowRenderer::removeNodeFromShadowList(scene::ISceneNode *node)
@ -258,8 +256,7 @@ void ShadowRenderer::updateSMTextures()
assert(shadowMapTextureFinal != nullptr);
for (auto &node : m_shadow_node_array)
if (node.shadowMode == ESM_RECEIVE || node.shadowMode == ESM_BOTH)
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
}
if (!m_shadow_node_array.empty() && !m_light_list.empty()) {