Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquick3dextensionhelpers.cpp
Go to the documentation of this file.
1
// Copyright (C) 2023 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
#
include
"qquick3dextensionhelpers.h"
7
#
include
"qquick3dobject_p.h"
8
9
#
include
<
QtQuick3DUtils
/
private
/
qssgassert_p
.
h
>
10
#
include
<
QtQuick3DRuntimeRender
/
private
/
qssgrendernode_p
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
/*!
15
\typedef QSSGNodeId
16
\relates QtQuick3D
17
18
The QSSGNodeId is a handle to a QtQuick3D node object. \l Node objects are all
19
objects that inherits from \l Node, like the \l Model item.
20
*/
21
22
/*!
23
\typedef QSSGResourceId
24
\relates QtQuick3D
25
26
The QSSGResourceId is a handle to a QtQuick3D object. Resources are usually all
27
\l {Node}{none-node} types.
28
*/
29
30
/*!
31
\typedef QSSGCameraId
32
\relates QtQuick3D
33
34
The QSSGCameraId is a handle to a QtQuick3D \l Camera object, like the \l PerspectiveCamera item.
35
36
\note Cameras are also nodes.
37
*/
38
39
/*!
40
\typedef QSSGExtensionId
41
\relates QtQuick3D
42
43
The QSSGExtensionId is a handle to a QtQuick3D extension type, like items that inherits from the
44
\l RenderExtension type.
45
46
\sa QQuick3DRenderExtension, QSSGRenderExtension
47
*/
48
49
/*!
50
\class QQuick3DExtensionHelpers
51
\inmodule QtQuick3D
52
\since 6.6
53
54
\brief Helper functions for the Extensions APIs.
55
*/
56
57
QQuick3DExtensionHelpers::QQuick3DExtensionHelpers()
58
{
59
60
}
61
62
/*!
63
\return a \c QSSGNodeId that can be used to retrieve the object in the engine
64
corresponding to \a node.
65
66
//! \sa QSSGFrameData::getNode()
67
*/
68
QSSGNodeId QQuick3DExtensionHelpers::getNodeId(
const
QQuick3DObject &node)
69
{
70
auto
*po = QQuick3DObjectPrivate::get(&node);
71
QSSG_ASSERT_X(QSSGRenderGraphObject::isNodeType(po->type),
"Type is not a node"
,
return
QSSGNodeId::Invalid);
72
// NOTE: Implementation detail (don't rely on this in user code).
73
return
static_cast
<QSSGNodeId>(quintptr(QQuick3DObjectPrivate::get(&node)->spatialNode));
74
}
75
76
/*!
77
\return a \c QSSGResourceId that can be used to retrieve the corresponding \a resource object
78
in the engine.
79
80
//! \sa QSSGFrameData::getResource()
81
*/
82
QSSGResourceId QQuick3DExtensionHelpers::getResourceId(
const
QQuick3DObject &resource)
83
{
84
auto
*po = QQuick3DObjectPrivate::get(&resource);
85
QSSG_ASSERT_X(QSSGRenderGraphObject::isResource(po->type),
"Type is not a resource"
,
return
QSSGResourceId::Invalid);
86
// NOTE: Implementation detail (don't rely on this in user code).
87
return
static_cast
<QSSGResourceId>(quintptr(QQuick3DObjectPrivate::get(&resource)->spatialNode));
88
}
89
90
/*!
91
\return a \c QSSGCameraId that can be used to retrieve the corresponding \a camera object
92
in the engine.
93
94
//! \sa QSSGFrameData::getNode()
95
*/
96
QSSGCameraId QQuick3DExtensionHelpers::getCameraId(
const
QQuick3DObject &camera)
97
{
98
auto
*po = QQuick3DObjectPrivate::get(&camera);
99
QSSG_ASSERT_X(QSSGRenderGraphObject::isCamera(po->type),
"Type is not a camera"
,
return
QSSGCameraId::Invalid);
100
// NOTE: Implementation detail (don't rely on this in user code).
101
return
static_cast
<QSSGCameraId>(quintptr(po->spatialNode));
102
}
103
104
QSSGExtensionId QQuick3DExtensionHelpers::getExtensionId(
const
QQuick3DObject &extension)
105
{
106
auto
*po = QQuick3DObjectPrivate::get(&extension);
107
QSSG_ASSERT_X(QSSGRenderGraphObject::isExtension(po->type),
"Type is not an extension"
,
return
QSSGExtensionId::Invalid);
108
// NOTE: Implementation detail (don't rely on this in user code).
109
return
static_cast
<QSSGExtensionId>(quintptr(po->spatialNode));
110
}
111
112
113
/*!
114
\return the type of the node with the given \a nodeId.
115
116
This function is useful to determine the type of a \a nodeId.
117
*/
118
QSSGRenderGraphObject::Type QQuick3DExtensionHelpers::getNodeIdType(QSSGNodeId nodeId)
119
{
120
auto
*node = QSSGRenderGraphObjectUtils::getNode(nodeId);
121
return
node ? node->type : QSSGRenderGraphObject::Type::Unknown;
122
}
123
124
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
quick3d
extensions
qquick3dextensionhelpers.cpp
Generated on
for Qt by
1.18.0