diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2016-07-01 08:50:46 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-07-02 08:41:11 +0000 |
commit | 1e0fb6c74d81a5b6c17a7f127566e4fb8ed2f28b (patch) | |
tree | 35de4cc5802f3b1220fac5f8c0b67e54b6167d5d /src/render/materialsystem/shaderdata.cpp | |
parent | 69d3e9106765cf0560329cb827aa738bf43ba6b8 (diff) |
readPeerProperties is gone in QBackendNode
Since it's not called anymore, remove it from ShaderData and add the
handling of transformed properties to initializeFromPeer().
Change-Id: I462c8f99ae9d71025aff13176b98956fa9a40a6f
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/materialsystem/shaderdata.cpp')
-rw-r--r-- | src/render/materialsystem/shaderdata.cpp | 73 |
1 files changed, 15 insertions, 58 deletions
diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp index 0ac462e8d..01eceb696 100644 --- a/src/render/materialsystem/shaderdata.cpp +++ b/src/render/materialsystem/shaderdata.cpp @@ -107,7 +107,21 @@ void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) m_nestedShaderDataProperties.insert(propertyName, propertyValue); } } - // Note: we ignore transformed properties for now until we figure out how to best handle them + + // We look for transformed properties + QHash<QString, QVariant>::iterator it = m_properties.begin(); + const QHash<QString, QVariant>::iterator end = m_properties.end(); + + while (it != end) { + if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QVector3D) { + // if there is a matching QShaderData::TransformType propertyTransformed + QVariant value = m_properties.value(it.key() + QLatin1String("Transformed")); + // if that's the case, we apply a space transformation to the property + if (value.isValid() && value.type() == QVariant::Int) + m_transformedProperties.insert(it.key(), static_cast<TransformType>(value.toInt())); + } + ++it; + } } @@ -257,63 +271,6 @@ void ShaderData::markDirty() ShaderData::m_updatedShaderData.append(peerId()); } -void ShaderData::readPeerProperties(QShaderData *shaderData) -{ - const QMetaObject *metaObject = shaderData->metaObject(); - const int propertyOffset = QShaderData::staticMetaObject.propertyOffset(); - const int propertyCount = metaObject->propertyCount(); - - for (int i = propertyOffset; i < propertyCount; ++i) { - const QMetaProperty property = metaObject->property(i); - if (strcmp(property.name(), "data") == 0 || strcmp(property.name(), "childNodes") == 0) // We don't handle default Node properties - continue; - QVariant propertyValue = m_propertyReader->readProperty(shaderData->property(property.name())); - QString propertyName = QString::fromLatin1(property.name()); - - m_properties.insert(propertyName, propertyValue); - m_originalProperties.insert(propertyName, propertyValue); - - // We check if the property is a QNodeId or QVector<QNodeId> so that we can - // check nested QShaderData for update - if (propertyValue.userType() == qNodeIdTypeId) { - m_nestedShaderDataProperties.insert(propertyName, propertyValue); - } else if (propertyValue.userType() == QMetaType::QVariantList) { - QVariantList list = propertyValue.value<QVariantList>(); - if (list.count() > 0 && list.at(0).userType() == qNodeIdTypeId) - m_nestedShaderDataProperties.insert(propertyName, propertyValue); - } - } - - // Also check the dynamic properties - const auto propertyNames = shaderData->dynamicPropertyNames(); - for (const QByteArray &propertyName : propertyNames) { - if (propertyName == "data" || propertyName == "childNodes") // We don't handle default Node properties - continue; - - QVariant value = m_propertyReader->readProperty(shaderData->property(propertyName)); - QString key = QString::fromLatin1(propertyName); - - m_properties.insert(key, value); - m_originalProperties.insert(key, value); - } - - - // We look for transformed properties - QHash<QString, QVariant>::iterator it = m_properties.begin(); - const QHash<QString, QVariant>::iterator end = m_properties.end(); - - while (it != end) { - if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QVector3D) { - // if there is a matching QShaderData::TransformType propertyTransformed - QVariant value = m_properties.value(it.key() + QLatin1String("Transformed")); - // if that's the case, we apply a space transformation to the property - if (value.isValid() && value.type() == QVariant::Int) - m_transformedProperties.insert(it.key(), static_cast<TransformType>(value.toInt())); - } - ++it; - } -} - void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) { if (!m_propertyReader.isNull() && e->type() == PropertyUpdated) { |