RTS2D
|
00001 /* Codigo baseado do site: 00002 http://gamedev.tutsplus.com/tutorials/implementation/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space/ */ 00003 00004 #ifndef QUADTREE_H 00005 #include <vector> 00006 #include "Unit.h" 00007 #include "Rect.h" 00008 #define QUADTREE_H 00009 00013 class Quadtree { 00014 public: 00015 Quadtree(int pLevel, Rect* pBounds); 00016 virtual ~Quadtree(); 00017 Rect* getBounds(); 00018 Quadtree** getNodes(); 00019 std::vector<Unit*> getObjects(); 00020 00021 void insert(Unit* unit); 00022 void split(); 00023 void clear(); 00024 int getIndex(Unit* unit); 00025 std::vector<Unit*> retrieve(std::vector<Unit*> returnObjects, Unit* unit); 00026 00027 protected: 00028 private: 00029 int MAX_OBJECTS; 00030 int MAX_LEVELS; 00031 int level; 00032 Rect* bounds; 00033 Quadtree** nodes; 00034 std::vector<Unit*> objects; 00035 00036 }; 00037 00038 #endif // QUADTREE_H