Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssgscenedesc.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qssgscenedesc_p.h"
5
7
8bool QSSGSceneDesc::PropertyCall::set(QQuick3DObject &, const char *, const void *) { return false; }
9bool QSSGSceneDesc::PropertyCall::get(const QQuick3DObject &, const void *[]) const { return false; }
10
12{
13 /* root node uses the default value 0 */
14 return ++scene.nodeId;
15}
16
18{
19 Q_ASSERT(parent.scene);
20 node.scene = parent.scene;
21 node.id = getNextNodeId(*parent.scene);
22
23 if (QSSGRenderGraphObject::isResource(node.runtimeType) || node.nodeType == Node::Type::Mesh || node.nodeType == Node::Type::Skeleton)
24 node.scene->resources.push_back(&node);
25 else // Here goes nothing: kick all the resources out of the tree...
26 parent.children.push_back(&node);
27}
28
30{
31 if (scene.root) {
32 addNode(*scene.root, node);
33 } else {
34 Q_ASSERT(node.id == 0);
35 node.scene = &scene;
36 scene.root = &node;
37 }
38}
39
41{
42 id.clear();
43 nodeId = 0;
44 root = nullptr;
45 resources.clear();
46 meshStorage.clear();
47}
48
50{
51 id.clear();
52 nodeId = 0;
53
54 root->cleanupChildren();
55 delete root;
56 root = nullptr;
57
58 qDeleteAll(resources);
59 resources.clear();
60
61 for (auto *anim: animations) {
62 for (auto *ch: anim->channels) {
63 qDeleteAll(ch->keys);
64 ch->keys.clear();
65 delete ch;
66 }
67 delete anim;
68 }
69 animations.clear();
70}
71
73{
74 return QMetaType::fromType<QSSGSceneDesc::ListView *>();
75}
76
78{
79 if (!value.isValid())
80 return;
81
82 if (value.metaType() == QMetaType::fromType<QSSGSceneDesc::NodeList *>())
83 delete value.value<NodeList *>();
84 else if (value.metaType() == QMetaType::fromType<QSSGSceneDesc::ListView *>())
85 delete value.value<ListView *>();
86 // Non-pointer types are destructed by ~QVariant
87 else if ((value.metaType().flags() & QMetaType::TypeFlag::IsPointer)
88 // Mesh node will be deleted when cleaning up resources.
89 && (value.metaType() != QMetaType::fromType<QSSGSceneDesc::Mesh *>())
90 // Referencing nodes will not be deleted here.
91 // They should be deleted in the node hierarchy or resources.
92 && (value.metaType().id() != qMetaTypeId<QSSGSceneDesc::Node *>())) {
93 qWarning() << value.metaType().name() << " was not destroyed correctly.";
94 }
95}
96
98{
99 for (auto *prop : node.properties)
100 delete prop;
101 // Not necessary to clear the list as long as we only call this from the destructor
102}
103
105
107{
108 auto firstIt = children.begin();
109 auto lastIt = children.end();
110 for (auto it = firstIt; it != lastIt; ++it) {
111 Node *node = *it;
112 node->cleanupChildren();
113 delete node;
114 }
115}
116
118{
119 Q_ASSERT(node.scene);
121 prop->name = name;
122 prop->call = nullptr;
123 prop->value = value;
124 node.properties.push_back(prop);
125 return prop;
126}
127
129
131
133
135
137
139
141
143
148
151 , data(textureData)
152 , sz(size)
153 , fmt(format)
154 , flgs(flags)
155{}
156
161
\inmodule QtCore
Definition qbytearray.h:57
void push_back(parameter_type t)
Definition qlist.h:675
\inmodule QtCore
Definition qmetatype.h:341
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
static constexpr bool isResource(Type type) noexcept
\inmodule QtCore
Definition qsize.h:25
void push_back(const T &t)
\inmodule QtCore
Definition qvariant.h:65
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
static void setProperty(QSSGSceneDesc::Node &node, const char *name, Setter setter, T &&value)
Q_QUICK3DASSETUTILS_EXPORT void addNode(Node &parent, Node &node)
Q_QUICK3DASSETUTILS_EXPORT QMetaType listViewMetaType()
Q_QUICK3DASSETUTILS_EXPORT void destructNode(QSSGSceneDesc::Node &node)
Q_QUICK3DASSETUTILS_EXPORT void destructValue(QVariant &value)
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLbitfield flags
GLuint name
GLint GLsizei GLsizei GLenum format
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static quint16 getNextNodeId(QSSGSceneDesc::Scene &scene)
unsigned short quint16
Definition qtypes.h:48
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned char quint8
Definition qtypes.h:46
QVideoFrameFormat::PixelFormat fmt
QGraphicsScene scene
[0]
virtual bool get(const QQuick3DObject &, const void *[]) const =0
virtual bool set(QQuick3DObject &, const char *, const void *)=0
QSSGSceneDesc::PropertyCall * call
ResourceNodes resources
TextureData(const QByteArray &textureData, QSize size, const QByteArray &format, quint8 flags=0, QByteArray name={})
Definition moc.h:23