From fab0fccc0aaa18e915bcd08e81e5a04177e435cd Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 21 Oct 2024 19:06:58 +0200 Subject: fix quad tree collision checker --- ViewController.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'ViewController.cpp') diff --git a/ViewController.cpp b/ViewController.cpp index 3b298db..7f3fdfc 100644 --- a/ViewController.cpp +++ b/ViewController.cpp @@ -1,8 +1,9 @@ #include #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 tree = this->museum.collision.get_quadtree(); - this->update_quadtree_recursive(tree.get()); + shared_ptr checker = this->museum.collision.get_checker(); + auto tree = dynamic_cast(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) { -- cgit v1.2.3