summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-04-01 15:53:14 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-04-01 15:53:14 +0200
commit3b360c21777aad02394a643b32be2ab25362bba1 (patch)
treee5a3ed2c546e31c9e83170c53fc75c0016169384 /main.cpp
parentbd22509aa429c6f33075293e379f1e2b2714a094 (diff)
Some cleanup in preparation for dynamic subdivision of the terrain quadtree.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 36ddb10..9f3bf15 100644
--- a/main.cpp
+++ b/main.cpp
@@ -198,14 +198,14 @@ int main(int argc, char **argv) {
grid = !grid;
break;
case SDLK_KP_PLUS:
- delete qt;
- qt = new Quadtree(hm->w, hm->h, heightmap, ++level);
+ case SDLK_PLUS:
+ qt->create_nodes(++level);
level = qt->levels;
break;
case SDLK_KP_MINUS:
+ case SDLK_MINUS:
if(level > 0) {
- delete qt;
- qt = new Quadtree(hm->w, hm->h, heightmap, --level);
+ qt->create_nodes(--level);
}
break;
case SDLK_SPACE:
@@ -278,21 +278,19 @@ int main(int argc, char **argv) {
scene.move(forward, right, steps*(keystate[SDLK_LSHIFT]?10:1));
std::string move_str;
- {
- Quadtree::QuadNode *node = qt->find(scene.pos.x, scene.pos.z);
- if(node) {
- float y = node->get_height(scene.pos.x, scene.pos.z);
- if(scene.pos.y > y && !keystate[SDLK_e])
- scene.yvel -= 9.81 * steps / 85000;
- if(scene.yvel < -.5)
- scene.yvel = -.5;
- scene.pos.y += scene.yvel * steps;
- if(scene.pos.y < y) {
- scene.pos.y = y;
- scene.yvel = 0;
- }
- move_str = (boost::format("%s %.2f,%.2f %dx%d") % scene.pos.str() % node->x % node->y % node->width % node->height).str();
+ Quadtree::QuadNode *node = qt->find(scene.pos.x, scene.pos.z);
+ if(node) {
+ float y = node->get_height(scene.pos.x, scene.pos.z);
+ if(scene.pos.y > y && !keystate[SDLK_e])
+ scene.yvel -= 9.81 * steps / 85000;
+ if(scene.yvel < -.5)
+ scene.yvel = -.5;
+ scene.pos.y += scene.yvel * steps;
+ if(scene.pos.y < y) {
+ scene.pos.y = y;
+ scene.yvel = 0;
}
+ move_str = (boost::format("%s %.2f,%.2f %dx%d %d") % scene.pos.str() % node->x % node->y % node->width % node->height % node->level).str();
}
scene.lookat();