From 01ae0daea501f47ec56a8368e530cb4176fc44cd Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 15 Nov 2011 13:13:18 +0200 Subject: Properly update textures in node definitions --- src/client.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index c89273a80..7093a5190 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -222,16 +222,14 @@ Client::Client( // Build main texture atlas, now that the GameDef exists (that is, us) if(g_settings->getBool("enable_texture_atlas")) - tsrc->buildMainAtlas(this); + m_tsrc->buildMainAtlas(this); else infostream<<"Not building texture atlas."<updateTextures(tsrc); + // Update node textures + m_nodedef->updateTextures(m_tsrc); - // NOTE: This should be done only after getting possible dynamic - // game definitions from the server, or at least shut down and - // restarted when doing so + // Start threads after setting up content definitions m_mesh_update_thread.Start(); /* @@ -1568,17 +1566,28 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) rfile->drop(); continue; } - m_tsrc->insertImage(name, img); + m_tsrc->insertSourceImage(name, img); + img->drop(); rfile->drop(); } + + // Rebuild inherited images and recreate textures + m_tsrc->rebuildImagesAndTextures(); // Update texture atlas if(g_settings->getBool("enable_texture_atlas")) m_tsrc->buildMainAtlas(this); + // Update node textures + m_nodedef->updateTextures(m_tsrc); + // Resume threads m_mesh_update_thread.setRun(true); m_mesh_update_thread.Start(); + + ClientEvent event; + event.type = CE_TEXTURES_UPDATED; + m_client_event_queue.push_back(event); } else { -- cgit v1.2.3