diff options
Diffstat (limited to 'terrain_cache.cpp')
-rw-r--r-- | terrain_cache.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/terrain_cache.cpp b/terrain_cache.cpp index 01cc161..f0f757b 100644 --- a/terrain_cache.cpp +++ b/terrain_cache.cpp @@ -2,20 +2,28 @@ /* TerrainCacheObject */ -TerrainCacheObject::TerrainCacheObject(TerrainCache *cache, int64_t x, int64_t y, unsigned int width, unsigned int height, float *heights) { +TerrainCacheObject::TerrainCacheObject(TerrainCache *cache, int64_t x, int64_t y, unsigned int width, unsigned int height, + float *heights, std::list<Vector3> *objects) { this->cache = cache; this->x = x; this->y = y; this->width = width; this->height = height; + if(heights) this->heights = heights; else this->heights = cache->tl->get_chunk(x, y, width, height); + + if(objects) + this->objects.insert(this->objects.end(), objects->begin(), objects->end()); + else + this->objects = cache->tl->get_objects(x, y); } TerrainCacheObject::~TerrainCacheObject() { cache->tl->save_chunk(heights, x, y, width, height); + cache->tl->save_objects(objects, x, y); delete[] heights; } |