diff options
author | Svenn-Arne Dragly <s@dragly.com> | 2019-02-19 10:22:59 +0100 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-03-21 12:57:55 +0000 |
commit | b35009fa7ac4c98f79cffaf5e538b4e525212343 (patch) | |
tree | 114e6effc4bdd3303c2085bdc50ebf09e9c853da | |
parent | 8d04fda51ae00cdb8f6aa1eb68ade24aea1750ac (diff) |
Dragon: Properly handle enabled state for backend nodes
Previously, different nodes handled their enabled property
independently. This change makes sure any BackendNode object
handles the enabled property in the same way
Change-Id: Id8b7485f1e9a72fe38f9d5095ba48ae27d5eb6e0
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | src/runtime/dragon/dragonbackendnode_p.h | 9 | ||||
-rw-r--r-- | src/runtime/dragon/dragonentity.cpp | 9 | ||||
-rw-r--r-- | src/runtime/dragon/dragonmapper_p.h | 10 | ||||
-rw-r--r-- | src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp | 2 | ||||
-rw-r--r-- | src/runtime/dragon/jobs/dragonrenderviewjobs.cpp | 4 | ||||
-rw-r--r-- | src/runtime/dragon/materialsystem/dragonparameter.cpp | 2 | ||||
-rw-r--r-- | src/runtime/dragon/materialsystem/dragonrenderpass.cpp | 3 | ||||
-rw-r--r-- | src/runtime/dragon/materialsystem/dragontechnique.cpp | 4 |
8 files changed, 21 insertions, 22 deletions
diff --git a/src/runtime/dragon/dragonbackendnode_p.h b/src/runtime/dragon/dragonbackendnode_p.h index 40ec8fb..aa0be0b 100644 --- a/src/runtime/dragon/dragonbackendnode_p.h +++ b/src/runtime/dragon/dragonbackendnode_p.h @@ -85,13 +85,18 @@ public: bool isEnabled() const { - // TODO copy from real backend node - return true; + return m_enabled; + } + + void setEnabled(bool enabled) + { + m_enabled = enabled; } private: AbstractContainer *m_manager = nullptr; Qt3DCore::QNodeId m_peerId; + bool m_enabled = true; }; } // namespace Dragon diff --git a/src/runtime/dragon/dragonentity.cpp b/src/runtime/dragon/dragonentity.cpp index 2ffee1c..ad38490 100644 --- a/src/runtime/dragon/dragonentity.cpp +++ b/src/runtime/dragon/dragonentity.cpp @@ -113,15 +113,6 @@ void Entity::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) } break; } - - case PropertyUpdated: { - auto propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e); - if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { - m_enabled = propertyChange->value().toBool(); - markDirty(); - } - break; - } default: break; } diff --git a/src/runtime/dragon/dragonmapper_p.h b/src/runtime/dragon/dragonmapper_p.h index 130c60c..4399764 100644 --- a/src/runtime/dragon/dragonmapper_p.h +++ b/src/runtime/dragon/dragonmapper_p.h @@ -45,6 +45,8 @@ #include <private/dragonbackendnode_p.h> #include <private/dragonvaluecontainer_p.h> +#include <Qt3DCore/qpropertyupdatedchange.h> + QT_BEGIN_NAMESPACE namespace Qt3DRender { @@ -95,6 +97,7 @@ public: // Using a std::move here because we are assigning to the same node. nodes[id] = std::move(nodes[id]).modified([&change](Backend *node){ node->initializeFromPeer(change); + node->setEnabled(change->isNodeEnabled()); }); } @@ -104,6 +107,13 @@ public: // Using a std::move here because we are assigning to the same node. nodes[id] = std::move(nodes[id]).modified([&e](Backend *element){ + if (e->type() == Qt3DCore::PropertyUpdated) { + Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); + if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { + element->setEnabled(propertyChange->value().toBool()); + element->markDirty(); + } + } element->sceneChangeEvent(e); }); diff --git a/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp b/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp index 2e1b321..e996c7d 100644 --- a/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp +++ b/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp @@ -205,7 +205,7 @@ LocalBoundingVolumes calculateLocalBoundingVolumes(LocalBoundingVolumes localBou result.geometryRendererId = entity->m_geometryRendererComponent; } - if (!entity->m_enabled) + if (!entity->isEnabled()) return result; if (result.geometryRendererId.isNull()) diff --git a/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp b/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp index 6371cf9..3f67116 100644 --- a/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp +++ b/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp @@ -729,7 +729,7 @@ RenderCommands buildDrawRenderCommands(RenderCommands renderCommands, continue; // TODO consider if this is the correct behavior (to hide when disabled) - if (!entity->m_enabled) + if (!entity->isEnabled()) continue; bool accepted = true; @@ -1119,7 +1119,7 @@ GatheredParameters gatherMaterialParameters(GatheredParameters gatherResult, result = update(std::move(result), technique->parameters()); for (const auto &renderPass : passes) { - if (!renderPass->m_enabled) + if (!renderPass->isEnabled()) continue; RenderPassParameterIds renderPassParameterIds; renderPassParameterIds.renderPass = renderPass; diff --git a/src/runtime/dragon/materialsystem/dragonparameter.cpp b/src/runtime/dragon/materialsystem/dragonparameter.cpp index f1ebc22..558babe 100644 --- a/src/runtime/dragon/materialsystem/dragonparameter.cpp +++ b/src/runtime/dragon/materialsystem/dragonparameter.cpp @@ -70,8 +70,6 @@ void Parameter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) } else if (propertyChange->propertyName() == QByteArrayLiteral("value")) { m_uniformValue = UniformValue::fromVariant(propertyChange->value()); markDirty(); - } else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { - markDirty(); } } diff --git a/src/runtime/dragon/materialsystem/dragonrenderpass.cpp b/src/runtime/dragon/materialsystem/dragonrenderpass.cpp index b4ea1d8..e4eae52 100644 --- a/src/runtime/dragon/materialsystem/dragonrenderpass.cpp +++ b/src/runtime/dragon/materialsystem/dragonrenderpass.cpp @@ -80,9 +80,6 @@ void RenderPass::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) if (change->propertyName() == QByteArrayLiteral("shaderProgram")) { m_shaderUuid = change->value().value<Qt3DCore::QNodeId>(); markDirty(); - } else if (change->propertyName() == QByteArrayLiteral("enabled")) { - m_enabled = change->value().toBool(); - markDirty(); } break; } diff --git a/src/runtime/dragon/materialsystem/dragontechnique.cpp b/src/runtime/dragon/materialsystem/dragontechnique.cpp index bc0f04b..6bd7914 100644 --- a/src/runtime/dragon/materialsystem/dragontechnique.cpp +++ b/src/runtime/dragon/materialsystem/dragontechnique.cpp @@ -64,9 +64,7 @@ void Technique::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) switch (e->type()) { case PropertyUpdated: { const auto change = qSharedPointerCast<QPropertyUpdatedChange>(e); - if (change->propertyName() == QByteArrayLiteral("enabled")) { - markDirty(); - } else if (change->propertyName() == QByteArrayLiteral("graphicsApiFilterData")) { + if (change->propertyName() == QByteArrayLiteral("graphicsApiFilterData")) { m_graphicsApiFilterData = change->value().value<GraphicsApiFilterData>(); markDirty(); } |