Panda3D
panda
src
collide
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
19
TypeHandle
CollisionRecorder::_type_handle;
20
21
/**
22
*
23
*/
24
CollisionRecorder::
25
CollisionRecorder() {
26
_num_missed = 0;
27
_num_detected = 0;
28
_trav =
nullptr
;
29
}
30
31
/**
32
*
33
*/
34
CollisionRecorder::
35
~CollisionRecorder() {
36
if
(_trav !=
nullptr
) {
37
_trav->clear_recorder();
38
}
39
}
40
41
/**
42
*
43
*/
44
void
CollisionRecorder::
45
output(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
*/
55
void
CollisionRecorder::
56
begin_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
*/
66
void
CollisionRecorder::
67
collision_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
*/
80
void
CollisionRecorder::
81
end_traversal() {
82
}
83
84
#endif // DO_COLLISION_RECORDING
collisionTraverser.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CollisionEntry
Defines a single collision event.
Definition:
collisionEntry.h:42
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition:
typeHandle.h:81
collisionRecorder.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Generated on Wed Jan 23 2019 21:39:54 for Panda3D by
1.8.15