00001 // Filename: physxRaycastReport.cxx 00002 // Created by: enn0x (21Oct09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "physxRaycastReport.h" 00016 #include "physxRaycastHit.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: PhysxRaycastReport::onRaycast 00020 // Access: Public 00021 // Description: 00022 //////////////////////////////////////////////////////////////////// 00023 bool PhysxRaycastReport:: 00024 onHit(const NxRaycastHit& hit) { 00025 00026 _hits.push_back(PhysxRaycastHit(hit)); 00027 return true; 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: PhysxRaycastReport::get_num_hits 00032 // Access: Published 00033 // Description: 00034 //////////////////////////////////////////////////////////////////// 00035 unsigned int PhysxRaycastReport:: 00036 get_num_hits() const { 00037 00038 return _hits.size(); 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: PhysxRaycastReport::get_first_hit 00043 // Access: Published 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 PhysxRaycastHit PhysxRaycastReport:: 00047 get_first_hit() { 00048 00049 _iterator = _hits.begin(); 00050 return get_next_hit(); 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: PhysxRaycastReport::get_next_hit 00055 // Access: Published 00056 // Description: 00057 //////////////////////////////////////////////////////////////////// 00058 PhysxRaycastHit PhysxRaycastReport:: 00059 get_next_hit() { 00060 00061 if (_iterator != _hits.end()) { 00062 return *_iterator++; 00063 } 00064 00065 // No more items. Return an empty hit. 00066 NxRaycastHit hit; 00067 hit.shape = NULL; 00068 return PhysxRaycastHit(hit); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PhysxRaycastReport::get_hit 00073 // Access: Published 00074 // Description: 00075 //////////////////////////////////////////////////////////////////// 00076 PhysxRaycastHit PhysxRaycastReport:: 00077 get_hit(unsigned int idx) { 00078 00079 if (!(idx < _hits.size())) 00080 { 00081 // Index out of bounds. Return an empty hit. 00082 NxRaycastHit hit; 00083 hit.shape = NULL; 00084 return PhysxRaycastHit(hit); 00085 } 00086 00087 return _hits[idx]; 00088 } 00089