summaryrefslogtreecommitdiff
path: root/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game.cpp')
-rw-r--r--game.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/game.cpp b/game.cpp
index 1288b0c..819b35c 100644
--- a/game.cpp
+++ b/game.cpp
@@ -171,9 +171,20 @@ void Game::handle_object() {
std::cerr << "got object for non-existing chunk, discarding" << std::endl;
return;
}
-
pos.y = chunk->find(pos.x, pos.z)->get_height(pos.x, pos.z);
- chunk->objects.push_back(Terrain::Chunk::ObjectPair(scene->tree, pos));
+
+ int64_t x = pos.x;
+ x -= x % Terrain::chunk_size;
+
+ int64_t z = pos.z;
+ z -= z % Terrain::chunk_size;
+
+ TerrainCacheObject::p ob = scene->terrain->tc->get_chunk(x, z, Terrain::chunk_size_total, Terrain::chunk_size_total);
+ ob->objects.push_back(pos);
+
+ models::ModelManager& model_mgr = models::ModelManager::get_instance();
+
+ chunk->objects.push_back(Terrain::Chunk::ObjectPair(model_mgr.get_model("tree"), pos));
}
Game& Game::get_instance() {
@@ -181,3 +192,10 @@ Game& Game::get_instance() {
game = new Game();
return *game;
}
+
+void Game::free() {
+ if(game) {
+ delete game;
+ game = NULL;
+ }
+}