Panda3D
Loading...
Searching...
No Matches
physxRaycastReport.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 physxRaycastReport.cxx
10 * @author enn0x
11 * @date 2009-10-21
12 */
13
14#include "physxRaycastReport.h"
15#include "physxRaycastHit.h"
16
17/**
18 *
19 */
20bool PhysxRaycastReport::
21onHit(const NxRaycastHit& hit) {
22
23 _hits.push_back(PhysxRaycastHit(hit));
24 return true;
25}
26
27/**
28 *
29 */
30unsigned int PhysxRaycastReport::
31get_num_hits() const {
32
33 return _hits.size();
34}
35
36/**
37 *
38 */
39PhysxRaycastHit PhysxRaycastReport::
40get_first_hit() {
41
42 _iterator = _hits.begin();
43 return get_next_hit();
44}
45
46/**
47 *
48 */
49PhysxRaycastHit PhysxRaycastReport::
50get_next_hit() {
51
52 if (_iterator != _hits.end()) {
53 return *_iterator++;
54 }
55
56 // No more items. Return an empty hit.
57 NxRaycastHit hit;
58 hit.shape = nullptr;
59 return PhysxRaycastHit(hit);
60}
61
62/**
63 *
64 */
65PhysxRaycastHit PhysxRaycastReport::
66get_hit(unsigned int idx) {
67
68 if (!(idx < _hits.size()))
69 {
70 // Index out of bounds. Return an empty hit.
71 NxRaycastHit hit;
72 hit.shape = nullptr;
73 return PhysxRaycastHit(hit);
74 }
75
76 return _hits[idx];
77}
This structure captures results for a single raycast query.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.