trpage_managers.h
来自「最新osg包」· C头文件 代码 · 共 525 行 · 第 1/2 页
H
525 行
protected: trpgr_Archive *archive; // Center of paging trpg2dPoint pagePt; /* Information associated with each terrain level of detail as related to paging. */ TX_EXDECL class TX_CLDECL LodPageInfo { friend class trpgPageManager; public: LodPageInfo(void); virtual ~LodPageInfo(void); /* Initializes the class with its current LOD. It figures out all the rest. */ virtual bool Init(trpgr_Archive *, int myLod, double scale, int freeListDivider = 1); /* Reset the location. This forces a recalculation of what to load and unload if the cell has changed or if this is the first SetLocation. The location passed in must be relative to the southwest corner of the TerraPage archive. */ virtual bool SetLocation(trpg2dPoint &); // Return the next tile to load for this terrain lod virtual trpgManagedTile *GetNextLoad(void); // Acknowledge the load. Move the active tile to the // loaded list. virtual void AckLoad(); // Get the lsit of //bool GetLoadedTile // Return the next tile to unload for this terrain lod virtual trpgManagedTile *GetNextUnload(void); // Acknowledge the unload. Move the active tile to the // free list. virtual void AckUnload(void); // Called to stop paging. Everything active is dumped on // the unload list. virtual bool Stop(void); // Print current status and content information virtual void Print(trpgPrintBuffer &); const trpg2iPoint& GetLodSize() const { return lodSize; } int GetLod() const { return lod; } double GetPageDistance() const { return pageDist; } const trpg2dPoint& GetCellSize() const { return cellSize; } // The unit are cellSize const trpg2iPoint& GetAreaOfInterest() const { return aoiSize; } // The middle of this cell correspond to our paging // location const trpg2iPoint& GetCellPagingLocation() const { return cell; } protected: virtual void Clean(void); virtual void Update(void); // Add to the load list the given tile if it is within the proper // bound bool AddToLoadList(int x, int y, const trpgwAppAddress& addr); // Add the children of the given parent list // to the load list if it it not already loaded // or if it is not already in the list void AddChildrenToLoadList(std::vector<trpgManagedTile*>& parentList); // Check if the given tile is within the area we care about bool isWithin(trpgManagedTile *,trpg2iPoint &sw,trpg2iPoint &ne); // Get the list of currently loaded tiles that fall within // the region calculated from the given paging distance. void GetLoadedTileWithin(double pagingDistance, std::vector<trpgManagedTile*>& tileList); bool valid; // Terrain LOD we're responsible for int lod; /* Adjusted (e.g. paranoid) distance outward from which to page this terrain LOD. This takes into account the distance in the header as well as any factor the user may have added. */ double pageDist; /* Max tiles we could have loaded in at any given time. This is just a guess because it's up to the user to load (and, more importantly) unload. */ int maxNumTiles; // Size of a single cell. Copied from the archive. trpg2dPoint cellSize; // Number of tiles (cells) in each direction trpg2iPoint lodSize; /* Area of interest size in cells This is a linear distance "ahead" of the center cell. */ trpg2iPoint aoiSize; /* Our effective paging location sits at the middle of this cell. We don't recalculate unless the cell changes. */ trpg2iPoint cell; // List of tiles to load std::deque<trpgManagedTile *> load; // List of tiles to unload std::deque<trpgManagedTile *> unload; // List of currently loaded tiles std::deque<trpgManagedTile *> current; // Used by Update. Here because we want to avoid memory allocs, if possible. std::vector<bool> tmpCurrent; // Set if a load is in progress // Load w/o ACK bool activeLoad; // Set if an unload is in progress // Unload w/o ACK bool activeUnload; // List of tile pointers we can reuse std::deque<trpgManagedTile *> freeList; // TerraPage version int majorVersion, minorVersion; const trpgTileTable *tileTable; }; // Per terrain lod paging information std::vector<LodPageInfo> pageInfo; // Enumerated type for lastLoad typedef enum {Load,Unload,None} LoadType; /* Information about what the pending load/unload operation is. It's up to the user to complete and acknowledge it. */ LoadType lastLoad; // LOD for the pending load/unload requested operation int lastLod; // Tile to be loaded/unloaded trpgManagedTile *lastTile; // Optional scaling factor double scale; // Mapping from group IDs to user defined data typedef std::map<int,void *> ManageGroupMap; ManageGroupMap groupMap; // Terrapge Version int majorVersion, minorVersion; bool valid;};// For Version 2.1 an over, the tile table only contains// tiles of lod 0. To get access the other tiles, parent tile// must be parsed to get at trpgChildRef nodes that will contain// location info about the children. This callback can be use to// parse the tile data. After parsing the callback object will contain// the list of trpgChildRef nodes found.TX_EXDECL class TX_CLDECL trpgr_ChildRefCB : public trpgr_Callback{ public: void *Parse(trpgToken tok, trpgReadBuffer& rbuf); // After parsing this will return the number of trpgChildRef node found. unsigned int GetNbChildren() const; // This will return the trpgChildRef node associated with the index. // Will throw an exception if the index is out of bound const trpgChildRef& GetChildRef(unsigned int idx) const; // Clear the children list void Reset(); protected:// typedef std::vector<const trpgChildRef> ChildList;// The const in the template parameter was removed because it causes GCC to // freak out. I am of the opinion that const doesn't make sense in a template // parameter for std::vector anyway... const prevents you from changing the // value, so what exactly is the point? How does one add entries to the vector // without giving them a value? -ADS typedef std::vector<trpgChildRef> ChildList; ChildList childList;};/* Page Manager Tester. This class tests a given paging manager by applying likely */TX_EXDECL class TX_CLDECL trpgPageManageTester{ public: trpgPageManageTester(); virtual ~trpgPageManageTester(); /* Initialize the tester with a paging manager and an archive. */ void Init(trpgPrintBuffer *,trpgPageManager *,trpgr_Archive *); /* Feeds the paging manager coordinates starting from the lower left to upper right of the database in the given increment. */ void Fly_LL_to_UR(double dist=100.0); /* Jumps around randomly within the archive loading and unloading as needed. */ void RandomTest(int no=100,int seed=-1); protected: // Does the work of "load" and "unloading" void ProcessChanges(); trpgPageManager *manager; trpgr_Archive *archive; trpgPrintBuffer *printBuf; trpgr_ChildRefCB childRefCB; trpgr_Parser tileParser; // TerraPage version int majorVersion, minorVersion;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?