Panda3D
collisionRecorder.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 collisionRecorder.h
10  * @author drose
11  * @date 2003-04-16
12  */
13 
14 #ifndef COLLISIONRECORDER_H
15 #define COLLISIONRECORDER_H
16 
17 #include "pandabase.h"
18 #include "typeHandle.h"
19 #include "typedObject.h"
20 
21 class CollisionTraverser;
22 class CollisionEntry;
23 
24 #ifdef DO_COLLISION_RECORDING
25 
26 /**
27  * This class is used to help debug the work the collisions system is doing.
28  * It is a virtual base class that just provides an interface for recording
29  * collisions tested and detected each frame.
30  */
31 class EXPCL_PANDA_COLLIDE CollisionRecorder : public TypedObject {
32 protected:
33  CollisionRecorder();
34 public:
35  virtual ~CollisionRecorder();
36 
37 PUBLISHED:
38  void output(std::ostream &out) const;
39 
40 public:
41  virtual void begin_traversal();
42  virtual void collision_tested(const CollisionEntry &entry, bool detected);
43  virtual void end_traversal();
44 
45 private:
46  int _num_missed;
47  int _num_detected;
48  CollisionTraverser *_trav;
49 
50 public:
51  static TypeHandle get_class_type() {
52  return _type_handle;
53  }
54  static void init_type() {
56  register_type(_type_handle, "CollisionRecorder",
57  TypedObject::get_class_type());
58  }
59  virtual TypeHandle get_type() const {
60  return get_class_type();
61  }
62  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
63 
64 private:
65  static TypeHandle _type_handle;
66 
67  friend class CollisionTraverser;
68 };
69 
70 #include "collisionRecorder.I"
71 
72 #endif // DO_COLLISION_RECORDING
73 
74 
75 #endif
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:44
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 an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a single collision event.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class manages the traversal through the scene graph to detect collisions.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81