Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/collide/collisionRecorder.cxx

Go to the documentation of this file.
00001 // Filename: collisionRecorder.cxx
00002 // Created by:  drose (16Apr03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "collisionRecorder.h"
00020 #include "collisionTraverser.h"
00021 
00022 #ifdef DO_COLLISION_RECORDING
00023 
00024 TypeHandle CollisionRecorder::_type_handle;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: CollisionRecorder::Constructor
00028 //       Access: Protected
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 CollisionRecorder::
00032 CollisionRecorder() {
00033   _num_missed = 0;
00034   _num_detected = 0;
00035   _trav = (CollisionTraverser *)NULL;
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: CollisionRecorder::Destructor
00040 //       Access: Public, Virtual
00041 //  Description:
00042 ////////////////////////////////////////////////////////////////////
00043 CollisionRecorder::
00044 ~CollisionRecorder() {
00045   if (_trav != (CollisionTraverser *)NULL) {
00046     _trav->clear_recorder();
00047   }
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: CollisionRecorder::output
00052 //       Access: Public
00053 //  Description: 
00054 ////////////////////////////////////////////////////////////////////
00055 void CollisionRecorder::
00056 output(ostream &out) const {
00057   out << "tested " << _num_missed + _num_detected << ", detected "
00058       << _num_detected << "\n";
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: CollisionRecorder::begin_traversal
00063 //       Access: Public, Virtual
00064 //  Description: This method is called at the beginning of a
00065 //               CollisionTraverser::traverse() call.  It is provided
00066 //               as a hook for the derived class to reset its state as
00067 //               appropriate.
00068 ////////////////////////////////////////////////////////////////////
00069 void CollisionRecorder::
00070 begin_traversal() {
00071   _num_missed = 0;
00072   _num_detected = 0;
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: CollisionRecorder::collision_tested
00077 //       Access: Public, Virtual
00078 //  Description: This method is called when a pair of collision solids
00079 //               have passed all bounding-volume tests and have been
00080 //               tested for a collision.  The detected value is set
00081 //               true if a collision was detected, false otherwise.
00082 ////////////////////////////////////////////////////////////////////
00083 void CollisionRecorder::
00084 collision_tested(const CollisionEntry &entry, bool detected) {
00085   if (detected) {
00086     _num_detected++;
00087   } else {
00088     _num_missed++;
00089   }
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: CollisionRecorder::end_traversal
00094 //       Access: Public, Virtual
00095 //  Description: This method is called at the end of a
00096 //               CollisionTraverser::traverse() call.  It is provided
00097 //               as a hook for the derived class to finalize its state
00098 //               as appropriate.
00099 ////////////////////////////////////////////////////////////////////
00100 void CollisionRecorder::
00101 end_traversal() {
00102 }
00103 
00104 #endif  // DO_COLLISION_RECORDING

Generated on Fri May 2 00:35:42 2003 for Panda by doxygen1.3