1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qquick3dextensionhelpers.h"
#include "qquick3dobject_p.h"
#include <QtQuick3DUtils/private/qssgassert_p.h>
QT_BEGIN_NAMESPACE
/*!
\typedef QSSGNodeId
\relates QtQuick3D
The QSSGNodeId is a handle to a QtQuick3D node object. \l Node objects are all
objects that inherits from \l Node, like the \l Model item.
*/
/*!
\typedef QSSGResourceId
\relates QtQuick3D
The QSSGResourceId is a handle to a QtQuick3D object. Resources are usually all
\l {Node}{none-node} types.
*/
/*!
\typedef QSSGCameraId
\relates QtQuick3D
The QSSGCameraId is a handle to a QtQuick3D \l Camera object, like the \l PerspectiveCamera item.
\note Cameras are also nodes.
*/
/*!
\typedef QSSGExtensionId
\relates QtQuick3D
The QSSGExtensionId is a handle to a QtQuick3D extension type, like items that inherits from the
\l RenderExtension type.
\sa QQuick3DRenderExtension, QSSGRenderExtension
*/
/*!
\class QQuick3DExtensionHelpers
\inmodule QtQuick3D
\since 6.6
\brief Helper functions for the Extensions APIs.
*/
QQuick3DExtensionHelpers::QQuick3DExtensionHelpers()
{
}
/*!
\return a \c QSSGNodeId that can be used to retrieve the object in the engine
corresponding to \a node.
//! \sa QSSGFrameData::getNode()
*/
QSSGNodeId QQuick3DExtensionHelpers::getNodeId(const QQuick3DObject &node)
{
auto *po = QQuick3DObjectPrivate::get(&node);
QSSG_ASSERT_X(QSSGRenderGraphObject::isNodeType(po->type), "Type is not a node", return QSSGNodeId::Invalid);
// NOTE: Implementation detail (don't rely on this in user code).
return static_cast<QSSGNodeId>(quintptr(QQuick3DObjectPrivate::get(&node)->spatialNode));
}
/*!
\return a \c QSSGResourceId that can be used to retrieve the corresponding \a resource object
in the engine.
//! \sa QSSGFrameData::getResource()
*/
QSSGResourceId QQuick3DExtensionHelpers::getResourceId(const QQuick3DObject &resource)
{
auto *po = QQuick3DObjectPrivate::get(&resource);
QSSG_ASSERT_X(QSSGRenderGraphObject::isResource(po->type), "Type is not a resource", return QSSGResourceId::Invalid);
// NOTE: Implementation detail (don't rely on this in user code).
return static_cast<QSSGResourceId>(quintptr(QQuick3DObjectPrivate::get(&resource)->spatialNode));
}
/*!
\return a \c QSSGCameraId that can be used to retrieve the corresponding \a camera object
in the engine.
//! \sa QSSGFrameData::getNode()
*/
QSSGCameraId QQuick3DExtensionHelpers::getCameraId(const QQuick3DObject &camera)
{
auto *po = QQuick3DObjectPrivate::get(&camera);
QSSG_ASSERT_X(QSSGRenderGraphObject::isCamera(po->type), "Type is not a camera", return QSSGCameraId::Invalid);
// NOTE: Implementation detail (don't rely on this in user code).
return static_cast<QSSGCameraId>(quintptr(po->spatialNode));
}
QSSGExtensionId QQuick3DExtensionHelpers::getExtensionId(const QQuick3DObject &extension)
{
auto *po = QQuick3DObjectPrivate::get(&extension);
QSSG_ASSERT_X(QSSGRenderGraphObject::isExtension(po->type), "Type is not an extension", return QSSGExtensionId::Invalid);
// NOTE: Implementation detail (don't rely on this in user code).
return static_cast<QSSGExtensionId>(quintptr(po->spatialNode));
}
QT_END_NAMESPACE
|