Panda3D
physxOverlapReport.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 physxOverlapReport.cxx
10  * @author enn0x
11  * @date 2009-10-21
12  */
13 
14 #include "physxOverlapReport.h"
15 #include "physxShape.h"
16 
17 /**
18  *
19  */
20 bool PhysxOverlapReport::
21 onEvent(NxU32 nbEntities, NxShape **entities) {
22 
23  for (unsigned int i=0; i<nbEntities; i++) {
24  PhysxShape *shape = (PhysxShape *)entities[i]->userData;
25  _overlaps.push_back(shape);
26  }
27 
28  return true;
29 }
30 
31 /**
32  *
33  */
34 unsigned int PhysxOverlapReport::
35 get_num_overlaps() const {
36 
37  return _overlaps.size();
38 }
39 
40 /**
41  *
42  */
43 PhysxShape *PhysxOverlapReport::
44 get_first_overlap() {
45 
46  _iterator = _overlaps.begin();
47  return get_next_overlap();
48 }
49 
50 /**
51  *
52  */
53 PhysxShape *PhysxOverlapReport::
54 get_next_overlap() {
55 
56  if (_iterator != _overlaps.end()) {
57  return *_iterator++;
58  }
59 
60  // No more items. Return empty overlap.
61  return nullptr;
62 }
63 
64 /**
65  *
66  */
67 PhysxShape *PhysxOverlapReport::
68 get_overlap(unsigned int idx) {
69 
70  nassertr(idx < get_num_overlaps(), nullptr);
71  return _overlaps[idx];
72 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Abstract base class for shapes.
Definition: physxShape.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.