diff options
Diffstat (limited to 'src/render/jobs')
-rw-r--r-- | src/render/jobs/loadscenejob.cpp | 16 | ||||
-rw-r--r-- | src/render/jobs/renderviewjobutils.cpp | 17 | ||||
-rw-r--r-- | src/render/jobs/renderviewjobutils_p.h | 5 |
3 files changed, 26 insertions, 12 deletions
diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp index 79ac91d9a..701942976 100644 --- a/src/render/jobs/loadscenejob.cpp +++ b/src/render/jobs/loadscenejob.cpp @@ -90,9 +90,11 @@ void LoadSceneJob::run() // Reset status scene->setStatus(QSceneLoader::None); + QSceneLoader::Status finalStatus = QSceneLoader::None; // Perform the loading only if the source wasn't explicitly set to empty if (!m_source.isEmpty()) { + finalStatus = QSceneLoader::Error; for (QSceneIOHandler *sceneIOHandler : qAsConst(m_sceneIOHandlers)) { if (!sceneIOHandler->isFileTypeSupported(m_source)) continue; @@ -102,15 +104,11 @@ void LoadSceneJob::run() // File type is supported, try to load it sceneIOHandler->setSource(m_source); - Qt3DCore::QEntity *sub = sceneIOHandler->scene(); - if (sub) { - sceneSubTree = sub; + sceneSubTree = sceneIOHandler->scene(); + if (sceneSubTree != nullptr) { // Successfully built a subtree - scene->setStatus(QSceneLoader::Ready); + finalStatus = QSceneLoader::Ready; break; - } else { - // Tree wasn't build so something went wrong obviously - scene->setStatus(QSceneLoader::Error); } } } @@ -120,6 +118,10 @@ void LoadSceneJob::run() // Set clone of sceneTree in sceneComponent. This will move the sceneSubTree // to the QCoreApplication thread which is where the frontend object tree lives. scene->setSceneSubtree(sceneSubTree); + + // Note: the status is set after the subtree so that bindinds depending on the status + // in the frontend will be consistent + scene->setStatus(finalStatus); } } // namespace Render diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp index 798828bd3..3face7197 100644 --- a/src/render/jobs/renderviewjobutils.cpp +++ b/src/render/jobs/renderviewjobutils.cpp @@ -438,7 +438,7 @@ UniformBlockValueBuilder::~UniformBlockValueBuilder() { } -void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QString &blockName, const QString &qmlPropertyName, const QVariant &value) +void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData, const QString &blockName, const QString &qmlPropertyName, const QVariant &value) { // In the end, values are either scalar or a scalar array // Composed elements (structs, structs array) are simplified into simple scalars @@ -471,20 +471,29 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QStrin QString varName = blockName + QLatin1Char('.') + qmlPropertyName; if (uniforms.contains(varName)) { qCDebug(Shaders) << "UBO scalar member " << varName << " set for update"; - activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value); + + // If the property needs to be transformed, we transform it here as + // the shaderdata cannot hold transformed properties for multiple + // thread contexts at once + if (currentShaderData->propertyTransformType(qmlPropertyName) != ShaderData::NoTransform) + activeUniformNamesToValue.insert(StringToInt::lookupId(varName), + currentShaderData->getTransformedProperty(qmlPropertyName, viewMatrix)); + else + activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value); } } } void UniformBlockValueBuilder::buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, const QString &blockName, const QString &qmlPropertyName) { - const QHash<QString, QVariant> &properties = updatedPropertiesOnly ? rShaderData->updatedProperties() : rShaderData->properties(); + const QHash<QString, QVariant> &properties = rShaderData->properties(); QHash<QString, QVariant>::const_iterator it = properties.begin(); const QHash<QString, QVariant>::const_iterator end = properties.end(); while (it != end) { const auto prefix = qmlPropertyName.isEmpty() ? QLatin1String("") : QLatin1String("."); - buildActiveUniformNameValueMapHelper(blockName + prefix + qmlPropertyName, + buildActiveUniformNameValueMapHelper(rShaderData, + blockName + prefix + qmlPropertyName, it.key(), it.value()); ++it; diff --git a/src/render/jobs/renderviewjobutils_p.h b/src/render/jobs/renderviewjobutils_p.h index df4753980..c08083494 100644 --- a/src/render/jobs/renderviewjobutils_p.h +++ b/src/render/jobs/renderviewjobutils_p.h @@ -55,6 +55,7 @@ #include <Qt3DCore/qnodeid.h> #include <QtCore/qhash.h> #include <QtCore/qvariant.h> +#include <QMatrix4x4> #include <Qt3DRender/private/uniform_p.h> QT_BEGIN_NAMESPACE @@ -158,7 +159,8 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder UniformBlockValueBuilder(); ~UniformBlockValueBuilder(); - void buildActiveUniformNameValueMapHelper(const QString &blockName, + void buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData, + const QString &blockName, const QString &qmlPropertyName, const QVariant &value); void buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, @@ -169,6 +171,7 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder QHash<QString, ShaderUniform> uniforms; UniformBlockValueBuilderHash activeUniformNamesToValue; ShaderDataManager *shaderDataManager; + QMatrix4x4 viewMatrix; }; } // namespace Render |