UGDK
|
00001 #ifndef PYRAMIDWORKS_COLLISION_COLLISIONMANAGER_H_ 00002 #define PYRAMIDWORKS_COLLISION_COLLISIONMANAGER_H_ 00003 00004 #include <string> 00005 #include <map> 00006 #include <set> 00007 #include <ugdk/util/intervalkdtree.h> 00008 #include <pyramidworks/collision.h> 00009 #include <ugdk/action.h> 00010 #include <ugdk/util/uncopyable.h> 00011 00012 namespace pyramidworks { 00013 namespace collision { 00014 00017 class CollisionManager : public ugdk::util::Uncopyable { 00018 public: 00019 CollisionManager(const ugdk::ikdtree::Box<2>& tree_bounding_box); 00020 ~CollisionManager(); 00021 00023 void Generate(const std::string &name); 00024 void Generate(const char n[]) { const std::string str(n); Generate(str); } 00025 00027 void Generate(const std::string &name, const std::string &parent); 00028 void Generate(const char n[], const char p[]) { 00029 const std::string name(n), parent(p); 00030 Generate(name, parent); 00031 } 00032 00034 00037 CollisionClass* Get(const std::string &name) { return cache_[name]; } 00038 CollisionClass* Get(const char n[]) { const std::string str(n); return Get(str); } 00039 00040 void AddActiveObject(const CollisionObject* obj) { active_objects_.insert(obj); } 00041 void RemoveActiveObject(const CollisionObject* obj) { active_objects_.erase(obj); } 00042 00044 ugdk::action::Task* GenerateHandleCollisionTask(); 00045 00046 private: 00047 const ugdk::ikdtree::Box<2> tree_bounding_box_; 00048 std::map<std::string, CollisionClass*> cache_; 00049 std::set<const CollisionObject*> active_objects_; 00050 }; 00051 00052 } // namespace collision 00053 } // namespace pyramidworks 00054 00055 #endif /* PYRAMIDWORKS_COLLISION_COLLISIONMANAGER_H_ */