summaryrefslogtreecommitdiffstats
path: root/src/runtime/q3dscustommaterial.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-11-29 14:10:21 +0100
committerAndy Nichols <andy.nichols@qt.io>2017-11-29 15:40:06 +0000
commitb5d7e5a2cd6ecfc09ec2c4da825e7aedafa54031 (patch)
tree3c75e4ffb35538186a9a9a9eb63ffea9b05ab6a8 /src/runtime/q3dscustommaterial.cpp
parent587a2bd1e4d35b8950c882876410d9ac374fb2fa (diff)
Parse Buffer in custom materials
and fix them up for effects. Having maps with value type of PassBuffer would lead to slicing instances of the subclasses (e.g. an ImageBuffer) when placing such objects into the container. Avoid this. Task-number: QT3DS-586 Change-Id: Iaf68345cc34cd51a0c8af691dd80d6ad3149a89e Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/runtime/q3dscustommaterial.cpp')
-rw-r--r--src/runtime/q3dscustommaterial.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/runtime/q3dscustommaterial.cpp b/src/runtime/q3dscustommaterial.cpp
index 9326c11..48fb1db 100644
--- a/src/runtime/q3dscustommaterial.cpp
+++ b/src/runtime/q3dscustommaterial.cpp
@@ -89,16 +89,21 @@ QString Q3DSCustomMaterial::shadersSharedCode() const
return m_shadersSharedCode;
}
-QVector<Q3DSMaterial::Shader> Q3DSCustomMaterial::shaders() const
+const QVector<Q3DSMaterial::Shader> &Q3DSCustomMaterial::shaders() const
{
return m_shaders;
}
-QVector<Q3DSMaterial::Pass> Q3DSCustomMaterial::passes() const
+const QVector<Q3DSMaterial::Pass> &Q3DSCustomMaterial::passes() const
{
return m_passes;
}
+const QHash<QString, Q3DSMaterial::Buffer> &Q3DSCustomMaterial::buffers() const
+{
+ return m_buffers;
+}
+
Qt3DRender::QMaterial *Q3DSCustomMaterial::generateMaterial()
{
auto material = new Qt3DRender::QMaterial();
@@ -544,9 +549,8 @@ void Q3DSCustomMaterialParser::parsePasses()
m_material.m_shaderKey = value;
}
}
- while (r->readNextStartElement()) {
+ while (r->readNextStartElement())
r->skipCurrentElement();
- }
} else if (r->name() == QStringLiteral("LayerKey")) {
for (auto attribute : r->attributes()) {
if (attribute.name() == QStringLiteral("count")) {
@@ -555,14 +559,10 @@ void Q3DSCustomMaterialParser::parsePasses()
m_material.m_layerCount = count;
}
}
- while (r->readNextStartElement()) {
+ while (r->readNextStartElement())
r->skipCurrentElement();
- }
} else if (r->name() == QStringLiteral("Buffer")) {
- // ### parse Buffer
- while (r->readNextStartElement()) {
- r->skipCurrentElement();
- }
+ parseBuffer();
} else {
r->skipCurrentElement();
}
@@ -691,6 +691,13 @@ void Q3DSCustomMaterialParser::parsePass()
m_material.m_passes.append(pass);
}
+void Q3DSCustomMaterialParser::parseBuffer()
+{
+ QXmlStreamReader *r = reader();
+ Q3DSMaterial::Buffer buffer = Q3DSMaterial::parseBuffer(r);
+ m_material.m_buffers.insert(buffer.name(), buffer);
+}
+
bool Q3DSCustomMaterialParser::isPropertyNameUnique(const QString &name)
{
for (auto property : m_material.m_properties) {