From 920d2e6e2b28ccf8e29d174b1009ef1e2766345b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 7 May 2017 21:57:29 +0200 Subject: Implement linear interpolation for animations Change-Id: I88522f53bead171f5ee7411b255d729ba5eb9565 Reviewed-by: Sean Harmer --- src/animation/backend/fcurve.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/animation/backend/fcurve.cpp b/src/animation/backend/fcurve.cpp index 809949472..56145c726 100644 --- a/src/animation/backend/fcurve.cpp +++ b/src/animation/backend/fcurve.cpp @@ -60,12 +60,35 @@ float FCurve::evaluateAtTime(float localTime) const return m_keyframes.last().value; } else { // Find keyframes that sandwich the requested localTime - int keyframe0 = m_rangeFinder.findLowerBound(localTime); - - BezierEvaluator evaluator(m_localTimes[keyframe0], m_keyframes[keyframe0], - m_localTimes[keyframe0 + 1], m_keyframes[keyframe0 + 1]); - return evaluator.valueForTime(localTime); + const int idx = m_rangeFinder.findLowerBound(localTime); + + const float t0 = m_localTimes[idx]; + const float t1 = m_localTimes[idx + 1]; + const Keyframe &keyframe0(m_keyframes[idx]); + const Keyframe &keyframe1(m_keyframes[idx + 1]); + + switch (keyframe0.interpolation) { + case QKeyFrame::ConstantInterpolation: + qWarning("Constant interpolation not implemented yet"); + break; + case QKeyFrame::LinearInterpolation: + if (localTime >= t0 && localTime <= t1 && t1 > t0) { + float t = (localTime - t0) / (t1 - t0); + return (1 - t) * keyframe0.value + t * keyframe1.value; + } + break; + case QKeyFrame::BezierInterpolation: + { + BezierEvaluator evaluator(t0, keyframe0, t1, keyframe1); + return evaluator.valueForTime(localTime); + } + default: + qWarning("Unknown interpolation type %d", keyframe0.interpolation); + break; + } } + + return m_keyframes.first().value; } float FCurve::startTime() const -- cgit v1.2.3 From e423907090e2ba1a3f5980b2cbf7e7b4fbc37dfe Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 7 May 2017 23:23:01 +0200 Subject: Add support for animating a QColor Using components R, G, B and expecting redF(), greenF() and blueF() in the corresponding keyframes. Change-Id: Ibac1488fe87bdf39d3446b23120114952874a5dc Reviewed-by: Sean Harmer --- src/animation/backend/animationutils.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index ef6aec058..c0287e9f2 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -69,6 +70,7 @@ int componentsForType(int type) break; case QVariant::Vector3D: + case QVariant::Color: componentCount = 3; break; @@ -149,15 +151,21 @@ ComponentIndices channelComponentsToIndices(const Channel &channel, int dataType #if defined Q_COMPILER_UNIFORM_INIT static const QVector standardSuffixes = { 'X', 'Y', 'Z', 'W' }; static const QVector quaternionSuffixes = { 'W', 'X', 'Y', 'Z' }; + static const QVector colorSuffixes = { 'R', 'G', 'B' }; #else static const QVector standardSuffixes = (QVector() << 'X' << 'Y' << 'Z' << 'W'); static const QVector quaternionSuffixes = (QVector() << 'W' << 'X' << 'Y' << 'Z'); + static const QVector colorSuffixes = (QVector() << 'R' << 'G' << 'B'); #endif - if (dataType != QVariant::Quaternion) - return channelComponentsToIndicesHelper(channel, dataType, offset, standardSuffixes); - else + switch (dataType) { + case QVariant::Quaternion: return channelComponentsToIndicesHelper(channel, dataType, offset, quaternionSuffixes); + case QVariant::Color: + return channelComponentsToIndicesHelper(channel, dataType, offset, colorSuffixes); + default: + return channelComponentsToIndicesHelper(channel, dataType, offset, standardSuffixes); + } } ComponentIndices channelComponentsToIndicesHelper(const Channel &channel, @@ -268,6 +276,14 @@ QVector preparePropertyChanges(Qt3DCore::QNodeId anim break; } + case QVariant::Color: { + const QColor color = QColor::fromRgbF(channelResults[mappingData.channelIndices[0]], + channelResults[mappingData.channelIndices[1]], + channelResults[mappingData.channelIndices[2]]); + v = QVariant::fromValue(color); + break; + } + default: qWarning() << "Unhandled animation type"; continue; -- cgit v1.2.3 From 8155dae53f4b9f9d2c9d198758fe8c636c2e1cd1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Jun 2017 12:40:06 +0200 Subject: Fix and extend animationutils autotest Test QColor and fix various issues and typos. Change-Id: I559fa9887f65d176bb4b7d678deab0b182d0b3a8 Reviewed-by: Sean Harmer --- .../animationutils/tst_animationutils.cpp | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index a70fd271c..fea110856 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1000,7 +1001,7 @@ private Q_SLOTS: MappingData mapping; mapping.targetId = Qt3DCore::QNodeId::createId(); mapping.propertyName = "foo"; - mapping.type = static_cast(QVariant::Vector2D); + mapping.type = static_cast(QVariant::Vector4D); mapping.channelIndices = QVector() << 0 << 1 << 2 << 3; mappingData.push_back(mapping); channelResults = QVector() << 4.0f << 3.0f << 2.0f << 1.0f; @@ -1036,7 +1037,7 @@ private Q_SLOTS: auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(mapping.targetId); change->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); change->setPropertyName(mapping.propertyName); - change->setValue(QVariant::fromValue(QQuaternion(1.0f, 0.0f, 0.0f, 1.0f))); + change->setValue(QVariant::fromValue(QQuaternion(1.0f, 0.0f, 0.0f, 1.0f).normalized())); expectedChanges.push_back(change); QTest::newRow("quaternion rotation") @@ -1047,6 +1048,34 @@ private Q_SLOTS: channelResults.clear(); expectedChanges.clear(); } + + // Single property, QColor + { + animatorId = Qt3DCore::QNodeId::createId(); + MappingData mapping; + mapping.targetId = Qt3DCore::QNodeId::createId(); + mapping.propertyName = "color"; + mapping.type = static_cast(QVariant::Color); + mapping.channelIndices = QVector() << 0 << 1 << 2; + mappingData.push_back(mapping); + channelResults = QVector() << 0.5f << 0.4f << 0.3f; + finalFrame = false; + + auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(mapping.targetId); + change->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); + change->setPropertyName(mapping.propertyName); + change->setValue(QVariant::fromValue(QColor::fromRgbF(0.5f, 0.4f, 0.3f))); + expectedChanges.push_back(change); + + QTest::newRow("QColor color") + << animatorId << mappingData << channelResults << finalFrame + << expectedChanges; + + mappingData.clear(); + channelResults.clear(); + expectedChanges.clear(); + } + } void checkPreparePropertyChanges() @@ -1067,7 +1096,7 @@ private Q_SLOTS: for (int i = 0; i < actualChanges.size(); ++i) { auto expectedChange = expectedChanges[i]; auto actualChange - = qSharedPointerCast(expectedChanges[i]); + = qSharedPointerCast(actualChanges[i]); QCOMPARE(actualChange->subjectId(), expectedChange->subjectId()); QCOMPARE(actualChange->deliveryFlags(), expectedChange->deliveryFlags()); -- cgit v1.2.3 From d7cf1685706a19e2455e178c52646c8a54b751e5 Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Thu, 8 Jun 2017 19:20:35 -0300 Subject: Fix memory leak in Quick3DNodeInstantiatorPrivate Objects are managed by the instance model, so delete instead of deleting objects directly. Task-number: QTBUG-61293 Change-Id: I6ff17e646fce60bf12d575c4c377bee3c82a60cb Reviewed-by: Sean Harmer --- src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp index 1626554ea..c6e8aa7c1 100644 --- a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp +++ b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp @@ -98,7 +98,8 @@ Quick3DNodeInstantiatorPrivate::Quick3DNodeInstantiatorPrivate() Quick3DNodeInstantiatorPrivate::~Quick3DNodeInstantiatorPrivate() { - qDeleteAll(m_objects); + if (m_ownModel) + delete m_instanceModel; } void Quick3DNodeInstantiatorPrivate::clear() -- cgit v1.2.3 From 86148b286b2a562f44ca517c96a1c78d8d0eae31 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Jun 2017 13:05:10 +0200 Subject: Add support for linear interpolation in clip json ...and add an autotest Change-Id: I5c473f5f5918db9cc108f9966fe549e2cba374de Reviewed-by: Sean Harmer --- src/animation/backend/fcurve.cpp | 19 ++++--- .../animation/animationutils/animationutils.qrc | 1 + tests/auto/animation/animationutils/clip4.json | 65 ++++++++++++++++++++++ .../animationutils/tst_animationutils.cpp | 22 ++++++++ 4 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 tests/auto/animation/animationutils/clip4.json diff --git a/src/animation/backend/fcurve.cpp b/src/animation/backend/fcurve.cpp index 56145c726..4a2cf30fd 100644 --- a/src/animation/backend/fcurve.cpp +++ b/src/animation/backend/fcurve.cpp @@ -126,16 +126,21 @@ void FCurve::read(const QJsonObject &json) float localTime = keyframeCoords.at(0).toDouble(); Keyframe keyframe; - keyframe.interpolation = QKeyFrame::BezierInterpolation; keyframe.value = keyframeCoords.at(1).toDouble(); - const QJsonArray leftHandle = keyframeData[QLatin1String("leftHandle")].toArray(); - keyframe.leftControlPoint[0] = leftHandle.at(0).toDouble(); - keyframe.leftControlPoint[1] = leftHandle.at(1).toDouble(); + if (keyframeData.contains(QLatin1String("leftHandle"))) { + keyframe.interpolation = QKeyFrame::BezierInterpolation; - const QJsonArray rightHandle = keyframeData[QLatin1String("rightHandle")].toArray(); - keyframe.rightControlPoint[0] = rightHandle.at(0).toDouble(); - keyframe.rightControlPoint[1] = rightHandle.at(1).toDouble(); + const QJsonArray leftHandle = keyframeData[QLatin1String("leftHandle")].toArray(); + keyframe.leftControlPoint[0] = leftHandle.at(0).toDouble(); + keyframe.leftControlPoint[1] = leftHandle.at(1).toDouble(); + + const QJsonArray rightHandle = keyframeData[QLatin1String("rightHandle")].toArray(); + keyframe.rightControlPoint[0] = rightHandle.at(0).toDouble(); + keyframe.rightControlPoint[1] = rightHandle.at(1).toDouble(); + } else { + keyframe.interpolation = QKeyFrame::LinearInterpolation; + } appendKeyframe(localTime, keyframe); } diff --git a/tests/auto/animation/animationutils/animationutils.qrc b/tests/auto/animation/animationutils/animationutils.qrc index bbcd96524..ddaeab7f1 100644 --- a/tests/auto/animation/animationutils/animationutils.qrc +++ b/tests/auto/animation/animationutils/animationutils.qrc @@ -3,5 +3,6 @@ clip1.json clip2.json clip3.json + clip4.json diff --git a/tests/auto/animation/animationutils/clip4.json b/tests/auto/animation/animationutils/clip4.json new file mode 100644 index 000000000..0915294cd --- /dev/null +++ b/tests/auto/animation/animationutils/clip4.json @@ -0,0 +1,65 @@ +{ + "animations": [ + { + "animationName": "LinearTranslation", + "channels": [ + { + "channelComponents": [ + { + "channelComponentName": "Location X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + 5.0 + ] + } + ] + }, + { + "channelComponentName": "Location Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + -2.0 + ] + } + ] + }, + { + "channelComponentName": "Location Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + 6.0 + ] + } + ] + } + ], + "channelName": "Location" + } + ] + } + ] +} diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index fea110856..4c97cf7e5 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -1186,6 +1186,28 @@ private Q_SLOTS: << handler << clip << localTime << expectedResults; expectedResults.clear(); } + { + // a clip with linear interpolation + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip4.json")); + localTime = clip->duration(); + expectedResults = QVector() << 5.0 << -2.0f << 6.0f; + + QTest::newRow("clip4.json, linear, t = duration") + << handler << clip << localTime << expectedResults; + expectedResults.clear(); + } + { + // a clip with linear interpolation + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip4.json")); + localTime = clip->duration() / 2.0f; + expectedResults = QVector() << 2.5f << -1.0f << 3.0f; + + QTest::newRow("clip4.json, linear, t = duration/2") + << handler << clip << localTime << expectedResults; + expectedResults.clear(); + } } void checkEvaluateClipAtLocalTime() -- cgit v1.2.3 From 6263af19264a4d2cb9b0f2ae6d5801438204c601 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 11 May 2017 19:06:48 +0200 Subject: Pick the right type for QVariant channel targets Animating a Parameter node would be impossible otherwise since the 'value' property is a QVariant so QChannelMapping has no chance of know what really is expected there. If a value is already set, we can automatically determine the QVariant's underlying type. If not, show a warning since we have no chance then. Start handling QMetaType::Float as well since a QVariant will ofen contain this, not a Double. Change-Id: I0ba2abbb2c8d85f2aa1a152ed4b8c6cd26f1fc97 Reviewed-by: Sean Harmer --- src/animation/backend/animationutils.cpp | 2 ++ src/animation/frontend/qchannelmapping.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index c0287e9f2..c12ad99f7 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -61,6 +61,7 @@ int componentsForType(int type) { int componentCount = 1; switch (type) { + case QMetaType::Float: case QVariant::Double: componentCount = 1; break; @@ -237,6 +238,7 @@ QVector preparePropertyChanges(Qt3DCore::QNodeId anim // Build the new value from the channel/fcurve evaluation results QVariant v; switch (mappingData.type) { + case QMetaType::Float: case QVariant::Double: { v = QVariant::fromValue(channelResults[mappingData.channelIndices[0]]); break; diff --git a/src/animation/frontend/qchannelmapping.cpp b/src/animation/frontend/qchannelmapping.cpp index b3d3816a0..90504d942 100644 --- a/src/animation/frontend/qchannelmapping.cpp +++ b/src/animation/frontend/qchannelmapping.cpp @@ -74,6 +74,15 @@ void QChannelMappingPrivate::updatePropertyNameAndType() QMetaProperty mp = mo->property(propertyIndex); propertyName = mp.name(); type = mp.userType(); + if (type == QMetaType::QVariant) { + QVariant currentValue = m_target->property(mp.name()); + if (!currentValue.isNull()) { + type = currentValue.userType(); + } else { + qWarning("QChannelMapping: Attempted to target QVariant property with no value set." + "Set a value first in order to be able to determine the type."); + } + } } if (m_type != type) { -- cgit v1.2.3 From 716ef2a1108347c37443c0d68d0e39d684fa75b2 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Thu, 15 Jun 2017 17:06:24 +0100 Subject: Add missing private export macros Was found when Nathan tried extending QCamera. Probably good to go through other parts of Qt3D. Change-Id: I317acaa36ffe3fd0b1ac0bbf4af70eabb1111ab7 Reviewed-by: Paul Lemire --- src/render/frontend/qcamera_p.h | 3 ++- src/render/frontend/qcameralens_p.h | 3 ++- src/render/frontend/qcomputecommand_p.h | 3 ++- src/render/frontend/qlayer_p.h | 3 ++- src/render/frontend/qlevelofdetail_p.h | 3 ++- src/render/frontend/qpickingsettings_p.h | 3 ++- src/render/frontend/qrendersettings_p.h | 3 ++- src/render/frontend/qrendertarget_p.h | 3 ++- src/render/frontend/qrendertargetoutput_p.h | 3 ++- src/render/geometry/qgeometryrenderer_p.h | 3 ++- src/render/geometry/qmesh_p.h | 3 ++- src/render/lights/qabstractlight_p.h | 3 ++- src/render/lights/qdirectionallight_p.h | 3 ++- src/render/lights/qenvironmentlight_p.h | 3 ++- src/render/lights/qpointlight_p.h | 3 ++- src/render/lights/qspotlight_p.h | 3 ++- src/render/materialsystem/qeffect_p.h | 3 ++- src/render/materialsystem/qfilterkey_p.h | 3 ++- src/render/materialsystem/qgraphicsapifilter_p.h | 3 ++- src/render/picking/qobjectpicker_p.h | 3 ++- src/render/renderstates/qblendequation_p.h | 3 ++- src/render/renderstates/qblendequationarguments_p.h | 3 ++- src/render/renderstates/qclipplane_p.h | 3 ++- src/render/renderstates/qcolormask_p.h | 3 ++- src/render/renderstates/qcullface_p.h | 3 ++- src/render/renderstates/qdepthtest_p.h | 3 ++- src/render/renderstates/qfrontface_p.h | 3 ++- src/render/renderstates/qpointsize_p.h | 3 ++- src/render/renderstates/qpolygonoffset_p.h | 3 ++- src/render/renderstates/qscissortest_p.h | 3 ++- src/render/renderstates/qstencilmask_p.h | 3 ++- src/render/renderstates/qstenciloperation_p.h | 3 ++- src/render/renderstates/qstenciloperationarguments_p.h | 3 ++- src/render/renderstates/qstenciltest_p.h | 3 ++- src/render/renderstates/qstenciltestarguments_p.h | 3 ++- src/render/texture/qpaintedtextureimage_p.h | 3 ++- src/render/texture/qtexture_p.h | 3 ++- src/render/texture/qtextureimage_p.h | 3 ++- 38 files changed, 76 insertions(+), 38 deletions(-) diff --git a/src/render/frontend/qcamera_p.h b/src/render/frontend/qcamera_p.h index 107b1d268..a310fc765 100644 --- a/src/render/frontend/qcamera_p.h +++ b/src/render/frontend/qcamera_p.h @@ -54,12 +54,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QCameraPrivate : public Qt3DCore::QEntityPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QCameraPrivate : public Qt3DCore::QEntityPrivate { public: QCameraPrivate(); diff --git a/src/render/frontend/qcameralens_p.h b/src/render/frontend/qcameralens_p.h index 71759d5f8..e79645b3c 100644 --- a/src/render/frontend/qcameralens_p.h +++ b/src/render/frontend/qcameralens_p.h @@ -52,6 +52,7 @@ // #include +#include #include "qcameralens.h" #include @@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QCameraLensPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QCameraLensPrivate : public Qt3DCore::QComponentPrivate { public: QCameraLensPrivate(); diff --git a/src/render/frontend/qcomputecommand_p.h b/src/render/frontend/qcomputecommand_p.h index 3b595ef99..874edb1fc 100644 --- a/src/render/frontend/qcomputecommand_p.h +++ b/src/render/frontend/qcomputecommand_p.h @@ -52,12 +52,13 @@ // #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QComputeCommandPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QComputeCommandPrivate : public Qt3DCore::QComponentPrivate { public: QComputeCommandPrivate(); diff --git a/src/render/frontend/qlayer_p.h b/src/render/frontend/qlayer_p.h index e31d8fe7a..998dcce86 100644 --- a/src/render/frontend/qlayer_p.h +++ b/src/render/frontend/qlayer_p.h @@ -52,13 +52,14 @@ // #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QLayerPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QLayerPrivate : public Qt3DCore::QComponentPrivate { public: QLayerPrivate(); diff --git a/src/render/frontend/qlevelofdetail_p.h b/src/render/frontend/qlevelofdetail_p.h index 1d7a05a71..136d2ffa3 100644 --- a/src/render/frontend/qlevelofdetail_p.h +++ b/src/render/frontend/qlevelofdetail_p.h @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -61,7 +62,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QLevelOfDetailPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QLevelOfDetailPrivate : public Qt3DCore::QComponentPrivate { public: QLevelOfDetailPrivate(); diff --git a/src/render/frontend/qpickingsettings_p.h b/src/render/frontend/qpickingsettings_p.h index 039b6a435..7928597c8 100644 --- a/src/render/frontend/qpickingsettings_p.h +++ b/src/render/frontend/qpickingsettings_p.h @@ -53,12 +53,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QPickingSettingsPrivate : public Qt3DCore::QNodePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QPickingSettingsPrivate : public Qt3DCore::QNodePrivate { public: QPickingSettingsPrivate(); diff --git a/src/render/frontend/qrendersettings_p.h b/src/render/frontend/qrendersettings_p.h index f05124296..9420a9546 100644 --- a/src/render/frontend/qrendersettings_p.h +++ b/src/render/frontend/qrendersettings_p.h @@ -54,12 +54,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QRenderSettingsPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderSettingsPrivate : public Qt3DCore::QComponentPrivate { public: QRenderSettingsPrivate(); diff --git a/src/render/frontend/qrendertarget_p.h b/src/render/frontend/qrendertarget_p.h index 44a8ac0c1..f1035e846 100644 --- a/src/render/frontend/qrendertarget_p.h +++ b/src/render/frontend/qrendertarget_p.h @@ -52,6 +52,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -60,7 +61,7 @@ namespace Qt3DRender { class QRenderTargetOutput; class QRenderTarget; -class QRenderTargetPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetPrivate : public Qt3DCore::QComponentPrivate { public: QRenderTargetPrivate(); diff --git a/src/render/frontend/qrendertargetoutput_p.h b/src/render/frontend/qrendertargetoutput_p.h index abd352ac9..df855f184 100644 --- a/src/render/frontend/qrendertargetoutput_p.h +++ b/src/render/frontend/qrendertargetoutput_p.h @@ -53,6 +53,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -60,7 +61,7 @@ namespace Qt3DRender { class QAbstractTexture; -class QRenderTargetOutputPrivate : public Qt3DCore::QNodePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetOutputPrivate : public Qt3DCore::QNodePrivate { public: QRenderTargetOutputPrivate(); diff --git a/src/render/geometry/qgeometryrenderer_p.h b/src/render/geometry/qgeometryrenderer_p.h index 622cfb254..324dc9609 100644 --- a/src/render/geometry/qgeometryrenderer_p.h +++ b/src/render/geometry/qgeometryrenderer_p.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QGeometryRendererPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QGeometryRendererPrivate : public Qt3DCore::QComponentPrivate { public: QGeometryRendererPrivate(); diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h index a621525cc..23449d22a 100644 --- a/src/render/geometry/qmesh_p.h +++ b/src/render/geometry/qmesh_p.h @@ -52,6 +52,7 @@ // #include +#include #include QT_BEGIN_NAMESPACE @@ -60,7 +61,7 @@ namespace Qt3DRender { class QMesh; -class QMeshPrivate : public QGeometryRendererPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QMeshPrivate : public QGeometryRendererPrivate { public: QMeshPrivate(); diff --git a/src/render/lights/qabstractlight_p.h b/src/render/lights/qabstractlight_p.h index bfab787a3..f7831dce2 100644 --- a/src/render/lights/qabstractlight_p.h +++ b/src/render/lights/qabstractlight_p.h @@ -52,6 +52,7 @@ // #include +#include #include QT_BEGIN_NAMESPACE @@ -60,7 +61,7 @@ namespace Qt3DRender { class QAbstractLight; -class Q_AUTOTEST_EXPORT QAbstractLightPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractLightPrivate : public Qt3DCore::QComponentPrivate { public: explicit QAbstractLightPrivate(QAbstractLight::Type type); diff --git a/src/render/lights/qdirectionallight_p.h b/src/render/lights/qdirectionallight_p.h index bc815ce30..ea80913eb 100644 --- a/src/render/lights/qdirectionallight_p.h +++ b/src/render/lights/qdirectionallight_p.h @@ -52,6 +52,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -59,7 +60,7 @@ namespace Qt3DRender { class QDirectionalLight; -class QDirectionalLightPrivate : QAbstractLightPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QDirectionalLightPrivate : QAbstractLightPrivate { public: QDirectionalLightPrivate(); diff --git a/src/render/lights/qenvironmentlight_p.h b/src/render/lights/qenvironmentlight_p.h index e98da5f59..02358dafc 100644 --- a/src/render/lights/qenvironmentlight_p.h +++ b/src/render/lights/qenvironmentlight_p.h @@ -52,6 +52,7 @@ // #include +#include #include QT_BEGIN_NAMESPACE @@ -61,7 +62,7 @@ namespace Qt3DRender { class QAbstractTexture; class QEnvironmentLight; -class Q_AUTOTEST_EXPORT QEnvironmentLightPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QEnvironmentLightPrivate : public Qt3DCore::QComponentPrivate { public: explicit QEnvironmentLightPrivate(); diff --git a/src/render/lights/qpointlight_p.h b/src/render/lights/qpointlight_p.h index 978627fb7..147867667 100644 --- a/src/render/lights/qpointlight_p.h +++ b/src/render/lights/qpointlight_p.h @@ -52,6 +52,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -59,7 +60,7 @@ namespace Qt3DRender { class QPointLight; -class QPointLightPrivate : public QAbstractLightPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QPointLightPrivate : public QAbstractLightPrivate { public: QPointLightPrivate(); diff --git a/src/render/lights/qspotlight_p.h b/src/render/lights/qspotlight_p.h index 0bb0cb80f..eabc00353 100644 --- a/src/render/lights/qspotlight_p.h +++ b/src/render/lights/qspotlight_p.h @@ -52,6 +52,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -59,7 +60,7 @@ namespace Qt3DRender { class QSpotLight; -class QSpotLightPrivate : public QAbstractLightPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QSpotLightPrivate : public QAbstractLightPrivate { public: QSpotLightPrivate(); diff --git a/src/render/materialsystem/qeffect_p.h b/src/render/materialsystem/qeffect_p.h index 716bb76de..39c7d1ecc 100644 --- a/src/render/materialsystem/qeffect_p.h +++ b/src/render/materialsystem/qeffect_p.h @@ -53,6 +53,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -62,7 +63,7 @@ class QEffect; class QParameter; class QTechnique; -class QEffectPrivate : public Qt3DCore::QNodePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QEffectPrivate : public Qt3DCore::QNodePrivate { public : QEffectPrivate(); diff --git a/src/render/materialsystem/qfilterkey_p.h b/src/render/materialsystem/qfilterkey_p.h index 3a9855f08..4050bc295 100644 --- a/src/render/materialsystem/qfilterkey_p.h +++ b/src/render/materialsystem/qfilterkey_p.h @@ -53,12 +53,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QFilterKeyPrivate : public Qt3DCore::QNodePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QFilterKeyPrivate : public Qt3DCore::QNodePrivate { public: QFilterKeyPrivate(); diff --git a/src/render/materialsystem/qgraphicsapifilter_p.h b/src/render/materialsystem/qgraphicsapifilter_p.h index 723eb14c2..5a7d874ed 100644 --- a/src/render/materialsystem/qgraphicsapifilter_p.h +++ b/src/render/materialsystem/qgraphicsapifilter_p.h @@ -42,6 +42,7 @@ #include #include +#include // // W A R N I N G @@ -74,7 +75,7 @@ struct Q_AUTOTEST_EXPORT GraphicsApiFilterData bool operator <(const GraphicsApiFilterData &other) const; }; -class Q_AUTOTEST_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate { public: QGraphicsApiFilterPrivate() diff --git a/src/render/picking/qobjectpicker_p.h b/src/render/picking/qobjectpicker_p.h index 884e5673b..3c48b9419 100644 --- a/src/render/picking/qobjectpicker_p.h +++ b/src/render/picking/qobjectpicker_p.h @@ -50,6 +50,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -58,7 +59,7 @@ namespace Qt3DRender { /*! \internal */ -class QObjectPickerPrivate : public Qt3DCore::QComponentPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QObjectPickerPrivate : public Qt3DCore::QComponentPrivate { public: QObjectPickerPrivate() diff --git a/src/render/renderstates/qblendequation_p.h b/src/render/renderstates/qblendequation_p.h index 978944566..228e61f15 100644 --- a/src/render/renderstates/qblendequation_p.h +++ b/src/render/renderstates/qblendequation_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QBlendEquationPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationPrivate : public QRenderStatePrivate { public: QBlendEquationPrivate() diff --git a/src/render/renderstates/qblendequationarguments_p.h b/src/render/renderstates/qblendequationarguments_p.h index 55766b1c2..110039295 100644 --- a/src/render/renderstates/qblendequationarguments_p.h +++ b/src/render/renderstates/qblendequationarguments_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QBlendEquationArgumentsPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationArgumentsPrivate : public QRenderStatePrivate { public: QBlendEquationArgumentsPrivate(Render::StateMask type = Render::BlendEquationArgumentsMask) diff --git a/src/render/renderstates/qclipplane_p.h b/src/render/renderstates/qclipplane_p.h index 11ce8335d..517831e10 100644 --- a/src/render/renderstates/qclipplane_p.h +++ b/src/render/renderstates/qclipplane_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QClipPlanePrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QClipPlanePrivate : public QRenderStatePrivate { public: QClipPlanePrivate() diff --git a/src/render/renderstates/qcolormask_p.h b/src/render/renderstates/qcolormask_p.h index 32a350b75..1e2386eb9 100644 --- a/src/render/renderstates/qcolormask_p.h +++ b/src/render/renderstates/qcolormask_p.h @@ -49,12 +49,13 @@ // #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QColorMaskPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QColorMaskPrivate : public QRenderStatePrivate { public: QColorMaskPrivate() diff --git a/src/render/renderstates/qcullface_p.h b/src/render/renderstates/qcullface_p.h index a258ef38f..98cf99454 100644 --- a/src/render/renderstates/qcullface_p.h +++ b/src/render/renderstates/qcullface_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QCullFacePrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QCullFacePrivate : public QRenderStatePrivate { public: QCullFacePrivate() diff --git a/src/render/renderstates/qdepthtest_p.h b/src/render/renderstates/qdepthtest_p.h index b3a3106fd..555be2d4a 100644 --- a/src/render/renderstates/qdepthtest_p.h +++ b/src/render/renderstates/qdepthtest_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QDepthTestPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QDepthTestPrivate : public QRenderStatePrivate { public : QDepthTestPrivate() diff --git a/src/render/renderstates/qfrontface_p.h b/src/render/renderstates/qfrontface_p.h index c9354b0d5..3849714fd 100644 --- a/src/render/renderstates/qfrontface_p.h +++ b/src/render/renderstates/qfrontface_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QFrontFacePrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QFrontFacePrivate : public QRenderStatePrivate { public: QFrontFacePrivate() diff --git a/src/render/renderstates/qpointsize_p.h b/src/render/renderstates/qpointsize_p.h index e1f216133..eb669b131 100644 --- a/src/render/renderstates/qpointsize_p.h +++ b/src/render/renderstates/qpointsize_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QPointSizePrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QPointSizePrivate : public QRenderStatePrivate { public: QPointSizePrivate(QPointSize::SizeMode sizeMode, float value) diff --git a/src/render/renderstates/qpolygonoffset_p.h b/src/render/renderstates/qpolygonoffset_p.h index d1dc67530..66a62674e 100644 --- a/src/render/renderstates/qpolygonoffset_p.h +++ b/src/render/renderstates/qpolygonoffset_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QPolygonOffsetPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QPolygonOffsetPrivate : public QRenderStatePrivate { public: QPolygonOffsetPrivate() diff --git a/src/render/renderstates/qscissortest_p.h b/src/render/renderstates/qscissortest_p.h index e5bbaad13..7c7bfdfe0 100644 --- a/src/render/renderstates/qscissortest_p.h +++ b/src/render/renderstates/qscissortest_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QScissorTestPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QScissorTestPrivate : public QRenderStatePrivate { public: QScissorTestPrivate() diff --git a/src/render/renderstates/qstencilmask_p.h b/src/render/renderstates/qstencilmask_p.h index 2333476b7..a6aad60b9 100644 --- a/src/render/renderstates/qstencilmask_p.h +++ b/src/render/renderstates/qstencilmask_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QStencilMaskPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilMaskPrivate : public QRenderStatePrivate { public: QStencilMaskPrivate() diff --git a/src/render/renderstates/qstenciloperation_p.h b/src/render/renderstates/qstenciloperation_p.h index b6f9d5958..3273ada23 100644 --- a/src/render/renderstates/qstenciloperation_p.h +++ b/src/render/renderstates/qstenciloperation_p.h @@ -52,12 +52,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QStencilOperationPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationPrivate : public QRenderStatePrivate { public: QStencilOperationPrivate() diff --git a/src/render/renderstates/qstenciloperationarguments_p.h b/src/render/renderstates/qstenciloperationarguments_p.h index a0082c60b..3babd3373 100644 --- a/src/render/renderstates/qstenciloperationarguments_p.h +++ b/src/render/renderstates/qstenciloperationarguments_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QStencilOperationArgumentsPrivate : public QObjectPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationArgumentsPrivate : public QObjectPrivate { public: QStencilOperationArgumentsPrivate(QStencilOperationArguments::FaceMode mode) diff --git a/src/render/renderstates/qstenciltest_p.h b/src/render/renderstates/qstenciltest_p.h index 67f465c69..fc17cfde8 100644 --- a/src/render/renderstates/qstenciltest_p.h +++ b/src/render/renderstates/qstenciltest_p.h @@ -52,12 +52,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QStencilTestPrivate : public QRenderStatePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilTestPrivate : public QRenderStatePrivate { public: QStencilTestPrivate() diff --git a/src/render/renderstates/qstenciltestarguments_p.h b/src/render/renderstates/qstenciltestarguments_p.h index 06a5bb91a..662301843 100644 --- a/src/render/renderstates/qstenciltestarguments_p.h +++ b/src/render/renderstates/qstenciltestarguments_p.h @@ -50,12 +50,13 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QStencilTestArgumentsPrivate : public QObjectPrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilTestArgumentsPrivate : public QObjectPrivate { public: QStencilTestArgumentsPrivate(QStencilTestArguments::StencilFaceMode face) diff --git a/src/render/texture/qpaintedtextureimage_p.h b/src/render/texture/qpaintedtextureimage_p.h index 4fcaa6c93..9db2f4d9c 100644 --- a/src/render/texture/qpaintedtextureimage_p.h +++ b/src/render/texture/qpaintedtextureimage_p.h @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -62,7 +63,7 @@ class QPainter; namespace Qt3DRender { -class QPaintedTextureImagePrivate : public QAbstractTextureImagePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QPaintedTextureImagePrivate : public QAbstractTextureImagePrivate { public: QPaintedTextureImagePrivate(); diff --git a/src/render/texture/qtexture_p.h b/src/render/texture/qtexture_p.h index 7035cfb33..2cdb4c689 100644 --- a/src/render/texture/qtexture_p.h +++ b/src/render/texture/qtexture_p.h @@ -54,12 +54,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QTextureLoaderPrivate : public QAbstractTexturePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QTextureLoaderPrivate : public QAbstractTexturePrivate { public: QTextureLoaderPrivate(); diff --git a/src/render/texture/qtextureimage_p.h b/src/render/texture/qtextureimage_p.h index 323742781..8db8f50f0 100644 --- a/src/render/texture/qtextureimage_p.h +++ b/src/render/texture/qtextureimage_p.h @@ -57,12 +57,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QTextureImagePrivate : public QAbstractTextureImagePrivate +class QT3DRENDERSHARED_PRIVATE_EXPORT QTextureImagePrivate : public QAbstractTextureImagePrivate { public: QTextureImagePrivate() -- cgit v1.2.3 From ff53707d666cf77b408373cc573e6ff5bc0bd3fb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Jun 2017 17:13:58 +0200 Subject: Fix mix up regarding QVariant::isNull() and isValid() Needs isValid() to check for a default constructed QVariant with no underlying type yet. Using isNull() was a mistake since it will be true for many default constructed types (0.0f, QVector3D(0), etc.) Change-Id: I1c7ac10bbb0732a40b67e7dbf61ae5d4185ebac2 Reviewed-by: Sean Harmer --- src/animation/frontend/qchannelmapping.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/animation/frontend/qchannelmapping.cpp b/src/animation/frontend/qchannelmapping.cpp index 90504d942..faa77f5db 100644 --- a/src/animation/frontend/qchannelmapping.cpp +++ b/src/animation/frontend/qchannelmapping.cpp @@ -76,10 +76,10 @@ void QChannelMappingPrivate::updatePropertyNameAndType() type = mp.userType(); if (type == QMetaType::QVariant) { QVariant currentValue = m_target->property(mp.name()); - if (!currentValue.isNull()) { + if (currentValue.isValid()) { type = currentValue.userType(); } else { - qWarning("QChannelMapping: Attempted to target QVariant property with no value set." + qWarning("QChannelMapping: Attempted to target QVariant property with no value set. " "Set a value first in order to be able to determine the type."); } } -- cgit v1.2.3 From c804e393e7b0e66c03ebe5ca3d7c5a246e5fcda8 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 13 Jun 2017 16:16:55 +0200 Subject: Doc: typo in definition qmltype QAbsractClipAnimator --> QAbstractClipAnimator Change-Id: Iad454a48f22741e9c22e0539981a7e0b1c74c1dd Reviewed-by: Sean Harmer --- src/animation/frontend/qabstractclipanimator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/animation/frontend/qabstractclipanimator.cpp b/src/animation/frontend/qabstractclipanimator.cpp index 0d215b470..c75b92d47 100644 --- a/src/animation/frontend/qabstractclipanimator.cpp +++ b/src/animation/frontend/qabstractclipanimator.cpp @@ -54,7 +54,7 @@ QAbstractClipAnimatorPrivate::QAbstractClipAnimatorPrivate() } /*! - \qmltype AbsractClipAnimator + \qmltype AbstractClipAnimator \instantiates Qt3DAnimation::QAbstractClipAnimator \inqmlmodule Qt3D.Animation \since 5.9 -- cgit v1.2.3 From 01a6bcd086cecef3169e5d79bd72dbb0d1393a0f Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Thu, 15 Jun 2017 19:35:42 -0300 Subject: Update NodeInstantiator's children on parent update Currently the parent for elements created by NodeInstantiator are set to the instantiator's parent. This doesn't work for nested instantiators, since at the time the inner instantiator's children are being created the instantiator itself doesn't yet have a parent node yet. Update the parent of elements created by the instantiator when the instantiator's parent changes. Change-Id: I6f260ad2a8a81af5551799e6c643d8849f46e342 Reviewed-by: Sean Harmer Reviewed-by: Kevin Ottens --- .../quick3d/items/quick3dnodeinstantiator.cpp | 12 +++++++++ .../quick3d/items/quick3dnodeinstantiator_p.h | 3 +++ .../quick3dnodeinstantiator/data/createNested.qml | 15 +++++++++++ .../quick3dnodeinstantiator.pro | 1 + .../tst_quick3dnodeinstantiator.cpp | 29 ++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 tests/auto/quick3d/quick3dnodeinstantiator/data/createNested.qml diff --git a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp index c6e8aa7c1..b99f6ae75 100644 --- a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp +++ b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp @@ -245,6 +245,7 @@ void Quick3DNodeInstantiatorPrivate::makeModel() Quick3DNodeInstantiator::Quick3DNodeInstantiator(QNode *parent) : QNode(*new Quick3DNodeInstantiatorPrivate, parent) { + connect(this, &QNode::parentChanged, this, &Quick3DNodeInstantiator::onParentChanged); } /*! @@ -501,6 +502,17 @@ void Quick3DNodeInstantiator::componentComplete() } } +/*! + \internal +*/ +void Quick3DNodeInstantiator::onParentChanged(QObject *parent) +{ + Q_D(const Quick3DNodeInstantiator); + auto parentNode = static_cast(parent); + for (auto obj : d->m_objects) + static_cast(obj.data())->setParent(parentNode); +} + // TODO: Avoid cloning here //void Quick3DNodeInstantiator::copy(const QNode *ref) //{ diff --git a/src/quick3d/quick3d/items/quick3dnodeinstantiator_p.h b/src/quick3d/quick3d/items/quick3dnodeinstantiator_p.h index fd7a1d83d..a79cb4f90 100644 --- a/src/quick3d/quick3d/items/quick3dnodeinstantiator_p.h +++ b/src/quick3d/quick3d/items/quick3dnodeinstantiator_p.h @@ -113,6 +113,9 @@ Q_SIGNALS: void objectAdded(int index, QObject *object); void objectRemoved(int index, QObject *object); +private slots: + void onParentChanged(QObject *parent); + private: Q_DISABLE_COPY(Quick3DNodeInstantiator) Q_DECLARE_PRIVATE(Quick3DNodeInstantiator) diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/data/createNested.qml b/tests/auto/quick3d/quick3dnodeinstantiator/data/createNested.qml new file mode 100644 index 000000000..55be54297 --- /dev/null +++ b/tests/auto/quick3d/quick3dnodeinstantiator/data/createNested.qml @@ -0,0 +1,15 @@ +import QtQml 2.1 +import Qt3D.Core 2.0 + +Entity { + NodeInstantiator { + model: 3 + delegate: NodeInstantiator { + model: 4 + delegate: Entity { + property bool success: true + property int idx: index + } + } + } +} diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/quick3dnodeinstantiator.pro b/tests/auto/quick3d/quick3dnodeinstantiator/quick3dnodeinstantiator.pro index 15435d13e..9026f91ff 100644 --- a/tests/auto/quick3d/quick3dnodeinstantiator/quick3dnodeinstantiator.pro +++ b/tests/auto/quick3d/quick3dnodeinstantiator/quick3dnodeinstantiator.pro @@ -12,6 +12,7 @@ OTHER_FILES = \ data/createMultiple.qml \ data/createNone.qml \ data/createSingle.qml \ + data/createNested.qml \ data/inactive.qml \ data/stringModel.qml diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp index acaba6690..d4d0d56e2 100644 --- a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp +++ b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp @@ -50,6 +50,7 @@ private slots: void createNone(); void createSingle(); void createMultiple(); + void createNested(); void stringModel(); void activeProperty(); void intModelChange(); @@ -109,6 +110,34 @@ void tst_quick3dnodeinstantiator::createMultiple() } } +void tst_quick3dnodeinstantiator::createNested() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("createNested.qml")); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + + auto instantiators = root->findChildren(); + QCOMPARE(instantiators.count(), 4); + + const auto outerInstantiator = instantiators.takeFirst(); + QCOMPARE(outerInstantiator->isActive(), true); + QCOMPARE(outerInstantiator->count(), 3); + + for (const auto instantiator : instantiators) { + QCOMPARE(instantiator->isActive(), true); + QCOMPARE(instantiator->count(), 4); + + for (int i = 0; i < 4; i++) { + auto object = instantiator->objectAt(i); + QVERIFY(object); + QCOMPARE(object->parent(), root); + QCOMPARE(object->property("success").toBool(), true); + QCOMPARE(object->property("idx").toInt(), i); + } + } +} + void tst_quick3dnodeinstantiator::stringModel() { QQmlEngine engine; -- cgit v1.2.3