#ifndef TERRAIN_CACHE_H #define TERRAIN_CACHE_H #include "terrain_loader.h" #include "vector.h" #include #include #include class TerrainCache; struct TerrainCacheObject { typedef boost::shared_ptr p; TerrainCache *cache; float *heights; // FIXME: Support other object types. std::list objects; int64_t x, y; unsigned int width, height; TerrainCacheObject(TerrainCache *cache, int64_t x, int64_t y, unsigned int width, unsigned int height, float *heights = NULL, std::list *objects = NULL); virtual ~TerrainCacheObject(); }; class TerrainCache { friend class TerrainCacheObject; private: typedef std::pair intpair; typedef std::map cache_map; cache_map caches; size_t max_size; TerrainCacheObject::p make_object(int64_t x, int64_t y, unsigned int width, unsigned int height, float *heights = NULL); public: typedef boost::shared_ptr p; TerrainCache(fs::path root, size_t max_size); TerrainCache(TerrainLoader::p loader, size_t max_size); virtual ~TerrainCache(); TerrainLoader::p tl; TerrainCacheObject::p get_chunk(int64_t x, int64_t y, unsigned int width, unsigned int height); void add_chunk(float *heights, int64_t x, int64_t y, unsigned int width, unsigned int height); size_t get_size(); }; #endif