]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/FGTileLoader.cxx
Tile loading is interleaved now when not threaded. Threaded loader is
[flightgear.git] / src / Scenery / FGTileLoader.cxx
index 6a787926fba57af17dd65a125091d6b39285e61a..a709b57f0fdb1b5b7ccaaa0393c93a2b04bef3ef 100644 (file)
@@ -29,6 +29,9 @@
 #include "tileentry.hxx"
 #include "tilemgr.hxx"
 
+extern ssgBranch *terrain;
+extern ssgBranch *ground;
+
 /**
  * 
  */
@@ -83,11 +86,7 @@ FGTileLoader::add( FGTileEntry* tile )
        beenhere = true;
     }
 
-#ifdef ENABLE_THREADS
-    tile_queue.push( tile );
-#else
-    tile->load( tile_path, true );
-#endif // ENABLE_THREADS
+    tile_load_queue.push( tile );
 }
 
 /**
@@ -97,9 +96,20 @@ void
 FGTileLoader::update()
 {
 #ifdef ENABLE_THREADS
+    // send a signal to the pager thread that it is allowed to load
+    // another tile
     mutex.lock();
     frame_cond.signal();
     mutex.unlock();
+#else
+    if ( !tile_load_queue.empty() ) {
+        cout << "loading next tile ..." << endl;
+        // load the next tile in the queue
+        FGTileEntry* tile = tile_load_queue.front();
+        tile_load_queue.pop();
+        tile->load( tile_path, true );
+        FGTileMgr::loaded( tile );
+    }
 #endif // ENABLE_THREADS
 }
 
@@ -114,12 +124,12 @@ FGTileLoader::LoaderThread::run()
     pthread_cleanup_push( cleanup_handler, loader );
     while ( true ) {
        // Wait for a load request to be placed in the queue.
-       FGTileEntry* tile = loader->tile_queue.pop();
+       FGTileEntry* tile = loader->tile_load_queue.pop();
 
         // Wait for the next frame signal before we load a tile from the queue
-        // loader->mutex.lock();
-        // loader->frame_cond.wait( loader->mutex );
-        // loader->mutex.unlock();
+        loader->mutex.lock();
+        loader->frame_cond.wait( loader->mutex );
+        loader->mutex.unlock();
 
        set_cancel( SGThread::CANCEL_DISABLE );
        tile->load( loader->tile_path, true );