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
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DRender {
9namespace RayCasting {
10
11QCollisionQueryResultPrivate::QCollisionQueryResultPrivate()
12 : QSharedData()
13 , m_handle(0)
14{
15}
16
17QCollisionQueryResultPrivate::QCollisionQueryResultPrivate(const QCollisionQueryResultPrivate &copy)
18 : QSharedData(copy)
19 , m_handle(copy.m_handle)
20 , m_hits(copy.m_hits)
21{
22}
23
24void 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
30void QCollisionQueryResultPrivate::setHandle(const QQueryHandle &handle)
31{
32 m_handle = handle;
33}
34
35QCollisionQueryResult::QCollisionQueryResult()
36 : d_ptr(new QCollisionQueryResultPrivate())
37{
38}
39
40QCollisionQueryResult::QCollisionQueryResult(const QCollisionQueryResult &result)
41 : d_ptr(result.d_ptr)
42{
43}
44
45QCollisionQueryResult::~QCollisionQueryResult()
46{
47}
48
49QCollisionQueryResult &QCollisionQueryResult::operator=(const QCollisionQueryResult &result)
50{
51 d_ptr = result.d_ptr;
52 return *this;
53}
54
55const std::vector<QCollisionQueryResult::Hit> &QCollisionQueryResult::hits() const
56{
57 Q_D(const QCollisionQueryResult);
58 return d->m_hits;
59}
60
61std::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*/
74QCollisionQueryResult::QCollisionQueryResult(QCollisionQueryResultPrivate &p)
75 : d_ptr(&p)
76{
77}
78
79/*!
80 \internal
81*/
82QCollisionQueryResultPrivate *QCollisionQueryResult::d_func()
83{
84 return d_ptr.data();
85}
86
87QQueryHandle QCollisionQueryResult::handle() const
88{
89 Q_D(const QCollisionQueryResult);
90 return d->m_handle;
91}
92
93} // RayCasting
94} // Qt3DRender
95
96QT_END_NAMESPACE
97

source code of qt3d/src/render/raycasting/qcollisionqueryresult.cpp