aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/clientmap.cpp10
-rw-r--r--src/client/clientmap.h1
-rw-r--r--src/client/content_cao.cpp3
-rw-r--r--src/client/shadows/dynamicshadowsrender.cpp65
-rw-r--r--src/client/shadows/dynamicshadowsrender.h2
5 files changed, 34 insertions, 47 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp
index 3b6a319f3..83f9beb89 100644
--- a/src/client/clientmap.cpp
+++ b/src/client/clientmap.cpp
@@ -146,12 +146,8 @@ void ClientMap::OnRegisterSceneNode()
}
ISceneNode::OnRegisterSceneNode();
-
- if (!m_added_to_shadow_renderer) {
- m_added_to_shadow_renderer = true;
- if (auto shadows = m_rendering_engine->get_shadow_renderer())
- shadows->addNodeToShadowList(this);
- }
+ // It's not needed to register this node to the shadow renderer
+ // we have other way to find it
}
void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
@@ -721,7 +717,7 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
return;
}
- for (auto &i : m_drawlist_shadow) {
+ for (const auto &i : m_drawlist_shadow) {
// only process specific part of the list & break early
++count;
if (count <= low_bound)
diff --git a/src/client/clientmap.h b/src/client/clientmap.h
index 8c45b5382..f5e02d6d0 100644
--- a/src/client/clientmap.h
+++ b/src/client/clientmap.h
@@ -204,6 +204,5 @@ private:
bool m_cache_trilinear_filter;
bool m_cache_bilinear_filter;
bool m_cache_anistropic_filter;
- bool m_added_to_shadow_renderer{false};
u16 m_cache_transparency_sorting_distance;
};
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index a03154340..993fa6e59 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -568,7 +568,8 @@ void GenericCAO::removeFromScene(bool permanent)
}
if (auto shadow = RenderingEngine::get_shadow_renderer())
- shadow->removeNodeFromShadowList(getSceneNode());
+ if (auto node = getSceneNode())
+ shadow->removeNodeFromShadowList(node);
if (m_meshnode) {
m_meshnode->remove();
diff --git a/src/client/shadows/dynamicshadowsrender.cpp b/src/client/shadows/dynamicshadowsrender.cpp
index e9b2053e3..ebdd1d2af 100644
--- a/src/client/shadows/dynamicshadowsrender.cpp
+++ b/src/client/shadows/dynamicshadowsrender.cpp
@@ -132,7 +132,7 @@ void ShadowRenderer::initialize()
m_texture_format_color = m_shadow_map_texture_32bit
? video::ECOLOR_FORMAT::ECF_G32R32F
: video::ECOLOR_FORMAT::ECF_G16R16F;
-
+
m_shadows_enabled &= m_shadows_supported;
}
@@ -176,16 +176,15 @@ void ShadowRenderer::setShadowIntensity(float shadow_intensity)
void ShadowRenderer::addNodeToShadowList(
scene::ISceneNode *node, E_SHADOW_MODE shadowMode)
{
- if (!node)
- return;
m_shadow_node_array.emplace_back(node, shadowMode);
+ // node should never be ClientMap
+ assert(strcmp(node->getName(), "ClientMap") != 0);
+
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
}
void ShadowRenderer::removeNodeFromShadowList(scene::ISceneNode *node)
{
- if (!node)
- return;
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
for (auto it = m_shadow_node_array.begin(); it != m_shadow_node_array.end();) {
if (it->node == node) {
@@ -286,7 +285,7 @@ void ShadowRenderer::updateSMTextures()
cb->PerspectiveBiasZ = getPerspectiveBiasZ();
cb->CameraPos = light.getFuturePlayerPos();
}
-
+
// set the Render Target
// right now we can only render in usual RTT, not
// Depth texture is available in irrlicth maybe we
@@ -349,7 +348,7 @@ void ShadowRenderer::update(video::ITexture *outputTarget)
for (DirectionalLight &light : m_light_list) {
// Static shader values for entities are set in updateSMTextures
- // SM texture for entities is not updated incrementally and
+ // SM texture for entities is not updated incrementally and
// must by updated using current player position.
m_shadow_depth_entity_cb->CameraPos = light.getPlayerPos();
@@ -392,7 +391,7 @@ void ShadowRenderer::drawDebug()
m_driver->draw2DImage(shadowMapClientMap,
core::rect<s32>(0, 50 + 128, 128, 128 + 50 + 128),
core::rect<s32>({0, 0}, shadowMapTextureFinal->getSize()));
-
+
if (shadowMapTextureDynamicObjects)
m_driver->draw2DImage(shadowMapTextureDynamicObjects,
core::rect<s32>(0, 128 + 50 + 128, 128,
@@ -429,39 +428,32 @@ void ShadowRenderer::renderShadowMap(video::ITexture *target,
m_driver->setTransform(video::ETS_VIEW, light.getFutureViewMatrix());
m_driver->setTransform(video::ETS_PROJECTION, light.getFutureProjectionMatrix());
- // Operate on the client map
- for (const auto &shadow_node : m_shadow_node_array) {
- if (strcmp(shadow_node.node->getName(), "ClientMap") != 0)
- continue;
-
- ClientMap *map_node = static_cast<ClientMap *>(shadow_node.node);
+ ClientMap &map_node = static_cast<ClientMap &>(m_client->getEnv().getMap());
- video::SMaterial material;
- if (map_node->getMaterialCount() > 0) {
- // we only want the first material, which is the one with the albedo info
- material = map_node->getMaterial(0);
- }
+ video::SMaterial material;
+ if (map_node.getMaterialCount() > 0) {
+ // we only want the first material, which is the one with the albedo info
+ material = map_node.getMaterial(0);
+ }
- material.BackfaceCulling = false;
- material.FrontfaceCulling = true;
+ material.BackfaceCulling = false;
+ material.FrontfaceCulling = true;
- if (m_shadow_map_colored && pass != scene::ESNRP_SOLID) {
- material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader_trans;
- }
- else {
- material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader;
- material.BlendOperation = video::EBO_MIN;
- }
+ if (m_shadow_map_colored && pass != scene::ESNRP_SOLID) {
+ material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader_trans;
+ }
+ else {
+ material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader;
+ material.BlendOperation = video::EBO_MIN;
+ }
- m_driver->setTransform(video::ETS_WORLD,
- map_node->getAbsoluteTransformation());
+ m_driver->setTransform(video::ETS_WORLD,
+ map_node.getAbsoluteTransformation());
- int frame = m_force_update_shadow_map ? 0 : m_current_frame;
- int total_frames = m_force_update_shadow_map ? 1 : m_map_shadow_update_frames;
+ int frame = m_force_update_shadow_map ? 0 : m_current_frame;
+ int total_frames = m_force_update_shadow_map ? 1 : m_map_shadow_update_frames;
- map_node->renderMapShadows(m_driver, material, pass, frame, total_frames);
- break;
- }
+ map_node.renderMapShadows(m_driver, material, pass, frame, total_frames);
}
void ShadowRenderer::renderShadowObjects(
@@ -472,8 +464,7 @@ void ShadowRenderer::renderShadowObjects(
for (const auto &shadow_node : m_shadow_node_array) {
// we only take care of the shadow casters
- if (shadow_node.shadowMode == ESM_RECEIVE ||
- strcmp(shadow_node.node->getName(), "ClientMap") == 0)
+ if (shadow_node.shadowMode == ESM_RECEIVE)
continue;
// render other objects
diff --git a/src/client/shadows/dynamicshadowsrender.h b/src/client/shadows/dynamicshadowsrender.h
index 79dd25c44..7fe3461bc 100644
--- a/src/client/shadows/dynamicshadowsrender.h
+++ b/src/client/shadows/dynamicshadowsrender.h
@@ -163,7 +163,7 @@ private:
/**
* @brief Create a shadow renderer if settings allow this.
- *
+ *
* @param device Device to be used to render shadows.
* @param client Reference to the client context.
* @return A new ShadowRenderer instance or nullptr if shadows are disabled or not supported.