]> git.mxchange.org Git - flightgear.git/commitdiff
Crash fix: thread-safe material conditions
authorJames Turner <zakalawe@mac.com>
Mon, 6 Jan 2014 08:28:40 +0000 (08:28 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 6 Jan 2014 08:28:40 +0000 (08:28 +0000)
When tiles are being loaded, re-evaluate the materials cache once
per update cycle. (This is probably too often, but no worse than the
previous approach).

src/Scenery/tilemgr.cxx

index 8216c0a8621f9999d672ce8d20bc0156f60c4d08..3df77c0e531c3d753d148ce2fd167cc4f4f8081b 100644 (file)
@@ -38,6 +38,7 @@
 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tsync/terrasync.hxx>
 #include <simgear/misc/strutils.hxx>
+#include <simgear/scene/material/matlib.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -251,7 +252,8 @@ void FGTileMgr::update_queues(bool& isDownloadingScenery)
     TileEntry *e;
     int loading=0;
     int sz=0;
-
+    bool didRefreshMaterialCache = false;
+    
     tile_cache.set_current_time( current_time );
     tile_cache.reset_traversal();
 
@@ -266,6 +268,11 @@ void FGTileMgr::update_queues(bool& isDownloadingScenery)
             e->prep_ssg_node(vis);
             
             if (!e->is_loaded()) {
+                if (!didRefreshMaterialCache) {
+                    didRefreshMaterialCache = true;
+                    globals->get_matlib()->refreshActiveMaterials();
+                }
+                
                 bool nonExpiredOrCurrent = !e->is_expired(current_time) || e->is_current_view();
                 bool downloading = isTileDirSyncing(e->tileFileName);
                 isDownloadingScenery |= downloading;