Panda3D
collisionHandlerQueue.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file collisionHandlerQueue.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef COLLISIONHANDLERQUEUE_H
15 #define COLLISIONHANDLERQUEUE_H
16 
17 #include "pandabase.h"
18 
19 #include "collisionHandler.h"
20 #include "collisionEntry.h"
21 
22 /**
23  * A special kind of CollisionHandler that does nothing except remember the
24  * CollisionEntries detected the last pass. This set of CollisionEntries may
25  * then be queried by the calling function. It's primarily useful when a
26  * simple intersection test is being made, e.g. for picking from the window.
27  */
28 class EXPCL_PANDA_COLLIDE CollisionHandlerQueue : public CollisionHandler {
29 PUBLISHED:
31 
32 public:
33  virtual void begin_group();
34  virtual void add_entry(CollisionEntry *entry);
35 
36 PUBLISHED:
37  void sort_entries();
38  void clear_entries();
39 
40  int get_num_entries() const;
41  CollisionEntry *get_entry(int n) const;
42  MAKE_SEQ(get_entries, get_num_entries, get_entry);
43  MAKE_SEQ_PROPERTY(entries, get_num_entries, get_entry);
44 
45  void output(std::ostream &out) const;
46  void write(std::ostream &out, int indent_level = 0) const;
47 
48 private:
49  typedef pvector< PT(CollisionEntry) > Entries;
50  Entries _entries;
51 
52 public:
53  static TypeHandle get_class_type() {
54  return _type_handle;
55  }
56  static void init_type() {
57  CollisionHandler::init_type();
58  register_type(_type_handle, "CollisionHandlerQueue",
59  CollisionHandler::get_class_type());
60  }
61  virtual TypeHandle get_type() const {
62  return get_class_type();
63  }
64  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
65 
66 private:
67  static TypeHandle _type_handle;
68 };
69 
70 INLINE std::ostream &operator << (std::ostream &out, const CollisionHandlerQueue &chq) {
71  chq.output(out);
72  return out;
73 }
74 
75 #endif
The abstract interface to a number of classes that decide what to do when a collision is detected.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a single collision event.
A special kind of CollisionHandler that does nothing except remember the CollisionEntries detected th...
virtual void begin_group()
Will be called by the CollisionTraverser before a new traversal is begun.
virtual void add_entry(CollisionEntry *entry)
Called between a begin_group() .
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81