Panda3D
 All Classes Functions Variables Enumerations
physxOverlapReport.cxx
1 // Filename: physOverlapReport.cxx
2 // Created by: enn0x (21Oct09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxOverlapReport.h"
16 #include "physxShape.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxOverlapReport::onEvent
20 // Access: Public
21 // Description:
22 ////////////////////////////////////////////////////////////////////
23 bool PhysxOverlapReport::
24 onEvent(NxU32 nbEntities, NxShape **entities) {
25 
26  for (unsigned int i=0; i<nbEntities; i++) {
27  PhysxShape *shape = (PhysxShape *)entities[i]->userData;
28  _overlaps.push_back(shape);
29  }
30 
31  return true;
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: PhysxOverlapReport::get_num_overlaps
36 // Access: Published
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 unsigned int PhysxOverlapReport::
40 get_num_overlaps() const {
41 
42  return _overlaps.size();
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: PhysxOverlapReport::get_first_overlap
47 // Access: Published
48 // Description:
49 ////////////////////////////////////////////////////////////////////
50 PhysxShape *PhysxOverlapReport::
51 get_first_overlap() {
52 
53  _iterator = _overlaps.begin();
54  return get_next_overlap();
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: PhysxOverlapReport::get_next_overlap
59 // Access: Published
60 // Description:
61 ////////////////////////////////////////////////////////////////////
62 PhysxShape *PhysxOverlapReport::
63 get_next_overlap() {
64 
65  if (_iterator != _overlaps.end()) {
66  return *_iterator++;
67  }
68 
69  // No more items. Return empty overlap.
70  return NULL;
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: PhysxOverlapReport::get_overlap
75 // Access: Published
76 // Description:
77 ////////////////////////////////////////////////////////////////////
78 PhysxShape *PhysxOverlapReport::
79 get_overlap(unsigned int idx) {
80 
81  nassertr(idx < get_num_overlaps(), NULL);
82  return _overlaps[idx];
83 }
84 
Abstract base class for shapes.
Definition: physxShape.h:41