summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-06-04 17:22:14 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-06-08 11:26:02 +0000
commitd1669c623288a36f104d5d344b5799935e2857a4 (patch)
tree42fe302aeec80f751368af99b509571218c95b67
parentde89bc619d034a23a0c6398eaa001fef929f5f4b (diff)
Fix visibility updates
Task-number: QT3DS-1866 Change-Id: I3ce33b60f20994d87e76367e697c73a68c4ddad6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/runtime/q3dsscenemanager.cpp40
-rw-r--r--src/runtime/q3dsslideplayer.cpp49
-rw-r--r--src/runtime/q3dsuippresentation_p.h2
3 files changed, 48 insertions, 43 deletions
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp
index e50f652..4324acf 100644
--- a/src/runtime/q3dsscenemanager.cpp
+++ b/src/runtime/q3dsscenemanager.cpp
@@ -1677,7 +1677,7 @@ void Q3DSSceneManager::setLayerProperties(Q3DSLayerNode *layer3DS)
setClearColorForClearBuffers(data->clearBuffers, layer3DS);
if (data->compositorEntity) // may not exist if this is still buildLayer()
- data->compositorEntity->setEnabled(layer3DS->flags().testFlag(Q3DSNode::Active));
+ data->compositorEntity->setEnabled(layer3DS->flags().testFlag(Q3DSNode::Active) && (data->visibilityTag == Q3DSGraphObjectAttached::Visible));
// IBL Probes
if (!data->iblProbeData.lightProbeProperties) {
@@ -3857,12 +3857,12 @@ void Q3DSSceneManager::updateGlobals(Q3DSNode *node, UpdateGlobalFlags flags)
// update the global, inherited opacity
globalOpacity = clampOpacity(parentData->globalOpacity * (node->localOpacity() / 100.0f));
// update inherited visibility
- globalVisibility = node->flags().testFlag(Q3DSNode::Active) && parentData->globalVisibility;
+ globalVisibility = node->flags().testFlag(Q3DSNode::Active) && (parentData->visibilityTag == Q3DSGraphObjectAttached::Visible) && parentData->globalVisibility;
} else {
if (!flags.testFlag(UpdateGlobalsSkipTransform))
globalTransform = data->transform->matrix();
globalOpacity = clampOpacity(node->localOpacity() / 100.0f);
- globalVisibility = node->flags().testFlag(Q3DSNode::Active);
+ globalVisibility = node->flags().testFlag(Q3DSNode::Active) && (data->visibilityTag == Q3DSGraphObjectAttached::Visible);
}
if (!flags.testFlag(UpdateGlobalsSkipTransform) && globalTransform != data->globalTransform) {
@@ -6742,10 +6742,36 @@ void Q3DSSceneManager::updateSubTree(Q3DSGraphObject *obj)
for (auto it = m_pendingObjectVisibility.constBegin(); it != m_pendingObjectVisibility.constEnd(); ++it) {
if (it.key()->isNode() && it.key()->type() != Q3DSGraphObject::Layer && it.key()->type() != Q3DSGraphObject::Camera) {
- setNodeVisibility(static_cast<Q3DSNode *>(it.key()), it.value());
+ Q3DSNode *node = static_cast<Q3DSNode *>(it.key());
+ const bool visible = (it.value() && node->flags().testFlag(Q3DSNode::Active));
+ it.key()->attached()->visibilityTag = visible ? Q3DSGraphObjectAttached::Visible
+ : Q3DSGraphObjectAttached::Hidden;
+ setNodeVisibility(node, visible);
+ } else if (it.key()->type() == Q3DSGraphObject::Effect){
+ Q3DSEffectInstance *effect = static_cast<Q3DSEffectInstance *>(it.key());
+ it.key()->attached()->visibilityTag = (it.value() && effect->active()) ? Q3DSGraphObjectAttached::Visible
+ : Q3DSGraphObjectAttached::Hidden;
+ updateEffectStatus(effect->attached<Q3DSEffectAttached>()->layer3DS);
+ } else if (it.key()->type() == Q3DSGraphObject::Layer) {
+ Q3DSLayerNode *layer3DS = static_cast<Q3DSLayerNode *>(it.key());
+ Q3DSLayerAttached *data = static_cast<Q3DSLayerAttached *>(layer3DS->attached());
+ if (data && data->compositorEntity) { // may not exist if this is still buildLayer()
+ const bool enabled = it.value() && layer3DS->flags().testFlag(Q3DSNode::Active);
+ it.key()->attached()->visibilityTag = enabled ? Q3DSGraphObjectAttached::Visible
+ : Q3DSGraphObjectAttached::Hidden;
+ data->compositorEntity->setEnabled(enabled);
+ }
+ } else if (it.key()->type() == Q3DSGraphObject::Camera) {
+ Q3DSCameraNode *cam3DS = static_cast<Q3DSCameraNode *>(it.key());
+ Q3DSCameraAttached *data = static_cast<Q3DSCameraAttached *>(cam3DS->attached());
+ if (data) {
+ const bool visible = (it.value() && cam3DS->flags().testFlag(Q3DSNode::Active));
+ it.key()->attached()->visibilityTag = visible ? Q3DSGraphObjectAttached::Visible
+ : Q3DSGraphObjectAttached::Hidden;
+ updateLayerCamera(data->layer3DS);
+ }
} else {
- // NOTE: Special handling for e.g., Camera, layers and effects.
- it.key()->attached()->visibilityTag = (it.value() ? Q3DSGraphObjectAttached::Visible : Q3DSGraphObjectAttached::Hidden);
+ Q_UNREACHABLE();
}
}
m_pendingObjectVisibility.clear();
@@ -7131,7 +7157,7 @@ void Q3DSSceneManager::updateNodeFromChangeFlags(Q3DSNode *node, Qt3DCore::QTran
// changes get processed after an initial visit of all objects)
m_pendingObjectVisibility.remove(node);
- const bool active = node->flags().testFlag(Q3DSNode::Active);
+ const bool active = (node->flags().testFlag(Q3DSNode::Active) && (node->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible));
setNodeVisibility(node, active);
}
m_wasDirty = true;
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp
index 5ed0873..877d598 100644
--- a/src/runtime/q3dsslideplayer.cpp
+++ b/src/runtime/q3dsslideplayer.cpp
@@ -545,13 +545,10 @@ void Q3DSSlidePlayer::setSlideDeck(Q3DSSlideDeck *slideDeck)
Q3DSSlide *masterSlide = slideDeck->masterSlide();
masterSlide->attached<Q3DSSlideAttached>()->slidePlayer = this;
forAllComponentsOnSlide(masterSlide);
- Q3DSSlide *currentSlide = slideDeck->currentSlide();
Q3DSSlide *slide = static_cast<Q3DSSlide *>(masterSlide->firstChild());
while (slide) {
slide->attached<Q3DSSlideAttached>()->slidePlayer = this;
forAllComponentsOnSlide(slide);
- if (slide != currentSlide)
- setSlideTime(slide, -1.0f);
slide = static_cast<Q3DSSlide *>(slide->nextSibling());
}
};
@@ -707,9 +704,6 @@ void Q3DSSlidePlayer::handleCurrentSlideChanged(Q3DSSlide *slide,
});
};
if (previousSlide && slideDidChange) {
- if (parentChanged)
- cleanUpComponentPlayers(static_cast<Q3DSSlide *>(previousSlide->parent()));
- setSlideTime(previousSlide, -1.0f);
cleanUpComponentPlayers(previousSlide);
Q3DSSlideAttached *data = previousSlide->attached<Q3DSSlideAttached>();
if (data && data->animator) {
@@ -719,12 +713,16 @@ void Q3DSSlidePlayer::handleCurrentSlideChanged(Q3DSSlide *slide,
detatchPositionCallback(previousSlide);
m_animationManager->clearAnimations(previousSlide);
}
+ if (parentChanged)
+ cleanUpComponentPlayers(static_cast<Q3DSSlide *>(previousSlide->parent()));
+
+ setSlideTime(previousSlide, -1.0f);
}
if (slide && slideDidChange && isSlideVisible(slide)) {
+ setSlideTime(slide, 0.0f);
processPropertyChanges(slide);
attatchPositionCallback(slide);
- setSlideTime(slide, 0.0f);
m_animationManager->updateAnimations(slide, (m_mode == PlayerMode::Editor));
Q3DSGraphObject *eventTarget = m_sceneManager->m_scene;
@@ -795,23 +793,14 @@ static bool objectHasVisibilityTag(Q3DSGraphObject *object)
Q_ASSERT(object->attached());
Q_ASSERT(object->isNode() || object->type() == Q3DSGraphObject::Effect);
- auto entity = object->attached()->entity;
- if (!entity)
- return false;
-
- if (object->type() == Q3DSGraphObject::Camera || object->type() == Q3DSGraphObject::Layer || object->type() == Q3DSGraphObject::Effect)
- return (object->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible);
-
- auto layerAttached = static_cast<Q3DSLayerAttached *>(object->isNode() ? object->attached<Q3DSNodeAttached>()->layer3DS->attached()
- : object->attached<Q3DSEffectAttached>()->layer3DS->attached());
- if (entity->components().contains(layerAttached->opaqueTag) || entity->components().contains(layerAttached->transparentTag))
- return true;
-
- return false;
+ return (object->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible);
}
void Q3DSSlidePlayer::setSlideTime(Q3DSSlide *slide, float time, bool parentVisible)
{
+ if (!slide)
+ return;
+
// If this is a component player, then check if the component is visible in the parent.
const bool visibleInParent = (m_type == Q3DSSlidePlayer::PlayerType::ComponentSlide) ? ((m_component->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible) && parentVisible)
: true;
@@ -832,17 +821,15 @@ void Q3DSSlidePlayer::setSlideTime(Q3DSSlide *slide, float time, bool parentVisi
if ((!obj->isNode() && !isEffect))
continue;
- const bool isRealNode = (obj->isNode() && obj->type() != Q3DSGraphObject::Layer && obj->type() != Q3DSGraphObject::Camera);
- Q3DSNode *node = isRealNode ? static_cast<Q3DSNode *>(obj) : nullptr;
+ Q3DSNode *node = static_cast<Q3DSNode *>(obj);
if (node && !node->attached())
continue;
- const bool nodeActive = (node && node->flags().testFlag(Q3DSNode::Active) && node->attached<Q3DSNodeAttached>()->globalVisibility);
- const bool otherActive = !node && (obj->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible);
-
+ const bool nodeActive = (node && node->flags().testFlag(Q3DSNode::Active));
+ const bool effectActive = (isEffect && static_cast<Q3DSEffectInstance *>(obj)->active());
const bool shouldBeVisible = visibleInParent
&& time >= obj->startTime() && time <= obj->endTime()
- && (nodeActive || otherActive);
+ && (nodeActive || effectActive);
if (forceUpdate || shouldBeVisible != objectHasVisibilityTag(obj))
updateObjectVisibility(obj, shouldBeVisible);
@@ -973,22 +960,14 @@ void Q3DSSlidePlayer::processPropertyChanges(Q3DSSlide *currentSlide)
return false;
object->applyPropertyChanges(masterRollbackList);
- object->notifyPropertyChanges(masterRollbackList);
return false;
});
}
// Filter out properties that we needs to be marked dirty, i.e., eyeball changes.
const auto &propertyChanges = currentSlide->propertyChanges();
- for (auto it = propertyChanges.cbegin(); it != propertyChanges.cend(); ++it) {
+ for (auto it = propertyChanges.cbegin(); it != propertyChanges.cend(); ++it)
it.key()->applyPropertyChanges(*it.value());
- std::find_if((*it)->cbegin(), (*it)->cend(), [it](const Q3DSPropertyChange &propChange) {
- if (propChange.name() == QLatin1String("eyeball"))
- it.key()->notifyPropertyChanges(Q3DSPropertyChangeList({propChange}));
-
- return false;
- });
- }
// Now update the propeties from dynamic property values
for (auto it = dynamicPropertyChanges.cbegin(), ite = dynamicPropertyChanges.cend(); it != ite; ++it)
diff --git a/src/runtime/q3dsuippresentation_p.h b/src/runtime/q3dsuippresentation_p.h
index af41cc8..cb2ae65 100644
--- a/src/runtime/q3dsuippresentation_p.h
+++ b/src/runtime/q3dsuippresentation_p.h
@@ -210,7 +210,7 @@ public:
};
Q_DECLARE_FLAGS(FrameDirtyFlags, FrameDirtyFlag)
- VisibilityTag visibilityTag = Visible;
+ VisibilityTag visibilityTag = Hidden;
FrameDirtyFlags frameDirty;
int frameChangeFlags = 0;
};