mirror of https://github.com/qt/qt3d.git
Remove use of messages for RayCaster
Change-Id: Ibe0b38df62700608135788331adfcb7fa28159a7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
parent
35919326b4
commit
a40654ad45
|
|
@ -337,11 +337,7 @@ void QAbstractRayCaster::addLayer(QLayer *layer)
|
||||||
if (!layer->parent())
|
if (!layer->parent())
|
||||||
layer->setParent(this);
|
layer->setParent(this);
|
||||||
|
|
||||||
if (d->m_changeArbiter != nullptr) {
|
d->updateNode(layer, "layer", Qt3DCore::PropertyValueAdded);
|
||||||
const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), layer);
|
|
||||||
change->setPropertyName("layer");
|
|
||||||
d->notifyObservers(change);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,11 +348,7 @@ void QAbstractRayCaster::removeLayer(QLayer *layer)
|
||||||
{
|
{
|
||||||
Q_ASSERT(layer);
|
Q_ASSERT(layer);
|
||||||
Q_D(QAbstractRayCaster);
|
Q_D(QAbstractRayCaster);
|
||||||
if (d->m_changeArbiter != nullptr) {
|
d->updateNode(layer, "layer", Qt3DCore::PropertyValueRemoved);
|
||||||
const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), layer);
|
|
||||||
change->setPropertyName("layer");
|
|
||||||
d->notifyObservers(change);
|
|
||||||
}
|
|
||||||
d->m_layers.removeOne(layer);
|
d->m_layers.removeOne(layer);
|
||||||
// Remove bookkeeping connection
|
// Remove bookkeeping connection
|
||||||
d->unregisterDestructionHelper(layer);
|
d->unregisterDestructionHelper(layer);
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ private Q_SLOTS:
|
||||||
QScopedPointer<Qt3DRender::QRayCaster> rayCaster(new Qt3DRender::QRayCaster());
|
QScopedPointer<Qt3DRender::QRayCaster> rayCaster(new Qt3DRender::QRayCaster());
|
||||||
|
|
||||||
QVERIFY(!rayCaster->isEnabled());
|
QVERIFY(!rayCaster->isEnabled());
|
||||||
QVERIFY(rayCaster->direction().length() > 0.);
|
QVERIFY(rayCaster->direction().length() > 0.f);
|
||||||
QCOMPARE(rayCaster->runMode(), Qt3DRender::QAbstractRayCaster::SingleShot);
|
QCOMPARE(rayCaster->runMode(), Qt3DRender::QAbstractRayCaster::SingleShot);
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
|
@ -125,13 +125,11 @@ private Q_SLOTS:
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
QCOMPARE(arbiter.events.size(), 1);
|
QCOMPARE(arbiter.events.size(), 0);
|
||||||
auto addChange = arbiter.events.first().staticCast<Qt3DCore::QPropertyNodeAddedChange>();
|
QCOMPARE(arbiter.dirtyNodes.size(), 1);
|
||||||
QCOMPARE(addChange->propertyName(), "layer");
|
QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data());
|
||||||
QCOMPARE(addChange->subjectId(), rayCaster->id());
|
|
||||||
QCOMPARE(addChange->addedNodeId(), rayCaster->layers().at(0)->id());
|
|
||||||
QCOMPARE(addChange->type(), Qt3DCore::PropertyValueAdded);
|
|
||||||
|
|
||||||
|
arbiter.dirtyNodes.clear();
|
||||||
arbiter.events.clear();
|
arbiter.events.clear();
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
|
@ -141,13 +139,11 @@ private Q_SLOTS:
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
QCOMPARE(arbiter.events.size(), 1);
|
QCOMPARE(arbiter.events.size(), 0);
|
||||||
addChange = arbiter.events.first().staticCast<Qt3DCore::QPropertyNodeAddedChange>();
|
QCOMPARE(arbiter.dirtyNodes.size(), 1);
|
||||||
QCOMPARE(addChange->propertyName(), "layer");
|
QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data());
|
||||||
QCOMPARE(addChange->subjectId(), rayCaster->id());
|
|
||||||
QCOMPARE(addChange->addedNodeId(), rayCaster->layers().at(1)->id());
|
|
||||||
QCOMPARE(addChange->type(), Qt3DCore::PropertyValueAdded);
|
|
||||||
|
|
||||||
|
arbiter.dirtyNodes.clear();
|
||||||
arbiter.events.clear();
|
arbiter.events.clear();
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
|
@ -156,13 +152,11 @@ private Q_SLOTS:
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
QCOMPARE(arbiter.events.size(), 1);
|
QCOMPARE(arbiter.events.size(), 0);
|
||||||
auto removeChange = arbiter.events.first().staticCast<Qt3DCore::QPropertyNodeRemovedChange>();
|
QCOMPARE(arbiter.dirtyNodes.size(), 1);
|
||||||
QCOMPARE(removeChange->propertyName(), "layer");
|
QCOMPARE(arbiter.dirtyNodes.front(), rayCaster.data());
|
||||||
QCOMPARE(removeChange->subjectId(), rayCaster->id());
|
|
||||||
QCOMPARE(removeChange->removedNodeId(), layer->id());
|
|
||||||
QCOMPARE(removeChange->type(), Qt3DCore::PropertyValueRemoved);
|
|
||||||
|
|
||||||
|
arbiter.dirtyNodes.clear();
|
||||||
arbiter.events.clear();
|
arbiter.events.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,29 +203,6 @@ private Q_SLOTS:
|
||||||
<< QByteArray(SIGNAL(hitsChanged(const Hits &)))
|
<< QByteArray(SIGNAL(hitsChanged(const Hits &)))
|
||||||
<< QByteArrayLiteral("hits");
|
<< QByteArrayLiteral("hits");
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkBackendUpdates()
|
|
||||||
{
|
|
||||||
// GIVEN
|
|
||||||
QFETCH(QByteArray, signalPrototype);
|
|
||||||
QFETCH(QByteArray, propertyName);
|
|
||||||
QScopedPointer<MyRayCaster> rayCaster(new MyRayCaster());
|
|
||||||
QSignalSpy spy(rayCaster.data(), signalPrototype.constData());
|
|
||||||
Qt3DRender::QRayCaster::Hits hits;
|
|
||||||
|
|
||||||
// WHEN
|
|
||||||
// Create Backend Change and distribute it to frontend node
|
|
||||||
Qt3DCore::QPropertyUpdatedChangePtr e(new Qt3DCore::QPropertyUpdatedChange(rayCaster->id()));
|
|
||||||
e->setPropertyName(propertyName.constData());
|
|
||||||
QVariant v;
|
|
||||||
v.setValue<Qt3DRender::QRayCaster::Hits>(hits);
|
|
||||||
e->setValue(v);
|
|
||||||
rayCaster->sceneChangeEvent(e);
|
|
||||||
|
|
||||||
// THEN
|
|
||||||
// Check that the QRayCaster triggers the expected signal
|
|
||||||
QCOMPARE(spy.count(), 1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_MAIN(tst_QRayCaster)
|
QTEST_MAIN(tst_QRayCaster)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue