From e4f7c92cff0badd6c40b47bd90b1fc1b35456a1a Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 15 Mar 2015 07:25:22 +0100 Subject: Finer progress bar updates when initializing nodes The bar is only drawn when the user will notice a change, which prevents time overheads that this commit would cause, resulting from useless draws. --- src/nodedef.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/nodedef.cpp') diff --git a/src/nodedef.cpp b/src/nodedef.cpp index a0dcf6b71..4aee1b1c6 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -398,7 +398,9 @@ public: virtual content_t set(const std::string &name, const ContentFeatures &def); virtual content_t allocateDummy(const std::string &name); virtual void updateAliases(IItemDefManager *idef); - virtual void updateTextures(IGameDef *gamedef); + virtual void updateTextures(IGameDef *gamedef, + /*argument: */void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress), + /*argument: */void *progress_callback_args); void serialize(std::ostream &os, u16 protocol_version); void deSerialize(std::istream &is); @@ -715,7 +717,9 @@ void CNodeDefManager::updateAliases(IItemDefManager *idef) } -void CNodeDefManager::updateTextures(IGameDef *gamedef) +void CNodeDefManager::updateTextures(IGameDef *gamedef, + void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress), + void *progress_callback_args) { #ifndef SERVER infostream << "CNodeDefManager::updateTextures(): Updating " @@ -738,7 +742,9 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef) bool use_normal_texture = enable_shaders && (enable_bumpmapping || enable_parallax_occlusion); - for (u32 i = 0; i < m_content_features.size(); i++) { + u32 size = m_content_features.size(); + + for (u32 i = 0; i < size; i++) { ContentFeatures *f = &m_content_features[i]; // Figure out the actual tiles to use @@ -911,6 +917,8 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef) recalculateBoundingBox(f->mesh_ptr[0]); meshmanip->recalculateNormals(f->mesh_ptr[0], true, false); } + + progress_callback(progress_callback_args, i, size); } #endif } -- cgit v1.2.3