aboutsummaryrefslogtreecommitdiff
path: root/ViewController.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-21 19:06:58 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-21 19:06:58 +0200
commitfab0fccc0aaa18e915bcd08e81e5a04177e435cd (patch)
tree0e8e51ff61c88b60d1f845bc9fde20ea5ba7099b /ViewController.cpp
parent10ce9f45b9551dc103272c2b2374db1c1e3b8bcb (diff)
fix quad tree collision checker
Diffstat (limited to 'ViewController.cpp')
-rw-r--r--ViewController.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/ViewController.cpp b/ViewController.cpp
index 3b298db..7f3fdfc 100644
--- a/ViewController.cpp
+++ b/ViewController.cpp
@@ -1,8 +1,9 @@
#include <memory>
#include "ViewController.h"
-#include "QuadTree.h"
-#include "ToggleArtistVisibilityCommand.h"
+#include "CollisionChecker.h"
+#include "ControlBooleanCommand.h"
+#include "QuadTreeCollisionChecker.h"
#include "Exception.h"
#include "KeyboardCode.h"
#include "MouseCode.h"
@@ -67,7 +68,7 @@ void ViewController::update_artists() {
void ViewController::update_pathfinding() {
}
-void ViewController::update_quadtree_recursive(QuadTree * tree) {
+void ViewController::update_quadtree_recursive(QuadTreeCollisionChecker * tree) {
if (tree == nullptr) return;
const Rectangle & tree_boundary = tree->get_boundary();
@@ -86,8 +87,10 @@ void ViewController::update_quadtree_recursive(QuadTree * tree) {
}
void ViewController::update_quadtree() {
- shared_ptr<QuadTree> tree = this->museum.collision.get_quadtree();
- this->update_quadtree_recursive(tree.get());
+ shared_ptr<CollisionChecker> checker = this->museum.collision.get_checker();
+ auto tree = dynamic_cast<QuadTreeCollisionChecker*>(checker.get());
+ if (tree == nullptr) return;
+ this->update_quadtree_recursive(tree);
}
void ViewController::ev_keydown(KeyboardCode key) {
@@ -106,7 +109,7 @@ void ViewController::ev_keydown(KeyboardCode key) {
break;
}
case KEY_A: {
- ToggleArtistVisibilityCommand(*this).execute();
+ ControlBooleanCommand(this->draw_artists).execute();
break;
}
case KEY_LEFT: {
@@ -117,6 +120,14 @@ void ViewController::ev_keydown(KeyboardCode key) {
TimeTravelCommand(this->museum, true).execute();
break;
}
+ case KEY_C: {
+ // CycleCollisionMethodCommand(this->museum).execute();
+ break;
+ }
+ case KEY_Q: {
+ ControlBooleanCommand(this->draw_quadtree).execute();
+ break;
+ }
default: break;
}
} catch (Exception & e) {