-
-
Save Zeno-/960b82defa1f68645331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 09a50fbe70aa6670b4bf59bb07d5f58f29420062 Mon Sep 17 00:00:00 2001 | |
From: Craig Robbins <kde.psych@gmail.com> | |
Date: Wed, 11 Feb 2015 14:48:26 +1000 | |
Subject: [PATCH] Increase performance by XXXXXXXXXXXXXXXXXXXXX Avoid changing | |
a global value to solve a local problem | |
--- | |
src/client.cpp | 3 ++- | |
src/client.h | 3 ++- | |
src/itemdef.cpp | 11 +---------- | |
src/mapblock_mesh.cpp | 5 +++-- | |
src/mapblock_mesh.h | 3 ++- | |
src/wieldmesh.cpp | 4 +++- | |
6 files changed, 13 insertions(+), 16 deletions(-) | |
diff --git a/src/client.cpp b/src/client.cpp | |
index b13631f..107e16f 100644 | |
--- a/src/client.cpp | |
+++ b/src/client.cpp | |
@@ -283,6 +283,7 @@ void * MeshUpdateThread::Thread() | |
} | |
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting"); | |
+ m_cache_enable_shaders = g_settings->getBool("enable_shaders"); | |
} | |
void Client::Stop() | |
@@ -2681,7 +2682,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent) | |
Create a task to update the mesh of the block | |
*/ | |
- MeshMakeData *data = new MeshMakeData(this); | |
+ MeshMakeData *data = new MeshMakeData(this, m_cache_enable_shaders); | |
{ | |
//TimeTaker timer("data fill"); | |
diff --git a/src/client.h b/src/client.h | |
index fd43361..9314300 100644 | |
--- a/src/client.h | |
+++ b/src/client.h | |
@@ -623,8 +623,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef | |
Database *localdb; | |
Server *localserver; | |
- // TODO: Add callback to update this when g_settings changes | |
+ // TODO: Add callback to update these when g_settings changes | |
bool m_cache_smooth_lighting; | |
+ bool m_cache_enable_shaders; | |
}; | |
#endif // !CLIENT_HEADER | |
diff --git a/src/itemdef.cpp b/src/itemdef.cpp | |
index ac67c5b..d356b96 100644 | |
--- a/src/itemdef.cpp | |
+++ b/src/itemdef.cpp | |
@@ -362,8 +362,6 @@ class CItemDefManager: public IWritableItemDefManager | |
scene::IMesh *node_mesh = NULL; | |
- bool reenable_shaders = false; | |
- | |
if (need_rtt_mesh || need_wield_mesh) { | |
u8 param1 = 0; | |
if (f.param_type == CPT_LIGHT) | |
@@ -372,11 +370,7 @@ class CItemDefManager: public IWritableItemDefManager | |
/* | |
Make a mesh from the node | |
*/ | |
- if (g_settings->getBool("enable_shaders")) { | |
- reenable_shaders = true; | |
- g_settings->setBool("enable_shaders", false); | |
- } | |
- MeshMakeData mesh_make_data(gamedef); | |
+ MeshMakeData mesh_make_data(gamedef, false); | |
u8 param2 = 0; | |
if (f.param_type_2 == CPT2_WALLMOUNTED) | |
param2 = 1; | |
@@ -443,9 +437,6 @@ class CItemDefManager: public IWritableItemDefManager | |
if (node_mesh) | |
node_mesh->drop(); | |
- | |
- if (reenable_shaders) | |
- g_settings->setBool("enable_shaders",true); | |
} | |
// Put in cache | |
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp | |
index cf311ac..318be14 100644 | |
--- a/src/mapblock_mesh.cpp | |
+++ b/src/mapblock_mesh.cpp | |
@@ -42,7 +42,7 @@ static void applyFacesShading(video::SColor& color, float factor) | |
MeshMakeData | |
*/ | |
-MeshMakeData::MeshMakeData(IGameDef *gamedef): | |
+MeshMakeData::MeshMakeData(IGameDef *gamedef, bool use_shaders): | |
m_vmanip(), | |
m_blockpos(-1337,-1337,-1337), | |
m_crack_pos_relative(-1337, -1337, -1337), | |
@@ -50,7 +50,8 @@ static void applyFacesShading(video::SColor& color, float factor) | |
m_smooth_lighting(false), | |
m_show_hud(false), | |
m_highlight_mesh_color(255, 255, 255, 255), | |
- m_gamedef(gamedef) | |
+ m_gamedef(gamedef), | |
+ m_use_shaders(use_shaders) | |
{} | |
void MeshMakeData::fill(MapBlock *block) | |
diff --git a/src/mapblock_mesh.h b/src/mapblock_mesh.h | |
index be56d4c..98af92c 100644 | |
--- a/src/mapblock_mesh.h | |
+++ b/src/mapblock_mesh.h | |
@@ -45,8 +45,9 @@ struct MeshMakeData | |
video::SColor m_highlight_mesh_color; | |
IGameDef *m_gamedef; | |
+ bool m_use_shaders; | |
- MeshMakeData(IGameDef *gamedef); | |
+ MeshMakeData(IGameDef *gamedef, bool use_shaders); | |
/* | |
Copy central data directly from block, and other data from | |
diff --git a/src/wieldmesh.cpp b/src/wieldmesh.cpp | |
index 4ddae36..7c16bdd 100644 | |
--- a/src/wieldmesh.cpp | |
+++ b/src/wieldmesh.cpp | |
@@ -340,7 +340,9 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef) | |
} else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) { | |
setCube(f.tiles, def.wield_scale, tsrc); | |
} else { | |
- MeshMakeData mesh_make_data(gamedef); | |
+ //// TODO: Change false in the following constructor args to | |
+ //// appropriate value when shader is added for wield items (if applicable) | |
+ MeshMakeData mesh_make_data(gamedef, false); | |
MapNode mesh_make_node(id, 255, 0); | |
mesh_make_data.fillSingleNode(&mesh_make_node); | |
MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0)); | |
-- | |
1.9.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment