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 #include "extension.h"
22 
23 /**
24  * A special kind of CollisionHandler that does nothing except remember the
25  * CollisionEntries detected the last pass. This set of CollisionEntries may
26  * then be queried by the calling function. It's primarily useful when a
27  * simple intersection test is being made, e.g. for picking from the window.
28  */
29 class EXPCL_PANDA_COLLIDE CollisionHandlerQueue : public CollisionHandler {
30 PUBLISHED:
32 
33 public:
34  virtual void begin_group();
35  virtual void add_entry(CollisionEntry *entry);
36 
37 PUBLISHED:
38  void sort_entries();
39  void clear_entries();
40 
41  int get_num_entries() const;
42  CollisionEntry *get_entry(int n) const;
43  MAKE_SEQ(get_entries, get_num_entries, get_entry);
44  MAKE_SEQ_PROPERTY(entries, get_num_entries, get_entry);
45 
46  void output(std::ostream &out) const;
47  void write(std::ostream &out, int indent_level = 0) const;
48 
49  EXTENSION(PyObject *__reduce__(PyObject *self) const);
50 
51 private:
52  typedef pvector< PT(CollisionEntry) > Entries;
53  Entries _entries;
54 
55 public:
56  static TypeHandle get_class_type() {
57  return _type_handle;
58  }
59  static void init_type() {
60  CollisionHandler::init_type();
61  register_type(_type_handle, "CollisionHandlerQueue",
62  CollisionHandler::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 };
72 
73 INLINE std::ostream &operator << (std::ostream &out, const CollisionHandlerQueue &chq) {
74  chq.output(out);
75  return out;
76 }
77 
78 #endif
Defines a single collision event.
A special kind of CollisionHandler that does nothing except remember the CollisionEntries detected th...
The abstract interface to a number of classes that decide what to do when a collision is detected.
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
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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