Panda3D
|
00001 // Filename: collisionHandlerQueue.h 00002 // Created by: drose (16Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef COLLISIONHANDLERQUEUE_H 00016 #define COLLISIONHANDLERQUEUE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "collisionHandler.h" 00021 #include "collisionEntry.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : CollisionHandlerQueue 00025 // Description : A special kind of CollisionHandler that does nothing 00026 // except remember the CollisionEntries detected the 00027 // last pass. This set of CollisionEntries may then be 00028 // queried by the calling function. It's primarily 00029 // useful when a simple intersection test is being made, 00030 // e.g. for picking from the window. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA_COLLIDE CollisionHandlerQueue : public CollisionHandler { 00033 PUBLISHED: 00034 CollisionHandlerQueue(); 00035 00036 public: 00037 virtual void begin_group(); 00038 virtual void add_entry(CollisionEntry *entry); 00039 00040 PUBLISHED: 00041 void sort_entries(); 00042 void clear_entries(); 00043 00044 int get_num_entries() const; 00045 CollisionEntry *get_entry(int n) const; 00046 MAKE_SEQ(get_entries, get_num_entries, get_entry); 00047 00048 void output(ostream &out) const; 00049 void write(ostream &out, int indent_level = 0) const; 00050 00051 private: 00052 typedef pvector< PT(CollisionEntry) > Entries; 00053 Entries _entries; 00054 00055 public: 00056 static TypeHandle get_class_type() { 00057 return _type_handle; 00058 } 00059 static void init_type() { 00060 CollisionHandler::init_type(); 00061 register_type(_type_handle, "CollisionHandlerQueue", 00062 CollisionHandler::get_class_type()); 00063 } 00064 virtual TypeHandle get_type() const { 00065 return get_class_type(); 00066 } 00067 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00068 00069 private: 00070 static TypeHandle _type_handle; 00071 }; 00072 00073 INLINE ostream &operator << (ostream &out, const CollisionHandlerQueue &chq) { 00074 chq.output(out); 00075 return out; 00076 } 00077 00078 #endif 00079 00080 00081