osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 00004 * http://osgearth.org 00005 * 00006 * osgEarth is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 #ifndef OSGEARTH_ENGINE_OSGTERRAIN_STREAMING_TERRAIN 00020 #define OSGEARTH_ENGINE_OSGTERRAIN_STREAMING_TERRAIN 1 00021 00022 #include "Terrain" 00023 #include "StreamingTile" 00024 #include <osgEarth/TaskService> 00025 00026 using namespace osgEarth; 00027 00031 class StreamingTerrain : public Terrain 00032 { 00033 public: 00034 StreamingTerrain( 00035 const MapFrame& update_mapf, 00036 const MapFrame& cull_mapf, 00037 OSGTileFactory* factory, 00038 bool quickReleaseGLObjects ); 00039 00040 virtual const char* libraryName() const { return "osgEarth"; } 00041 virtual const char* className() const { return "StreamingTerrain"; } 00042 00043 //override 00044 virtual Tile* createTile(const TileKey& key, GeoLocator* locator) const; 00045 00046 public: 00047 00048 TaskService* getImageryTaskService(int layerId); 00049 TaskService* getElevationTaskService(); 00050 TaskService* getTileGenerationTaskService(); 00051 00057 void updateTaskServiceThreads( const MapFrame& mapf ); 00058 00059 const LoadingPolicy& getLoadingPolicy() const { return _loadingPolicy; } 00060 00061 protected: 00062 00063 virtual ~StreamingTerrain(); 00064 00065 //override 00066 virtual unsigned getNumActiveTasks() const; 00067 00068 //override 00069 virtual void updateTraversal( osg::NodeVisitor& nv ); 00070 00071 private: 00072 00073 TaskService* createTaskService( const std::string& name, int id, int numThreads ); 00074 TaskService* getTaskService( int id ); 00075 00076 void refreshFamily( const MapInfo& info, const TileKey& key, StreamingTile::Relative* family, bool tileTableLocked ); 00077 00078 typedef std::map< int, osg::ref_ptr< TaskService > > TaskServiceMap; 00079 00080 TaskServiceMap _taskServices; 00081 OpenThreads::Mutex _taskServiceMutex; 00082 int _numLoadingThreads; 00083 LoadingPolicy _loadingPolicy; 00084 UID _elevationTaskServiceUID; 00085 }; 00086 00087 #endif // OSGEARTH_ENGINE_OSGTERRAIN_STREAMING_TERRAIN