1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qcollisionqueryresult_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DRender { |
9 | namespace RayCasting { |
10 | |
11 | QCollisionQueryResultPrivate::QCollisionQueryResultPrivate() |
12 | : QSharedData() |
13 | , m_handle(0) |
14 | { |
15 | } |
16 | |
17 | QCollisionQueryResultPrivate::QCollisionQueryResultPrivate(const QCollisionQueryResultPrivate ©) |
18 | : QSharedData(copy) |
19 | , m_handle(copy.m_handle) |
20 | , m_hits(copy.m_hits) |
21 | { |
22 | } |
23 | |
24 | void QCollisionQueryResultPrivate::addEntityHit(Qt3DCore::QNodeId entity, const Vector3D& intersection, |
25 | float distance, const Vector3D& uvw) |
26 | { |
27 | m_hits.emplace_back(args&: entity, args: intersection, args&: distance, args: uvw); |
28 | } |
29 | |
30 | void QCollisionQueryResultPrivate::setHandle(const QQueryHandle &handle) |
31 | { |
32 | m_handle = handle; |
33 | } |
34 | |
35 | QCollisionQueryResult::QCollisionQueryResult() |
36 | : d_ptr(new QCollisionQueryResultPrivate()) |
37 | { |
38 | } |
39 | |
40 | QCollisionQueryResult::QCollisionQueryResult(const QCollisionQueryResult &result) |
41 | : d_ptr(result.d_ptr) |
42 | { |
43 | } |
44 | |
45 | QCollisionQueryResult::~QCollisionQueryResult() |
46 | { |
47 | } |
48 | |
49 | QCollisionQueryResult &QCollisionQueryResult::operator=(const QCollisionQueryResult &result) |
50 | { |
51 | d_ptr = result.d_ptr; |
52 | return *this; |
53 | } |
54 | |
55 | const std::vector<QCollisionQueryResult::Hit> &QCollisionQueryResult::hits() const |
56 | { |
57 | Q_D(const QCollisionQueryResult); |
58 | return d->m_hits; |
59 | } |
60 | |
61 | std::vector<Qt3DCore::QNodeId> QCollisionQueryResult::entitiesHit() const |
62 | { |
63 | Q_D(const QCollisionQueryResult); |
64 | std::vector<Qt3DCore::QNodeId> result; |
65 | result.reserve(n: d->m_hits.size()); |
66 | for (const Hit& hit : d->m_hits) |
67 | result.push_back(x: hit.m_entityId); |
68 | return result; |
69 | } |
70 | |
71 | /*! |
72 | \internal |
73 | */ |
74 | QCollisionQueryResult::QCollisionQueryResult(QCollisionQueryResultPrivate &p) |
75 | : d_ptr(&p) |
76 | { |
77 | } |
78 | |
79 | /*! |
80 | \internal |
81 | */ |
82 | QCollisionQueryResultPrivate *QCollisionQueryResult::d_func() |
83 | { |
84 | return d_ptr.data(); |
85 | } |
86 | |
87 | QQueryHandle QCollisionQueryResult::handle() const |
88 | { |
89 | Q_D(const QCollisionQueryResult); |
90 | return d->m_handle; |
91 | } |
92 | |
93 | } // RayCasting |
94 | } // Qt3DRender |
95 | |
96 | QT_END_NAMESPACE |
97 |