Panda3D
Loading...
Searching...
No Matches
collisionRecorder.cxx
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.cxx
10 * @author drose
11 * @date 2003-04-16
12 */
13
14#include "collisionRecorder.h"
15#include "collisionTraverser.h"
16
17#ifdef DO_COLLISION_RECORDING
18
19TypeHandle CollisionRecorder::_type_handle;
20
21/**
22 *
23 */
24CollisionRecorder::
25CollisionRecorder() {
26 _num_missed = 0;
27 _num_detected = 0;
28 _trav = nullptr;
29}
30
31/**
32 *
33 */
34CollisionRecorder::
35~CollisionRecorder() {
36 if (_trav != nullptr) {
37 _trav->clear_recorder();
38 }
39}
40
41/**
42 *
43 */
44void CollisionRecorder::
45output(std::ostream &out) const {
46 out << "tested " << _num_missed + _num_detected << ", detected "
47 << _num_detected << "\n";
48}
49
50/**
51 * This method is called at the beginning of a CollisionTraverser::traverse()
52 * call. It is provided as a hook for the derived class to reset its state as
53 * appropriate.
54 */
55void CollisionRecorder::
56begin_traversal() {
57 _num_missed = 0;
58 _num_detected = 0;
59}
60
61/**
62 * This method is called when a pair of collision solids have passed all
63 * bounding-volume tests and have been tested for a collision. The detected
64 * value is set true if a collision was detected, false otherwise.
65 */
66void CollisionRecorder::
67collision_tested(const CollisionEntry &entry, bool detected) {
68 if (detected) {
69 _num_detected++;
70 } else {
71 _num_missed++;
72 }
73}
74
75/**
76 * This method is called at the end of a CollisionTraverser::traverse() call.
77 * It is provided as a hook for the derived class to finalize its state as
78 * appropriate.
79 */
80void CollisionRecorder::
81end_traversal() {
82}
83
84#endif // DO_COLLISION_RECORDING
Defines a single collision event.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.