Panda3D
 All Classes Functions Variables Enumerations
physxOverlapReport.cxx
00001 // Filename: physOverlapReport.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 "physxOverlapReport.h"
00016 #include "physxShape.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxOverlapReport::onEvent
00020 //       Access: Public
00021 //  Description: 
00022 ////////////////////////////////////////////////////////////////////
00023 bool PhysxOverlapReport::
00024 onEvent(NxU32 nbEntities, NxShape **entities) {
00025 
00026   for (unsigned int i=0; i<nbEntities; i++) {
00027     PhysxShape *shape = (PhysxShape *)entities[i]->userData;
00028     _overlaps.push_back(shape);
00029   }
00030 
00031   return true;
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: PhysxOverlapReport::get_num_overlaps
00036 //       Access: Published
00037 //  Description: 
00038 ////////////////////////////////////////////////////////////////////
00039 unsigned int PhysxOverlapReport::
00040 get_num_overlaps() const {
00041 
00042   return _overlaps.size();
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: PhysxOverlapReport::get_first_overlap
00047 //       Access: Published
00048 //  Description: 
00049 ////////////////////////////////////////////////////////////////////
00050 PhysxShape *PhysxOverlapReport::
00051 get_first_overlap() {
00052 
00053   _iterator = _overlaps.begin();
00054   return get_next_overlap();
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: PhysxOverlapReport::get_next_overlap
00059 //       Access: Published
00060 //  Description: 
00061 ////////////////////////////////////////////////////////////////////
00062 PhysxShape *PhysxOverlapReport::
00063 get_next_overlap() {
00064 
00065   if (_iterator != _overlaps.end()) {
00066     return *_iterator++;
00067   }
00068 
00069   // No more items. Return empty overlap.
00070   return NULL;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: PhysxOverlapReport::get_overlap
00075 //       Access: Published
00076 //  Description: 
00077 ////////////////////////////////////////////////////////////////////
00078 PhysxShape *PhysxOverlapReport::
00079 get_overlap(unsigned int idx) {
00080 
00081   nassertr(idx < get_num_overlaps(), NULL);
00082   return _overlaps[idx];
00083 }
00084 
 All Classes Functions Variables Enumerations